summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:30 +0000
committerKaleb Keithley <kaleb@freedesktop.org>2003-11-14 15:54:30 +0000
commitdeae12c6b683898f5213992d561a59d4ea889cca (patch)
tree3ed14c7b76f47ec80c1868c34bd0e5de385db618
R6.6 is the Xorg base-lineXORG-MAIN
-rw-r--r--include/X11/XKBlib.h1351
-rw-r--r--include/X11/Xcms.h923
-rw-r--r--include/X11/Xlib.h4646
-rw-r--r--include/X11/Xlibint.h1278
-rw-r--r--include/X11/Xlocale.h70
-rw-r--r--include/X11/Xresource.h413
-rw-r--r--include/X11/Xutil.h907
-rw-r--r--include/X11/cursorfont.h107
-rw-r--r--man/AllPlanes.man382
-rw-r--r--man/BlackPixelOfScreen.man287
-rw-r--r--man/DisplayOfCCC.man196
-rw-r--r--man/ImageByteOrder.man247
-rw-r--r--man/IsCursorKey.man209
-rw-r--r--man/XAddConnectionWatch.man278
-rw-r--r--man/XAddHost.man359
-rw-r--r--man/XAllocClassHint.man275
-rw-r--r--man/XAllocColor.man493
-rw-r--r--man/XAllocIconSize.man274
-rw-r--r--man/XAllocSizeHints.man531
-rw-r--r--man/XAllocStandardColormap.man421
-rw-r--r--man/XAllocWMHints.man425
-rw-r--r--man/XAllowEvents.man192
-rw-r--r--man/XAnyEvent.man270
-rw-r--r--man/XButtonEvent.man354
-rw-r--r--man/XChangeKeyboardControl.man466
-rw-r--r--man/XChangeKeyboardMapping.man488
-rw-r--r--man/XChangePointerControl.man226
-rw-r--r--man/XChangeSaveSet.man239
-rw-r--r--man/XChangeWindowAttributes.man440
-rw-r--r--man/XCirculateEvent.man230
-rw-r--r--man/XCirculateRequestEvent.man225
-rw-r--r--man/XClearArea.man267
-rw-r--r--man/XClientMessageEvent.man228
-rw-r--r--man/XColormapEvent.man239
-rw-r--r--man/XConfigureEvent.man248
-rw-r--r--man/XConfigureRequestEvent.man231
-rw-r--r--man/XConfigureWindow.man486
-rw-r--r--man/XCopyArea.man326
-rw-r--r--man/XCreateColormap.man379
-rw-r--r--man/XCreateFontCursor.man337
-rw-r--r--man/XCreateFontSet.man387
-rw-r--r--man/XCreateGC.man1211
-rw-r--r--man/XCreateIC.man223
-rw-r--r--man/XCreateOC.man234
-rw-r--r--man/XCreatePixmap.man238
-rw-r--r--man/XCreateRegion.man185
-rw-r--r--man/XCreateWindow.man532
-rw-r--r--man/XCreateWindowEvent.man228
-rw-r--r--man/XCrossingEvent.man325
-rw-r--r--man/XDefineCursor.man208
-rw-r--r--man/XDestroyWindow.man223
-rw-r--r--man/XDestroyWindowEvent.man218
-rw-r--r--man/XDrawArc.man349
-rw-r--r--man/XDrawImageString.man270
-rw-r--r--man/XDrawLine.man333
-rw-r--r--man/XDrawPoint.man268
-rw-r--r--man/XDrawRectangle.man267
-rw-r--r--man/XDrawString.man236
-rw-r--r--man/XDrawText.man308
-rw-r--r--man/XEmptyRegion.man220
-rw-r--r--man/XErrorEvent.man202
-rw-r--r--man/XExposeEvent.man231
-rw-r--r--man/XExtentsOfFontSet.man173
-rw-r--r--man/XFillRectangle.man440
-rw-r--r--man/XFilterEvent.man188
-rw-r--r--man/XFlush.man274
-rw-r--r--man/XFocusChangeEvent.man265
-rw-r--r--man/XFontSetExtents.man192
-rw-r--r--man/XFontsOfFontSet.man301
-rw-r--r--man/XFree.man159
-rw-r--r--man/XGetVisualInfo.man328
-rw-r--r--man/XGetWindowAttributes.man408
-rw-r--r--man/XGetWindowProperty.man521
-rw-r--r--man/XGrabButton.man330
-rw-r--r--man/XGrabKey.man312
-rw-r--r--man/XGrabKeyboard.man307
-rw-r--r--man/XGrabPointer.man388
-rw-r--r--man/XGrabServer.man172
-rw-r--r--man/XGraphicsExposeEvent.man275
-rw-r--r--man/XGravityEvent.man223
-rw-r--r--man/XIconifyWindow.man273
-rw-r--r--man/XIfEvent.man234
-rw-r--r--man/XInitImage.man360
-rw-r--r--man/XInitThreads.man205
-rw-r--r--man/XInstallColormap.man256
-rw-r--r--man/XInternAtom.man302
-rw-r--r--man/XIntersectRegion.man241
-rw-r--r--man/XKeymapEvent.man219
-rw-r--r--man/XListFonts.man279
-rw-r--r--man/XLoadFont.man562
-rw-r--r--man/XLookupKeysym.man294
-rw-r--r--man/XMapEvent.man289
-rw-r--r--man/XMapRequestEvent.man213
-rw-r--r--man/XMapWindow.man287
-rw-r--r--man/XNextEvent.man351
-rw-r--r--man/XNoOp.man159
-rw-r--r--man/XOpenDisplay.man258
-rw-r--r--man/XOpenIM.man339
-rw-r--r--man/XOpenOM.man267
-rw-r--r--man/XParseGeometry.man304
-rw-r--r--man/XPolygonRegion.man189
-rw-r--r--man/XPropertyEvent.man243
-rw-r--r--man/XPutBackEvent.man170
-rw-r--r--man/XPutImage.man437
-rw-r--r--man/XQueryBestSize.man304
-rw-r--r--man/XQueryColor.man370
-rw-r--r--man/XQueryPointer.man228
-rw-r--r--man/XQueryTree.man193
-rw-r--r--man/XRaiseWindow.man370
-rw-r--r--man/XReadBitmapFile.man395
-rw-r--r--man/XRecolorCursor.man245
-rw-r--r--man/XReparentEvent.man230
-rw-r--r--man/XReparentWindow.man233
-rw-r--r--man/XResizeRequestEvent.man215
-rw-r--r--man/XResourceManagerString.man186
-rw-r--r--man/XSaveContext.man222
-rw-r--r--man/XSelectInput.man215
-rw-r--r--man/XSelectionClearEvent.man220
-rw-r--r--man/XSelectionEvent.man228
-rw-r--r--man/XSelectionRequestEvent.man232
-rw-r--r--man/XSendEvent.man330
-rw-r--r--man/XSetArcMode.man255
-rw-r--r--man/XSetClipOrigin.man312
-rw-r--r--man/XSetCloseDownMode.man226
-rw-r--r--man/XSetCommand.man237
-rw-r--r--man/XSetErrorHandler.man292
-rw-r--r--man/XSetFillStyle.man226
-rw-r--r--man/XSetFont.man191
-rw-r--r--man/XSetFontPath.man225
-rw-r--r--man/XSetICFocus.man186
-rw-r--r--man/XSetICValues.man237
-rw-r--r--man/XSetInputFocus.man285
-rw-r--r--man/XSetLineAttributes.man284
-rw-r--r--man/XSetPointerMapping.man225
-rw-r--r--man/XSetScreenSaver.man308
-rw-r--r--man/XSetSelectionOwner.man294
-rw-r--r--man/XSetState.man282
-rw-r--r--man/XSetTextProperty.man281
-rw-r--r--man/XSetTile.man254
-rw-r--r--man/XSetTransientForHint.man219
-rw-r--r--man/XSetWMClientMachine.man206
-rw-r--r--man/XSetWMColormapWindows.man252
-rw-r--r--man/XSetWMIconName.man268
-rw-r--r--man/XSetWMName.man275
-rw-r--r--man/XSetWMProperties.man395
-rw-r--r--man/XSetWMProtocols.man250
-rw-r--r--man/XStoreBytes.man277
-rw-r--r--man/XStoreColors.man323
-rw-r--r--man/XStringListToTextProperty.man263
-rw-r--r--man/XStringToKeysym.man237
-rw-r--r--man/XSupportsLocale.man226
-rw-r--r--man/XSynchronize.man184
-rw-r--r--man/XTextExtents.man342
-rw-r--r--man/XTextWidth.man177
-rw-r--r--man/XTranslateCoordinates.man207
-rw-r--r--man/XUnmapEvent.man225
-rw-r--r--man/XUnmapWindow.man216
-rw-r--r--man/XVaCreateNestedList.man170
-rw-r--r--man/XVisibilityEvent.man243
-rw-r--r--man/XWarpPointer.man224
-rw-r--r--man/XcmsAllocColor.man277
-rw-r--r--man/XcmsCCCOfColormap.man193
-rw-r--r--man/XcmsCIELabQueryMaxC.man245
-rw-r--r--man/XcmsCIELuvQueryMaxC.man245
-rw-r--r--man/XcmsColor.man273
-rw-r--r--man/XcmsConvertColors.man207
-rw-r--r--man/XcmsCreateCCC.man216
-rw-r--r--man/XcmsDefaultCCC.man170
-rw-r--r--man/XcmsQueryBlack.man228
-rw-r--r--man/XcmsQueryColor.man291
-rw-r--r--man/XcmsSetWhitePoint.man204
-rw-r--r--man/XcmsStoreColor.man317
-rw-r--r--man/XcmsTekHVCQueryMaxC.man273
-rw-r--r--man/XmbDrawImageString.man224
-rw-r--r--man/XmbDrawString.man216
-rw-r--r--man/XmbDrawText.man260
-rw-r--r--man/XmbLookupString.man307
-rw-r--r--man/XmbResetIC.man195
-rw-r--r--man/XmbTextEscapement.man186
-rw-r--r--man/XmbTextExtents.man226
-rw-r--r--man/XmbTextListToTextProperty.man444
-rw-r--r--man/XmbTextPerCharExtents.man269
-rw-r--r--man/XrmEnumerateDatabase.man243
-rw-r--r--man/XrmGetFileDatabase.man330
-rw-r--r--man/XrmGetResource.man359
-rw-r--r--man/XrmInitialize.man272
-rw-r--r--man/XrmMergeDatabases.man222
-rw-r--r--man/XrmPutResource.man281
-rw-r--r--man/XrmUniqueQuark.man314
-rw-r--r--modules/im/ximcp/imCallbk.c890
-rw-r--r--modules/im/ximcp/imDefFlt.c416
-rw-r--r--modules/im/ximcp/imDefIc.c1588
-rw-r--r--modules/im/ximcp/imDefIm.c2021
-rw-r--r--modules/im/ximcp/imDefLkup.c1186
-rw-r--r--modules/im/ximcp/imDispch.c122
-rw-r--r--modules/im/ximcp/imEvToWire.c786
-rw-r--r--modules/im/ximcp/imExten.c612
-rw-r--r--modules/im/ximcp/imImSw.c53
-rw-r--r--modules/im/ximcp/imInsClbk.c303
-rw-r--r--modules/im/ximcp/imInt.c266
-rw-r--r--modules/im/ximcp/imLcFlt.c90
-rw-r--r--modules/im/ximcp/imLcGIc.c48
-rw-r--r--modules/im/ximcp/imLcIc.c180
-rw-r--r--modules/im/ximcp/imLcIm.c274
-rw-r--r--modules/im/ximcp/imLcLkup.c330
-rw-r--r--modules/im/ximcp/imLcPrs.c508
-rw-r--r--modules/im/ximcp/imLcSIc.c54
-rw-r--r--modules/im/ximcp/imRm.c3135
-rw-r--r--modules/im/ximcp/imRmAttr.c1534
-rw-r--r--modules/im/ximcp/imThaiFlt.c1215
-rw-r--r--modules/im/ximcp/imThaiIc.c215
-rw-r--r--modules/im/ximcp/imThaiIm.c198
-rw-r--r--modules/im/ximcp/imTrX.c519
-rw-r--r--modules/im/ximcp/imTrans.c315
-rw-r--r--modules/im/ximcp/imTransR.c311
-rw-r--r--modules/lc/def/lcDefConv.c362
-rw-r--r--modules/lc/gen/lcGenConv.c2882
-rw-r--r--modules/lc/xlocale/lcEuc.c1505
-rw-r--r--modules/lc/xlocale/lcJis.c925
-rw-r--r--modules/lc/xlocale/lcSjis.c1569
-rw-r--r--modules/om/generic/omDefault.c406
-rw-r--r--modules/om/generic/omGeneric.c2178
-rw-r--r--modules/om/generic/omImText.c100
-rw-r--r--modules/om/generic/omText.c373
-rw-r--r--modules/om/generic/omTextEsc.c283
-rw-r--r--modules/om/generic/omTextExt.c144
-rw-r--r--modules/om/generic/omTextPer.c216
-rw-r--r--modules/om/generic/omXChar.c467
-rw-r--r--nls/C/XI18N_OBJS8
-rw-r--r--nls/C/XLC_LOCALE.pre50
-rw-r--r--nls/compose.dir.pre93
-rw-r--r--nls/en_US.UTF-8/Compose.pre2245
-rw-r--r--nls/en_US.UTF-8/XI18N_OBJS8
-rw-r--r--nls/en_US.UTF-8/XLC_LOCALE.pre365
-rw-r--r--nls/iso8859-1/Compose.pre810
-rw-r--r--nls/iso8859-1/XI18N_OBJS8
-rw-r--r--nls/iso8859-1/XLC_LOCALE.pre72
-rw-r--r--nls/iso8859-10/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-13/XI18N_OBJS8
-rw-r--r--nls/iso8859-2/Compose.pre450
-rw-r--r--nls/iso8859-2/XI18N_OBJS8
-rw-r--r--nls/iso8859-2/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-3/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-4/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-5/XI18N_OBJS8
-rw-r--r--nls/iso8859-5/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-6/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-7/XI18N_OBJS8
-rw-r--r--nls/iso8859-7/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-8/XLC_LOCALE.pre73
-rw-r--r--nls/iso8859-9/XI18N_OBJS8
-rw-r--r--nls/iso8859-9/XLC_LOCALE.pre73
-rw-r--r--nls/ja.JIS/XLC_LOCALE.pre123
-rw-r--r--nls/ja.S90/XLC_LOCALE.pre151
-rw-r--r--nls/ja.SJIS/XI18N_OBJS10
-rw-r--r--nls/ja.SJIS/XLC_LOCALE.pre383
-rw-r--r--nls/ja.U90/XLC_LOCALE.pre152
-rw-r--r--nls/ja/XI18N_OBJS11
-rw-r--r--nls/ja/XLC_LOCALE.pre123
-rw-r--r--nls/ko/XI18N_OBJS7
-rw-r--r--nls/ko/XLC_LOCALE.pre71
-rw-r--r--nls/koi8-r/XLC_LOCALE.pre58
-rw-r--r--nls/locale.alias.pre417
-rw-r--r--nls/locale.dir.pre123
-rw-r--r--nls/zh_TW/XI18N_OBJS7
-rw-r--r--nls/zh_TW/XLC_LOCALE.pre143
-rw-r--r--src/AllCells.c63
-rw-r--r--src/AllPlanes.c70
-rw-r--r--src/AllowEv.c48
-rw-r--r--src/AutoRep.c48
-rw-r--r--src/Backgnd.c46
-rw-r--r--src/BdrWidth.c50
-rw-r--r--src/Bell.c43
-rw-r--r--src/Border.c46
-rw-r--r--src/ChAccCon.c58
-rw-r--r--src/ChActPGb.c46
-rw-r--r--src/ChClMode.c44
-rw-r--r--src/ChCmap.c46
-rw-r--r--src/ChGC.c48
-rw-r--r--src/ChKeyCon.c80
-rw-r--r--src/ChPntCon.c50
-rw-r--r--src/ChProp.c107
-rw-r--r--src/ChSaveSet.c58
-rw-r--r--src/ChWAttrs.c55
-rw-r--r--src/ChWindow.c59
-rw-r--r--src/ChkIfEv.c83
-rw-r--r--src/ChkMaskEv.c90
-rw-r--r--src/ChkTypEv.c75
-rw-r--r--src/ChkTypWEv.c77
-rw-r--r--src/ChkWinEv.c91
-rw-r--r--src/CirWin.c45
-rw-r--r--src/CirWinDn.c44
-rw-r--r--src/CirWinUp.c44
-rw-r--r--src/ClDisplay.c70
-rw-r--r--src/Clear.c46
-rw-r--r--src/ClearArea.c51
-rw-r--r--src/ConfWind.c66
-rw-r--r--src/ConnDis.c1157
-rw-r--r--src/Context.c317
-rw-r--r--src/ConvSel.c49
-rw-r--r--src/CopyArea.c59
-rw-r--r--src/CopyCmap.c49
-rw-r--r--src/CopyGC.c134
-rw-r--r--src/CopyPlane.c61
-rw-r--r--src/CrBFData.c85
-rw-r--r--src/CrCmap.c53
-rw-r--r--src/CrCursor.c57
-rw-r--r--src/CrGC.c342
-rw-r--r--src/CrGlCur.c59
-rw-r--r--src/CrPFBData.c83
-rw-r--r--src/CrPixmap.c49
-rw-r--r--src/CrWindow.c74
-rw-r--r--src/Cursor.c51
-rw-r--r--src/DefCursor.c46
-rw-r--r--src/DelProp.c44
-rw-r--r--src/Depths.c60
-rw-r--r--src/DestSubs.c42
-rw-r--r--src/DestWind.c42
-rw-r--r--src/DisName.c62
-rw-r--r--src/DrArc.c79
-rw-r--r--src/DrArcs.c54
-rw-r--r--src/DrLine.c95
-rw-r--r--src/DrLines.c54
-rw-r--r--src/DrPoint.c93
-rw-r--r--src/DrPoints.c82
-rw-r--r--src/DrRect.c95
-rw-r--r--src/DrRects.c62
-rw-r--r--src/DrSegs.c63
-rw-r--r--src/ErrDes.c196
-rw-r--r--src/ErrHndlr.c95
-rw-r--r--src/EvToWire.c404
-rw-r--r--src/FSSaver.c60
-rw-r--r--src/FSWrap.c273
-rw-r--r--src/FetchName.c93
-rw-r--r--src/FillArc.c96
-rw-r--r--src/FillArcs.c64
-rw-r--r--src/FillPoly.c61
-rw-r--r--src/FillRct.c92
-rw-r--r--src/FillRcts.c63
-rw-r--r--src/FilterEv.c104
-rw-r--r--src/Flush.c40
-rw-r--r--src/Font.c241
-rw-r--r--src/FontInfo.c248
-rw-r--r--src/FontNames.c118
-rw-r--r--src/FreeCmap.c46
-rw-r--r--src/FreeCols.c54
-rw-r--r--src/FreeCurs.c41
-rw-r--r--src/FreeEData.c43
-rw-r--r--src/FreeGC.c47
-rw-r--r--src/FreePix.c42
-rw-r--r--src/GCMisc.c103
-rw-r--r--src/Geom.c98
-rw-r--r--src/GetAtomNm.c204
-rw-r--r--src/GetColor.c111
-rw-r--r--src/GetDflt.c247
-rw-r--r--src/GetFPath.c90
-rw-r--r--src/GetFProp.c53
-rw-r--r--src/GetGCVals.c126
-rw-r--r--src/GetGeom.c58
-rw-r--r--src/GetHColor.c57
-rw-r--r--src/GetHints.c337
-rw-r--r--src/GetIFocus.c47
-rw-r--r--src/GetImage.c122
-rw-r--r--src/GetKCnt.c53
-rw-r--r--src/GetMoEv.c83
-rw-r--r--src/GetNrmHint.c125
-rw-r--r--src/GetPCnt.c49
-rw-r--r--src/GetPntMap.c127
-rw-r--r--src/GetProp.c129
-rw-r--r--src/GetRGBCMap.c133
-rw-r--r--src/GetSOwner.c44
-rw-r--r--src/GetSSaver.c52
-rw-r--r--src/GetStCmap.c115
-rw-r--r--src/GetTxtProp.c111
-rw-r--r--src/GetWAttrs.c144
-rw-r--r--src/GetWMCMapW.c85
-rw-r--r--src/GetWMProto.c85
-rw-r--r--src/GrButton.c57
-rw-r--r--src/GrKey.c55
-rw-r--r--src/GrKeybd.c56
-rw-r--r--src/GrPointer.c63
-rw-r--r--src/GrServer.c40
-rw-r--r--src/Host.c91
-rw-r--r--src/Iconify.c84
-rw-r--r--src/IfEvent.c72
-rw-r--r--src/ImText.c109
-rw-r--r--src/ImText16.c111
-rw-r--r--src/ImUtil.c1016
-rw-r--r--src/InitExt.c473
-rw-r--r--src/InsCmap.c41
-rw-r--r--src/IntAtom.c319
-rw-r--r--src/KeyBind.c731
-rw-r--r--src/KeysymStr.c137
-rw-r--r--src/KillCl.c41
-rw-r--r--src/LiHosts.c100
-rw-r--r--src/LiICmaps.c70
-rw-r--r--src/LiProps.c68
-rw-r--r--src/ListExt.c96
-rw-r--r--src/LoadFont.c54
-rw-r--r--src/LockDis.c90
-rw-r--r--src/LookupCol.c104
-rw-r--r--src/LowerWin.c46
-rw-r--r--src/Macros.c250
-rw-r--r--src/MapRaised.c48
-rw-r--r--src/MapSubs.c40
-rw-r--r--src/MapWindow.c41
-rw-r--r--src/MaskEvent.c80
-rw-r--r--src/Misc.c67
-rw-r--r--src/ModMap.c198
-rw-r--r--src/MoveWin.c61
-rw-r--r--src/NextEvent.c52
-rw-r--r--src/OCWrap.c161
-rw-r--r--src/OMWrap.c152
-rw-r--r--src/OpenDis.c760
-rw-r--r--src/ParseCmd.c234
-rw-r--r--src/ParseCol.c135
-rw-r--r--src/ParseGeom.c186
-rw-r--r--src/PeekEvent.c48
-rw-r--r--src/PeekIfEv.c73
-rw-r--r--src/Pending.c57
-rw-r--r--src/PixFormats.c60
-rw-r--r--src/PmapBgnd.c45
-rw-r--r--src/PmapBord.c45
-rw-r--r--src/PolyReg.c630
-rw-r--r--src/PolyTxt.c230
-rw-r--r--src/PolyTxt16.c264
-rw-r--r--src/PropAlloc.c73
-rw-r--r--src/PutBEvent.c59
-rw-r--r--src/PutImage.c998
-rw-r--r--src/QuBest.c58
-rw-r--r--src/QuColor.c59
-rw-r--r--src/QuColors.c75
-rw-r--r--src/QuCurShp.c57
-rw-r--r--src/QuExt.c63
-rw-r--r--src/QuKeybd.c52
-rw-r--r--src/QuPntr.c60
-rw-r--r--src/QuStipShp.c57
-rw-r--r--src/QuTextE16.c91
-rw-r--r--src/QuTextExt.c90
-rw-r--r--src/QuTileShp.c58
-rw-r--r--src/QuTree.c71
-rw-r--r--src/Quarks.c431
-rw-r--r--src/RaiseWin.c46
-rw-r--r--src/RdBitF.c289
-rw-r--r--src/RecolorC.c50
-rw-r--r--src/ReconfWM.c139
-rw-r--r--src/ReconfWin.c78
-rw-r--r--src/Region.c1672
-rw-r--r--src/RegstFlt.c160
-rw-r--r--src/RepWindow.c47
-rw-r--r--src/RestackWs.c67
-rw-r--r--src/RotProp.c60
-rw-r--r--src/ScrResStr.c54
-rw-r--r--src/SelInput.c46
-rw-r--r--src/SendEvent.c73
-rw-r--r--src/SetBack.c43
-rw-r--r--src/SetCRects.c79
-rw-r--r--src/SetClMask.c44
-rw-r--r--src/SetClOrig.c49
-rw-r--r--src/SetDashes.c61
-rw-r--r--src/SetFPath.c75
-rw-r--r--src/SetFont.c44
-rw-r--r--src/SetFore.c43
-rw-r--r--src/SetFunc.c43
-rw-r--r--src/SetHints.c296
-rw-r--r--src/SetIFocus.c47
-rw-r--r--src/SetLStyle.c60
-rw-r--r--src/SetLocale.c230
-rw-r--r--src/SetNrmHint.c108
-rw-r--r--src/SetPMask.c43
-rw-r--r--src/SetPntMap.c84
-rw-r--r--src/SetRGBCMap.c98
-rw-r--r--src/SetSOwner.c46
-rw-r--r--src/SetSSaver.c47
-rw-r--r--src/SetStCmap.c90
-rw-r--r--src/SetState.c60
-rw-r--r--src/SetStip.c43
-rw-r--r--src/SetTSOrig.c49
-rw-r--r--src/SetTile.c43
-rw-r--r--src/SetTxtProp.c91
-rw-r--r--src/SetWMCMapW.c72
-rw-r--r--src/SetWMProto.c72
-rw-r--r--src/StBytes.c114
-rw-r--r--src/StColor.c67
-rw-r--r--src/StColors.c62
-rw-r--r--src/StNColor.c92
-rw-r--r--src/StName.c63
-rw-r--r--src/StrKeysym.c148
-rw-r--r--src/StrToText.c88
-rw-r--r--src/Sync.c59
-rw-r--r--src/Synchro.c96
-rw-r--r--src/Text.c146
-rw-r--r--src/Text16.c159
-rw-r--r--src/TextExt.c252
-rw-r--r--src/TextExt16.c228
-rw-r--r--src/TextToStr.c115
-rw-r--r--src/TrCoords.c61
-rw-r--r--src/UndefCurs.c46
-rw-r--r--src/UngrabBut.c46
-rw-r--r--src/UngrabKbd.c42
-rw-r--r--src/UngrabKey.c50
-rw-r--r--src/UngrabPtr.c41
-rw-r--r--src/UngrabSvr.c41
-rw-r--r--src/UninsCmap.c41
-rw-r--r--src/UnldFont.c42
-rw-r--r--src/UnmapSubs.c41
-rw-r--r--src/UnmapWin.c42
-rw-r--r--src/VisUtil.c253
-rw-r--r--src/WMGeom.c195
-rw-r--r--src/WMProps.c132
-rw-r--r--src/WarpPtr.c54
-rw-r--r--src/WinEvent.c84
-rw-r--r--src/Window.c136
-rw-r--r--src/Withdraw.c81
-rw-r--r--src/WrBitF.c159
-rw-r--r--src/XErrorDB737
-rw-r--r--src/XKeysymDB206
-rw-r--r--src/Xatomtype.h134
-rw-r--r--src/XlibAsync.c153
-rw-r--r--src/XlibInt.c3424
-rw-r--r--src/XomGeneric.h181
-rw-r--r--src/Xrm.c2667
-rw-r--r--src/XrmI.h47
-rw-r--r--src/evtomask.c78
-rw-r--r--src/globals.c235
-rw-r--r--src/imConv.c897
-rw-r--r--src/locking.c642
-rw-r--r--src/locking.h173
-rw-r--r--src/poly.h295
-rw-r--r--src/udcInf.c711
-rw-r--r--src/util/makekeys.c259
-rw-r--r--src/util/mkks.sh11
-rw-r--r--src/xcms/AddDIC.c156
-rw-r--r--src/xcms/AddSF.c155
-rw-r--r--src/xcms/CCC.c287
-rw-r--r--src/xcms/CvColW.c139
-rw-r--r--src/xcms/CvCols.c1048
-rw-r--r--src/xcms/HVC.c611
-rw-r--r--src/xcms/HVCGcC.c153
-rw-r--r--src/xcms/HVCGcV.c206
-rw-r--r--src/xcms/HVCGcVC.c267
-rw-r--r--src/xcms/HVCMnV.c167
-rw-r--r--src/xcms/HVCMxC.c247
-rw-r--r--src/xcms/HVCMxV.c250
-rw-r--r--src/xcms/HVCMxVC.c244
-rw-r--r--src/xcms/HVCMxVs.c166
-rw-r--r--src/xcms/HVCWpAj.c118
-rw-r--r--src/xcms/IdOfPr.c111
-rw-r--r--src/xcms/LRGB.c1813
-rw-r--r--src/xcms/Lab.c416
-rw-r--r--src/xcms/LabGcC.c124
-rw-r--r--src/xcms/LabGcL.c176
-rw-r--r--src/xcms/LabGcLC.c225
-rw-r--r--src/xcms/LabMnL.c218
-rw-r--r--src/xcms/LabMxC.c205
-rw-r--r--src/xcms/LabMxL.c218
-rw-r--r--src/xcms/LabMxLC.c226
-rw-r--r--src/xcms/LabWpAj.c97
-rw-r--r--src/xcms/Luv.c385
-rw-r--r--src/xcms/LuvGcC.c124
-rw-r--r--src/xcms/LuvGcL.c176
-rw-r--r--src/xcms/LuvGcLC.c225
-rw-r--r--src/xcms/LuvMnL.c218
-rw-r--r--src/xcms/LuvMxC.c205
-rw-r--r--src/xcms/LuvMxL.c218
-rw-r--r--src/xcms/LuvMxLC.c226
-rw-r--r--src/xcms/LuvWpAj.c100
-rw-r--r--src/xcms/OfCCC.c160
-rw-r--r--src/xcms/PrOfId.c107
-rw-r--r--src/xcms/QBlack.c82
-rw-r--r--src/xcms/QBlue.c82
-rw-r--r--src/xcms/QGreen.c82
-rw-r--r--src/xcms/QRed.c82
-rw-r--r--src/xcms/QWhite.c82
-rw-r--r--src/xcms/QuCol.c76
-rw-r--r--src/xcms/QuCols.c75
-rw-r--r--src/xcms/SetCCC.c150
-rw-r--r--src/xcms/SetGetCols.c201
-rw-r--r--src/xcms/StCol.c79
-rw-r--r--src/xcms/StCols.c110
-rw-r--r--src/xcms/UNDEFINED.c102
-rw-r--r--src/xcms/XRGB.c245
-rw-r--r--src/xcms/XYZ.c192
-rw-r--r--src/xcms/Xcms.txt61
-rw-r--r--src/xcms/Xcmsint.h246
-rw-r--r--src/xcms/cmsAllCol.c71
-rw-r--r--src/xcms/cmsAllNCol.c214
-rw-r--r--src/xcms/cmsCmap.c492
-rw-r--r--src/xcms/cmsColNm.c1049
-rw-r--r--src/xcms/cmsGlobls.c160
-rw-r--r--src/xcms/cmsInt.c420
-rw-r--r--src/xcms/cmsLkCol.c213
-rw-r--r--src/xcms/cmsMath.c138
-rw-r--r--src/xcms/cmsProp.c143
-rw-r--r--src/xcms/cmsTrig.c600
-rw-r--r--src/xcms/uvY.c409
-rw-r--r--src/xcms/xyY.c381
-rw-r--r--src/xkb/XKB.c926
-rw-r--r--src/xkb/XKBAlloc.c587
-rw-r--r--src/xkb/XKBBell.c231
-rw-r--r--src/xkb/XKBBind.c963
-rw-r--r--src/xkb/XKBCompat.c277
-rw-r--r--src/xkb/XKBCtrls.c418
-rw-r--r--src/xkb/XKBCvt.c642
-rw-r--r--src/xkb/XKBExtDev.c953
-rw-r--r--src/xkb/XKBGAlloc.c1377
-rw-r--r--src/xkb/XKBGeom.c779
-rw-r--r--src/xkb/XKBGetByName.c231
-rw-r--r--src/xkb/XKBGetMap.c975
-rw-r--r--src/xkb/XKBList.c273
-rw-r--r--src/xkb/XKBMAlloc.c1077
-rw-r--r--src/xkb/XKBMisc.c1071
-rw-r--r--src/xkb/XKBNames.c953
-rw-r--r--src/xkb/XKBRdBuf.c322
-rw-r--r--src/xkb/XKBSetGeom.c561
-rw-r--r--src/xkb/XKBSetMap.c716
-rw-r--r--src/xkb/XKBUse.c837
-rw-r--r--src/xkb/XKBleds.c408
-rw-r--r--src/xkb/XKBlibint.h406
-rw-r--r--src/xlibi18n/ICWrap.c475
-rw-r--r--src/xlibi18n/IMWrap.c218
-rw-r--r--src/xlibi18n/XDefaultIMIF.c501
-rw-r--r--src/xlibi18n/XDefaultOMIF.c1372
-rw-r--r--src/xlibi18n/Xaixlcint.h54
-rw-r--r--src/xlibi18n/XimImSw.h53
-rw-r--r--src/xlibi18n/XimProto.h227
-rw-r--r--src/xlibi18n/XimThai.h201
-rw-r--r--src/xlibi18n/XimTrInt.h73
-rw-r--r--src/xlibi18n/XimTrX.h67
-rw-r--r--src/xlibi18n/XimTrans.h127
-rw-r--r--src/xlibi18n/Ximint.h1144
-rw-r--r--src/xlibi18n/XimintL.h78
-rw-r--r--src/xlibi18n/XimintP.h301
-rw-r--r--src/xlibi18n/XlcDL.c650
-rw-r--r--src/xlibi18n/XlcGeneric.h146
-rw-r--r--src/xlibi18n/XlcPubI.h252
-rw-r--r--src/xlibi18n/XlcPublic.h287
-rw-r--r--src/xlibi18n/XlcSL.c79
-rw-r--r--src/xlibi18n/Xlcint.h1003
-rw-r--r--src/xlibi18n/lcCT.c909
-rw-r--r--src/xlibi18n/lcCharSet.c164
-rw-r--r--src/xlibi18n/lcConv.c332
-rw-r--r--src/xlibi18n/lcDB.c1281
-rw-r--r--src/xlibi18n/lcDynamic.c74
-rw-r--r--src/xlibi18n/lcFile.c417
-rw-r--r--src/xlibi18n/lcGeneric.c1185
-rw-r--r--src/xlibi18n/lcInit.c229
-rw-r--r--src/xlibi18n/lcPrTxt.c252
-rw-r--r--src/xlibi18n/lcPubWrap.c104
-rw-r--r--src/xlibi18n/lcPublic.c308
-rw-r--r--src/xlibi18n/lcRM.c122
-rw-r--r--src/xlibi18n/lcStd.c305
-rw-r--r--src/xlibi18n/lcTxtPr.c235
-rw-r--r--src/xlibi18n/lcUtil.c78
-rw-r--r--src/xlibi18n/lcWrap.c620
-rw-r--r--src/xlibi18n/mbWMProps.c84
-rw-r--r--src/xlibi18n/mbWrap.c220
-rw-r--r--src/xlibi18n/wcWrap.c218
658 files changed, 181892 insertions, 0 deletions
diff --git a/include/X11/XKBlib.h b/include/X11/XKBlib.h
new file mode 100644
index 00000000..0369c8c6
--- /dev/null
+++ b/include/X11/XKBlib.h
@@ -0,0 +1,1351 @@
+/* $Xorg: XKBlib.h,v 1.6 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#ifndef _XKBLIB_H_
+#define _XKBLIB_H_
+
+#include <X11/Xlib.h>
+#include <X11/extensions/XKBstr.h>
+
+typedef struct _XkbAnyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* # of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XKB event minor code */
+ unsigned int device; /* device ID */
+} XkbAnyEvent;
+
+typedef struct _XkbNewKeyboardNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbNewKeyboardNotify */
+ int device; /* device ID */
+ int old_device; /* device ID of previous keyboard */
+ int min_key_code; /* minimum key code */
+ int max_key_code; /* maximum key code */
+ int old_min_key_code;/* min key code of previous kbd */
+ int old_max_key_code;/* max key code of previous kbd */
+ unsigned int changed; /* changed aspects of the keyboard */
+ char req_major; /* major and minor opcode of req */
+ char req_minor; /* that caused change, if applicable */
+} XkbNewKeyboardNotifyEvent;
+
+typedef struct _XkbMapNotifyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbMapNotify */
+ int device; /* device ID */
+ unsigned int changed; /* fields which have been changed */
+ unsigned int flags; /* reserved */
+ int first_type; /* first changed key type */
+ int num_types; /* number of changed key types */
+ KeyCode min_key_code;
+ KeyCode max_key_code;
+ KeyCode first_key_sym;
+ KeyCode first_key_act;
+ KeyCode first_key_behavior;
+ KeyCode first_key_explicit;
+ KeyCode first_modmap_key;
+ KeyCode first_vmodmap_key;
+ int num_key_syms;
+ int num_key_acts;
+ int num_key_behaviors;
+ int num_key_explicit;
+ int num_modmap_keys;
+ int num_vmodmap_keys;
+ unsigned int vmods; /* mask of changed virtual mods */
+} XkbMapNotifyEvent;
+
+typedef struct _XkbStateNotifyEvent {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* # of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbStateNotify */
+ int device; /* device ID */
+ unsigned int changed; /* mask of changed state components */
+ int group; /* keyboard group */
+ int base_group; /* base keyboard group */
+ int latched_group; /* latched keyboard group */
+ int locked_group; /* locked keyboard group */
+ unsigned int mods; /* modifier state */
+ unsigned int base_mods; /* base modifier state */
+ unsigned int latched_mods; /* latched modifiers */
+ unsigned int locked_mods; /* locked modifiers */
+ int compat_state; /* compatibility state */
+ unsigned char grab_mods; /* mods used for grabs */
+ unsigned char compat_grab_mods;/* grab mods for non-XKB clients */
+ unsigned char lookup_mods; /* mods sent to clients */
+ unsigned char compat_lookup_mods; /* mods sent to non-XKB clients */
+ int ptr_buttons; /* pointer button state */
+ KeyCode keycode; /* keycode that caused the change */
+ char event_type; /* KeyPress or KeyRelease */
+ char req_major; /* Major opcode of request */
+ char req_minor; /* Minor opcode of request */
+} XkbStateNotifyEvent;
+
+typedef struct _XkbControlsNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbControlsNotify */
+ int device; /* device ID */
+ unsigned int changed_ctrls; /* controls with changed sub-values */
+ unsigned int enabled_ctrls; /* controls currently enabled */
+ unsigned int enabled_ctrl_changes;/* controls just {en,dis}abled */
+ int num_groups; /* total groups on keyboard */
+ KeyCode keycode; /* key that caused change or 0 */
+ char event_type; /* type of event that caused change */
+ char req_major; /* if keycode==0, major and minor */
+ char req_minor; /* opcode of req that caused change */
+} XkbControlsNotifyEvent;
+
+typedef struct _XkbIndicatorNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbIndicatorNotify */
+ int device; /* device ID */
+ unsigned int changed; /* indicators with new state or map */
+ unsigned int state; /* current state of all indicators */
+} XkbIndicatorNotifyEvent;
+
+typedef struct _XkbNamesNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbNamesNotify */
+ int device; /* device ID */
+ unsigned int changed; /* names that have changed */
+ int first_type; /* first key type with new name */
+ int num_types; /* number of key types with new names */
+ int first_lvl; /* first key type new new level names */
+ int num_lvls; /* # of key types w/new level names */
+ int num_aliases; /* total number of key aliases*/
+ int num_radio_groups;/* total number of radio groups */
+ unsigned int changed_vmods; /* virtual modifiers with new names */
+ unsigned int changed_groups; /* groups with new names */
+ unsigned int changed_indicators;/* indicators with new names */
+ int first_key; /* first key with new name */
+ int num_keys; /* number of keys with new names */
+} XkbNamesNotifyEvent;
+
+typedef struct _XkbCompatMapNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbCompatMapNotify */
+ int device; /* device ID */
+ unsigned int changed_groups; /* groups with new compat maps */
+ int first_si; /* first new symbol interp */
+ int num_si; /* number of new symbol interps */
+ int num_total_si; /* total # of symbol interps */
+} XkbCompatMapNotifyEvent;
+
+typedef struct _XkbBellNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbBellNotify */
+ int device; /* device ID */
+ int percent; /* requested volume as a % of maximum */
+ int pitch; /* requested pitch in Hz */
+ int duration; /* requested duration in useconds */
+ int bell_class; /* (input extension) feedback class */
+ int bell_id; /* (input extension) ID of feedback */
+ Atom name; /* "name" of requested bell */
+ Window window; /* window associated with event */
+ Bool event_only; /* "event only" requested */
+} XkbBellNotifyEvent;
+
+typedef struct _XkbActionMessage {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbActionMessage */
+ int device; /* device ID */
+ KeyCode keycode; /* key that generated the event */
+ Bool press; /* true if act caused by key press */
+ Bool key_event_follows;/* true if key event also generated */
+ int group; /* effective group */
+ unsigned int mods; /* effective mods */
+ char message[XkbActionMessageLength+1];
+ /* message -- leave space for NUL */
+} XkbActionMessageEvent;
+
+typedef struct _XkbAccessXNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbAccessXNotify */
+ int device; /* device ID */
+ int detail; /* XkbAXN_* */
+ int keycode; /* key of event */
+ int sk_delay; /* current slow keys delay */
+ int debounce_delay; /* current debounce delay */
+} XkbAccessXNotifyEvent;
+
+typedef struct _XkbExtensionDeviceNotify {
+ int type; /* XkbAnyEvent */
+ unsigned long serial; /* of last req processed by server */
+ Bool send_event; /* is this from a SendEvent request? */
+ Display * display; /* Display the event was read from */
+ Time time; /* milliseconds */
+ int xkb_type; /* XkbExtensionDeviceNotify */
+ int device; /* device ID */
+ unsigned int reason; /* reason for the event */
+ unsigned int supported; /* mask of supported features */
+ unsigned int unsupported; /* mask of unsupported features */
+ /* that some app tried to use */
+ int first_btn; /* first button that changed */
+ int num_btns; /* range of buttons changed */
+ unsigned int leds_defined; /* indicators with names or maps */
+ unsigned int led_state; /* current state of the indicators */
+ int led_class; /* feedback class for led changes */
+ int led_id; /* feedback id for led changes */
+} XkbExtensionDeviceNotifyEvent;
+
+typedef union _XkbEvent {
+ int type;
+ XkbAnyEvent any;
+ XkbNewKeyboardNotifyEvent new_kbd;
+ XkbMapNotifyEvent map;
+ XkbStateNotifyEvent state;
+ XkbControlsNotifyEvent ctrls;
+ XkbIndicatorNotifyEvent indicators;
+ XkbNamesNotifyEvent names;
+ XkbCompatMapNotifyEvent compat;
+ XkbBellNotifyEvent bell;
+ XkbActionMessageEvent message;
+ XkbAccessXNotifyEvent accessx;
+ XkbExtensionDeviceNotifyEvent device;
+ XEvent core;
+} XkbEvent;
+
+typedef struct _XkbKbdDpyState XkbKbdDpyStateRec,*XkbKbdDpyStatePtr;
+
+ /* XkbOpenDisplay error codes */
+#define XkbOD_Success 0
+#define XkbOD_BadLibraryVersion 1
+#define XkbOD_ConnectionRefused 2
+#define XkbOD_NonXkbServer 3
+#define XkbOD_BadServerVersion 4
+
+ /* Values for XlibFlags */
+#define XkbLC_ForceLatin1Lookup (1<<0)
+#define XkbLC_ConsumeLookupMods (1<<1)
+#define XkbLC_AlwaysConsumeShiftAndLock (1<<2)
+#define XkbLC_IgnoreNewKeyboards (1<<3)
+#define XkbLC_ControlFallback (1<<4)
+#define XkbLC_ConsumeKeysOnComposeFail (1<<29)
+#define XkbLC_ComposeLED (1<<30)
+#define XkbLC_BeepOnComposeFail (1<<31)
+
+#define XkbLC_AllComposeControls (0xc0000000)
+#define XkbLC_AllControls (0xc000001f)
+
+_XFUNCPROTOBEGIN
+
+extern Bool XkbIgnoreExtension(
+#if NeedFunctionPrototypes
+ Bool /* ignore */
+#endif
+);
+
+extern Display *XkbOpenDisplay(
+#if NeedFunctionPrototypes
+ char * /* name */,
+ int * /* ev_rtrn */,
+ int * /* err_rtrn */,
+ int * /* major_rtrn */,
+ int * /* minor_rtrn */,
+ int * /* reason */
+#endif
+);
+
+extern Bool XkbQueryExtension(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ int * /* opcodeReturn */,
+ int * /* eventBaseReturn */,
+ int * /* errorBaseReturn */,
+ int * /* majorRtrn */,
+ int * /* minorRtrn */
+#endif
+);
+
+extern Bool XkbUseExtension(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ int * /* major_rtrn */,
+ int * /* minor_rtrn */
+#endif
+);
+
+extern Bool XkbLibraryVersion(
+#if NeedFunctionPrototypes
+ int * /* libMajorRtrn */,
+ int * /* libMinorRtrn */
+#endif
+);
+
+extern unsigned int XkbSetXlibControls(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+#endif
+);
+
+extern unsigned int XkbGetXlibControls(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+
+typedef Atom (*XkbInternAtomFunc)(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ _Xconst char * /* name */,
+ Bool /* only_if_exists */
+#endif
+);
+
+typedef char * (*XkbGetAtomNameFunc)(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Atom /* atom */
+#endif
+);
+
+extern void XkbSetAtomFuncs(
+#if NeedFunctionPrototypes
+ XkbInternAtomFunc /* getAtom */,
+ XkbGetAtomNameFunc /* getName */
+#endif
+);
+
+extern KeySym XkbKeycodeToKeysym(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+#if NeedWidePrototypes
+ unsigned int /* kc */,
+#else
+ KeyCode /* kc */,
+#endif
+ int /* group */,
+ int /* level */
+#endif
+);
+
+extern unsigned int XkbKeysymToModifiers(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ KeySym /* ks */
+#endif
+);
+
+extern Bool XkbLookupKeySym(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ KeyCode /* keycode */,
+ unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+#endif
+);
+
+extern int XkbLookupKeyBinding(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ KeySym /* sym_rtrn */,
+ unsigned int /* mods */,
+ char * /* buffer */,
+ int /* nbytes */,
+ int * /* extra_rtrn */
+#endif
+);
+
+extern Bool XkbTranslateKeyCode(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ KeyCode /* keycode */,
+ unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+#endif
+);
+
+extern int XkbTranslateKeySym(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ register KeySym * /* sym_return */,
+ unsigned int /* modifiers */,
+ char * /* buffer */,
+ int /* nbytes */,
+ int * /* extra_rtrn */
+#endif
+);
+
+extern Bool XkbSetAutoRepeatRate(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* delay */,
+ unsigned int /* interval */
+#endif
+);
+
+extern Bool XkbGetAutoRepeatRate(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int * /* delayRtrn */,
+ unsigned int * /* intervalRtrn */
+#endif
+);
+
+extern Bool XkbChangeEnabledControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+#endif
+);
+
+extern Bool XkbDeviceBell(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Window /* win */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */,
+ Atom /* name */
+#endif
+);
+
+extern Bool XkbForceDeviceBell(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */
+#endif
+);
+
+extern Bool XkbDeviceBellEvent(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Window /* win */,
+ int /* deviceSpec */,
+ int /* bellClass */,
+ int /* bellID */,
+ int /* percent */,
+ Atom /* name */
+#endif
+);
+
+extern Bool XkbBell(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ Atom /* name */
+#endif
+);
+
+extern Bool XkbForceBell(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ int /* percent */
+#endif
+);
+
+extern Bool XkbBellEvent(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Window /* win */,
+ int /* percent */,
+ Atom /* name */
+#endif
+);
+
+extern Bool XkbSelectEvents(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceID */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+#endif
+);
+
+extern Bool XkbSelectEventDetails(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceID */,
+ unsigned int /* eventType */,
+ unsigned long /* affect */,
+ unsigned long /* details */
+#endif
+);
+
+extern void XkbNoteMapChanges(
+#if NeedFunctionPrototypes
+ XkbMapChangesPtr /* old */,
+ XkbMapNotifyEvent * /* new */,
+ unsigned int /* wanted */
+#endif
+);
+
+extern void XkbNoteNameChanges(
+#if NeedFunctionPrototypes
+ XkbNameChangesPtr /* old */,
+ XkbNamesNotifyEvent * /* new */,
+ unsigned int /* wanted */
+#endif
+);
+
+extern Status XkbGetIndicatorState(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int * /* pStateRtrn */
+#endif
+);
+
+extern Status XkbGetDeviceIndicatorState(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ unsigned int * /* pStateRtrn */
+#endif
+);
+
+extern Status XkbGetIndicatorMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Bool XkbSetIndicatorMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+#define XkbNoteIndicatorMapChanges(o,n,w) \
+ ((o)->map_changes|=((n)->map_changes&(w)))
+#define XkbNoteIndicatorStateChanges(o,n,w)\
+ ((o)->state_changes|=((n)->state_changes&(w)))
+#define XkbGetIndicatorMapChanges(d,x,c) \
+ (XkbGetIndicatorMap((d),(c)->map_changes,x)
+#define XkbChangeIndicatorMaps(d,x,c) \
+ (XkbSetIndicatorMap((d),(c)->map_changes,x))
+
+extern Bool XkbGetNamedIndicator(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Atom /* name */,
+ int * /* pNdxRtrn */,
+ Bool * /* pStateRtrn */,
+ XkbIndicatorMapPtr /* pMapRtrn */,
+ Bool * /* pRealRtrn */
+#endif
+);
+
+extern Bool XkbGetNamedDeviceIndicator(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ Atom /* name */,
+ int * /* pNdxRtrn */,
+ Bool * /* pStateRtrn */,
+ XkbIndicatorMapPtr /* pMapRtrn */,
+ Bool * /* pRealRtrn */
+#endif
+);
+
+extern Bool XkbSetNamedIndicator(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Atom /* name */,
+ Bool /* changeState */,
+ Bool /* state */,
+ Bool /* createNewMap */,
+ XkbIndicatorMapPtr /* pMap */
+#endif
+);
+
+extern Bool XkbSetNamedDeviceIndicator(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ Atom /* name */,
+ Bool /* changeState */,
+ Bool /* state */,
+ Bool /* createNewMap */,
+ XkbIndicatorMapPtr /* pMap */
+#endif
+);
+
+extern Bool XkbLockModifiers(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+#endif
+);
+
+extern Bool XkbLatchModifiers(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affect */,
+ unsigned int /* values */
+#endif
+);
+
+extern Bool XkbLockGroup(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* group */
+#endif
+);
+
+extern Bool XkbLatchGroup(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* group */
+#endif
+);
+
+extern Bool XkbSetServerInternalMods(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affectReal */,
+ unsigned int /* realValues */,
+ unsigned int /* affectVirtual */,
+ unsigned int /* virtualValues */
+#endif
+);
+
+extern Bool XkbSetIgnoreLockMods(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* affectReal */,
+ unsigned int /* realValues */,
+ unsigned int /* affectVirtual */,
+ unsigned int /* virtualValues */
+#endif
+);
+
+
+extern Bool XkbVirtualModsToReal(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* virtual_mask */,
+ unsigned int * /* mask_rtrn */
+#endif
+);
+
+extern Bool XkbComputeEffectiveMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ XkbKeyTypePtr /* type */,
+ unsigned char * /* map_rtrn */
+#endif
+);
+
+extern Status XkbInitCanonicalKeyTypes(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ int /* keypadVMod */
+#endif
+);
+
+extern XkbDescPtr XkbAllocKeyboard(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern void XkbFreeKeyboard(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeDesc */
+#endif
+);
+
+extern Status XkbAllocClientMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nTypes */
+#endif
+);
+
+extern Status XkbAllocServerMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nActions */
+#endif
+);
+
+extern void XkbFreeClientMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* what */,
+ Bool /* freeMap */
+#endif
+);
+
+extern void XkbFreeServerMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* what */,
+ Bool /* freeMap */
+#endif
+);
+
+extern XkbKeyTypePtr XkbAddKeyType(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ Atom /* name */,
+ int /* map_count */,
+ Bool /* want_preserve */,
+ int /* num_lvls */
+#endif
+);
+
+extern Status XkbAllocIndicatorMaps(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern void XkbFreeIndicatorMaps(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern XkbDescPtr XkbGetMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+#endif
+);
+
+extern Status XkbGetUpdatedMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Status XkbGetMapChanges(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbMapChangesPtr /* changes */
+#endif
+);
+
+
+extern Status XkbRefreshKeyboardMapping(
+#if NeedFunctionPrototypes
+ XkbMapNotifyEvent * /* event */
+#endif
+);
+
+extern Status XkbGetKeyTypes(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern Status XkbGetKeySyms(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern Status XkbGetKeyActions(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* first */,
+ unsigned int /* num */,
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern Status XkbGetKeyBehaviors(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Status XkbGetVirtualMods(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Status XkbGetKeyExplicitComponents(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Status XkbGetKeyModifierMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* firstKey */,
+ unsigned int /* nKeys */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Status XkbAllocControls(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which*/
+#endif
+);
+
+extern void XkbFreeControls(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+#endif
+);
+
+extern Status XkbGetControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Bool XkbSetControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned long /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern void XkbNoteControlsChanges(
+#if NeedFunctionPrototypes
+ XkbControlsChangesPtr /* old */,
+ XkbControlsNotifyEvent * /* new */,
+ unsigned int /* wanted */
+#endif
+);
+
+#define XkbGetControlsChanges(d,x,c) XkbGetControls(d,(c)->changed_ctrls,x)
+#define XkbChangeControls(d,x,c) XkbSetControls(d,(c)->changed_ctrls,x)
+
+extern Status XkbAllocCompatMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ unsigned int /* nInterpret */
+#endif
+);
+
+extern void XkbFreeCompatMap(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+#endif
+);
+
+extern Status XkbGetCompatMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* xkb */
+#endif
+);
+
+extern Bool XkbSetCompatMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* xkb */,
+ Bool /* updateActions */
+#endif
+);
+
+extern XkbSymInterpretPtr XkbAddSymInterpret(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ XkbSymInterpretPtr /* si */,
+ Bool /* updateMap */,
+ XkbChangesPtr /* changes */
+#endif
+);
+
+extern Status XkbAllocNames(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ int /* nTotalRG */,
+ int /* nTotalAliases */
+#endif
+);
+
+extern Status XkbGetNames(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Bool XkbSetNames(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* firstType */,
+ unsigned int /* nTypes */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Bool XkbChangeNames(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDescPtr /* xkb */,
+ XkbNameChangesPtr /* changes */
+#endif
+);
+
+extern void XkbFreeNames(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ unsigned int /* which */,
+ Bool /* freeMap */
+#endif
+);
+
+
+extern Status XkbGetState(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbStatePtr /* rtrnState */
+#endif
+);
+
+extern Bool XkbSetMap(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDescPtr /* desc */
+#endif
+);
+
+extern Bool XkbChangeMap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XkbDescPtr /* desc */,
+ XkbMapChangesPtr /* changes */
+#endif
+);
+
+extern Bool XkbSetDetectableAutoRepeat(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Bool /* detectable */,
+ Bool * /* supported */
+#endif
+);
+
+extern Bool XkbGetDetectableAutoRepeat(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ Bool * /* supported */
+#endif
+);
+
+extern Bool XkbSetAutoResetControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* changes */,
+ unsigned int * /* auto_ctrls */,
+ unsigned int * /* auto_values */
+#endif
+);
+
+extern Bool XkbGetAutoResetControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int * /* auto_ctrls */,
+ unsigned int * /* auto_ctrl_values */
+#endif
+);
+
+extern Bool XkbSetPerClientControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* change */,
+ unsigned int * /* values */
+#endif
+);
+
+extern Bool XkbGetPerClientControls(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int * /* ctrls */
+#endif
+);
+
+extern Status XkbCopyKeyType(
+#if NeedFunctionPrototypes
+ XkbKeyTypePtr /* from */,
+ XkbKeyTypePtr /* into */
+#endif
+);
+
+extern Status XkbCopyKeyTypes(
+#if NeedFunctionPrototypes
+ XkbKeyTypePtr /* from */,
+ XkbKeyTypePtr /* into */,
+ int /* num_types */
+#endif
+);
+
+extern Status XkbResizeKeyType(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ int /* type_ndx */,
+ int /* map_count */,
+ Bool /* want_preserve */,
+ int /* new_num_lvls */
+#endif
+);
+
+extern KeySym *XkbResizeKeySyms(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* desc */,
+ int /* forKey */,
+ int /* symsNeeded */
+#endif
+);
+
+extern XkbAction *XkbResizeKeyActions(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* desc */,
+ int /* forKey */,
+ int /* actsNeeded */
+#endif
+);
+
+extern Status XkbChangeTypesOfKey(
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */,
+ int /* key */,
+ int /* num_groups */,
+ unsigned int /* groups */,
+ int * /* newTypes */,
+ XkbMapChangesPtr /* pChanges */
+#endif
+);
+
+/***====================================================================***/
+
+extern XkbComponentListPtr XkbListComponents(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbComponentNamesPtr /* ptrns */,
+ int * /* max_inout */
+#endif
+);
+
+extern void XkbFreeComponentList(
+#if NeedFunctionPrototypes
+ XkbComponentListPtr /* list */
+#endif
+);
+
+extern XkbDescPtr XkbGetKeyboard(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */
+#endif
+);
+
+extern XkbDescPtr XkbGetKeyboardByName(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* deviceSpec */,
+ XkbComponentNamesPtr /* names */,
+ unsigned int /* want */,
+ unsigned int /* need */,
+ Bool /* load */
+#endif
+);
+
+/***====================================================================***/
+
+extern int XkbKeyTypesForCoreSymbols( /* returns # of groups */
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */, /* keyboard device */
+ int /* map_width */, /* width of core KeySym array */
+ KeySym * /* core_syms */, /* always mapWidth symbols */
+ unsigned int /* protected */, /* explicit key types */
+ int * /* types_inout */, /* always four type indices */
+ KeySym * /* xkb_syms_rtrn */ /* must have enough space */
+#endif
+);
+
+extern Bool XkbApplyCompatMapToKey( /* False only on error */
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */, /* keymap to be edited */
+ KeyCode /* key */, /* key to be updated */
+ XkbChangesPtr /* changes */ /* resulting changes to map */
+#endif
+);
+
+extern Bool XkbUpdateMapFromCore( /* False only on error */
+#if NeedFunctionPrototypes
+ XkbDescPtr /* xkb */, /* XKB keyboard to be edited */
+ KeyCode /* first_key */, /* first changed key */
+ int /* num_keys */, /* number of changed keys */
+ int /* map_width */, /* width of core keymap */
+ KeySym * /* core_keysyms */, /* symbols from core keymap */
+ XkbChangesPtr /* changes */ /* resulting changes */
+#endif
+);
+
+/***====================================================================***/
+
+extern XkbDeviceLedInfoPtr XkbAddDeviceLedInfo(
+#if NeedFunctionPrototypes
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledId */
+#endif
+);
+
+extern Status XkbResizeDeviceButtonActions(
+#if NeedFunctionPrototypes
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* newTotal */
+#endif
+);
+
+extern XkbDeviceInfoPtr XkbAllocDeviceInfo(
+#if NeedFunctionPrototypes
+ unsigned int /* deviceSpec */,
+ unsigned int /* nButtons */,
+ unsigned int /* szLeds */
+#endif
+);
+
+extern void XkbFreeDeviceInfo(
+#if NeedFunctionPrototypes
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* which */,
+ Bool /* freeDevI */
+#endif
+);
+
+extern void XkbNoteDeviceChanges(
+#if NeedFunctionPrototypes
+ XkbDeviceChangesPtr /* old */,
+ XkbExtensionDeviceNotifyEvent * /* new */,
+ unsigned int /* wanted */
+#endif
+);
+
+extern XkbDeviceInfoPtr XkbGetDeviceInfo(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ unsigned int /* deviceSpec */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */
+#endif
+);
+
+extern Status XkbGetDeviceInfoChanges(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ XkbDeviceChangesPtr /* changes */
+#endif
+);
+
+extern Status XkbGetDeviceButtonActions(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ Bool /* all */,
+ unsigned int /* first */,
+ unsigned int /* nBtns */
+#endif
+);
+
+extern Status XkbGetDeviceLedInfo(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass (class, XIDflt, XIAll) */,
+ unsigned int /* ledId (id, XIDflt, XIAll) */,
+ unsigned int /* which (XkbXI_Indicator{Names,Map}Mask */
+#endif
+);
+
+extern Bool XkbSetDeviceInfo(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* which */,
+ XkbDeviceInfoPtr /* devi */
+#endif
+);
+
+extern Bool XkbChangeDeviceInfo(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XkbDeviceInfoPtr /* desc */,
+ XkbDeviceChangesPtr /* changes */
+#endif
+);
+
+extern Bool XkbSetDeviceLedInfo(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* ledClass */,
+ unsigned int /* ledID */,
+ unsigned int /* which */
+#endif
+);
+
+extern Bool XkbSetDeviceButtonActions(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbDeviceInfoPtr /* devi */,
+ unsigned int /* first */,
+ unsigned int /* nBtns */
+#endif
+);
+
+/***====================================================================***/
+
+extern char XkbToControl(
+#if NeedFunctionPrototypes
+ char /* c */
+#endif
+);
+
+/***====================================================================***/
+
+extern Bool XkbSetDebuggingFlags(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ unsigned int /* mask */,
+ unsigned int /* flags */,
+ char * /* msg */,
+ unsigned int /* ctrls_mask */,
+ unsigned int /* ctrls */,
+ unsigned int * /* rtrn_flags */,
+ unsigned int * /* rtrn_ctrls */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XKBLIB_H_ */
diff --git a/include/X11/Xcms.h b/include/X11/Xcms.h
new file mode 100644
index 00000000..d9e9c3b4
--- /dev/null
+++ b/include/X11/Xcms.h
@@ -0,0 +1,923 @@
+/* $Xorg: Xcms.h,v 1.6 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * DESCRIPTION
+ * Public include file for X Color Management System
+ */
+#ifndef _XCMS_H_
+#define _XCMS_H_
+
+#include <X11/Xlib.h>
+
+ /*
+ * XCMS Status Values
+ */
+#define XcmsFailure 0
+#define XcmsSuccess 1
+#define XcmsSuccessWithCompression 2
+
+ /*
+ * Color Space Format ID's
+ * Color Space ID's are of XcmsColorFormat type.
+ *
+ * bit 31
+ * 0 == Device-Independent
+ * 1 == Device-Dependent
+ *
+ * bit 30:
+ * 0 == Registered with X Consortium
+ * 1 == Unregistered
+ */
+#define XcmsUndefinedFormat (XcmsColorFormat)0x00000000
+#define XcmsCIEXYZFormat (XcmsColorFormat)0x00000001
+#define XcmsCIEuvYFormat (XcmsColorFormat)0x00000002
+#define XcmsCIExyYFormat (XcmsColorFormat)0x00000003
+#define XcmsCIELabFormat (XcmsColorFormat)0x00000004
+#define XcmsCIELuvFormat (XcmsColorFormat)0x00000005
+#define XcmsTekHVCFormat (XcmsColorFormat)0x00000006
+#define XcmsRGBFormat (XcmsColorFormat)0x80000000
+#define XcmsRGBiFormat (XcmsColorFormat)0x80000001
+
+ /*
+ * State of XcmsPerScrnInfo
+ */
+#define XcmsInitNone 0x00 /* no initialization attempted */
+#define XcmsInitSuccess 0x01 /* initialization successful */
+#define XcmsInitFailure 0xff /* failure, use defaults */
+
+#define DisplayOfCCC(ccc) ((ccc)->dpy)
+#define ScreenNumberOfCCC(ccc) ((ccc)->screenNumber)
+#define VisualOfCCC(ccc) ((ccc)->visual)
+#define ClientWhitePointOfCCC(ccc) (&(ccc)->clientWhitePt)
+#define ScreenWhitePointOfCCC(ccc) (&(ccc)->pPerScrnInfo->screenWhitePt)
+#define FunctionSetOfCCC(ccc) ((ccc)->pPerScrnInfo->functionSet)
+
+typedef unsigned long XcmsColorFormat; /* Color Space Format ID */
+
+typedef double XcmsFloat;
+
+ /*
+ * Device RGB
+ */
+typedef struct {
+ unsigned short red; /* scaled from 0x0000 to 0xffff */
+ unsigned short green; /* scaled from 0x0000 to 0xffff */
+ unsigned short blue; /* scaled from 0x0000 to 0xffff */
+} XcmsRGB;
+
+ /*
+ * RGB Intensity
+ */
+typedef struct {
+ XcmsFloat red; /* 0.0 - 1.0 */
+ XcmsFloat green; /* 0.0 - 1.0 */
+ XcmsFloat blue; /* 0.0 - 1.0 */
+} XcmsRGBi;
+
+ /*
+ * CIE XYZ
+ */
+typedef struct {
+ XcmsFloat X;
+ XcmsFloat Y;
+ XcmsFloat Z;
+} XcmsCIEXYZ;
+
+ /*
+ * CIE u'v'Y
+ */
+typedef struct {
+ XcmsFloat u_prime; /* 0.0 - 1.0 */
+ XcmsFloat v_prime; /* 0.0 - 1.0 */
+ XcmsFloat Y; /* 0.0 - 1.0 */
+} XcmsCIEuvY;
+
+ /*
+ * CIE xyY
+ */
+typedef struct {
+ XcmsFloat x; /* 0.0 - 1.0 */
+ XcmsFloat y; /* 0.0 - 1.0 */
+ XcmsFloat Y; /* 0.0 - 1.0 */
+} XcmsCIExyY;
+
+ /*
+ * CIE L*a*b*
+ */
+typedef struct {
+ XcmsFloat L_star; /* 0.0 - 100.0 */
+ XcmsFloat a_star;
+ XcmsFloat b_star;
+} XcmsCIELab;
+
+ /*
+ * CIE L*u*v*
+ */
+typedef struct {
+ XcmsFloat L_star; /* 0.0 - 100.0 */
+ XcmsFloat u_star;
+ XcmsFloat v_star;
+} XcmsCIELuv;
+
+ /*
+ * TekHVC
+ */
+typedef struct {
+ XcmsFloat H; /* 0.0 - 360.0 */
+ XcmsFloat V; /* 0.0 - 100.0 */
+ XcmsFloat C; /* 0.0 - 100.0 */
+} XcmsTekHVC;
+
+ /*
+ * PAD
+ */
+typedef struct {
+ XcmsFloat pad0;
+ XcmsFloat pad1;
+ XcmsFloat pad2;
+ XcmsFloat pad3;
+} XcmsPad;
+
+
+ /*
+ * XCMS Color Structure
+ */
+typedef struct {
+ union {
+ XcmsRGB RGB;
+ XcmsRGBi RGBi;
+ XcmsCIEXYZ CIEXYZ;
+ XcmsCIEuvY CIEuvY;
+ XcmsCIExyY CIExyY;
+ XcmsCIELab CIELab;
+ XcmsCIELuv CIELuv;
+ XcmsTekHVC TekHVC;
+ XcmsPad Pad;
+ } spec; /* the color specification */
+ unsigned long pixel; /* pixel value (as needed) */
+ XcmsColorFormat format; /* the specification format */
+} XcmsColor;
+
+
+ /*
+ * XCMS Per Screen related data
+ */
+
+typedef struct _XcmsPerScrnInfo {
+ XcmsColor screenWhitePt; /* Screen White point */
+ XPointer functionSet; /* pointer to Screen Color Characterization */
+ /* Function Set structure */
+ XPointer screenData; /* pointer to corresponding Screen Color*/
+ /* Characterization Data */
+ unsigned char state; /* XcmsInitNone, XcmsInitSuccess, XcmsInitFailure */
+ char pad[3];
+} XcmsPerScrnInfo;
+
+typedef struct _XcmsCCC *XcmsCCC;
+
+typedef Status (*XcmsCompressionProc)( /* Gamut Compression Proc */
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+typedef Status (*XcmsWhiteAdjustProc)( /* White Point Adjust Proc */
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+ /*
+ * XCMS Color Conversion Context
+ */
+typedef struct _XcmsCCC {
+ Display *dpy; /* X Display */
+ int screenNumber; /* X screen number */
+ Visual *visual; /* X Visual */
+ XcmsColor clientWhitePt; /* Client White Point */
+ XcmsCompressionProc gamutCompProc; /* Gamut Compression Function */
+ XPointer gamutCompClientData; /* Gamut Comp Func Client Data */
+ XcmsWhiteAdjustProc whitePtAdjProc; /* White Point Adjustment Function */
+ XPointer whitePtAdjClientData; /* White Pt Adj Func Client Data */
+ XcmsPerScrnInfo *pPerScrnInfo; /* pointer to per screen information */
+ /* associated with the above display */
+ /* screenNumber */
+} XcmsCCCRec;
+
+typedef Status (*XcmsScreenInitProc)( /* Screen Initialization Proc */
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screen_number */,
+ XcmsPerScrnInfo* /* screen_info */
+#endif
+);
+
+typedef void (*XcmsScreenFreeProc)(
+#if NeedFunctionPrototypes
+ XPointer /* screenData */
+#endif
+);
+
+ /*
+ * Function List Pointer -- pointer to an array of function pointers.
+ * The end of list is indicated by a NULL pointer.
+ */
+typedef Status (*XcmsConversionProc)();
+typedef XcmsConversionProc *XcmsFuncListPtr;
+
+typedef int (*XcmsParseStringProc)( /* Color String Parsing Proc */
+#if NeedFunctionPrototypes
+ char* /* color_string */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+ /*
+ * Color Space -- per Color Space related data (Device-Independent
+ * or Device-Dependent)
+ */
+typedef struct _XcmsColorSpace {
+ char *prefix; /* Prefix of string format. */
+ XcmsColorFormat id; /* Format ID number. */
+ XcmsParseStringProc parseString;
+ /* String format parsing function */
+ XcmsFuncListPtr to_CIEXYZ; /* Pointer to an array of function */
+ /* pointers such that when the */
+ /* functions are executed in sequence */
+ /* will convert a XcmsColor structure */
+ /* from this color space to CIEXYZ */
+ /* space. */
+ XcmsFuncListPtr from_CIEXYZ;/* Pointer to an array of function */
+ /* pointers such that when the */
+ /* functions are executed in sequence */
+ /* will convert a XcmsColor structure */
+ /* from CIEXYZ space to this color */
+ /* space. */
+ int inverse_flag; /* If 1, indicates that for 0 <= i < n */
+ /* where n is the number of function */
+ /* pointers in the lists to_CIEXYZ */
+ /* and from_CIEXYZ; for each function */
+ /* to_CIEXYZ[i] its inverse function */
+ /* is from_CIEXYZ[n - i]. */
+
+} XcmsColorSpace;
+
+ /*
+ * Screen Color Characterization Function Set -- per device class
+ * color space conversion functions.
+ */
+typedef struct _XcmsFunctionSet {
+ XcmsColorSpace **DDColorSpaces;
+ /* Pointer to an array of pointers to */
+ /* Device-DEPENDENT color spaces */
+ /* understood by this SCCFuncSet. */
+ XcmsScreenInitProc screenInitProc;
+ /* Screen initialization function that */
+ /* reads Screen Color Characterization*/
+ /* Data off properties on the screen's*/
+ /* root window. */
+ XcmsScreenFreeProc screenFreeProc;
+ /* Function that frees the SCCData */
+ /* structures. */
+} XcmsFunctionSet;
+
+_XFUNCPROTOBEGIN
+
+extern Status XcmsAddColorSpace (
+#if NeedFunctionPrototypes
+ XcmsColorSpace* /* pColorSpace */
+#endif
+);
+
+extern Status XcmsAddFunctionSet (
+#if NeedFunctionPrototypes
+ XcmsFunctionSet* /* functionSet */
+#endif
+);
+
+extern Status XcmsAllocColor (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* color_in_out */,
+ XcmsColorFormat /* result_format */
+#endif
+);
+
+extern Status XcmsAllocNamedColor (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_string */,
+ XcmsColor* /* color_scrn_return */,
+ XcmsColor* /* color_exact_return */,
+ XcmsColorFormat /* result_format */
+#endif
+);
+
+extern XcmsCCC XcmsCCCOfColormap (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */
+#endif
+);
+
+extern Status XcmsCIELabClipab(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELabClipL(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELabClipLab(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELabQueryMaxC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* L_star */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELabQueryMaxL (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELabQueryMaxLC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELabQueryMinL (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELabToCIEXYZ (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIELabWhiteShiftColors(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELuvClipL(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELuvClipLuv(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELuvClipuv(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIELuvQueryMaxC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* L_star */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELuvQueryMaxL (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELuvQueryMaxLC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELuvQueryMinL (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue_angle */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsCIELuvToCIEuvY (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIELuvWhiteShiftColors(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIEXYZToCIELab (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIEXYZToCIEuvY (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIEXYZToCIExyY (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIEXYZToRGBi (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsCIEuvYToCIELuv (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIEuvYToCIEXYZ (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIEuvYToTekHVC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsCIExyYToCIEXYZ (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern XcmsColor *XcmsClientWhitePointOfCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern Status XcmsConvertColors (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colorArry_in_out */,
+ unsigned int /* nColors */,
+ XcmsColorFormat /* targetFormat */,
+ Bool* /* compArry_return */
+#endif
+);
+
+extern XcmsCCC XcmsCreateCCC (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screenNumber */,
+ Visual* /* visual */,
+ XcmsColor* /* clientWhitePt */,
+ XcmsCompressionProc /* gamutCompProc */,
+ XPointer /* gamutCompClientData */,
+ XcmsWhiteAdjustProc /* whitePtAdjProc */,
+ XPointer /* whitePtAdjClientData */
+#endif
+);
+
+extern XcmsCCC XcmsDefaultCCC (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* screenNumber */
+#endif
+);
+
+extern Display *XcmsDisplayOfCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern XcmsColorFormat XcmsFormatOfPrefix (
+#if NeedFunctionPrototypes
+ char* /* prefix */
+#endif
+);
+
+extern void XcmsFreeCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern Status XcmsLookupColor (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_string */,
+ XcmsColor* /* pColor_exact_in_out */,
+ XcmsColor* /* pColor_scrn_in_out */,
+ XcmsColorFormat /* result_format */
+#endif
+);
+
+extern char *XcmsPrefixOfFormat (
+#if NeedFunctionPrototypes
+ XcmsColorFormat /* id */
+#endif
+);
+
+extern Status XcmsQueryBlack (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsQueryBlue (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsQueryColor (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* pColor_in_out */,
+ XcmsColorFormat /* result_format */
+#endif
+);
+
+extern Status XcmsQueryColors (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* colorArry_in_out */,
+ unsigned int /* nColors */,
+ XcmsColorFormat /* result_format */
+#endif
+);
+
+extern Status XcmsQueryGreen (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsQueryRed (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsQueryWhite (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsRGBiToCIEXYZ (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsRGBiToRGB (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsRGBToRGBi (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern int XcmsScreenNumberOfCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern XcmsColor *XcmsScreenWhitePointOfCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern XcmsCCC XcmsSetCCCOfColormap(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsCCC /* ccc */
+#endif
+);
+
+extern XcmsCompressionProc XcmsSetCompressionProc (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsCompressionProc /* compression_proc */,
+ XPointer /* client_data */
+#endif
+);
+
+extern XcmsWhiteAdjustProc XcmsSetWhiteAdjustProc (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsWhiteAdjustProc /* white_adjust_proc */,
+ XPointer /* client_data */
+#endif
+);
+
+extern Status XcmsSetWhitePoint (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* color */
+#endif
+);
+
+extern Status XcmsStoreColor (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* pColor_in */
+#endif
+);
+
+extern Status XcmsStoreColors (
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Colormap /* colormap */,
+ XcmsColor* /* colorArry_in */,
+ unsigned int /* nColors */,
+ Bool* /* compArry_return */
+#endif
+);
+
+extern Status XcmsTekHVCClipC(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsTekHVCClipV(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsTekHVCClipVC(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ unsigned int /* index */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Status XcmsTekHVCQueryMaxC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* value */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsTekHVCQueryMaxV (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsTekHVCQueryMaxVC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsTekHVCQueryMaxVSamples (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsColor* /* colors_return */,
+ unsigned int /* nsamples */
+#endif
+);
+
+extern Status XcmsTekHVCQueryMinV (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsFloat /* hue */,
+ XcmsFloat /* chroma */,
+ XcmsColor* /* color_return */
+#endif
+);
+
+extern Status XcmsTekHVCToCIEuvY (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* white_point */,
+ XcmsColor* /* colors */,
+ unsigned int /* ncolors */
+#endif
+);
+
+extern Status XcmsTekHVCWhiteShiftColors(
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */,
+ XcmsColor* /* initial_white_point*/,
+ XcmsColor* /* target_white_point*/,
+ XcmsColorFormat /* target_format */,
+ XcmsColor* /* colors_in_out */,
+ unsigned int /* ncolors */,
+ Bool* /* compression_flags_return */
+#endif
+);
+
+extern Visual *XcmsVisualOfCCC (
+#if NeedFunctionPrototypes
+ XcmsCCC /* ccc */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XCMS_H_ */
diff --git a/include/X11/Xlib.h b/include/X11/Xlib.h
new file mode 100644
index 00000000..0cf9d86e
--- /dev/null
+++ b/include/X11/Xlib.h
@@ -0,0 +1,4646 @@
+/* $Xorg: Xlib.h,v 1.6 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+
+/*
+ * Xlib.h - Header definition and support file for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol (V11).
+ * Structures and symbols starting with "_" are private to the library.
+ */
+#ifndef _XLIB_H_
+#define _XLIB_H_
+
+#define XlibSpecificationRelease 6
+
+#ifdef USG
+#ifndef __TYPES__
+#include <sys/types.h> /* forgot to protect it... */
+#define __TYPES__
+#endif /* __TYPES__ */
+#else
+#if defined(_POSIX_SOURCE) && defined(MOTOROLA)
+#undef _POSIX_SOURCE
+#include <sys/types.h>
+#define _POSIX_SOURCE
+#else
+#include <sys/types.h>
+#endif
+#endif /* USG */
+
+#include <X11/X.h>
+
+/* applications should not depend on these two headers being included! */
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_WCHAR
+#ifdef X_NOT_STDC_ENV
+#define X_WCHAR
+#endif
+#endif
+
+#ifndef X_WCHAR
+#include <stddef.h>
+#else
+/* replace this with #include or typedef appropriate for your system */
+typedef unsigned long wchar_t;
+#endif
+
+typedef char *XPointer;
+
+#define Bool int
+#define Status int
+#define True 1
+#define False 0
+
+#define QueuedAlready 0
+#define QueuedAfterReading 1
+#define QueuedAfterFlush 2
+
+#define ConnectionNumber(dpy) (((_XPrivDisplay)dpy)->fd)
+#define RootWindow(dpy, scr) (ScreenOfDisplay(dpy,scr)->root)
+#define DefaultScreen(dpy) (((_XPrivDisplay)dpy)->default_screen)
+#define DefaultRootWindow(dpy) (ScreenOfDisplay(dpy,DefaultScreen(dpy))->root)
+#define DefaultVisual(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_visual)
+#define DefaultGC(dpy, scr) (ScreenOfDisplay(dpy,scr)->default_gc)
+#define BlackPixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->black_pixel)
+#define WhitePixel(dpy, scr) (ScreenOfDisplay(dpy,scr)->white_pixel)
+#define AllPlanes ((unsigned long)~0L)
+#define QLength(dpy) (((_XPrivDisplay)dpy)->qlen)
+#define DisplayWidth(dpy, scr) (ScreenOfDisplay(dpy,scr)->width)
+#define DisplayHeight(dpy, scr) (ScreenOfDisplay(dpy,scr)->height)
+#define DisplayWidthMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mwidth)
+#define DisplayHeightMM(dpy, scr)(ScreenOfDisplay(dpy,scr)->mheight)
+#define DisplayPlanes(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DisplayCells(dpy, scr) (DefaultVisual(dpy,scr)->map_entries)
+#define ScreenCount(dpy) (((_XPrivDisplay)dpy)->nscreens)
+#define ServerVendor(dpy) (((_XPrivDisplay)dpy)->vendor)
+#define ProtocolVersion(dpy) (((_XPrivDisplay)dpy)->proto_major_version)
+#define ProtocolRevision(dpy) (((_XPrivDisplay)dpy)->proto_minor_version)
+#define VendorRelease(dpy) (((_XPrivDisplay)dpy)->release)
+#define DisplayString(dpy) (((_XPrivDisplay)dpy)->display_name)
+#define DefaultDepth(dpy, scr) (ScreenOfDisplay(dpy,scr)->root_depth)
+#define DefaultColormap(dpy, scr)(ScreenOfDisplay(dpy,scr)->cmap)
+#define BitmapUnit(dpy) (((_XPrivDisplay)dpy)->bitmap_unit)
+#define BitmapBitOrder(dpy) (((_XPrivDisplay)dpy)->bitmap_bit_order)
+#define BitmapPad(dpy) (((_XPrivDisplay)dpy)->bitmap_pad)
+#define ImageByteOrder(dpy) (((_XPrivDisplay)dpy)->byte_order)
+#ifdef CRAY /* unable to get WORD64 without pulling in other symbols */
+#define NextRequest(dpy) XNextRequest(dpy)
+#else
+#define NextRequest(dpy) (((_XPrivDisplay)dpy)->request + 1)
+#endif
+#define LastKnownRequestProcessed(dpy) (((_XPrivDisplay)dpy)->last_request_read)
+
+/* macros for screen oriented applications (toolkit) */
+#define ScreenOfDisplay(dpy, scr)(&((_XPrivDisplay)dpy)->screens[scr])
+#define DefaultScreenOfDisplay(dpy) ScreenOfDisplay(dpy,DefaultScreen(dpy))
+#define DisplayOfScreen(s) ((s)->display)
+#define RootWindowOfScreen(s) ((s)->root)
+#define BlackPixelOfScreen(s) ((s)->black_pixel)
+#define WhitePixelOfScreen(s) ((s)->white_pixel)
+#define DefaultColormapOfScreen(s)((s)->cmap)
+#define DefaultDepthOfScreen(s) ((s)->root_depth)
+#define DefaultGCOfScreen(s) ((s)->default_gc)
+#define DefaultVisualOfScreen(s)((s)->root_visual)
+#define WidthOfScreen(s) ((s)->width)
+#define HeightOfScreen(s) ((s)->height)
+#define WidthMMOfScreen(s) ((s)->mwidth)
+#define HeightMMOfScreen(s) ((s)->mheight)
+#define PlanesOfScreen(s) ((s)->root_depth)
+#define CellsOfScreen(s) (DefaultVisualOfScreen((s))->map_entries)
+#define MinCmapsOfScreen(s) ((s)->min_maps)
+#define MaxCmapsOfScreen(s) ((s)->max_maps)
+#define DoesSaveUnders(s) ((s)->save_unders)
+#define DoesBackingStore(s) ((s)->backing_store)
+#define EventMaskOfScreen(s) ((s)->root_input_mask)
+
+/*
+ * Extensions need a way to hang private data on some structures.
+ */
+typedef struct _XExtData {
+ int number; /* number returned by XRegisterExtension */
+ struct _XExtData *next; /* next item on list of data for structure */
+ int (*free_private)(); /* called to free private storage */
+ XPointer private_data; /* data private to this extension. */
+} XExtData;
+
+/*
+ * This file contains structures used by the extension mechanism.
+ */
+typedef struct { /* public to extension, cannot be changed */
+ int extension; /* extension number */
+ int major_opcode; /* major op-code assigned by server */
+ int first_event; /* first event number for the extension */
+ int first_error; /* first error number for the extension */
+} XExtCodes;
+
+/*
+ * Data structure for retrieving info about pixmap formats.
+ */
+
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+
+
+/*
+ * Data structure for setting graphics context.
+ */
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask;/* plane mask */
+ unsigned long foreground;/* foreground pixel */
+ unsigned long background;/* background pixel */
+ int line_width; /* line width */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt,
+ CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled,
+ FillStippled, FillOpaeueStippled */
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stipping */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures;/* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+
+/*
+ * Graphics context. The contents of this structure are implementation
+ * dependent. A GC should be treated as opaque by application code.
+ */
+
+typedef struct _XGC
+#ifdef XLIB_ILLEGAL_ACCESS
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#endif
+*GC;
+
+/*
+ * Visual structure; contains information about colormapping possible.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ VisualID visualid; /* visual id of this visual */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ class of screen (monochrome, etc.) */
+#else
+ int class; /* class of screen (monochrome, etc.) */
+#endif
+ unsigned long red_mask, green_mask, blue_mask; /* mask values */
+ int bits_per_rgb; /* log base 2 of distinct color values */
+ int map_entries; /* color map entries */
+} Visual;
+
+/*
+ * Depth structure; contains information for each possible depth.
+ */
+typedef struct {
+ int depth; /* this depth (Z) of the depth */
+ int nvisuals; /* number of Visual types at this depth */
+ Visual *visuals; /* list of visuals possible at this depth */
+} Depth;
+
+/*
+ * Information about the screen. The contents of this structure are
+ * implementation dependent. A Screen should be treated as opaque
+ * by application code.
+ */
+
+struct _XDisplay; /* Forward declare before use for C++ */
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XDisplay *display;/* back pointer to display structure */
+ Window root; /* Root window id. */
+ int width, height; /* width and height of screen */
+ int mwidth, mheight; /* width and height of in millimeters */
+ int ndepths; /* number of depths possible */
+ Depth *depths; /* list of allowable depths on the screen */
+ int root_depth; /* bits per pixel */
+ Visual *root_visual; /* root visual */
+ GC default_gc; /* GC for the root root visual */
+ Colormap cmap; /* default color map */
+ unsigned long white_pixel;
+ unsigned long black_pixel; /* White and Black pixel values */
+ int max_maps, min_maps; /* max and min color maps */
+ int backing_store; /* Never, WhenMapped, Always */
+ Bool save_unders;
+ long root_input_mask; /* initial root input mask */
+} Screen;
+
+/*
+ * Format structure; describes ZFormat data the screen will understand.
+ */
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ int depth; /* depth of this image format */
+ int bits_per_pixel; /* bits/pixel at this depth */
+ int scanline_pad; /* scanline must padded to this multiple */
+} ScreenFormat;
+
+/*
+ * Data structure for setting window attributes.
+ */
+typedef struct {
+ Pixmap background_pixmap; /* background or None or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preseved if possible */
+ unsigned long backing_pixel;/* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ InputOutput, InputOnly*/
+#else
+ int class; /* InputOutput, InputOnly*/
+#endif
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes;/* planes to be preserved if possible */
+ unsigned long backing_pixel;/* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+
+/*
+ * Data structure for host setting; getting routines.
+ *
+ */
+
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the bytes */
+} XHostAddress;
+
+/*
+ * Data structure for "image" data, used by image manipulation routines.
+ */
+typedef struct _XImage {
+ int width, height; /* size of image */
+ int xoffset; /* number of pixels offset in X direction */
+ int format; /* XYBitmap, XYPixmap, ZPixmap */
+ char *data; /* pointer to image data */
+ int byte_order; /* data byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* quant. of scanline 8, 16, 32 */
+ int bitmap_bit_order; /* LSBFirst, MSBFirst */
+ int bitmap_pad; /* 8, 16, 32 either XY or ZPixmap */
+ int depth; /* depth of image */
+ int bytes_per_line; /* accelarator to next line */
+ int bits_per_pixel; /* bits per pixel (ZPixmap) */
+ unsigned long red_mask; /* bits in z arrangment */
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ XPointer obdata; /* hook for the object routines to hang on */
+ struct funcs { /* image manipulation routines */
+ struct _XImage *(*create_image)();
+#if NeedFunctionPrototypes
+ int (*destroy_image) (struct _XImage *);
+ unsigned long (*get_pixel) (struct _XImage *, int, int);
+ int (*put_pixel) (struct _XImage *, int, int, unsigned long);
+ struct _XImage *(*sub_image)(struct _XImage *, int, int, unsigned int, unsigned int);
+ int (*add_pixel) (struct _XImage *, long);
+#else
+ int (*destroy_image)();
+ unsigned long (*get_pixel)();
+ int (*put_pixel)();
+ struct _XImage *(*sub_image)();
+ int (*add_pixel)();
+#endif
+ } f;
+} XImage;
+
+/*
+ * Data structure for XReconfigureWindow
+ */
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+
+/*
+ * Data structure used by color operations
+ */
+typedef struct {
+ unsigned long pixel;
+ unsigned short red, green, blue;
+ char flags; /* do_red, do_green, do_blue */
+ char pad;
+} XColor;
+
+/*
+ * Data structures for graphics operations. On most machines, these are
+ * congruent with the wire protocol structures, so reformatting the data
+ * can be avoided on these architectures.
+ */
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+
+typedef struct {
+ short x, y;
+} XPoint;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2;
+} XArc;
+
+
+/* Data structure for XChangeKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode;
+ int key;
+ int auto_repeat_mode; /* On, Off, Default */
+} XKeyboardControl;
+
+/* Data structure for XGetKeyboardControl */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+
+/* Data structure for XGetMotionEvents. */
+
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+
+/* Data structure for X{Set,Get}ModifierMapping */
+
+typedef struct {
+ int max_keypermod; /* The server's max # of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of modifiers */
+} XModifierKeymap;
+
+
+/*
+ * Display datatype maintaining display specific data.
+ * The contents of this structure are implementation dependent.
+ * A Display should be treated as opaque by application code.
+ */
+#ifndef XLIB_ILLEGAL_ACCESS
+typedef struct _XDisplay Display;
+#endif
+
+struct _XPrivate; /* Forward declare before use for C++ */
+struct _XrmHashBucketRec;
+
+typedef struct
+#ifdef XLIB_ILLEGAL_ACCESS
+_XDisplay
+#endif
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XPrivate *private1;
+ int fd; /* Network socket. */
+ int private2;
+ int proto_major_version;/* major version of server's X protocol */
+ int proto_minor_version;/* minor version of servers X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID private3;
+ XID private4;
+ XID private5;
+ int private6;
+ XID (*resource_alloc)();/* allocator function */
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int private8;
+ int release; /* release of the server */
+ struct _XPrivate *private9, *private10;
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ XPointer private11;
+ XPointer private12;
+ XPointer private13;
+ XPointer private14;
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*private15)();
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long private16;
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ XPointer private17;
+ XPointer private18;
+ int private19;
+ char *xdefaults; /* contents of defaults from server */
+ /* there is more to this structure, but it is private to Xlib */
+}
+#ifdef XLIB_ILLEGAL_ACCESS
+Display,
+#endif
+*_XPrivDisplay;
+
+#if NeedFunctionPrototypes /* prototypes require event type definitions */
+#undef _XEVENT_
+#endif
+#ifndef _XEVENT_
+/*
+ * Definitions of specific events.
+ */
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occured on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window it is reported relative to */
+ Window root; /* root window that the event occured on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occured on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+
+typedef struct {
+ int type; /* of event */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* "event" window reported relative to */
+ Window root; /* root window that the event occured on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+
+/* generated on EnterWindow and FocusIn when KeyMapState selected */
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+} XExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if non-zero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state; /* Visibility state */
+} XVisibilityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* NewValue, Deleted */
+} XPropertyEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* ATOM or None */
+ Time time;
+} XSelectionEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* COLORMAP or None */
+#if defined(__cplusplus) || defined(c_plusplus)
+ Bool c_new; /* C++ */
+#else
+ Bool new;
+#endif
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ XID resourceid; /* resource id */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+} XErrorEvent;
+
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display;/* Display the event was read from */
+ Window window; /* window on which event was requested in event mask */
+} XAnyEvent;
+
+/*
+ * this union is defined so Xlib can always use the same sized
+ * event structure internally, to avoid memory fragmentation.
+ */
+typedef union _XEvent {
+ int type; /* must not be changed; first element */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ long pad[24];
+} XEvent;
+#endif
+
+#define XAllocID(dpy) ((*((_XPrivDisplay)dpy)->resource_alloc)((dpy)))
+
+/*
+ * per character font metric information.
+ */
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+
+/*
+ * To allow arbitrary information with fonts, there are additional properties
+ * returned.
+ */
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about direction the font is painted */
+ unsigned min_char_or_byte2;/* first character */
+ unsigned max_char_or_byte2;/* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist;/* flag if all characters have non-zero size*/
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties*/
+ XCharStruct min_bounds; /* minimum bounds over all existing char*/
+ XCharStruct max_bounds; /* maximum bounds over all existing char*/
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* log. extent above baseline for spacing */
+ int descent; /* log. descent below baseline for spacing */
+} XFontStruct;
+
+/*
+ * PolyText routines take these as arguments.
+ */
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem;
+
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+
+typedef struct {
+ XChar2b *chars; /* two byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+
+
+typedef union { Display *display;
+ GC gc;
+ Visual *visual;
+ Screen *screen;
+ ScreenFormat *pixmap_format;
+ XFontStruct *font; } XEDataObject;
+
+typedef struct {
+ XRectangle max_ink_extent;
+ XRectangle max_logical_extent;
+} XFontSetExtents;
+
+typedef void (*XOMProc)();
+
+typedef struct _XOM *XOM;
+typedef struct _XOC *XOC, *XFontSet;
+
+typedef struct {
+ char *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XmbTextItem;
+
+typedef struct {
+ wchar_t *chars;
+ int nchars;
+ int delta;
+ XFontSet font_set;
+} XwcTextItem;
+
+#define XNRequiredCharSet "requiredCharSet"
+#define XNQueryOrientation "queryOrientation"
+#define XNBaseFontName "baseFontName"
+#define XNOMAutomatic "omAutomatic"
+#define XNMissingCharSet "missingCharSet"
+#define XNDefaultString "defaultString"
+#define XNOrientation "orientation"
+#define XNDirectionalDependentDrawing "directionalDependentDrawing"
+#define XNContextualDrawing "contextualDrawing"
+#define XNFontInfo "fontInfo"
+
+typedef struct {
+ int charset_count;
+ char **charset_list;
+} XOMCharSetList;
+
+typedef enum {
+ XOMOrientation_LTR_TTB,
+ XOMOrientation_RTL_TTB,
+ XOMOrientation_TTB_LTR,
+ XOMOrientation_TTB_RTL,
+ XOMOrientation_Context
+} XOrientation;
+
+typedef struct {
+ int num_orientation;
+ XOrientation *orientation; /* Input Text description */
+} XOMOrientation;
+
+typedef struct {
+ int num_font;
+ XFontStruct **font_struct_list;
+ char **font_name_list;
+} XOMFontInfo;
+
+typedef void (*XIMProc)();
+
+typedef struct _XIM *XIM;
+typedef struct _XIC *XIC;
+
+typedef unsigned long XIMStyle;
+
+typedef struct {
+ unsigned short count_styles;
+ XIMStyle *supported_styles;
+} XIMStyles;
+
+#define XIMPreeditArea 0x0001L
+#define XIMPreeditCallbacks 0x0002L
+#define XIMPreeditPosition 0x0004L
+#define XIMPreeditNothing 0x0008L
+#define XIMPreeditNone 0x0010L
+#define XIMStatusArea 0x0100L
+#define XIMStatusCallbacks 0x0200L
+#define XIMStatusNothing 0x0400L
+#define XIMStatusNone 0x0800L
+
+#define XNVaNestedList "XNVaNestedList"
+#define XNQueryInputStyle "queryInputStyle"
+#define XNClientWindow "clientWindow"
+#define XNInputStyle "inputStyle"
+#define XNFocusWindow "focusWindow"
+#define XNResourceName "resourceName"
+#define XNResourceClass "resourceClass"
+#define XNGeometryCallback "geometryCallback"
+#define XNDestroyCallback "destroyCallback"
+#define XNFilterEvents "filterEvents"
+#define XNPreeditStartCallback "preeditStartCallback"
+#define XNPreeditDoneCallback "preeditDoneCallback"
+#define XNPreeditDrawCallback "preeditDrawCallback"
+#define XNPreeditCaretCallback "preeditCaretCallback"
+#define XNPreeditStateNotifyCallback "preeditStateNotifyCallback"
+#define XNPreeditAttributes "preeditAttributes"
+#define XNStatusStartCallback "statusStartCallback"
+#define XNStatusDoneCallback "statusDoneCallback"
+#define XNStatusDrawCallback "statusDrawCallback"
+#define XNStatusAttributes "statusAttributes"
+#define XNArea "area"
+#define XNAreaNeeded "areaNeeded"
+#define XNSpotLocation "spotLocation"
+#define XNColormap "colorMap"
+#define XNStdColormap "stdColorMap"
+#define XNForeground "foreground"
+#define XNBackground "background"
+#define XNBackgroundPixmap "backgroundPixmap"
+#define XNFontSet "fontSet"
+#define XNLineSpace "lineSpace"
+#define XNCursor "cursor"
+
+#define XNQueryIMValuesList "queryIMValuesList"
+#define XNQueryICValuesList "queryICValuesList"
+#define XNVisiblePosition "visiblePosition"
+#define XNR6PreeditCallback "r6PreeditCallback"
+#define XNStringConversionCallback "stringConversionCallback"
+#define XNStringConversion "stringConversion"
+#define XNResetState "resetState"
+#define XNHotKey "hotKey"
+#define XNHotKeyState "hotKeyState"
+#define XNPreeditState "preeditState"
+#define XNSeparatorofNestedList "separatorofNestedList"
+
+#define XBufferOverflow -1
+#define XLookupNone 1
+#define XLookupChars 2
+#define XLookupKeySym 3
+#define XLookupBoth 4
+
+#if NeedFunctionPrototypes
+typedef void *XVaNestedList;
+#else
+typedef XPointer XVaNestedList;
+#endif
+
+typedef struct {
+ XPointer client_data;
+ XIMProc callback;
+} XIMCallback;
+
+typedef unsigned long XIMFeedback;
+
+#define XIMReverse 1L
+#define XIMUnderline (1L<<1)
+#define XIMHighlight (1L<<2)
+#define XIMPrimary (1L<<5)
+#define XIMSecondary (1L<<6)
+#define XIMTertiary (1L<<7)
+#define XIMVisibleToForward (1L<<8)
+#define XIMVisibleToBackword (1L<<9)
+#define XIMVisibleToCenter (1L<<10)
+
+typedef struct _XIMText {
+ unsigned short length;
+ XIMFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *multi_byte;
+ wchar_t *wide_char;
+ } string;
+} XIMText;
+
+typedef unsigned long XIMPreeditState;
+
+#define XIMPreeditUnKnown 0L
+#define XIMPreeditEnable 1L
+#define XIMPreeditDisable (1L<<1)
+
+typedef struct _XIMPreeditStateNotifyCallbackStruct {
+ XIMPreeditState state;
+} XIMPreeditStateNotifyCallbackStruct;
+
+typedef unsigned long XIMResetState;
+
+#define XIMInitialState 1L
+#define XIMPreserveState (1L<<1)
+
+typedef unsigned long XIMStringConversionFeedback;
+
+#define XIMStringConversionLeftEdge (0x00000001)
+#define XIMStringConversionRightEdge (0x00000002)
+#define XIMStringConversionTopEdge (0x00000004)
+#define XIMStringConversionBottomEdge (0x00000008)
+#define XIMStringConversionConcealed (0x00000010)
+#define XIMStringConversionWrapped (0x00000020)
+
+typedef struct _XIMStringConversionText {
+ unsigned short length;
+ XIMStringConversionFeedback *feedback;
+ Bool encoding_is_wchar;
+ union {
+ char *mbs;
+ wchar_t *wcs;
+ } string;
+} XIMStringConversionText;
+
+typedef unsigned short XIMStringConversionPosition;
+
+typedef unsigned short XIMStringConversionType;
+
+#define XIMStringConversionBuffer (0x0001)
+#define XIMStringConversionLine (0x0002)
+#define XIMStringConversionWord (0x0003)
+#define XIMStringConversionChar (0x0004)
+
+typedef unsigned short XIMStringConversionOperation;
+
+#define XIMStringConversionSubstitution (0x0001)
+#define XIMStringConversionRetrieval (0x0002)
+
+typedef enum {
+ XIMForwardChar, XIMBackwardChar,
+ XIMForwardWord, XIMBackwardWord,
+ XIMCaretUp, XIMCaretDown,
+ XIMNextLine, XIMPreviousLine,
+ XIMLineStart, XIMLineEnd,
+ XIMAbsolutePosition,
+ XIMDontChange
+} XIMCaretDirection;
+
+typedef struct _XIMStringConversionCallbackStruct {
+ XIMStringConversionPosition position;
+ XIMCaretDirection direction;
+ XIMStringConversionOperation operation;
+ unsigned short factor;
+ XIMStringConversionText *text;
+} XIMStringConversionCallbackStruct;
+
+typedef struct _XIMPreeditDrawCallbackStruct {
+ int caret; /* Cursor offset within pre-edit string */
+ int chg_first; /* Starting change position */
+ int chg_length; /* Length of the change in character count */
+ XIMText *text;
+} XIMPreeditDrawCallbackStruct;
+
+typedef enum {
+ XIMIsInvisible, /* Disable caret feedback */
+ XIMIsPrimary, /* UI defined caret feedback */
+ XIMIsSecondary /* UI defined caret feedback */
+} XIMCaretStyle;
+
+typedef struct _XIMPreeditCaretCallbackStruct {
+ int position; /* Caret offset within pre-edit string */
+ XIMCaretDirection direction; /* Caret moves direction */
+ XIMCaretStyle style; /* Feedback of the caret */
+} XIMPreeditCaretCallbackStruct;
+
+typedef enum {
+ XIMTextType,
+ XIMBitmapType
+} XIMStatusDataType;
+
+typedef struct _XIMStatusDrawCallbackStruct {
+ XIMStatusDataType type;
+ union {
+ XIMText *text;
+ Pixmap bitmap;
+ } data;
+} XIMStatusDrawCallbackStruct;
+
+typedef struct _XIMHotKeyTrigger {
+ KeySym keysym;
+ int modifier;
+ int modifier_mask;
+} XIMHotKeyTrigger;
+
+typedef struct _XIMHotKeyTriggers {
+ int num_hot_key;
+ XIMHotKeyTrigger *key;
+} XIMHotKeyTriggers;
+
+typedef unsigned long XIMHotKeyState;
+
+#define XIMHotKeyStateON (0x0001L)
+#define XIMHotKeyStateOFF (0x0002L)
+
+typedef struct {
+ unsigned short count_values;
+ char **supported_values;
+} XIMValuesList;
+
+_XFUNCPROTOBEGIN
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _Xdebug (*_Xdebug_p)
+#endif
+
+extern int _Xdebug;
+
+extern XFontStruct *XLoadQueryFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* name */
+#endif
+);
+
+extern XFontStruct *XQueryFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* font_ID */
+#endif
+);
+
+
+extern XTimeCoord *XGetMotionEvents(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Time /* start */,
+ Time /* stop */,
+ int* /* nevents_return */
+#endif
+);
+
+extern XModifierKeymap *XDeleteModifiermapEntry(
+#if NeedFunctionPrototypes
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+#endif
+);
+
+extern XModifierKeymap *XGetModifierMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern XModifierKeymap *XInsertModifiermapEntry(
+#if NeedFunctionPrototypes
+ XModifierKeymap* /* modmap */,
+#if NeedWidePrototypes
+ unsigned int /* keycode_entry */,
+#else
+ KeyCode /* keycode_entry */,
+#endif
+ int /* modifier */
+#endif
+);
+
+extern XModifierKeymap *XNewModifiermap(
+#if NeedFunctionPrototypes
+ int /* max_keys_per_mod */
+#endif
+);
+
+extern XImage *XCreateImage(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Visual* /* visual */,
+ unsigned int /* depth */,
+ int /* format */,
+ int /* offset */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* bitmap_pad */,
+ int /* bytes_per_line */
+#endif
+);
+extern Status XInitImage(
+#if NeedFunctionPrototypes
+ XImage* /* image */
+#endif
+);
+extern XImage *XGetImage(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */
+#endif
+);
+extern XImage *XGetSubImage(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* plane_mask */,
+ int /* format */,
+ XImage* /* dest_image */,
+ int /* dest_x */,
+ int /* dest_y */
+#endif
+);
+
+/*
+ * X function declarations.
+ */
+extern Display *XOpenDisplay(
+#if NeedFunctionPrototypes
+ _Xconst char* /* display_name */
+#endif
+);
+
+extern void XrmInitialize(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern char *XFetchBytes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* nbytes_return */
+#endif
+);
+extern char *XFetchBuffer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* nbytes_return */,
+ int /* buffer */
+#endif
+);
+extern char *XGetAtomName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Atom /* atom */
+#endif
+);
+extern Status XGetAtomNames(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Atom* /* atoms */,
+ int /* count */,
+ char** /* names_return */
+#endif
+);
+extern char *XGetDefault(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* program */,
+ _Xconst char* /* option */
+#endif
+);
+extern char *XDisplayName(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */
+#endif
+);
+extern char *XKeysymToString(
+#if NeedFunctionPrototypes
+ KeySym /* keysym */
+#endif
+);
+
+extern int (*XSynchronize(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Bool /* onoff */
+#endif
+))();
+extern int (*XSetAfterFunction(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */
+#endif
+ ) /* procedure */
+#endif
+))();
+extern Atom XInternAtom(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* atom_name */,
+ Bool /* only_if_exists */
+#endif
+);
+extern Status XInternAtoms(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ char** /* names */,
+ int /* count */,
+ Bool /* onlyIfExists */,
+ Atom* /* atoms_return */
+#endif
+);
+extern Colormap XCopyColormapAndFree(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */
+#endif
+);
+extern Colormap XCreateColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Visual* /* visual */,
+ int /* alloc */
+#endif
+);
+extern Cursor XCreatePixmapCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Pixmap /* source */,
+ Pixmap /* mask */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */,
+ unsigned int /* x */,
+ unsigned int /* y */
+#endif
+);
+extern Cursor XCreateGlyphCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Font /* source_font */,
+ Font /* mask_font */,
+ unsigned int /* source_char */,
+ unsigned int /* mask_char */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+#endif
+);
+extern Cursor XCreateFontCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned int /* shape */
+#endif
+);
+extern Font XLoadFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* name */
+#endif
+);
+extern GC XCreateGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+#endif
+);
+extern GContext XGContextFromGC(
+#if NeedFunctionPrototypes
+ GC /* gc */
+#endif
+);
+extern void XFlushGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */
+#endif
+);
+extern Pixmap XCreatePixmap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* depth */
+#endif
+);
+extern Pixmap XCreateBitmapFromData(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+extern Pixmap XCreatePixmapFromBitmapData(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ char* /* data */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned long /* fg */,
+ unsigned long /* bg */,
+ unsigned int /* depth */
+#endif
+);
+extern Window XCreateSimpleWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ unsigned long /* border */,
+ unsigned long /* background */
+#endif
+);
+extern Window XGetSelectionOwner(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Atom /* selection */
+#endif
+);
+extern Window XCreateWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int /* border_width */,
+ int /* depth */,
+ unsigned int /* class */,
+ Visual* /* visual */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+#endif
+);
+extern Colormap *XListInstalledColormaps(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_return */
+#endif
+);
+extern char **XListFonts(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* actual_count_return */
+#endif
+);
+extern char **XListFontsWithInfo(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* pattern */,
+ int /* maxnames */,
+ int* /* count_return */,
+ XFontStruct** /* info_return */
+#endif
+);
+extern char **XGetFontPath(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* npaths_return */
+#endif
+);
+extern char **XListExtensions(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* nextensions_return */
+#endif
+);
+extern Atom *XListProperties(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int* /* num_prop_return */
+#endif
+);
+extern XHostAddress *XListHosts(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* nhosts_return */,
+ Bool* /* state_return */
+#endif
+);
+extern KeySym XKeycodeToKeysym(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* keycode */,
+#else
+ KeyCode /* keycode */,
+#endif
+ int /* index */
+#endif
+);
+extern KeySym XLookupKeysym(
+#if NeedFunctionPrototypes
+ XKeyEvent* /* key_event */,
+ int /* index */
+#endif
+);
+extern KeySym *XGetKeyboardMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+#if NeedWidePrototypes
+ unsigned int /* first_keycode */,
+#else
+ KeyCode /* first_keycode */,
+#endif
+ int /* keycode_count */,
+ int* /* keysyms_per_keycode_return */
+#endif
+);
+extern KeySym XStringToKeysym(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */
+#endif
+);
+extern long XMaxRequestSize(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern long XExtendedMaxRequestSize(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern char *XResourceManagerString(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern char *XScreenResourceString(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern unsigned long XDisplayMotionBufferSize(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern VisualID XVisualIDFromVisual(
+#if NeedFunctionPrototypes
+ Visual* /* visual */
+#endif
+);
+
+/* multithread routines */
+
+extern Status XInitThreads(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern void XLockDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern void XUnlockDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+/* routines for dealing with extensions */
+
+extern XExtCodes *XInitExtension(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* name */
+#endif
+);
+
+extern XExtCodes *XAddExtension(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern XExtData *XFindOnExtensionList(
+#if NeedFunctionPrototypes
+ XExtData** /* structure */,
+ int /* number */
+#endif
+);
+extern XExtData **XEHeadOfExtensionList(
+#if NeedFunctionPrototypes
+ XEDataObject /* object */
+#endif
+);
+
+/* these are routines for which there are also macros */
+extern Window XRootWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern Window XDefaultRootWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern Window XRootWindowOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern Visual *XDefaultVisual(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern Visual *XDefaultVisualOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern GC XDefaultGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern GC XDefaultGCOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern unsigned long XBlackPixel(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern unsigned long XWhitePixel(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern unsigned long XAllPlanes(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+extern unsigned long XBlackPixelOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern unsigned long XWhitePixelOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern unsigned long XNextRequest(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern unsigned long XLastKnownRequestProcessed(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern char *XServerVendor(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern char *XDisplayString(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern Colormap XDefaultColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern Colormap XDefaultColormapOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern Display *XDisplayOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+extern Screen *XScreenOfDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+extern Screen *XDefaultScreenOfDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+extern long XEventMaskOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XScreenNumberOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+typedef int (*XErrorHandler) ( /* WARNING, this type not in Xlib spec */
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XErrorEvent* /* error_event */
+#endif
+);
+
+extern XErrorHandler XSetErrorHandler (
+#if NeedFunctionPrototypes
+ XErrorHandler /* handler */
+#endif
+);
+
+
+typedef int (*XIOErrorHandler) ( /* WARNING, this type not in Xlib spec */
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern XIOErrorHandler XSetIOErrorHandler (
+#if NeedFunctionPrototypes
+ XIOErrorHandler /* handler */
+#endif
+);
+
+
+extern XPixmapFormatValues *XListPixmapFormats(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* count_return */
+#endif
+);
+extern int *XListDepths(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */,
+ int* /* count_return */
+#endif
+);
+
+/* ICCCM routines for things that don't require special include files; */
+/* other declarations are given in Xutil.h */
+extern Status XReconfigureWMWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */,
+ unsigned int /* mask */,
+ XWindowChanges* /* changes */
+#endif
+);
+
+extern Status XGetWMProtocols(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom** /* protocols_return */,
+ int* /* count_return */
+#endif
+);
+extern Status XSetWMProtocols(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* protocols */,
+ int /* count */
+#endif
+);
+extern Status XIconifyWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+#endif
+);
+extern Status XWithdrawWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* screen_number */
+#endif
+);
+extern Status XGetCommand(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ char*** /* argv_return */,
+ int* /* argc_return */
+#endif
+);
+extern Status XGetWMColormapWindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window** /* windows_return */,
+ int* /* count_return */
+#endif
+);
+extern Status XSetWMColormapWindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window* /* colormap_windows */,
+ int /* count */
+#endif
+);
+extern void XFreeStringList(
+#if NeedFunctionPrototypes
+ char** /* list */
+#endif
+);
+extern int XSetTransientForHint(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window /* prop_window */
+#endif
+);
+
+/* The following are given in alphabetical order */
+
+extern int XActivateScreenSaver(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XAddHost(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XHostAddress* /* host */
+#endif
+);
+
+extern int XAddHosts(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+#endif
+);
+
+extern int XAddToExtensionList(
+#if NeedFunctionPrototypes
+ struct _XExtData** /* structure */,
+ XExtData* /* ext_data */
+#endif
+);
+
+extern int XAddToSaveSet(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern Status XAllocColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* screen_in_out */
+#endif
+);
+
+extern Status XAllocColorCells(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* plane_masks_return */,
+ unsigned int /* nplanes */,
+ unsigned long* /* pixels_return */,
+ unsigned int /* npixels */
+#endif
+);
+
+extern Status XAllocColorPlanes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ Bool /* contig */,
+ unsigned long* /* pixels_return */,
+ int /* ncolors */,
+ int /* nreds */,
+ int /* ngreens */,
+ int /* nblues */,
+ unsigned long* /* rmask_return */,
+ unsigned long* /* gmask_return */,
+ unsigned long* /* bmask_return */
+#endif
+);
+
+extern Status XAllocNamedColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* screen_def_return */,
+ XColor* /* exact_def_return */
+#endif
+);
+
+extern int XAllowEvents(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* event_mode */,
+ Time /* time */
+#endif
+);
+
+extern int XAutoRepeatOff(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XAutoRepeatOn(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XBell(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* percent */
+#endif
+);
+
+extern int XBitmapBitOrder(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XBitmapPad(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XBitmapUnit(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XCellsOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XChangeActivePointerGrab(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned int /* event_mask */,
+ Cursor /* cursor */,
+ Time /* time */
+#endif
+);
+
+extern int XChangeGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values */
+#endif
+);
+
+extern int XChangeKeyboardControl(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned long /* value_mask */,
+ XKeyboardControl* /* values */
+#endif
+);
+
+extern int XChangeKeyboardMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* first_keycode */,
+ int /* keysyms_per_keycode */,
+ KeySym* /* keysyms */,
+ int /* num_codes */
+#endif
+);
+
+extern int XChangePointerControl(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Bool /* do_accel */,
+ Bool /* do_threshold */,
+ int /* accel_numerator */,
+ int /* accel_denominator */,
+ int /* threshold */
+#endif
+);
+
+extern int XChangeProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ Atom /* type */,
+ int /* format */,
+ int /* mode */,
+ _Xconst unsigned char* /* data */,
+ int /* nelements */
+#endif
+);
+
+extern int XChangeSaveSet(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* change_mode */
+#endif
+);
+
+extern int XChangeWindowAttributes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* valuemask */,
+ XSetWindowAttributes* /* attributes */
+#endif
+);
+
+extern Bool XCheckIfEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+#endif
+ ) /* predicate */,
+ XPointer /* arg */
+#endif
+);
+
+extern Bool XCheckMaskEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern Bool XCheckTypedEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* event_type */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern Bool XCheckTypedWindowEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* event_type */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern Bool XCheckWindowEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern int XCirculateSubwindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* direction */
+#endif
+);
+
+extern int XCirculateSubwindowsDown(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XCirculateSubwindowsUp(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XClearArea(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ Bool /* exposures */
+#endif
+);
+
+extern int XClearWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XCloseDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XConfigureWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* value_mask */,
+ XWindowChanges* /* values */
+#endif
+);
+
+extern int XConnectionNumber(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XConvertSelection(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Atom /* selection */,
+ Atom /* target */,
+ Atom /* property */,
+ Window /* requestor */,
+ Time /* time */
+#endif
+);
+
+extern int XCopyArea(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */
+#endif
+);
+
+extern int XCopyGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* src */,
+ unsigned long /* valuemask */,
+ GC /* dest */
+#endif
+);
+
+extern int XCopyPlane(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* src */,
+ Drawable /* dest */,
+ GC /* gc */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned long /* plane */
+#endif
+);
+
+extern int XDefaultDepth(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDefaultDepthOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XDefaultScreen(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XDefineCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Cursor /* cursor */
+#endif
+);
+
+extern int XDeleteProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */
+#endif
+);
+
+extern int XDestroyWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XDestroySubwindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XDoesBackingStore(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern Bool XDoesSaveUnders(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XDisableAccessControl(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+
+extern int XDisplayCells(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDisplayHeight(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDisplayHeightMM(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDisplayKeycodes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* min_keycodes_return */,
+ int* /* max_keycodes_return */
+#endif
+);
+
+extern int XDisplayPlanes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDisplayWidth(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDisplayWidthMM(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */
+#endif
+);
+
+extern int XDrawArc(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+#endif
+);
+
+extern int XDrawArcs(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+#endif
+);
+
+extern int XDrawImageString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+#endif
+);
+
+extern int XDrawImageString16(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+#endif
+);
+
+extern int XDrawLine(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x1 */,
+ int /* y1 */,
+ int /* x2 */,
+ int /* y2 */
+#endif
+);
+
+extern int XDrawLines(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+#endif
+);
+
+extern int XDrawPoint(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */
+#endif
+);
+
+extern int XDrawPoints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* mode */
+#endif
+);
+
+extern int XDrawRectangle(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XDrawRectangles(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+#endif
+);
+
+extern int XDrawSegments(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XSegment* /* segments */,
+ int /* nsegments */
+#endif
+);
+
+extern int XDrawString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* string */,
+ int /* length */
+#endif
+);
+
+extern int XDrawString16(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst XChar2b* /* string */,
+ int /* length */
+#endif
+);
+
+extern int XDrawText(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem* /* items */,
+ int /* nitems */
+#endif
+);
+
+extern int XDrawText16(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XTextItem16* /* items */,
+ int /* nitems */
+#endif
+);
+
+extern int XEnableAccessControl(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XEventsQueued(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* mode */
+#endif
+);
+
+extern Status XFetchName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ char** /* window_name_return */
+#endif
+);
+
+extern int XFillArc(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* angle1 */,
+ int /* angle2 */
+#endif
+);
+
+extern int XFillArcs(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XArc* /* arcs */,
+ int /* narcs */
+#endif
+);
+
+extern int XFillPolygon(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XPoint* /* points */,
+ int /* npoints */,
+ int /* shape */,
+ int /* mode */
+#endif
+);
+
+extern int XFillRectangle(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XFillRectangles(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XRectangle* /* rectangles */,
+ int /* nrectangles */
+#endif
+);
+
+extern int XFlush(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XForceScreenSaver(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* mode */
+#endif
+);
+
+extern int XFree(
+#if NeedFunctionPrototypes
+ void* /* data */
+#endif
+);
+
+extern int XFreeColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */
+#endif
+);
+
+extern int XFreeColors(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ unsigned long* /* pixels */,
+ int /* npixels */,
+ unsigned long /* planes */
+#endif
+);
+
+extern int XFreeCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Cursor /* cursor */
+#endif
+);
+
+extern int XFreeExtensionList(
+#if NeedFunctionPrototypes
+ char** /* list */
+#endif
+);
+
+extern int XFreeFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontStruct* /* font_struct */
+#endif
+);
+
+extern int XFreeFontInfo(
+#if NeedFunctionPrototypes
+ char** /* names */,
+ XFontStruct* /* free_info */,
+ int /* actual_count */
+#endif
+);
+
+extern int XFreeFontNames(
+#if NeedFunctionPrototypes
+ char** /* list */
+#endif
+);
+
+extern int XFreeFontPath(
+#if NeedFunctionPrototypes
+ char** /* list */
+#endif
+);
+
+extern int XFreeGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */
+#endif
+);
+
+extern int XFreeModifiermap(
+#if NeedFunctionPrototypes
+ XModifierKeymap* /* modmap */
+#endif
+);
+
+extern int XFreePixmap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Pixmap /* pixmap */
+#endif
+);
+
+extern int XGeometry(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen */,
+ _Xconst char* /* position */,
+ _Xconst char* /* default_position */,
+ unsigned int /* bwidth */,
+ unsigned int /* fwidth */,
+ unsigned int /* fheight */,
+ int /* xadder */,
+ int /* yadder */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */
+#endif
+);
+
+extern int XGetErrorDatabaseText(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* name */,
+ _Xconst char* /* message */,
+ _Xconst char* /* default_string */,
+ char* /* buffer_return */,
+ int /* length */
+#endif
+);
+
+extern int XGetErrorText(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* code */,
+ char* /* buffer_return */,
+ int /* length */
+#endif
+);
+
+extern Bool XGetFontProperty(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ Atom /* atom */,
+ unsigned long* /* value_return */
+#endif
+);
+
+extern Status XGetGCValues(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* valuemask */,
+ XGCValues* /* values_return */
+#endif
+);
+
+extern Status XGetGeometry(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ Window* /* root_return */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned int* /* border_width_return */,
+ unsigned int* /* depth_return */
+#endif
+);
+
+extern Status XGetIconName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ char** /* icon_name_return */
+#endif
+);
+
+extern int XGetInputFocus(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window* /* focus_return */,
+ int* /* revert_to_return */
+#endif
+);
+
+extern int XGetKeyboardControl(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XKeyboardState* /* values_return */
+#endif
+);
+
+extern int XGetPointerControl(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* accel_numerator_return */,
+ int* /* accel_denominator_return */,
+ int* /* threshold_return */
+#endif
+);
+
+extern int XGetPointerMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned char* /* map_return */,
+ int /* nmap */
+#endif
+);
+
+extern int XGetScreenSaver(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int* /* timeout_return */,
+ int* /* interval_return */,
+ int* /* prefer_blanking_return */,
+ int* /* allow_exposures_return */
+#endif
+);
+
+extern Status XGetTransientForHint(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window* /* prop_window_return */
+#endif
+);
+
+extern int XGetWindowProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom /* property */,
+ long /* long_offset */,
+ long /* long_length */,
+ Bool /* delete */,
+ Atom /* req_type */,
+ Atom* /* actual_type_return */,
+ int* /* actual_format_return */,
+ unsigned long* /* nitems_return */,
+ unsigned long* /* bytes_after_return */,
+ unsigned char** /* prop_return */
+#endif
+);
+
+extern Status XGetWindowAttributes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XWindowAttributes* /* window_attributes_return */
+#endif
+);
+
+extern int XGrabButton(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */
+#endif
+);
+
+extern int XGrabKey(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */
+#endif
+);
+
+extern int XGrabKeyboard(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Time /* time */
+#endif
+);
+
+extern int XGrabPointer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* grab_window */,
+ Bool /* owner_events */,
+ unsigned int /* event_mask */,
+ int /* pointer_mode */,
+ int /* keyboard_mode */,
+ Window /* confine_to */,
+ Cursor /* cursor */,
+ Time /* time */
+#endif
+);
+
+extern int XGrabServer(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XHeightMMOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XHeightOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XIfEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+#endif
+ ) /* predicate */,
+ XPointer /* arg */
+#endif
+);
+
+extern int XImageByteOrder(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XInstallColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */
+#endif
+);
+
+extern KeyCode XKeysymToKeycode(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ KeySym /* keysym */
+#endif
+);
+
+extern int XKillClient(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* resource */
+#endif
+);
+
+extern Status XLookupColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color_name */,
+ XColor* /* exact_def_return */,
+ XColor* /* screen_def_return */
+#endif
+);
+
+extern int XLowerWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XMapRaised(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XMapSubwindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XMapWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XMaskEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern int XMaxCmapsOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XMinCmapsOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XMoveResizeWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XMoveWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ int /* x */,
+ int /* y */
+#endif
+);
+
+extern int XNextEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern int XNoOp(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern Status XParseColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* spec */,
+ XColor* /* exact_def_return */
+#endif
+);
+
+extern int XParseGeometry(
+#if NeedFunctionPrototypes
+ _Xconst char* /* parsestring */,
+ int* /* x_return */,
+ int* /* y_return */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+#endif
+);
+
+extern int XPeekEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern int XPeekIfEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event_return */,
+ Bool (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ XPointer /* arg */
+#endif
+ ) /* predicate */,
+ XPointer /* arg */
+#endif
+);
+
+extern int XPending(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XPlanesOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+
+#endif
+);
+
+extern int XProtocolRevision(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XProtocolVersion(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+
+extern int XPutBackEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* event */
+#endif
+);
+
+extern int XPutImage(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ XImage* /* image */,
+ int /* src_x */,
+ int /* src_y */,
+ int /* dest_x */,
+ int /* dest_y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XQLength(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern Status XQueryBestCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+#endif
+);
+
+extern Status XQueryBestSize(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* class */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+#endif
+);
+
+extern Status XQueryBestStipple(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+#endif
+);
+
+extern Status XQueryBestTile(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* which_screen */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */
+#endif
+);
+
+extern int XQueryColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* def_in_out */
+#endif
+);
+
+extern int XQueryColors(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* defs_in_out */,
+ int /* ncolors */
+#endif
+);
+
+extern Bool XQueryExtension(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* name */,
+ int* /* major_opcode_return */,
+ int* /* first_event_return */,
+ int* /* first_error_return */
+#endif
+);
+
+extern int XQueryKeymap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ char [32] /* keys_return */
+#endif
+);
+
+extern Bool XQueryPointer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* child_return */,
+ int* /* root_x_return */,
+ int* /* root_y_return */,
+ int* /* win_x_return */,
+ int* /* win_y_return */,
+ unsigned int* /* mask_return */
+#endif
+);
+
+extern int XQueryTextExtents(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+#endif
+);
+
+extern int XQueryTextExtents16(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* font_ID */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+#endif
+);
+
+extern Status XQueryTree(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window* /* root_return */,
+ Window* /* parent_return */,
+ Window** /* children_return */,
+ unsigned int* /* nchildren_return */
+#endif
+);
+
+extern int XRaiseWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XReadBitmapFile(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ Pixmap* /* bitmap_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+#endif
+);
+
+extern int XReadBitmapFileData(
+#if NeedFunctionPrototypes
+ _Xconst char* /* filename */,
+ unsigned int* /* width_return */,
+ unsigned int* /* height_return */,
+ unsigned char** /* data_return */,
+ int* /* x_hot_return */,
+ int* /* y_hot_return */
+#endif
+);
+
+extern int XRebindKeysym(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ KeySym /* keysym */,
+ KeySym* /* list */,
+ int /* mod_count */,
+ _Xconst unsigned char* /* string */,
+ int /* bytes_string */
+#endif
+);
+
+extern int XRecolorCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Cursor /* cursor */,
+ XColor* /* foreground_color */,
+ XColor* /* background_color */
+#endif
+);
+
+extern int XRefreshKeyboardMapping(
+#if NeedFunctionPrototypes
+ XMappingEvent* /* event_map */
+#endif
+);
+
+extern int XRemoveFromSaveSet(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XRemoveHost(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XHostAddress* /* host */
+#endif
+);
+
+extern int XRemoveHosts(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XHostAddress* /* hosts */,
+ int /* num_hosts */
+#endif
+);
+
+extern int XReparentWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Window /* parent */,
+ int /* x */,
+ int /* y */
+#endif
+);
+
+extern int XResetScreenSaver(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XResizeWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XRestackWindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window* /* windows */,
+ int /* nwindows */
+#endif
+);
+
+extern int XRotateBuffers(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* rotate */
+#endif
+);
+
+extern int XRotateWindowProperties(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Atom* /* properties */,
+ int /* num_prop */,
+ int /* npositions */
+#endif
+);
+
+extern int XScreenCount(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XSelectInput(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */
+#endif
+);
+
+extern Status XSendEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Bool /* propagate */,
+ long /* event_mask */,
+ XEvent* /* event_send */
+#endif
+);
+
+extern int XSetAccessControl(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* mode */
+#endif
+);
+
+extern int XSetArcMode(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* arc_mode */
+#endif
+);
+
+extern int XSetBackground(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* background */
+#endif
+);
+
+extern int XSetClipMask(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* pixmap */
+#endif
+);
+
+extern int XSetClipOrigin(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */
+#endif
+);
+
+extern int XSetClipRectangles(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* clip_x_origin */,
+ int /* clip_y_origin */,
+ XRectangle* /* rectangles */,
+ int /* n */,
+ int /* ordering */
+#endif
+);
+
+extern int XSetCloseDownMode(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* close_mode */
+#endif
+);
+
+extern int XSetCommand(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ char** /* argv */,
+ int /* argc */
+#endif
+);
+
+extern int XSetDashes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* dash_offset */,
+ _Xconst char* /* dash_list */,
+ int /* n */
+#endif
+);
+
+extern int XSetFillRule(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_rule */
+#endif
+);
+
+extern int XSetFillStyle(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* fill_style */
+#endif
+);
+
+extern int XSetFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Font /* font */
+#endif
+);
+
+extern int XSetFontPath(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ char** /* directories */,
+ int /* ndirs */
+#endif
+);
+
+extern int XSetForeground(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */
+#endif
+);
+
+extern int XSetFunction(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* function */
+#endif
+);
+
+extern int XSetGraphicsExposures(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Bool /* graphics_exposures */
+#endif
+);
+
+extern int XSetIconName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* icon_name */
+#endif
+);
+
+extern int XSetInputFocus(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* focus */,
+ int /* revert_to */,
+ Time /* time */
+#endif
+);
+
+extern int XSetLineAttributes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned int /* line_width */,
+ int /* line_style */,
+ int /* cap_style */,
+ int /* join_style */
+#endif
+);
+
+extern int XSetModifierMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XModifierKeymap* /* modmap */
+#endif
+);
+
+extern int XSetPlaneMask(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* plane_mask */
+#endif
+);
+
+extern int XSetPointerMapping(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst unsigned char* /* map */,
+ int /* nmap */
+#endif
+);
+
+extern int XSetScreenSaver(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* timeout */,
+ int /* interval */,
+ int /* prefer_blanking */,
+ int /* allow_exposures */
+#endif
+);
+
+extern int XSetSelectionOwner(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Atom /* selection */,
+ Window /* owner */,
+ Time /* time */
+#endif
+);
+
+extern int XSetState(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ unsigned long /* foreground */,
+ unsigned long /* background */,
+ int /* function */,
+ unsigned long /* plane_mask */
+#endif
+);
+
+extern int XSetStipple(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* stipple */
+#endif
+);
+
+extern int XSetSubwindowMode(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* subwindow_mode */
+#endif
+);
+
+extern int XSetTSOrigin(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ int /* ts_x_origin */,
+ int /* ts_y_origin */
+#endif
+);
+
+extern int XSetTile(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Pixmap /* tile */
+#endif
+);
+
+extern int XSetWindowBackground(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* background_pixel */
+#endif
+);
+
+extern int XSetWindowBackgroundPixmap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* background_pixmap */
+#endif
+);
+
+extern int XSetWindowBorder(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned long /* border_pixel */
+#endif
+);
+
+extern int XSetWindowBorderPixmap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Pixmap /* border_pixmap */
+#endif
+);
+
+extern int XSetWindowBorderWidth(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ unsigned int /* width */
+#endif
+);
+
+extern int XSetWindowColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ Colormap /* colormap */
+#endif
+);
+
+extern int XStoreBuffer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */,
+ int /* buffer */
+#endif
+);
+
+extern int XStoreBytes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* bytes */,
+ int /* nbytes */
+#endif
+);
+
+extern int XStoreColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */
+#endif
+);
+
+extern int XStoreColors(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ XColor* /* color */,
+ int /* ncolors */
+#endif
+);
+
+extern int XStoreName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */
+#endif
+);
+
+extern int XStoreNamedColor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */,
+ _Xconst char* /* color */,
+ unsigned long /* pixel */,
+ int /* flags */
+#endif
+);
+
+extern int XSync(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Bool /* discard */
+#endif
+);
+
+extern int XTextExtents(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+#endif
+);
+
+extern int XTextExtents16(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* nchars */,
+ int* /* direction_return */,
+ int* /* font_ascent_return */,
+ int* /* font_descent_return */,
+ XCharStruct* /* overall_return */
+#endif
+);
+
+extern int XTextWidth(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+#endif
+);
+
+extern int XTextWidth16(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+#endif
+);
+
+extern Bool XTranslateCoordinates(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ int* /* dest_x_return */,
+ int* /* dest_y_return */,
+ Window* /* child_return */
+#endif
+);
+
+extern int XUndefineCursor(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XUngrabButton(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ unsigned int /* button */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+#endif
+);
+
+extern int XUngrabKey(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* keycode */,
+ unsigned int /* modifiers */,
+ Window /* grab_window */
+#endif
+);
+
+extern int XUngrabKeyboard(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Time /* time */
+#endif
+);
+
+extern int XUngrabPointer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Time /* time */
+#endif
+);
+
+extern int XUngrabServer(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XUninstallColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Colormap /* colormap */
+#endif
+);
+
+extern int XUnloadFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Font /* font */
+#endif
+);
+
+extern int XUnmapSubwindows(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XUnmapWindow(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern int XVendorRelease(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern int XWarpPointer(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* src_w */,
+ Window /* dest_w */,
+ int /* src_x */,
+ int /* src_y */,
+ unsigned int /* src_width */,
+ unsigned int /* src_height */,
+ int /* dest_x */,
+ int /* dest_y */
+#endif
+);
+
+extern int XWidthMMOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XWidthOfScreen(
+#if NeedFunctionPrototypes
+ Screen* /* screen */
+#endif
+);
+
+extern int XWindowEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ long /* event_mask */,
+ XEvent* /* event_return */
+#endif
+);
+
+extern int XWriteBitmapFile(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* filename */,
+ Pixmap /* bitmap */,
+ unsigned int /* width */,
+ unsigned int /* height */,
+ int /* x_hot */,
+ int /* y_hot */
+#endif
+);
+
+extern Bool XSupportsLocale(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern char *XSetLocaleModifiers(
+#if NeedFunctionPrototypes
+ _Xconst char* /* modifier_list */
+#endif
+);
+
+extern XOM XOpenOM(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ struct _XrmHashBucketRec* /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+#endif
+);
+
+extern Status XCloseOM(
+#if NeedFunctionPrototypes
+ XOM /* om */
+#endif
+);
+
+extern char *XSetOMValues(
+#if NeedVarargsPrototypes
+ XOM /* om */,
+ ...
+#endif
+);
+
+extern char *XGetOMValues(
+#if NeedVarargsPrototypes
+ XOM /* om */,
+ ...
+#endif
+);
+
+extern Display *XDisplayOfOM(
+#if NeedFunctionPrototypes
+ XOM /* om */
+#endif
+);
+
+extern char *XLocaleOfOM(
+#if NeedFunctionPrototypes
+ XOM /* om */
+#endif
+);
+
+extern XOC XCreateOC(
+#if NeedVarargsPrototypes
+ XOM /* om */,
+ ...
+#endif
+);
+
+extern void XDestroyOC(
+#if NeedFunctionPrototypes
+ XOC /* oc */
+#endif
+);
+
+extern XOM XOMOfOC(
+#if NeedFunctionPrototypes
+ XOC /* oc */
+#endif
+);
+
+extern char *XSetOCValues(
+#if NeedVarargsPrototypes
+ XOC /* oc */,
+ ...
+#endif
+);
+
+extern char *XGetOCValues(
+#if NeedVarargsPrototypes
+ XOC /* oc */,
+ ...
+#endif
+);
+
+extern XFontSet XCreateFontSet(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ _Xconst char* /* base_font_name_list */,
+ char*** /* missing_charset_list */,
+ int* /* missing_charset_count */,
+ char** /* def_string */
+#endif
+);
+
+extern void XFreeFontSet(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontSet /* font_set */
+#endif
+);
+
+extern int XFontsOfFontSet(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ XFontStruct*** /* font_struct_list */,
+ char*** /* font_name_list */
+#endif
+);
+
+extern char *XBaseFontNameListOfFontSet(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern char *XLocaleOfFontSet(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern Bool XContextDependentDrawing(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern Bool XDirectionalDependentDrawing(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern Bool XContextualDrawing(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern XFontSetExtents *XExtentsOfFontSet(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */
+#endif
+);
+
+extern int XmbTextEscapement(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+#endif
+);
+
+extern int XwcTextEscapement(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+#endif
+);
+
+extern int XmbTextExtents(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+#endif
+);
+
+extern int XwcTextExtents(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+#endif
+);
+
+extern Status XmbTextPerCharExtents(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* bytes_text */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+#endif
+);
+
+extern Status XwcTextPerCharExtents(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* overall_ink_return */,
+ XRectangle* /* overall_logical_return */
+#endif
+);
+
+extern void XmbDrawText(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XmbTextItem* /* text_items */,
+ int /* nitems */
+#endif
+);
+
+extern void XwcDrawText(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ XwcTextItem* /* text_items */,
+ int /* nitems */
+#endif
+);
+
+extern void XmbDrawString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+#endif
+);
+
+extern void XwcDrawString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+#endif
+);
+
+extern void XmbDrawImageString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* bytes_text */
+#endif
+);
+
+extern void XwcDrawImageString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* d */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* num_wchars */
+#endif
+);
+
+extern XIM XOpenIM(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+#endif
+);
+
+extern Status XCloseIM(
+#if NeedFunctionPrototypes
+ XIM /* im */
+#endif
+);
+
+extern char *XGetIMValues(
+#if NeedVarargsPrototypes
+ XIM /* im */, ...
+#endif
+);
+
+extern Display *XDisplayOfIM(
+#if NeedFunctionPrototypes
+ XIM /* im */
+#endif
+);
+
+extern char *XLocaleOfIM(
+#if NeedFunctionPrototypes
+ XIM /* im*/
+#endif
+);
+
+extern XIC XCreateIC(
+#if NeedVarargsPrototypes
+ XIM /* im */, ...
+#endif
+);
+
+extern void XDestroyIC(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern void XSetICFocus(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern void XUnsetICFocus(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern wchar_t *XwcResetIC(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern char *XmbResetIC(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern char *XSetICValues(
+#if NeedVarargsPrototypes
+ XIC /* ic */, ...
+#endif
+);
+
+extern char *XGetICValues(
+#if NeedVarargsPrototypes
+ XIC /* ic */, ...
+#endif
+);
+
+extern XIM XIMOfIC(
+#if NeedFunctionPrototypes
+ XIC /* ic */
+#endif
+);
+
+extern Bool XFilterEvent(
+#if NeedFunctionPrototypes
+ XEvent* /* event */,
+ Window /* window */
+#endif
+);
+
+extern int XmbLookupString(
+#if NeedFunctionPrototypes
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+#endif
+);
+
+extern int XwcLookupString(
+#if NeedFunctionPrototypes
+ XIC /* ic */,
+ XKeyPressedEvent* /* event */,
+ wchar_t* /* buffer_return */,
+ int /* wchars_buffer */,
+ KeySym* /* keysym_return */,
+ Status* /* status_return */
+#endif
+);
+
+extern XVaNestedList XVaCreateNestedList(
+#if NeedVarargsPrototypes
+ int /*unused*/, ...
+#endif
+);
+
+/* internal connections for IMs */
+
+extern Bool XRegisterIMInstantiateCallback(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIMProc /* callback */,
+ XPointer* /* client_data */
+#endif
+);
+
+extern Bool XUnregisterIMInstantiateCallback(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ struct _XrmHashBucketRec* /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIMProc /* callback */,
+ XPointer* /* client_data */
+#endif
+);
+
+typedef void (*XConnectionWatchProc)(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XPointer /* client_data */,
+ int /* fd */,
+ Bool /* opening */, /* open or close flag */
+ XPointer* /* watch_data */ /* open sets, close uses */
+#endif
+);
+
+
+extern Status XInternalConnectionNumbers(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int** /* fd_return */,
+ int* /* count_return */
+#endif
+);
+
+extern void XProcessInternalConnection(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* fd */
+#endif
+);
+
+extern Status XAddConnectionWatch(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+#endif
+);
+
+extern void XRemoveConnectionWatch(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ XConnectionWatchProc /* callback */,
+ XPointer /* client_data */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLIB_H_ */
diff --git a/include/X11/Xlibint.h b/include/X11/Xlibint.h
new file mode 100644
index 00000000..3f3826b6
--- /dev/null
+++ b/include/X11/Xlibint.h
@@ -0,0 +1,1278 @@
+/* $Xorg: Xlibint.h,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+
+/*
+
+Copyright 1984, 1985, 1987, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Xlibint.h - Header definition and support file for the internal
+ * support routines used by the C subroutine interface
+ * library (Xlib) to the X Window System.
+ *
+ * Warning, there be dragons here....
+ */
+
+#ifndef _XLIBINT_H_
+#define _XLIBINT_H_
+
+#include <X11/Xlib.h>
+
+#ifdef WIN32
+#define _XFlush _XFlushIt
+#endif
+
+/*
+ * If your BytesReadable correctly detects broken connections, then
+ * you should NOT define XCONN_CHECK_FREQ.
+ */
+#ifndef XCONN_CHECK_FREQ
+#define XCONN_CHECK_FREQ 256
+#endif
+
+struct _XGC
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ GContext gid; /* protocol ID for graphics context */
+ Bool rects; /* boolean: TRUE if clipmask is list of rectangles */
+ Bool dashes; /* boolean: TRUE if dash-list is really a list */
+ unsigned long dirty;/* cache dirty bits */
+ XGCValues values; /* shadow structure of values */
+};
+
+struct _XDisplay
+{
+ XExtData *ext_data; /* hook for extension to hang data */
+ struct _XFreeFuncs *free_funcs; /* internal free functions */
+ int fd; /* Network socket. */
+ int conn_checker; /* ugly thing used by _XEventsQueued */
+ int proto_major_version;/* maj. version of server's X protocol */
+ int proto_minor_version;/* minor version of server's X protocol */
+ char *vendor; /* vendor of the server hardware */
+ XID resource_base; /* resource ID base */
+ XID resource_mask; /* resource ID mask bits */
+ XID resource_id; /* allocator current ID */
+ int resource_shift; /* allocator shift to correct bits */
+ XID (*resource_alloc)(); /* allocator function */
+ int byte_order; /* screen byte order, LSBFirst, MSBFirst */
+ int bitmap_unit; /* padding and data requirements */
+ int bitmap_pad; /* padding requirements on bitmaps */
+ int bitmap_bit_order; /* LeastSignificant or MostSignificant */
+ int nformats; /* number of pixmap formats in list */
+ ScreenFormat *pixmap_format; /* pixmap format list */
+ int vnumber; /* Xlib's X protocol version number. */
+ int release; /* release of the server */
+ struct _XSQEvent *head, *tail; /* Input event queue. */
+ int qlen; /* Length of input event queue */
+ unsigned long last_request_read; /* seq number of last event read */
+ unsigned long request; /* sequence number of last request. */
+ char *last_req; /* beginning of last request, or dummy */
+ char *buffer; /* Output buffer starting address. */
+ char *bufptr; /* Output buffer index pointer. */
+ char *bufmax; /* Output buffer maximum+1 address. */
+ unsigned max_request_size; /* maximum number 32 bit words in request*/
+ struct _XrmHashBucketRec *db;
+ int (*synchandler)(); /* Synchronization handler */
+ char *display_name; /* "host:display" string used on this connect*/
+ int default_screen; /* default screen for operations */
+ int nscreens; /* number of screens on this server*/
+ Screen *screens; /* pointer to list of screens */
+ unsigned long motion_buffer; /* size of motion buffer */
+ unsigned long flags; /* internal connection flags */
+ int min_keycode; /* minimum defined keycode */
+ int max_keycode; /* maximum defined keycode */
+ KeySym *keysyms; /* This server's keysyms */
+ XModifierKeymap *modifiermap; /* This server's modifier keymap */
+ int keysyms_per_keycode;/* number of rows */
+ char *xdefaults; /* contents of defaults from server */
+ char *scratch_buffer; /* place to hang scratch buffer */
+ unsigned long scratch_length; /* length of scratch buffer */
+ int ext_number; /* extension number on this display */
+ struct _XExten *ext_procs; /* extensions initialized on this display */
+ /*
+ * the following can be fixed size, as the protocol defines how
+ * much address space is available.
+ * While this could be done using the extension vector, there
+ * may be MANY events processed, so a search through the extension
+ * list to find the right procedure for each event might be
+ * expensive if many extensions are being used.
+ */
+ Bool (*event_vec[128])(); /* vector for wire to event */
+ Status (*wire_vec[128])(); /* vector for event to wire */
+ KeySym lock_meaning; /* for XLookupString */
+ struct _XLockInfo *lock; /* multi-thread state, display lock */
+ struct _XInternalAsync *async_handlers; /* for internal async */
+ unsigned long bigreq_size; /* max size of big requests */
+ struct _XLockPtrs *lock_fns; /* pointers to threads functions */
+ void (*idlist_alloc)(); /* XID list allocator function */
+ /* things above this line should not move, for binary compatibility */
+ struct _XKeytrans *key_bindings; /* for XLookupString */
+ Font cursor_font; /* for XCreateFontCursor */
+ struct _XDisplayAtoms *atoms; /* for XInternAtom */
+ unsigned int mode_switch; /* keyboard group modifiers */
+ unsigned int num_lock; /* keyboard numlock modifiers */
+ struct _XContextDB *context_db; /* context database */
+ Bool (**error_vec)(); /* vector for wire to error */
+ /*
+ * Xcms information
+ */
+ struct {
+ XPointer defaultCCCs; /* pointer to an array of default XcmsCCC */
+ XPointer clientCmaps; /* pointer to linked list of XcmsCmapRec */
+ XPointer perVisualIntensityMaps;
+ /* linked list of XcmsIntensityMap */
+ } cms;
+ struct _XIMFilter *im_filters;
+ struct _XSQEvent *qfree; /* unallocated event queue elements */
+ unsigned long next_event_serial_num; /* inserted into next queue elt */
+ struct _XExten *flushes; /* Flush hooks */
+ struct _XConnectionInfo *im_fd_info; /* _XRegisterInternalConnection */
+ int im_fd_length; /* number of im_fd_info */
+ struct _XConnWatchInfo *conn_watchers; /* XAddConnectionWatch */
+ int watcher_count; /* number of conn_watchers */
+ XPointer filedes; /* struct pollfd cache for _XWaitForReadable */
+ int (*savedsynchandler)(); /* user synchandler when Xlib usurps */
+ XID resource_max; /* allocator max ID */
+ int xcmisc_opcode; /* major opcode for XC-MISC */
+ struct _XkbInfoRec *xkb_info; /* XKB info */
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+};
+
+#define XAllocIDs(dpy,ids,n) (*(dpy)->idlist_alloc)(dpy,ids,n)
+
+/*
+ * define the following if you want the Data macro to be a procedure instead
+ */
+#ifdef CRAY
+#define DataRoutineIsProcedure
+#endif /* CRAY */
+
+#ifndef _XEVENT_
+/*
+ * _QEvent datatype for use in input queueing.
+ */
+typedef struct _XSQEvent
+{
+ struct _XSQEvent *next;
+ XEvent event;
+ unsigned long qserial_num; /* so multi-threaded code can find new ones */
+} _XQEvent;
+#endif
+
+#ifdef XTHREADS /* for xReply */
+#define NEED_REPLIES
+#endif
+
+#if NeedFunctionPrototypes /* prototypes require event type definitions */
+#define NEED_EVENTS
+#define NEED_REPLIES
+#endif
+#include <X11/Xproto.h>
+#ifdef __sgi
+#define _SGI_MP_SOURCE /* turn this on to get MP safe errno */
+#endif
+#include <errno.h>
+#define _XBCOPYFUNC _Xbcopy
+#include <X11/Xfuncs.h>
+#include <X11/Xosdefs.h>
+
+/* Utek leaves kernel macros around in include files (bleah) */
+#ifdef dirty
+#undef dirty
+#endif
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#include <string.h>
+#else
+char *malloc(), *realloc(), *calloc();
+void exit();
+#ifdef SYSV
+#include <string.h>
+#else
+#include <strings.h>
+#endif
+#endif
+
+/*
+ * The following definitions can be used for locking requests in multi-threaded
+ * address spaces.
+ */
+#ifdef XTHREADS
+/* Author: Stephen Gildea, MIT X Consortium
+ *
+ * declarations for C Threads locking
+ */
+
+#include <X11/Xfuncproto.h>
+
+struct _XLockPtrs {
+ /* used by all, including extensions; do not move */
+ void (*lock_display)();
+ void (*unlock_display)();
+};
+
+typedef struct _LockInfoRec *LockInfoPtr;
+
+#if defined(WIN32) && !defined(_XLIBINT_)
+#define _XCreateMutex_fn (*_XCreateMutex_fn_p)
+#define _XFreeMutex_fn (*_XFreeMutex_fn_p)
+#define _XLockMutex_fn (*_XLockMutex_fn_p)
+#define _XUnlockMutex_fn (*_XUnlockMutex_fn_p)
+#define _Xglobal_lock (*_Xglobal_lock_p)
+#endif
+
+/* in XlibInt.c */
+extern void (*_XCreateMutex_fn)(
+#if NeedFunctionPrototypes
+ LockInfoPtr /* lock */
+#endif
+);
+extern void (*_XFreeMutex_fn)(
+#if NeedFunctionPrototypes
+ LockInfoPtr /* lock */
+#endif
+);
+extern void (*_XLockMutex_fn)(
+#if NeedFunctionPrototypes
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+#endif
+);
+extern void (*_XUnlockMutex_fn)(
+#if NeedFunctionPrototypes
+ LockInfoPtr /* lock */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char * /* file */
+ , int /* line */
+#endif
+#endif
+);
+
+extern LockInfoPtr _Xglobal_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)((d),__FILE__,__LINE__)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)((d),__FILE__,__LINE__)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock,__FILE__,__LINE__)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock,__FILE__,__LINE__)
+#else
+/* used everywhere, so must be fast if not using threads */
+#define LockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->lock_display)(d)
+#define UnlockDisplay(d) if ((d)->lock_fns) (*(d)->lock_fns->unlock_display)(d)
+#define _XLockMutex(lock) if (_XLockMutex_fn) (*_XLockMutex_fn)(lock)
+#define _XUnlockMutex(lock) if (_XUnlockMutex_fn) (*_XUnlockMutex_fn)(lock)
+#endif
+#define _XCreateMutex(lock) if (_XCreateMutex_fn) (*_XCreateMutex_fn)(lock);
+#define _XFreeMutex(lock) if (_XFreeMutex_fn) (*_XFreeMutex_fn)(lock);
+
+#else /* XTHREADS */
+#define LockDisplay(dis)
+#define _XLockMutex(lock)
+#define _XUnlockMutex(lock)
+#define UnlockDisplay(dis)
+#define _XCreateMutex(lock)
+#define _XFreeMutex(lock)
+#endif
+
+#define Xfree(ptr) free((ptr))
+
+/*
+ * Note that some machines do not return a valid pointer for malloc(0), in
+ * which case we provide an alternate under the control of the
+ * define MALLOC_0_RETURNS_NULL. This is necessary because some
+ * Xlib code expects malloc(0) to return a valid pointer to storage.
+ */
+#ifdef MALLOC_0_RETURNS_NULL
+
+# define Xmalloc(size) malloc(((size) == 0 ? 1 : (size)))
+# define Xrealloc(ptr, size) realloc((ptr), ((size) == 0 ? 1 : (size)))
+# define Xcalloc(nelem, elsize) calloc(((nelem) == 0 ? 1 : (nelem)), (elsize))
+
+#else
+
+# define Xmalloc(size) malloc((size))
+# define Xrealloc(ptr, size) realloc((ptr), (size))
+# define Xcalloc(nelem, elsize) calloc((nelem), (elsize))
+
+#endif
+
+#ifndef NULL
+#define NULL 0
+#endif
+#define LOCKED 1
+#define UNLOCKED 0
+
+#ifdef X_NOT_STDC_ENV
+extern int errno; /* Internal system error number. */
+#endif
+
+#ifndef BUFSIZE
+#define BUFSIZE 2048 /* X output buffer size. */
+#endif
+#ifndef PTSPERBATCH
+#define PTSPERBATCH 1024 /* point batching */
+#endif
+#ifndef WLNSPERBATCH
+#define WLNSPERBATCH 50 /* wide line batching */
+#endif
+#ifndef ZLNSPERBATCH
+#define ZLNSPERBATCH 1024 /* thin line batching */
+#endif
+#ifndef WRCTSPERBATCH
+#define WRCTSPERBATCH 10 /* wide line rectangle batching */
+#endif
+#ifndef ZRCTSPERBATCH
+#define ZRCTSPERBATCH 256 /* thin line rectangle batching */
+#endif
+#ifndef FRCTSPERBATCH
+#define FRCTSPERBATCH 256 /* filled rectangle batching */
+#endif
+#ifndef FARCSPERBATCH
+#define FARCSPERBATCH 256 /* filled arc batching */
+#endif
+#ifndef CURSORFONT
+#define CURSORFONT "cursor" /* standard cursor fonts */
+#endif
+
+/*
+ * Display flags
+ */
+#define XlibDisplayIOError (1L << 0)
+#define XlibDisplayClosing (1L << 1)
+#define XlibDisplayNoXkb (1L << 2)
+#define XlibDisplayPrivSync (1L << 3)
+#define XlibDisplayProcConni (1L << 4) /* in _XProcessInternalConnection */
+#define XlibDisplayReadEvents (1L << 5) /* in _XReadEvents */
+#define XlibDisplayReply (1L << 5) /* in _XReply */
+#define XlibDisplayWriting (1L << 6) /* in _XFlushInt, _XSend */
+
+/*
+ * X Protocol packetizing macros.
+ */
+
+/* Need to start requests on 64 bit word boundaries
+ * on a CRAY computer so add a NoOp (127) if needed.
+ * A character pointer on a CRAY computer will be non-zero
+ * after shifting right 61 bits of it is not pointing to
+ * a word boundary.
+ */
+#ifdef WORD64
+#define WORD64ALIGN if ((long)dpy->bufptr >> 61) {\
+ dpy->last_req = dpy->bufptr;\
+ *(dpy->bufptr) = X_NoOperation;\
+ *(dpy->bufptr+1) = 0;\
+ *(dpy->bufptr+2) = 0;\
+ *(dpy->bufptr+3) = 1;\
+ dpy->request++;\
+ dpy->bufptr += 4;\
+ }
+#else /* else does not require alignment on 64-bit boundaries */
+#define WORD64ALIGN
+#endif /* WORD64 */
+
+
+/*
+ * GetReq - Get the next available X request packet in the buffer and
+ * return it.
+ *
+ * "name" is the name of the request, e.g. CreatePixmap, OpenFont, etc.
+ * "req" is the name of the request pointer.
+ *
+ */
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req))>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req);\
+ dpy->request++
+
+#else /* non-ANSI C uses empty comment instead of "##" for token concatenation */
+#define GetReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req))>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req);\
+ dpy->request++
+#endif
+
+/* GetReqExtra is the same as GetReq, but allocates "n" additional
+ bytes after the request. "n" must be a multiple of 4! */
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x##name##Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x##name##Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = (SIZEOF(x##name##Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x##name##Req) + n;\
+ dpy->request++
+#else
+#define GetReqExtra(name, n, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(x/**/name/**/Req) + n) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (x/**/name/**/Req *)(dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = (SIZEOF(x/**/name/**/Req) + n)>>2;\
+ dpy->bufptr += SIZEOF(x/**/name/**/Req) + n;\
+ dpy->request++
+#endif
+
+
+/*
+ * GetResReq is for those requests that have a resource ID
+ * (Window, Pixmap, GContext, etc.) as their single argument.
+ * "rid" is the name of the resource.
+ */
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#else
+#define GetResReq(name, rid, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xResourceReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xResourceReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 2;\
+ req->id = (rid);\
+ dpy->bufptr += SIZEOF(xResourceReq);\
+ dpy->request++
+#endif
+
+/*
+ * GetEmptyReq is for those requests that have no arguments
+ * at all.
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_##name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#else
+#define GetEmptyReq(name, req) \
+ WORD64ALIGN\
+ if ((dpy->bufptr + SIZEOF(xReq)) > dpy->bufmax)\
+ _XFlush(dpy);\
+ req = (xReq *) (dpy->last_req = dpy->bufptr);\
+ req->reqType = X_/**/name;\
+ req->length = 1;\
+ dpy->bufptr += SIZEOF(xReq);\
+ dpy->request++
+#endif
+
+#ifdef WORD64
+#define MakeBigReq(req,n) \
+ { \
+ char _BRdat[4]; \
+ unsigned long _BRlen = req->length - 1; \
+ req->length = 0; \
+ memcpy(_BRdat, ((char *)req) + (_BRlen << 2), 4); \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ memcpy(((char *)req) + 4, _BRdat, 4); \
+ Data32(dpy, (long *)&_BRdat, 4); \
+ }
+#else
+#ifdef LONG64
+#define MakeBigReq(req,n) \
+ { \
+ CARD64 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#else
+#define MakeBigReq(req,n) \
+ { \
+ CARD32 _BRdat; \
+ CARD32 _BRlen = req->length - 1; \
+ req->length = 0; \
+ _BRdat = ((CARD32 *)req)[_BRlen]; \
+ memmove(((char *)req) + 8, ((char *)req) + 4, _BRlen << 2); \
+ ((CARD32 *)req)[1] = _BRlen + n + 2; \
+ Data32(dpy, &_BRdat, 4); \
+ }
+#endif
+#endif
+
+#define SetReqLen(req,n,badlen) \
+ if ((req->length + n) > (unsigned)65535) { \
+ if (dpy->bigreq_size) { \
+ MakeBigReq(req,n) \
+ } else { \
+ n = badlen; \
+ req->length += n; \
+ } \
+ } else \
+ req->length += n
+
+#define SyncHandle() \
+ if (dpy->synchandler) (*dpy->synchandler)(dpy)
+
+extern void _XFlushGCCache();
+#define FlushGC(dpy, gc) \
+ if ((gc)->dirty) _XFlushGCCache((dpy), (gc))
+/*
+ * Data - Place data in the buffer and pad the end to provide
+ * 32 bit word alignment. Transmit if the buffer fills.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pinter to a data buffer.
+ * "len" is the length of the data buffer.
+ */
+#ifndef DataRoutineIsProcedure
+#define Data(dpy, data, len) \
+ if (dpy->bufptr + (len) <= dpy->bufmax) {\
+ memcpy(dpy->bufptr, data, (int)len);\
+ dpy->bufptr += ((len) + 3) & ~3;\
+ } else\
+ _XSend(dpy, data, len)
+#endif /* DataRoutineIsProcedure */
+
+
+/* Allocate bytes from the buffer. No padding is done, so if
+ * the length is not a multiple of 4, the caller must be
+ * careful to leave the buffer aligned after sending the
+ * current request.
+ *
+ * "type" is the type of the pointer being assigned to.
+ * "ptr" is the pointer being assigned to.
+ * "n" is the number of bytes to allocate.
+ *
+ * Example:
+ * xTextElt *elt;
+ * BufAlloc (xTextElt *, elt, nbytes)
+ */
+
+#define BufAlloc(type, ptr, n) \
+ if (dpy->bufptr + (n) > dpy->bufmax) \
+ _XFlush (dpy); \
+ ptr = (type) dpy->bufptr; \
+ dpy->bufptr += (n);
+
+#ifdef WORD64
+#define Data16(dpy, data, len) _XData16(dpy, (short *)data, len)
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#else
+#define Data16(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead16Pad(dpy, data, len) _XReadPad((dpy), (char *)(data), (len))
+#define _XRead16(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#ifdef LONG64
+#define Data32(dpy, data, len) _XData32(dpy, (long *)data, len)
+#else
+#define Data32(dpy, data, len) Data((dpy), (char *)(data), (len))
+#define _XRead32(dpy, data, len) _XRead((dpy), (char *)(data), (len))
+#endif
+#endif /* not WORD64 */
+
+#define PackData16(dpy,data,len) Data16 (dpy, data, len)
+#define PackData32(dpy,data,len) Data32 (dpy, data, len)
+
+/* Xlib manual is bogus */
+#define PackData(dpy,data,len) PackData16 (dpy, data, len)
+
+#define min(a,b) (((a) < (b)) ? (a) : (b))
+#define max(a,b) (((a) > (b)) ? (a) : (b))
+
+#define CI_NONEXISTCHAR(cs) (((cs)->width == 0) && \
+ (((cs)->rbearing|(cs)->lbearing| \
+ (cs)->ascent|(cs)->descent) == 0))
+
+/*
+ * CI_GET_CHAR_INFO_1D - return the charinfo struct for the indicated 8bit
+ * character. If the character is in the column and exists, then return the
+ * appropriate metrics (note that fonts with common per-character metrics will
+ * return min_bounds). If none of these hold true, try again with the default
+ * char.
+ */
+#define CI_GET_CHAR_INFO_1D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_1D(fs,cs) \
+ CI_GET_CHAR_INFO_1D (fs, fs->default_char, NULL, cs)
+
+
+
+/*
+ * CI_GET_CHAR_INFO_2D - return the charinfo struct for the indicated row and
+ * column. This is used for fonts that have more than row zero.
+ */
+#define CI_GET_CHAR_INFO_2D(fs,row,col,def,cs) \
+{ \
+ cs = def; \
+ if (row >= fs->min_byte1 && row <= fs->max_byte1 && \
+ col >= fs->min_char_or_byte2 && col <= fs->max_char_or_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[((row - fs->min_byte1) * \
+ (fs->max_char_or_byte2 - \
+ fs->min_char_or_byte2 + 1)) + \
+ (col - fs->min_char_or_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+#define CI_GET_DEFAULT_INFO_2D(fs,cs) \
+{ \
+ unsigned int r = (fs->default_char >> 8); \
+ unsigned int c = (fs->default_char & 0xff); \
+ CI_GET_CHAR_INFO_2D (fs, r, c, NULL, cs); \
+}
+
+
+#ifdef MUSTCOPY
+
+/* for when 32-bit alignment is not good enough */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { dpy->bufptr -= 4; Data32 (dpy, (char *) &(srcvar), 4); }
+
+#else
+
+/* srcvar must be a variable for large architecture version */
+#define OneDataCard32(dpy,dstaddr,srcvar) \
+ { *(CARD32 *)(dstaddr) = (srcvar); }
+
+#endif /* MUSTCOPY */
+
+typedef struct _XInternalAsync {
+ struct _XInternalAsync *next;
+ /*
+ * handler arguments:
+ * rep is the generic reply that caused this handler
+ * to be invoked. It must also be passed to _XGetAsyncReply.
+ * buf and len are opaque values that must be passed to
+ * _XGetAsyncReply or _XGetAsyncData.
+ * data is the closure stored in this struct.
+ * The handler returns True iff it handled this reply.
+ */
+ Bool (*handler)(
+#if NeedNestedPrototypes
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+#endif
+ );
+ XPointer data;
+} _XAsyncHandler;
+
+typedef struct _XAsyncEState {
+ unsigned long min_sequence_number;
+ unsigned long max_sequence_number;
+ unsigned char error_code;
+ unsigned char major_opcode;
+ unsigned short minor_opcode;
+ unsigned char last_error_received;
+ int error_count;
+} _XAsyncErrorState;
+
+extern void _XDeqAsyncHandler();
+#define DeqAsyncHandler(dpy,handler) { \
+ if (dpy->async_handlers == (handler)) \
+ dpy->async_handlers = (handler)->next; \
+ else \
+ _XDeqAsyncHandler(dpy, handler); \
+ }
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XFreeFuncs {
+ void (*atoms)(); /* _XFreeAtomTable */
+ int (*modifiermap)(); /* XFreeModifierMap */
+ void (*key_bindings)(); /* _XFreeKeyBindings */
+ void (*context_db)(); /* _XFreeContextDB */
+ void (*defaultCCCs)(); /* _XcmsFreeDefaultCCCs */
+ void (*clientCmaps)(); /* _XcmsFreeClientCmaps */
+ void (*intensityMaps)(); /* _XcmsFreeIntensityMaps */
+ void (*im_filters)(); /* _XFreeIMFilters */
+ void (*xkb)(); /* _XkbFreeInfo */
+} _XFreeFuncRec;
+
+/*
+ * This structure is private to the library.
+ */
+typedef struct _XExten { /* private to extension mechanism */
+ struct _XExten *next; /* next in list */
+ XExtCodes codes; /* public information, all extension told */
+ int (*create_GC)(); /* routine to call when GC created */
+ int (*copy_GC)(); /* routine to call when GC copied */
+ int (*flush_GC)(); /* routine to call when GC flushed */
+ int (*free_GC)(); /* routine to call when GC freed */
+ int (*create_Font)(); /* routine to call when Font created */
+ int (*free_Font)(); /* routine to call when Font freed */
+ int (*close_display)(); /* routine to call when connection closed */
+ int (*error)(); /* who to call when an error occurs */
+ char *(*error_string)(); /* routine to supply error string */
+ char *name; /* name of this extension */
+ void (*error_values)(); /* routine to supply error values */
+ void (*before_flush)(); /* routine to call when sending data */
+ struct _XExten *next_flush; /* next in list of those with flushes */
+} _XExtension;
+
+/* extension hooks */
+
+_XFUNCPROTOBEGIN
+
+#ifdef DataRoutineIsProcedure
+extern void Data();
+#endif
+extern int _XError(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ xError* /* rep */
+#endif
+);
+extern int _XIOError(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+extern int (*_XIOErrorFunction)(
+#if NeedNestedPrototypes
+ Display* /* dpy */
+#endif
+);
+extern int (*_XErrorFunction)(
+#if NeedNestedPrototypes
+ Display* /* dpy */,
+ XErrorEvent* /* error_event */
+#endif
+);
+extern void _XEatData(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ unsigned long /* n */
+#endif
+);
+extern char *_XAllocScratch(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+#endif
+);
+extern char *_XAllocTemp(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ unsigned long /* nbytes */
+#endif
+);
+extern void _XFreeTemp(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ char* /* buf */,
+ unsigned long /* nbytes */
+#endif
+);
+extern Visual *_XVIDtoVisual(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ VisualID /* id */
+#endif
+);
+extern unsigned long _XSetLastRequestRead(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ xGenericReply* /* rep */
+#endif
+);
+extern int _XGetHostname(
+#if NeedFunctionPrototypes
+ char* /* buf */,
+ int /* maxlen */
+#endif
+);
+extern Screen *_XScreenOfWindow(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* w */
+#endif
+);
+extern Bool _XAsyncErrorHandler(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ XPointer /* data */
+#endif
+);
+extern char *_XGetAsyncReply(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ char* /* replbuf */,
+ xReply* /* rep */,
+ char* /* buf */,
+ int /* len */,
+ int /* extra */,
+ Bool /* discard */
+#endif
+);
+extern void _XFlush(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+extern int _XEventsQueued(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* mode */
+#endif
+);
+extern void _XReadEvents(
+#if NeedFunctionPrototypes
+ Display* /* dpy */
+#endif
+);
+extern int _XRead(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+#endif
+);
+extern void _XReadPad(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ char* /* data */,
+ long /* size */
+#endif
+);
+extern void _XSend(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ _Xconst char* /* data */,
+ long /* size */
+#endif
+);
+extern Status _XReply(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ xReply* /* rep */,
+ int /* extra */,
+ Bool /* discard */
+#endif
+);
+extern void _XEnq(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ xEvent* /* event */
+#endif
+);
+extern void _XDeq(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ _XQEvent* /* prev */,
+ _XQEvent* /* qelt */
+#endif
+);
+
+extern int (*XESetCreateGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, GC, XExtCodes*
+#endif
+);
+
+extern int (*XESetCopyGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, GC, XExtCodes*
+#endif
+);
+
+extern int (*XESetFlushGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, GC, XExtCodes*
+#endif
+);
+
+extern int (*XESetFreeGC(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, GC, XExtCodes*
+#endif
+);
+
+extern int (*XESetCreateFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XFontStruct*, XExtCodes*
+#endif
+);
+
+extern int (*XESetFreeFont(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XFontStruct*, XExtCodes*
+#endif
+);
+
+extern int (*XESetCloseDisplay(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XExtCodes*
+#endif
+);
+
+extern int (*XESetError(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ int (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, xError*, XExtCodes*, int*
+#endif
+);
+
+extern char* (*XESetErrorString(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ char* (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, int, XExtCodes*, char*, int
+#endif
+);
+
+extern void (*XESetPrintErrorValues (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* extension */,
+ void (*)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XErrorEvent*, void*
+#endif
+);
+
+extern Bool (*XESetWireToEvent(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* event_number */,
+ Bool (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XEvent*, xEvent*
+#endif
+);
+
+extern Status (*XESetEventToWire(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* event_number */,
+ Status (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XEvent*, xEvent*
+#endif
+);
+
+extern Bool (*XESetWireToError(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* error_number */,
+ Bool (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XErrorEvent*, xError*
+#endif
+);
+
+extern void (*XESetBeforeFlush(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* error_number */,
+ void (*) (
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ char* /* data */,
+ long /* len */
+#endif
+ ) /* proc */
+#endif
+))(
+#if NeedNestedPrototypes
+ Display*, XExtCodes*, char*, long
+#endif
+);
+
+/* internal connections for IMs */
+
+typedef void (*_XInternalConnectionProc)(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* fd */,
+ XPointer /* call_data */
+#endif
+);
+
+
+extern Status _XRegisterInternalConnection(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* fd */,
+ _XInternalConnectionProc /* callback */,
+ XPointer /* call_data */
+#endif
+);
+
+extern void _XUnregisterInternalConnection(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ int /* fd */
+#endif
+);
+
+/* Display structure has pointers to these */
+
+struct _XConnectionInfo { /* info from _XRegisterInternalConnection */
+ int fd;
+ _XInternalConnectionProc read_callback;
+ XPointer call_data;
+ XPointer *watch_data; /* set/used by XConnectionWatchProc */
+ struct _XConnectionInfo *next;
+};
+
+struct _XConnWatchInfo { /* info from XAddConnectionWatch */
+ XConnectionWatchProc fn;
+ XPointer client_data;
+ struct _XConnWatchInfo *next;
+};
+
+extern int _XTextHeight(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst char* /* string */,
+ int /* count */
+#endif
+);
+
+extern int _XTextHeight16(
+#if NeedFunctionPrototypes
+ XFontStruct* /* font_struct */,
+ _Xconst XChar2b* /* string */,
+ int /* count */
+#endif
+);
+
+#if defined(WIN32) || defined(__EMX__) /* || defined(OS2) */
+extern int _XOpenFile(
+#if NeedFunctionPrototypes
+ _Xconst char* /* path */,
+ int /* flags */
+#endif
+);
+
+extern void* _XFopenFile(
+#if NeedFunctionPrototypes
+ _Xconst char* /* path */,
+ _Xconst char* /* mode */
+#endif
+);
+
+extern int _XAccessFile(
+#if NeedFunctionPrototypes
+ _Xconst char* /* path */
+#endif
+);
+#else
+#define _XOpenFile(path,flags) open(path,flags)
+#define _XFopenFile(path,mode) fopen(path,mode)
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _XLIBINT_H_ */
diff --git a/include/X11/Xlocale.h b/include/X11/Xlocale.h
new file mode 100644
index 00000000..77702b1b
--- /dev/null
+++ b/include/X11/Xlocale.h
@@ -0,0 +1,70 @@
+/* $Xorg: Xlocale.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#ifndef _XLOCALE_H_
+#define _XLOCALE_H_
+
+#include <X11/Xfuncproto.h>
+#include <X11/Xosdefs.h>
+
+#ifndef X_LOCALE
+#ifdef X_NOT_STDC_ENV
+#define X_LOCALE
+#endif
+#endif
+
+#ifndef X_LOCALE
+#include <locale.h>
+#else
+
+#define LC_ALL 0
+#define LC_COLLATE 1
+#define LC_CTYPE 2
+#define LC_MONETARY 3
+#define LC_NUMERIC 4
+#define LC_TIME 5
+
+_XFUNCPROTOBEGIN
+extern char *_Xsetlocale(
+#if NeedFunctionPrototypes
+ int /* category */,
+ _Xconst char* /* name */
+#endif
+);
+_XFUNCPROTOEND
+
+#define setlocale _Xsetlocale
+
+#ifndef NULL
+#define NULL 0
+#endif
+
+#endif /* X_LOCALE */
+
+#endif /* _XLOCALE_H_ */
diff --git a/include/X11/Xresource.h b/include/X11/Xresource.h
new file mode 100644
index 00000000..b195bb51
--- /dev/null
+++ b/include/X11/Xresource.h
@@ -0,0 +1,413 @@
+/* $Xorg: Xresource.h,v 1.7 2001/02/09 02:03:39 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#ifndef _XRESOURCE_H_
+#define _XRESOURCE_H_
+
+/* You must include <X11/Xlib.h> before including this file */
+
+#include <X11/Xlib.h>
+
+/****************************************************************
+ ****************************************************************
+ *** ***
+ *** ***
+ *** X Resource Manager Intrinsics ***
+ *** ***
+ *** ***
+ ****************************************************************
+ ****************************************************************/
+
+_XFUNCPROTOBEGIN
+
+/****************************************************************
+ *
+ * Memory Management
+ *
+ ****************************************************************/
+
+extern char *Xpermalloc(
+#if NeedFunctionPrototypes
+ unsigned int /* size */
+#endif
+);
+
+/****************************************************************
+ *
+ * Quark Management
+ *
+ ****************************************************************/
+
+typedef int XrmQuark, *XrmQuarkList;
+#define NULLQUARK ((XrmQuark) 0)
+
+typedef char *XrmString;
+#define NULLSTRING ((XrmString) 0)
+
+/* find quark for string, create new quark if none already exists */
+extern XrmQuark XrmStringToQuark(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */
+#endif
+);
+
+extern XrmQuark XrmPermStringToQuark(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */
+#endif
+);
+
+/* find string for quark */
+extern XrmString XrmQuarkToString(
+#if NeedFunctionPrototypes
+ XrmQuark /* quark */
+#endif
+);
+
+extern XrmQuark XrmUniqueQuark(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+#define XrmStringsEqual(a1, a2) (strcmp(a1, a2) == 0)
+
+
+/****************************************************************
+ *
+ * Conversion of Strings to Lists
+ *
+ ****************************************************************/
+
+typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;
+
+extern void XrmStringToQuarkList(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */,
+ XrmQuarkList /* quarks_return */
+#endif
+);
+
+extern void XrmStringToBindingQuarkList(
+#if NeedFunctionPrototypes
+ _Xconst char* /* string */,
+ XrmBindingList /* bindings_return */,
+ XrmQuarkList /* quarks_return */
+#endif
+);
+
+/****************************************************************
+ *
+ * Name and Class lists.
+ *
+ ****************************************************************/
+
+typedef XrmQuark XrmName;
+typedef XrmQuarkList XrmNameList;
+#define XrmNameToString(name) XrmQuarkToString(name)
+#define XrmStringToName(string) XrmStringToQuark(string)
+#define XrmStringToNameList(str, name) XrmStringToQuarkList(str, name)
+
+typedef XrmQuark XrmClass;
+typedef XrmQuarkList XrmClassList;
+#define XrmClassToString(c_class) XrmQuarkToString(c_class)
+#define XrmStringToClass(c_class) XrmStringToQuark(c_class)
+#define XrmStringToClassList(str,c_class) XrmStringToQuarkList(str, c_class)
+
+
+
+/****************************************************************
+ *
+ * Resource Representation Types and Values
+ *
+ ****************************************************************/
+
+typedef XrmQuark XrmRepresentation;
+#define XrmStringToRepresentation(string) XrmStringToQuark(string)
+#define XrmRepresentationToString(type) XrmQuarkToString(type)
+
+typedef struct {
+ unsigned int size;
+ XPointer addr;
+} XrmValue, *XrmValuePtr;
+
+
+/****************************************************************
+ *
+ * Resource Manager Functions
+ *
+ ****************************************************************/
+
+typedef struct _XrmHashBucketRec *XrmHashBucket;
+typedef XrmHashBucket *XrmHashTable;
+typedef XrmHashTable XrmSearchList[];
+typedef struct _XrmHashBucketRec *XrmDatabase;
+
+
+extern void XrmDestroyDatabase(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */
+#endif
+);
+
+extern void XrmQPutResource(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation /* type */,
+ XrmValue* /* value */
+#endif
+);
+
+extern void XrmPutResource(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ _Xconst char* /* specifier */,
+ _Xconst char* /* type */,
+ XrmValue* /* value */
+#endif
+);
+
+extern void XrmQPutStringResource(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ _Xconst char* /* value */
+#endif
+);
+
+extern void XrmPutStringResource(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ _Xconst char* /* specifier */,
+ _Xconst char* /* value */
+#endif
+);
+
+extern void XrmPutLineResource(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ _Xconst char* /* line */
+#endif
+);
+
+extern Bool XrmQGetResource(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */,
+ XrmNameList /* quark_name */,
+ XrmClassList /* quark_class */,
+ XrmRepresentation* /* quark_type_return */,
+ XrmValue* /* value_return */
+#endif
+);
+
+extern Bool XrmGetResource(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */,
+ _Xconst char* /* str_name */,
+ _Xconst char* /* str_class */,
+ char** /* str_type_return */,
+ XrmValue* /* value_return */
+#endif
+);
+
+extern Bool XrmQGetSearchList(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */,
+ XrmNameList /* names */,
+ XrmClassList /* classes */,
+ XrmSearchList /* list_return */,
+ int /* list_length */
+#endif
+);
+
+extern Bool XrmQGetSearchResource(
+#if NeedFunctionPrototypes
+ XrmSearchList /* list */,
+ XrmName /* name */,
+ XrmClass /* class */,
+ XrmRepresentation* /* type_return */,
+ XrmValue* /* value_return */
+#endif
+);
+
+/****************************************************************
+ *
+ * Resource Database Management
+ *
+ ****************************************************************/
+
+extern void XrmSetDatabase(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XrmDatabase /* database */
+#endif
+);
+
+extern XrmDatabase XrmGetDatabase(
+#if NeedFunctionPrototypes
+ Display* /* display */
+#endif
+);
+
+extern XrmDatabase XrmGetFileDatabase(
+#if NeedFunctionPrototypes
+ _Xconst char* /* filename */
+#endif
+);
+
+extern Status XrmCombineFileDatabase(
+#if NeedFunctionPrototypes
+ _Xconst char* /* filename */,
+ XrmDatabase* /* target */,
+ Bool /* override */
+#endif
+);
+
+extern XrmDatabase XrmGetStringDatabase(
+#if NeedFunctionPrototypes
+ _Xconst char* /* data */ /* null terminated string */
+#endif
+);
+
+extern void XrmPutFileDatabase(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */,
+ _Xconst char* /* filename */
+#endif
+);
+
+extern void XrmMergeDatabases(
+#if NeedFunctionPrototypes
+ XrmDatabase /* source_db */,
+ XrmDatabase* /* target_db */
+#endif
+);
+
+extern void XrmCombineDatabase(
+#if NeedFunctionPrototypes
+ XrmDatabase /* source_db */,
+ XrmDatabase* /* target_db */,
+ Bool /* override */
+#endif
+);
+
+#define XrmEnumAllLevels 0
+#define XrmEnumOneLevel 1
+
+extern Bool XrmEnumerateDatabase(
+#if NeedFunctionPrototypes
+ XrmDatabase /* db */,
+ XrmNameList /* name_prefix */,
+ XrmClassList /* class_prefix */,
+ int /* mode */,
+ Bool (*)(
+#if NeedNestedPrototypes
+ XrmDatabase* /* db */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation* /* type */,
+ XrmValue* /* value */,
+ XPointer /* closure */
+#endif
+ ) /* proc */,
+ XPointer /* closure */
+#endif
+);
+
+extern char *XrmLocaleOfDatabase(
+#if NeedFunctionPrototypes
+ XrmDatabase /* database */
+#endif
+);
+
+
+/****************************************************************
+ *
+ * Command line option mapping to resource entries
+ *
+ ****************************************************************/
+
+typedef enum {
+ XrmoptionNoArg, /* Value is specified in OptionDescRec.value */
+ XrmoptionIsArg, /* Value is the option string itself */
+ XrmoptionStickyArg, /* Value is characters immediately following option */
+ XrmoptionSepArg, /* Value is next argument in argv */
+ XrmoptionResArg, /* Resource and value in next argument in argv */
+ XrmoptionSkipArg, /* Ignore this option and the next argument in argv */
+ XrmoptionSkipLine, /* Ignore this option and the rest of argv */
+ XrmoptionSkipNArgs /* Ignore this option and the next
+ OptionDescRes.value arguments in argv */
+} XrmOptionKind;
+
+typedef struct {
+ char *option; /* Option abbreviation in argv */
+ char *specifier; /* Resource specifier */
+ XrmOptionKind argKind; /* Which style of option it is */
+ XPointer value; /* Value to provide if XrmoptionNoArg */
+} XrmOptionDescRec, *XrmOptionDescList;
+
+
+extern void XrmParseCommand(
+#if NeedFunctionPrototypes
+ XrmDatabase* /* database */,
+ XrmOptionDescList /* table */,
+ int /* table_count */,
+ _Xconst char* /* name */,
+ int* /* argc_in_out */,
+ char** /* argv_in_out */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XRESOURCE_H_ */
+/* DON'T ADD STUFF AFTER THIS #endif */
diff --git a/include/X11/Xutil.h b/include/X11/Xutil.h
new file mode 100644
index 00000000..17438e89
--- /dev/null
+++ b/include/X11/Xutil.h
@@ -0,0 +1,907 @@
+/* $Xorg: Xutil.h,v 1.8 2001/02/09 02:03:39 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#ifndef _XUTIL_H_
+#define _XUTIL_H_
+
+/* You must include <X11/Xlib.h> before including this file */
+#include <X11/Xlib.h>
+
+/*
+ * Bitmask returned by XParseGeometry(). Each bit tells if the corresponding
+ * value (x, y, width, height) was found in the parsed string.
+ */
+#define NoValue 0x0000
+#define XValue 0x0001
+#define YValue 0x0002
+#define WidthValue 0x0004
+#define HeightValue 0x0008
+#define AllValues 0x000F
+#define XNegative 0x0010
+#define YNegative 0x0020
+
+/*
+ * new version containing base_width, base_height, and win_gravity fields;
+ * used with WM_NORMAL_HINTS.
+ */
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ int x, y; /* obsolete for new window mgrs, but clients */
+ int width, height; /* should set so old wm's don't mess up */
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+ struct {
+ int x; /* numerator */
+ int y; /* denominator */
+ } min_aspect, max_aspect;
+ int base_width, base_height; /* added by ICCCM version 1 */
+ int win_gravity; /* added by ICCCM version 1 */
+} XSizeHints;
+
+/*
+ * The next block of definitions are for window manager properties that
+ * clients and applications use for communication.
+ */
+
+/* flags argument in size hints */
+#define USPosition (1L << 0) /* user specified x, y */
+#define USSize (1L << 1) /* user specified width, height */
+
+#define PPosition (1L << 2) /* program specified position */
+#define PSize (1L << 3) /* program specified size */
+#define PMinSize (1L << 4) /* program specified minimum size */
+#define PMaxSize (1L << 5) /* program specified maximum size */
+#define PResizeInc (1L << 6) /* program specified resize increments */
+#define PAspect (1L << 7) /* program specified min and max aspect ratios */
+#define PBaseSize (1L << 8) /* program specified base for incrementing */
+#define PWinGravity (1L << 9) /* program specified window gravity */
+
+/* obsolete */
+#define PAllHints (PPosition|PSize|PMinSize|PMaxSize|PResizeInc|PAspect)
+
+
+
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ Bool input; /* does this application rely on the window manager to
+ get keyboard input? */
+ int initial_state; /* see below */
+ Pixmap icon_pixmap; /* pixmap to be used as icon */
+ Window icon_window; /* window to be used as icon */
+ int icon_x, icon_y; /* initial position of icon */
+ Pixmap icon_mask; /* icon mask bitmap */
+ XID window_group; /* id of related window group */
+ /* this structure may be extended in the future */
+} XWMHints;
+
+/* definition for flags of XWMHints */
+
+#define InputHint (1L << 0)
+#define StateHint (1L << 1)
+#define IconPixmapHint (1L << 2)
+#define IconWindowHint (1L << 3)
+#define IconPositionHint (1L << 4)
+#define IconMaskHint (1L << 5)
+#define WindowGroupHint (1L << 6)
+#define AllHints (InputHint|StateHint|IconPixmapHint|IconWindowHint| \
+IconPositionHint|IconMaskHint|WindowGroupHint)
+#define XUrgencyHint (1L << 8)
+
+/* definitions for initial window state */
+#define WithdrawnState 0 /* for windows that are not mapped */
+#define NormalState 1 /* most applications want to start this way */
+#define IconicState 3 /* application wants to start as an icon */
+
+/*
+ * Obsolete states no longer defined by ICCCM
+ */
+#define DontCareState 0 /* don't know or care */
+#define ZoomState 2 /* application wants to start zoomed */
+#define InactiveState 4 /* application believes it is seldom used; */
+ /* some wm's may put it on inactive menu */
+
+
+/*
+ * new structure for manipulating TEXT properties; used with WM_NAME,
+ * WM_ICON_NAME, WM_CLIENT_MACHINE, and WM_COMMAND.
+ */
+typedef struct {
+ unsigned char *value; /* same as Property routines */
+ Atom encoding; /* prop type */
+ int format; /* prop data format: 8, 16, or 32 */
+ unsigned long nitems; /* number of data items in value */
+} XTextProperty;
+
+#define XNoMemory -1
+#define XLocaleNotSupported -2
+#define XConverterNotFound -3
+
+typedef enum {
+ XStringStyle, /* STRING */
+ XCompoundTextStyle, /* COMPOUND_TEXT */
+ XTextStyle, /* text in owner's encoding (current locale)*/
+ XStdICCTextStyle /* STRING, else COMPOUND_TEXT */
+} XICCEncodingStyle;
+
+typedef struct {
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+} XIconSize;
+
+typedef struct {
+ char *res_name;
+ char *res_class;
+} XClassHint;
+
+/*
+ * These macros are used to give some sugar to the image routines so that
+ * naive people are more comfortable with them.
+ */
+#define XDestroyImage(ximage) \
+ ((*((ximage)->f.destroy_image))((ximage)))
+#define XGetPixel(ximage, x, y) \
+ ((*((ximage)->f.get_pixel))((ximage), (x), (y)))
+#define XPutPixel(ximage, x, y, pixel) \
+ ((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)))
+#define XSubImage(ximage, x, y, width, height) \
+ ((*((ximage)->f.sub_image))((ximage), (x), (y), (width), (height)))
+#define XAddPixel(ximage, value) \
+ ((*((ximage)->f.add_pixel))((ximage), (value)))
+
+/*
+ * Compose sequence status structure, used in calling XLookupString.
+ */
+typedef struct _XComposeStatus {
+ XPointer compose_ptr; /* state table pointer */
+ int chars_matched; /* match state */
+} XComposeStatus;
+
+/*
+ * Keysym macros, used on Keysyms to test for classes of symbols
+ */
+#define IsKeypadKey(keysym) \
+ (((KeySym)(keysym) >= XK_KP_Space) && ((KeySym)(keysym) <= XK_KP_Equal))
+
+#define IsPrivateKeypadKey(keysym) \
+ (((KeySym)(keysym) >= 0x11000000) && ((KeySym)(keysym) <= 0x1100FFFF))
+
+#define IsCursorKey(keysym) \
+ (((KeySym)(keysym) >= XK_Home) && ((KeySym)(keysym) < XK_Select))
+
+#define IsPFKey(keysym) \
+ (((KeySym)(keysym) >= XK_KP_F1) && ((KeySym)(keysym) <= XK_KP_F4))
+
+#define IsFunctionKey(keysym) \
+ (((KeySym)(keysym) >= XK_F1) && ((KeySym)(keysym) <= XK_F35))
+
+#define IsMiscFunctionKey(keysym) \
+ (((KeySym)(keysym) >= XK_Select) && ((KeySym)(keysym) <= XK_Break))
+
+#define IsModifierKey(keysym) \
+ ((((KeySym)(keysym) >= XK_Shift_L) && ((KeySym)(keysym) <= XK_Hyper_R)) \
+ || ((KeySym)(keysym) == XK_Mode_switch) \
+ || ((KeySym)(keysym) == XK_Num_Lock))
+/*
+ * opaque reference to Region data type
+ */
+typedef struct _XRegion *Region;
+
+/* Return values from XRectInRegion() */
+
+#define RectangleOut 0
+#define RectangleIn 1
+#define RectanglePart 2
+
+
+/*
+ * Information used by the visual utility routines to find desired visual
+ * type from the many visuals a display may support.
+ */
+
+typedef struct {
+ Visual *visual;
+ VisualID visualid;
+ int screen;
+ int depth;
+#if defined(__cplusplus) || defined(c_plusplus)
+ int c_class; /* C++ */
+#else
+ int class;
+#endif
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+} XVisualInfo;
+
+#define VisualNoMask 0x0
+#define VisualIDMask 0x1
+#define VisualScreenMask 0x2
+#define VisualDepthMask 0x4
+#define VisualClassMask 0x8
+#define VisualRedMaskMask 0x10
+#define VisualGreenMaskMask 0x20
+#define VisualBlueMaskMask 0x40
+#define VisualColormapSizeMask 0x80
+#define VisualBitsPerRGBMask 0x100
+#define VisualAllMask 0x1FF
+
+/*
+ * This defines a window manager property that clients may use to
+ * share standard color maps of type RGB_COLOR_MAP:
+ */
+typedef struct {
+ Colormap colormap;
+ unsigned long red_max;
+ unsigned long red_mult;
+ unsigned long green_max;
+ unsigned long green_mult;
+ unsigned long blue_max;
+ unsigned long blue_mult;
+ unsigned long base_pixel;
+ VisualID visualid; /* added by ICCCM version 1 */
+ XID killid; /* added by ICCCM version 1 */
+} XStandardColormap;
+
+#define ReleaseByFreeingColormap ((XID) 1L) /* for killid field above */
+
+
+/*
+ * return codes for XReadBitmapFile and XWriteBitmapFile
+ */
+#define BitmapSuccess 0
+#define BitmapOpenFailed 1
+#define BitmapFileInvalid 2
+#define BitmapNoMemory 3
+
+/****************************************************************
+ *
+ * Context Management
+ *
+ ****************************************************************/
+
+
+/* Associative lookup table return codes */
+
+#define XCSUCCESS 0 /* No error. */
+#define XCNOMEM 1 /* Out of memory */
+#define XCNOENT 2 /* No entry in table */
+
+typedef int XContext;
+
+#define XUniqueContext() ((XContext) XrmUniqueQuark())
+#define XStringToContext(string) ((XContext) XrmStringToQuark(string))
+
+_XFUNCPROTOBEGIN
+
+/* The following declarations are alphabetized. */
+
+extern XClassHint *XAllocClassHint (
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern XIconSize *XAllocIconSize (
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern XSizeHints *XAllocSizeHints (
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern XStandardColormap *XAllocStandardColormap (
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern XWMHints *XAllocWMHints (
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern int XClipBox(
+#if NeedFunctionPrototypes
+ Region /* r */,
+ XRectangle* /* rect_return */
+#endif
+);
+
+extern Region XCreateRegion(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern char *XDefaultString(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern int XDeleteContext(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */
+#endif
+);
+
+extern int XDestroyRegion(
+#if NeedFunctionPrototypes
+ Region /* r */
+#endif
+);
+
+extern int XEmptyRegion(
+#if NeedFunctionPrototypes
+ Region /* r */
+#endif
+);
+
+extern int XEqualRegion(
+#if NeedFunctionPrototypes
+ Region /* r1 */,
+ Region /* r2 */
+#endif
+);
+
+extern int XFindContext(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */,
+ XPointer* /* data_return */
+#endif
+);
+
+extern Status XGetClassHint(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XClassHint* /* class_hints_return */
+#endif
+);
+
+extern Status XGetIconSizes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XIconSize** /* size_list_return */,
+ int* /* count_return */
+#endif
+);
+
+extern Status XGetNormalHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */
+#endif
+);
+
+extern Status XGetRGBColormaps(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap** /* stdcmap_return */,
+ int* /* count_return */,
+ Atom /* property */
+#endif
+);
+
+extern Status XGetSizeHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ Atom /* property */
+#endif
+);
+
+extern Status XGetStandardColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* colormap_return */,
+ Atom /* property */
+#endif
+);
+
+extern Status XGetTextProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* window */,
+ XTextProperty* /* text_prop_return */,
+ Atom /* property */
+#endif
+);
+
+extern XVisualInfo *XGetVisualInfo(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ long /* vinfo_mask */,
+ XVisualInfo* /* vinfo_template */,
+ int* /* nitems_return */
+#endif
+);
+
+extern Status XGetWMClientMachine(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern XWMHints *XGetWMHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */
+#endif
+);
+
+extern Status XGetWMIconName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern Status XGetWMName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern Status XGetWMNormalHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ long* /* supplied_return */
+#endif
+);
+
+extern Status XGetWMSizeHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints_return */,
+ long* /* supplied_return */,
+ Atom /* property */
+#endif
+);
+
+extern Status XGetZoomHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* zhints_return */
+#endif
+);
+
+extern int XIntersectRegion(
+#if NeedFunctionPrototypes
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+#endif
+);
+
+extern void XConvertCase(
+#if NeedFunctionPrototypes
+ KeySym /* sym */,
+ KeySym* /* lower */,
+ KeySym* /* upper */
+#endif
+);
+
+extern int XLookupString(
+#if NeedFunctionPrototypes
+ XKeyEvent* /* event_struct */,
+ char* /* buffer_return */,
+ int /* bytes_buffer */,
+ KeySym* /* keysym_return */,
+ XComposeStatus* /* status_in_out */
+#endif
+);
+
+extern Status XMatchVisualInfo(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen */,
+ int /* depth */,
+ int /* class */,
+ XVisualInfo* /* vinfo_return */
+#endif
+);
+
+extern int XOffsetRegion(
+#if NeedFunctionPrototypes
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+#endif
+);
+
+extern Bool XPointInRegion(
+#if NeedFunctionPrototypes
+ Region /* r */,
+ int /* x */,
+ int /* y */
+#endif
+);
+
+extern Region XPolygonRegion(
+#if NeedFunctionPrototypes
+ XPoint* /* points */,
+ int /* n */,
+ int /* fill_rule */
+#endif
+);
+
+extern int XRectInRegion(
+#if NeedFunctionPrototypes
+ Region /* r */,
+ int /* x */,
+ int /* y */,
+ unsigned int /* width */,
+ unsigned int /* height */
+#endif
+);
+
+extern int XSaveContext(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XID /* rid */,
+ XContext /* context */,
+ _Xconst char* /* data */
+#endif
+);
+
+extern int XSetClassHint(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XClassHint* /* class_hints */
+#endif
+);
+
+extern int XSetIconSizes(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XIconSize* /* size_list */,
+ int /* count */
+#endif
+);
+
+extern int XSetNormalHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */
+#endif
+);
+
+extern void XSetRGBColormaps(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* stdcmaps */,
+ int /* count */,
+ Atom /* property */
+#endif
+);
+
+extern int XSetSizeHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */,
+ Atom /* property */
+#endif
+);
+
+extern int XSetStandardProperties(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ Pixmap /* icon_pixmap */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* hints */
+#endif
+);
+
+extern void XSetTextProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */,
+ Atom /* property */
+#endif
+);
+
+extern void XSetWMClientMachine(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+#endif
+);
+
+extern int XSetWMHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XWMHints* /* wm_hints */
+#endif
+);
+
+extern void XSetWMIconName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+#endif
+);
+
+extern void XSetWMName(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* text_prop */
+#endif
+);
+
+extern void XSetWMNormalHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */
+#endif
+);
+
+extern void XSetWMProperties(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XTextProperty* /* window_name */,
+ XTextProperty* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+#endif
+);
+
+extern void XmbSetWMProperties(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ _Xconst char* /* window_name */,
+ _Xconst char* /* icon_name */,
+ char** /* argv */,
+ int /* argc */,
+ XSizeHints* /* normal_hints */,
+ XWMHints* /* wm_hints */,
+ XClassHint* /* class_hints */
+#endif
+);
+
+extern void XSetWMSizeHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* hints */,
+ Atom /* property */
+#endif
+);
+
+extern int XSetRegion(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ Region /* r */
+#endif
+);
+
+extern void XSetStandardColormap(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XStandardColormap* /* colormap */,
+ Atom /* property */
+#endif
+);
+
+extern int XSetZoomHints(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* w */,
+ XSizeHints* /* zhints */
+#endif
+);
+
+extern int XShrinkRegion(
+#if NeedFunctionPrototypes
+ Region /* r */,
+ int /* dx */,
+ int /* dy */
+#endif
+);
+
+extern Status XStringListToTextProperty(
+#if NeedFunctionPrototypes
+ char** /* list */,
+ int /* count */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern int XSubtractRegion(
+#if NeedFunctionPrototypes
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+#endif
+);
+
+extern int XmbTextListToTextProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ char** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern int XwcTextListToTextProperty(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ wchar_t** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+extern void XwcFreeStringList(
+#if NeedFunctionPrototypes
+ wchar_t** /* list */
+#endif
+);
+
+extern Status XTextPropertyToStringList(
+#if NeedFunctionPrototypes
+ XTextProperty* /* text_prop */,
+ char*** /* list_return */,
+ int* /* count_return */
+#endif
+);
+
+extern int XmbTextPropertyToTextList(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XTextProperty* /* text_prop */,
+ char*** /* list_return */,
+ int* /* count_return */
+#endif
+);
+
+extern int XwcTextPropertyToTextList(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XTextProperty* /* text_prop */,
+ wchar_t*** /* list_return */,
+ int* /* count_return */
+#endif
+);
+
+extern int XUnionRectWithRegion(
+#if NeedFunctionPrototypes
+ XRectangle* /* rectangle */,
+ Region /* src_region */,
+ Region /* dest_region_return */
+#endif
+);
+
+extern int XUnionRegion(
+#if NeedFunctionPrototypes
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+#endif
+);
+
+extern int XWMGeometry(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* screen_number */,
+ _Xconst char* /* user_geometry */,
+ _Xconst char* /* default_geometry */,
+ unsigned int /* border_width */,
+ XSizeHints* /* hints */,
+ int* /* x_return */,
+ int* /* y_return */,
+ int* /* width_return */,
+ int* /* height_return */,
+ int* /* gravity_return */
+#endif
+);
+
+extern int XXorRegion(
+#if NeedFunctionPrototypes
+ Region /* sra */,
+ Region /* srb */,
+ Region /* dr_return */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XUTIL_H_ */
diff --git a/include/X11/cursorfont.h b/include/X11/cursorfont.h
new file mode 100644
index 00000000..c6204f1c
--- /dev/null
+++ b/include/X11/cursorfont.h
@@ -0,0 +1,107 @@
+/* $Xorg: cursorfont.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define XC_num_glyphs 154
+#define XC_X_cursor 0
+#define XC_arrow 2
+#define XC_based_arrow_down 4
+#define XC_based_arrow_up 6
+#define XC_boat 8
+#define XC_bogosity 10
+#define XC_bottom_left_corner 12
+#define XC_bottom_right_corner 14
+#define XC_bottom_side 16
+#define XC_bottom_tee 18
+#define XC_box_spiral 20
+#define XC_center_ptr 22
+#define XC_circle 24
+#define XC_clock 26
+#define XC_coffee_mug 28
+#define XC_cross 30
+#define XC_cross_reverse 32
+#define XC_crosshair 34
+#define XC_diamond_cross 36
+#define XC_dot 38
+#define XC_dotbox 40
+#define XC_double_arrow 42
+#define XC_draft_large 44
+#define XC_draft_small 46
+#define XC_draped_box 48
+#define XC_exchange 50
+#define XC_fleur 52
+#define XC_gobbler 54
+#define XC_gumby 56
+#define XC_hand1 58
+#define XC_hand2 60
+#define XC_heart 62
+#define XC_icon 64
+#define XC_iron_cross 66
+#define XC_left_ptr 68
+#define XC_left_side 70
+#define XC_left_tee 72
+#define XC_leftbutton 74
+#define XC_ll_angle 76
+#define XC_lr_angle 78
+#define XC_man 80
+#define XC_middlebutton 82
+#define XC_mouse 84
+#define XC_pencil 86
+#define XC_pirate 88
+#define XC_plus 90
+#define XC_question_arrow 92
+#define XC_right_ptr 94
+#define XC_right_side 96
+#define XC_right_tee 98
+#define XC_rightbutton 100
+#define XC_rtl_logo 102
+#define XC_sailboat 104
+#define XC_sb_down_arrow 106
+#define XC_sb_h_double_arrow 108
+#define XC_sb_left_arrow 110
+#define XC_sb_right_arrow 112
+#define XC_sb_up_arrow 114
+#define XC_sb_v_double_arrow 116
+#define XC_shuttle 118
+#define XC_sizing 120
+#define XC_spider 122
+#define XC_spraycan 124
+#define XC_star 126
+#define XC_target 128
+#define XC_tcross 130
+#define XC_top_left_arrow 132
+#define XC_top_left_corner 134
+#define XC_top_right_corner 136
+#define XC_top_side 138
+#define XC_top_tee 140
+#define XC_trek 142
+#define XC_ul_angle 144
+#define XC_umbrella 146
+#define XC_ur_angle 148
+#define XC_watch 150
+#define XC_xterm 152
diff --git a/man/AllPlanes.man b/man/AllPlanes.man
new file mode 100644
index 00000000..06e88a79
--- /dev/null
+++ b/man/AllPlanes.man
@@ -0,0 +1,382 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH AllPlanes 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+AllPlanes, BlackPixel, WhitePixel, ConnectionNumber, DefaultColormap, DefaultDepth, XListDepths, DefaultGC, DefaultRootWindow, DefaultScreenOfDisplay, DefaultScreen, DefaultVisual, DisplayCells, DisplayPlanes, DisplayString, XMaxRequestSize, XExtendedMaxRequestSize, LastKnownRequestProcessed, NextRequest, ProtocolVersion, ProtocolRevision, QLength, RootWindow, ScreenCount, ScreenOfDisplay, ServerVendor, VendorRelease \- Display macros and functions
+.SH SYNTAX
+AllPlanes
+.LP
+BlackPixel\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+WhitePixel\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+ConnectionNumber\^(\^\fIdisplay\fP\^)
+.LP
+DefaultColormap\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DefaultDepth\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+int *XListDepths\^(\^\fIdisplay\fP, \fIscreen_number\fP, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP;
+.br
+ int \fIscreen_number\fP;
+.br
+ int *\fIcount_return\fP;
+.LP
+DefaultGC\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DefaultRootWindow\^(\^\fIdisplay\fP\^)
+.LP
+DefaultScreenOfDisplay\^(\^\fIdisplay\fP\^)
+.LP
+DefaultScreen\^(\^\fIdisplay\fP\^)
+.LP
+DefaultVisual\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayCells\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayPlanes\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayString\^(\^\fIdisplay\fP\^)
+.LP
+long XMaxRequestSize(\^\fIdisplay\fP\^)
+ Display *\fIdisplay\fP\^;
+.LP
+long XExtendedMaxRequestSize(\^\fIdisplay\fP\^)
+ Display *\fIdisplay\fP\^;
+.LP
+LastKnownRequestProcessed\^(\^\fIdisplay\fP\^)
+.LP
+NextRequest\^(\^\fIdisplay\fP\^)
+.LP
+ProtocolVersion\^(\^\fIdisplay\fP\^)
+.LP
+ProtocolRevision\^(\^\fIdisplay\fP\^)
+.LP
+QLength\^(\^\fIdisplay\fP\^)
+.LP
+RootWindow\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+ScreenCount\^(\^\fIdisplay\fP\^)
+.LP
+ScreenOfDisplay\^(\^\fIdisplay\fP, \fIscreen_number\fP\^)
+.LP
+ServerVendor\^(\^\fIdisplay\fP\^)
+.LP
+VendorRelease\^(\^\fIdisplay\fP\^)
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen_number\fP 1i
+Specifies the appropriate screen number on the host server.
+.ds Cn depths
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.SH DESCRIPTION
+The
+.ZN AllPlanes
+macro returns a value with all bits set to 1 suitable for use in a plane
+argument to a procedure.
+.LP
+The
+.ZN BlackPixel
+macro returns the black pixel value for the specified screen.
+.LP
+The
+.ZN WhitePixel
+macro returns the white pixel value for the specified screen.
+.LP
+The
+.ZN ConnectionNumber
+macro returns a connection number for the specified display.
+.LP
+The
+.ZN DefaultColormap
+macro returns the default colormap ID for allocation on the specified screen.
+.LP
+The
+.ZN DefaultDepth
+macro returns the depth (number of planes) of the default root window for the
+specified screen.
+.LP
+The
+.ZN XListDepths
+function returns the array of depths
+that are available on the specified screen.
+If the specified screen_number is valid and sufficient memory for the array
+can be allocated,
+.ZN XListDepths
+sets count_return to the number of available depths.
+Otherwise, it does not set count_return and returns NULL.
+To release the memory allocated for the array of depths, use
+.ZN XFree .
+.LP
+The
+.ZN DefaultGC
+macro returns the default GC for the root window of the
+specified screen.
+.LP
+The
+.ZN DefaultRootWindow
+macro returns the root window for the default screen.
+.LP
+The
+.ZN DefaultScreenOfDisplay
+macro returns the default screen of the specified display.
+.LP
+The
+.ZN DefaultScreen
+macro returns the default screen number referenced in the
+.ZN XOpenDisplay
+routine.
+.LP
+The
+.ZN DefaultVisual
+macro returns the default visual type for the specified screen.
+.LP
+The
+.ZN DisplayCells
+macro returns the number of entries in the default colormap.
+.LP
+The
+.ZN DisplayPlanes
+macro returns the depth of the root window of the specified screen.
+.LP
+The
+.ZN DisplayString
+macro returns the string that was passed to
+.ZN XOpenDisplay
+when the current display was opened.
+.LP
+The
+.ZN XMaxRequestSize
+function returns the maximum request size (in 4-byte units) supported
+by the server without using an extended-length protocol encoding.
+Single protocol requests to the server can be no larger than this size
+unless an extended-length protocol encoding is supported by the server.
+The protocol guarantees the size to be no smaller than 4096 units
+(16384 bytes).
+Xlib automatically breaks data up into multiple protocol requests
+as necessary for the following functions:
+.ZN XDrawPoints ,
+.ZN XDrawRectangles ,
+.ZN XDrawSegments ,
+.ZN XFillArcs ,
+.ZN XFillRectangles ,
+and
+.ZN XPutImage .
+.LP
+The
+.ZN XExtendedMaxRequestSize
+function returns zero if the specified display does not support an
+extended-length protocol encoding; otherwise,
+it returns the maximum request size (in 4-byte units) supported
+by the server using the extended-length encoding.
+The Xlib functions
+.ZN XDrawLines ,
+.ZN XDrawArcs ,
+.ZN XFillPolygon ,
+.ZN XChangeProperty ,
+.ZN XSetClipRectangles ,
+and
+.ZN XSetRegion
+will use the extended-length encoding as necessary, if supported
+by the server. Use of the extended-length encoding in other Xlib
+functions (for example,
+.ZN XDrawPoints ,
+.ZN XDrawRectangles ,
+.ZN XDrawSegments ,
+.ZN XFillArcs ,
+.ZN XFillRectangles ,
+.ZN XPutImage )
+is permitted but not required; an Xlib implementation may choose to
+split the data across multiple smaller requests instead.
+.LP
+The
+.ZN LastKnownRequestProcessed
+macro extracts the full serial number of the last request known by Xlib
+to have been processed by the X server.
+.LP
+The
+.ZN NextRequest
+macro extracts the full serial number that is to be used for the next request.
+.LP
+The
+.ZN ProtocolVersion
+macro returns the major version number (11) of the X protocol associated with
+the connected display.
+.LP
+The
+.ZN ProtocolRevision
+macro returns the minor protocol revision number of the X server.
+.LP
+The
+.ZN QLength
+macro returns the length of the event queue for the connected display.
+.LP
+The
+.ZN RootWindow
+macro returns the root window.
+.LP
+The
+.ZN ScreenCount
+macro returns the number of available screens.
+.LP
+The
+.ZN ScreenOfDisplay
+macro returns a pointer to the screen of the specified display.
+.LP
+The
+.ZN ServerVendor
+macro returns a pointer to a null-terminated string that provides
+some identification of the owner of the X server implementation.
+.LP
+The
+.ZN VendorRelease
+macro returns a number related to a vendor's release of the X server.
+.SH "SEE ALSO"
+BlackPixelOfScreen(3X11),
+ImageByteOrder(3X11),
+IsCursorKey(3X11),
+XOpenDisplay(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/BlackPixelOfScreen.man b/man/BlackPixelOfScreen.man
new file mode 100644
index 00000000..4ce663ae
--- /dev/null
+++ b/man/BlackPixelOfScreen.man
@@ -0,0 +1,287 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH BlackPixelOfScreen 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+BlackPixelOfScreen, WhitePixelOfScreen, CellsOfScreen, DefaultColormapOfScreen, DefaultDepthOfScreen, DefaultGCOfScreen, DefaultVisualOfScreen, DoesBackingStore, DoesSaveUnders, DisplayOfScreen, XScreenNumberOfScreen, EventMaskOfScreen, HeightOfScreen, HeightMMOfScreen, MaxCmapsOfScreen, MinCmapsOfScreen, PlanesOfScreen, RootWindowOfScreen, WidthOfScreen, WidthMMOfScreen \- screen information functions and macros
+.SH SYNTAX
+BlackPixelOfScreen\^(\^\fIscreen\fP\^)
+.LP
+WhitePixelOfScreen\^(\^\fIscreen\fP\^)
+.LP
+CellsOfScreen\^(\^\fIscreen\fP\^)
+.LP
+DefaultColormapOfScreen\^(\^\fIscreen\fP\^)
+.LP
+DefaultDepthOfScreen\^(\^\fIscreen\fP\^)
+.LP
+DefaultGCOfScreen\^(\^\fIscreen\fP\^)
+.LP
+DefaultVisualOfScreen\^(\^\fIscreen\fP\^)
+.LP
+DoesBackingStore\^(\^\fIscreen\fP\^)
+.LP
+DoesSaveUnders\^(\^\fIscreen\fP\^)
+.LP
+DisplayOfScreen\^(\^\fIscreen\fP\^)
+.LP
+int XScreenNumberOfScreen\^(\^\fIscreen\fP\^)
+.br
+ Screen *\fIscreen\fP\^;
+.LP
+EventMaskOfScreen\^(\^\fIscreen\fP\^)
+.LP
+HeightOfScreen\^(\^\fIscreen\fP\^)
+.LP
+HeightMMOfScreen\^(\^\fIscreen\fP\^)
+.LP
+MaxCmapsOfScreen\^(\^\fIscreen\fP\^)
+.LP
+MinCmapsOfScreen\^(\^\fIscreen\fP\^)
+.LP
+PlanesOfScreen\^(\^\fIscreen\fP\^)
+.LP
+RootWindowOfScreen\^(\^\fIscreen\fP\^)
+.LP
+WidthOfScreen\^(\^\fIscreen\fP\^)
+.LP
+WidthMMOfScreen\^(\^\fIscreen\fP\^)
+.SH ARGUMENTS
+.IP \fIscreen\fP 1i
+Specifies the appropriate
+.ZN Screen
+structure.
+.SH DESCRIPTION
+The
+.ZN BlackPixelOfScreen
+macro returns the black pixel value of the specified screen.
+.LP
+The
+.ZN WhitePixelOfScreen
+macro returns the white pixel value of the specified screen.
+.LP
+The
+.ZN CellsOfScreen
+macro returns the number of colormap cells in the default colormap
+of the specified screen.
+.LP
+The
+.ZN DefaultColormapOfScreen
+macro returns the default colormap of the specified screen.
+.LP
+The
+.ZN DefaultDepthOfScreen
+macro returns the default depth of the root window of the specified screen.
+.LP
+The
+.ZN DefaultGCOfScreen
+macro returns the default GC of the specified screen,
+which has the same depth as the root window of the screen.
+.LP
+The
+.ZN DefaultVisualOfScreen
+macro returns the default visual of the specified screen.
+.LP
+The
+.ZN DoesBackingStore
+macro returns
+.ZN WhenMapped ,
+.ZN NotUseful ,
+or
+.ZN Always ,
+which indicate whether the screen supports backing stores.
+.LP
+The
+.ZN DoesSaveUnders
+macro returns a Boolean value indicating whether the
+screen supports save unders.
+.LP
+The
+.ZN DisplayOfScreen
+macro returns the display of the specified screen.
+.LP
+The
+.ZN XScreenNumberOfScreen
+function returns the screen index number of the specified screen.
+.LP
+The
+.ZN EventMaskOfScreen
+macro returns the root event mask of the root window for the specified screen
+at connection setup.
+.LP
+The
+.ZN HeightOfScreen
+macro returns the height of the specified screen.
+.LP
+The
+.ZN HeightMMOfScreen
+macro returns the height of the specified screen in millimeters.
+.LP
+The
+.ZN MaxCmapsOfScreen
+macro returns the maximum number of installed colormaps supported
+by the specified screen.
+.LP
+The
+.ZN MinCmapsOfScreen
+macro returns the minimum number of installed colormaps supported
+by the specified screen.
+.LP
+The
+.ZN PlanesOfScreen
+macro returns the number of planes in the root window of the specified screen.
+.LP
+The
+.ZN RootWindowOfScreen
+macro returns the root window of the specified screen.
+.LP
+The
+.ZN WidthOfScreen
+macro returns the width of the specified screen.
+.LP
+The
+.ZN WidthMMOfScreen
+macro returns the width of the specified screen in millimeters.
+.SH "SEE ALSO"
+AllPlanes(3X11),
+ImageByteOrder(3X11),
+IsCursorKey(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/DisplayOfCCC.man b/man/DisplayOfCCC.man
new file mode 100644
index 00000000..56af98b1
--- /dev/null
+++ b/man/DisplayOfCCC.man
@@ -0,0 +1,196 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH DisplayOfCCC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+DisplayOfCCC, VisualOfCCC, ScreenNumberOfCCC, ScreenWhitePointOfCCC, ClientWhitePointOfCCC \- Color Conversion Context macros
+.SH SYNTAX
+DisplayOfCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.LP
+VisualOfCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.LP
+ScreenNumberOfCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.LP
+ScreenWhitePointOfCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.LP
+ClientWhitePointOfCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+.SH DESCRIPTION
+The
+.ZN DisplayOfCCC
+macro returns the display associated with the specified CCC.
+.LP
+The
+.ZN VisualOfCCC
+macro returns the visual associated with the specified CCC.
+.LP
+The
+.ZN ScreenNumberOfCCC
+macro returns the number of the screen associated with the specified CCC.
+.LP
+The
+.ZN ScreenWhitePointOfCCC
+macro returns the screen white point of the screen associated with
+the specified CCC.
+.LP
+The
+.ZN ClientWhitePointOfCC
+macro returns the client white point of the screen associated with
+the specified CCC.
+.SH "SEE ALSO"
+XcmsCCCOfColormap(3X11),
+XcmsConvertColors(3X11),
+XcmsCreateCCC(3X11),
+XcmsDefaultCCC(3X11),
+XcmsSetWhitePoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/ImageByteOrder.man b/man/ImageByteOrder.man
new file mode 100644
index 00000000..769ac5a7
--- /dev/null
+++ b/man/ImageByteOrder.man
@@ -0,0 +1,247 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH ImageByteOrder 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+ImageByteOrder, BitmapBitOrder, BitmapPad, BitmapUnit, DisplayHeight, DisplayHeightMM, DisplayWidth, DisplayWidthMM, XListPixmapFormats, XPixmapFormatValues \- image format functions and macros
+.SH SYNTAX
+XPixmapFormatValues *XListPixmapFormats\^(\^\fIdisplay\fP, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.LP
+ImageByteOrder\^(\^\fIdisplay\fP\^)
+.LP
+BitmapBitOrder\^(\^\fIdisplay\fP\^)
+.LP
+BitmapPad\^(\^\fIdisplay\fP\^)
+.LP
+BitmapUnit\^(\^\fIdisplay\fP\^)
+.LP
+DisplayHeight\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayHeightMM\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayWidth\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.LP
+DisplayWidthMM\^(\^\fIdisplay\fP\^, \^\fIscreen_number\fP\^)
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Cn pixmap formats that are supported by the display
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIscreen_number\fP 1i
+Specifies the appropriate screen number on the host server.
+.SH DESCRIPTION
+The
+.ZN XListPixmapFormats
+function returns an array of
+.ZN XPixmapFormatValues
+structures that describe the types of Z format images supported
+by the specified display.
+If insufficient memory is available,
+.ZN XListPixmapFormats
+returns NULL.
+To free the allocated storage for the
+.ZN XPixmapFormatValues
+structures, use
+.ZN XFree .
+.LP
+The
+.ZN ImageByteOrder
+macro specifies the required byte order for images for each scanline unit in
+XY format (bitmap) or for each pixel value in Z format.
+.LP
+The
+.ZN BitmapBitOrder
+macro returns
+.ZN LSBFirst
+or
+.ZN MSBFirst
+to indicate whether the leftmost bit in the bitmap as displayed
+on the screen is the least or most significant bit in the unit.
+.LP
+The
+.ZN BitmapPad
+macro returns the number of bits that each scanline must be padded.
+.LP
+The
+.ZN BitmapUnit
+macro returns the size of a bitmap's scanline unit in bits.
+.LP
+The
+.ZN DisplayHeight
+macro returns the height of the specified screen in pixels.
+.LP
+The
+.ZN DisplayHeightMM
+macro returns the height of the specified screen in millimeters.
+.LP
+The
+.ZN DisplayWidth
+macro returns the width of the screen in pixels.
+.LP
+The
+.ZN DisplayWidthMM
+macro returns the width of the specified screen in millimeters.
+.SH STRUCTURES
+The
+.ZN XPixmapFormatValues
+structure provides an interface to the pixmap format information
+that is returned at the time of a connection setup.
+It contains:
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int depth;
+ int bits_per_pixel;
+ int scanline_pad;
+} XPixmapFormatValues;
+.De
+.SH "SEE ALSO"
+AllPlanes(3X11),
+BlackPixelOfScreen(3X11),
+IsCursorKey(3X11),
+XFree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/IsCursorKey.man b/man/IsCursorKey.man
new file mode 100644
index 00000000..c00cefb3
--- /dev/null
+++ b/man/IsCursorKey.man
@@ -0,0 +1,209 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH IsCursorKey 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+IsCursorKey, IsFunctionKey, IsKeypadKey, IsMiscFunctionKey, IsModiferKey, IsPFKey, IsPrivateKeypadKey \- keysym classification macros
+.SH SYNTAX
+IsCursorKey\^(\^\fIkeysym\fP\^)
+.LP
+IsFunctionKey\^(\^\fIkeysym\fP\^)
+.LP
+IsKeypadKey\^(\^\fIkeysym\fP\^)
+.LP
+IsMiscFunctionKey\^(\^\fIkeysym\fP\^)
+.LP
+IsModifierKey\^(\^\fIkeysym\fP\^)
+.LP
+IsPFKey\^(\^\fIkeysym\fP\^)
+.LP
+IsPrivateKeypadKey\^(\^\fIkeysym\fP\^)
+.SH ARGUMENTS
+.ds Fn tested
+.IP \fIkeysym\fP 1i
+Specifies the KeySym that is to be \*(Fn.
+.SH DESCRIPTION
+The
+.ZN IsCursorKey
+macro returns
+.ZN True
+if the specified KeySym is a cursor key.
+.LP
+The
+.ZN IsFunctionKey
+macro returns
+.ZN True
+if the KeySym is a function key.
+.LP
+The
+.ZN IsKeypadKey
+macro returns
+.ZN True
+if the specified KeySym is a keypad key.
+.LP
+The
+.ZN IsMiscFunctionKey
+macro returns
+.ZN True
+if the specified KeySym is a miscellaneous function key.
+.LP
+The
+.ZN IsModiferKey
+macro returns
+.ZN True
+if the specified KeySym is a modifier key.
+.LP
+The
+.ZN IsPFKey
+macro returns
+.ZN True
+if the specified KeySym is a PF key.
+.LP
+The
+.ZN IsPrivateKeypadKey
+macro returns
+.ZN True
+if the specified KeySym is a vendor-private keypad key.
+.SH "SEE ALSO"
+AllPlanes(3X11),
+BlackPixelOfScreen(3X11),
+ImageByteOrder(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAddConnectionWatch.man b/man/XAddConnectionWatch.man
new file mode 100644
index 00000000..2d52a511
--- /dev/null
+++ b/man/XAddConnectionWatch.man
@@ -0,0 +1,278 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAddConnectionWatch 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAddConnectionWatch, XRemoveConnectionWatch, XProcessInternalConnection, XInternalConnectionNumbers \- handle Xlib internal connections
+.SH SYNTAX
+typedef void (*XConnectionWatchProc)\^(\^\fIdisplay\fP, \fIclient_data\fP, \fIfd\fP, \fIopening\fP, \fIwatch_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XPointer \fIclient_data\fP\^;
+.br
+ int \fIfd\fP\^;
+.br
+ Bool \fIopening\fP\^;
+.br
+ XPointer *\fIwatch_data\fP\^;
+.LP
+Status XAddConnectionWatch\^(\^\fIdisplay\fP, \fIprocedure\fP\^, \fIclient_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XWatchProc \fIprocedure\fP\^;
+.br
+ XPointer \fIclient_data\fP\^;
+.LP
+Status XRemoveConnectionWatch\^(\^\fIdisplay\fP, \fIprocedure\fP\^, \fIclient_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XWatchProc \fIprocedure\fP\^;
+.br
+ XPointer \fIclient_data\fP\^;
+.LP
+void XProcessInternalConnection\^(\^\fIdisplay\fP, \fIfd\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIfd\fP\^;
+.LP
+void XProcessInternalConnection\^(\^\fIdisplay\fP, \fIfd\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIfd\fP\^;
+.LP
+Status XInternalConnectionNumbers\^(\^\fIdisplay\fP, \fIfd_return\fP\^, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int **\fIfd_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.SH ARGUMENTS
+.IP \fIclient_data\fP 1i
+Specifies the additional client data.
+.ds Cn file descriptors
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfd\fP 1i
+Specifies the file descriptor.
+.IP \fIfd_return\fP 1i
+Returns the file descriptors.
+.IP \fIprocedure\fP 1i
+Specifies the procedure to be called.
+.SH DESCRIPTION
+The
+.ZN XAddConnectionWatch
+function registers a procedure to be called each time Xlib opens or closes an
+internal connection for the specified display. The procedure is passed the
+display, the specified client_data, the file descriptor for the connection,
+a Boolean indicating whether the connection is being opened or closed, and a
+pointer to a location for private watch data. If opening is
+.ZN True ,
+the procedure can store a pointer to private data in the location pointed
+to by watch_data;
+when the procedure is later called for this same connection and opening is
+.ZN False ,
+the location pointed to by watch_data will hold this same private data pointer.
+.LP
+This function can be called at any time after a display is opened.
+If internal connections already exist, the registered procedure will
+immediately be called for each of them, before
+.ZN XAddConnectionWatch
+returns.
+.ZN XAddConnectionWatch
+returns a nonzero status if the procedure is successfully registered;
+otherwise, it returns zero.
+.LP
+The registered procedure should not call any Xlib functions.
+If the procedure directly or indirectly causes the state of internal
+connections or watch procedures to change, the result is not defined.
+If Xlib has been initialized for threads, the procedure is called with
+the display locked and the result of a call by the procedure to any
+Xlib function that locks the display is not defined unless the executing
+thread has externally locked the display using
+.ZN XLockDisplay .
+.LP
+The
+.ZN XRemoveConnectionWatch
+function removes a previously registered connection watch procedure.
+The client_data must match the client_data used when the procedure
+was initially registered.
+
+.LP
+The
+.ZN XProcessInternalConnection
+function processes input available on an internal connection.
+This function should be called for an internal connection only
+after an operating system facility (for example,
+.ZN select
+or
+.ZN poll )
+has indicated that input is available; otherwise,
+the effect is not defined.
+.LP
+The
+.ZN XProcessInternalConnection
+function processes input available on an internal connection.
+This function should be called for an internal connection only
+after an operating system facility (for example,
+.ZN select
+or
+.ZN poll )
+has indicated that input is available; otherwise,
+the effect is not defined.
+.LP
+The
+.ZN XInternalConnectionNumbers
+function returns a list of the file descriptors for all internal
+connections currently open for the specified display.
+When the allocated list is no longer needed,
+free it by using
+.ZN XFree .
+This functions returns a nonzero status if the list is successfully allocated;
+otherwise, it returns zero.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XAddHost.man b/man/XAddHost.man
new file mode 100644
index 00000000..0431632c
--- /dev/null
+++ b/man/XAddHost.man
@@ -0,0 +1,359 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAddHost 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAddHost, XAddHosts, XListHosts, XRemoveHost, XRemoveHosts, XSetAccessControl, XEnableAccessControl, XDisableAccessControl, XHostAddress \- control host access and host control structure
+.SH SYNTAX
+XAddHost\^(\^\fIdisplay\fP, \fIhost\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XHostAddress *\fIhost\fP\^;
+.LP
+XAddHosts\^(\^\fIdisplay\fP, \fIhosts\fP, \fInum_hosts\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XHostAddress *\fIhosts\fP\^;
+.br
+ int \fInum_hosts\fP\^;
+.LP
+XHostAddress *XListHosts\^(\^\fIdisplay\fP, \fInhosts_return\fP, \fIstate_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fInhosts_return\fP\^;
+.br
+ Bool *\fIstate_return\fP\^;
+.LP
+XRemoveHost\^(\^\fIdisplay\fP, \fIhost\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XHostAddress *\fIhost\fP\^;
+.LP
+XRemoveHosts\^(\^\fIdisplay\fP, \fIhosts\fP, \fInum_hosts\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XHostAddress *\fIhosts\fP\^;
+.br
+ int \fInum_hosts\fP\^;
+.LP
+XSetAccessControl\^(\^\fIdisplay\fP, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fImode\fP\^;
+.LP
+XEnableAccessControl\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XDisableAccessControl\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Ho added or removed
+.IP \fIhost\fP 1i
+Specifies the host that is to be \*(Ho.
+.ds Ho added or removed
+.IP \fIhosts\fP 1i
+Specifies each host that is to be \*(Ho.
+.IP \fImode\fP 1i
+Specifies the mode.
+You can pass
+.ZN EnableAccess
+or
+.ZN DisableAccess .
+.IP \fInhosts_return\fP 1i
+Returns the number of hosts currently in the access control list.
+.IP \fInum_hosts\fP 1i
+Specifies the number of hosts.
+.IP \fIstate_return\fP 1i
+Returns the state of the access control.
+.SH DESCRIPTION
+The
+.ZN XAddHost
+function adds the specified host to the access control list for that display.
+The server must be on the same host as the client issuing the command, or a
+.ZN BadAccess
+error results.
+.LP
+.ZN XAddHost
+can generate
+.ZN BadAccess
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XAddHosts
+function adds each specified host to the access control list for that display.
+The server must be on the same host as the client issuing the command, or a
+.ZN BadAccess
+error results.
+.LP
+.ZN XAddHosts
+can generate
+.ZN BadAccess
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XListHosts
+function returns the current access control list as well as whether the use
+of the list at connection setup was enabled or disabled.
+.ZN XListHosts
+allows a program to find out what machines can make connections.
+It also returns a pointer to a list of host structures that
+were allocated by the function.
+When no longer needed,
+this memory should be freed by calling
+.ZN XFree .
+.LP
+The
+.ZN XRemoveHost
+function removes the specified host from the access control list
+for that display.
+The server must be on the same host as the client process, or a
+.ZN BadAccess
+error results.
+If you remove your machine from the access list,
+you can no longer connect to that server,
+and this operation cannot be reversed unless you reset the server.
+.LP
+.ZN XRemoveHost
+can generate
+.ZN BadAccess
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XRemoveHosts
+function removes each specified host from the access control list for that
+display.
+The X server must be on the same host as the client process, or a
+.ZN BadAccess
+error results.
+If you remove your machine from the access list,
+you can no longer connect to that server,
+and this operation cannot be reversed unless you reset the server.
+.LP
+.ZN XRemoveHosts
+can generate
+.ZN BadAccess
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetAccessControl
+function either enables or disables the use of the access control list
+at each connection setup.
+.LP
+.ZN XSetAccessControl
+can generate
+.ZN BadAccess
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XEnableAccessControl
+function enables the use of the access control list at each connection setup.
+.LP
+.ZN XEnableAccessControl
+can generate a
+.ZN BadAccess
+error.
+.LP
+The
+.ZN XDisableAccessControl
+function disables the use of the access control list at each connection setup.
+.LP
+.ZN XDisableAccessControl
+can generate a
+.ZN BadAccess
+error.
+.SH STRUCTURES
+The
+.ZN XHostAddress
+structure contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int family; /* for example FamilyInternet */
+ int length; /* length of address, in bytes */
+ char *address; /* pointer to where to find the address */
+} XHostAddress;
+.De
+.LP
+The family member specifies which protocol address family to use
+(for example, TCP/IP or DECnet) and can be
+.ZN FamilyInternet ,
+.ZN FamilyDECnet ,
+or
+.ZN FamilyChaos .
+The length member specifies the length of the address in bytes.
+The address member specifies a pointer to the address.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to modify the access control list from other than the local
+(or otherwise authorized) host.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XFree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocClassHint.man b/man/XAllocClassHint.man
new file mode 100644
index 00000000..b1a5ad1d
--- /dev/null
+++ b/man/XAllocClassHint.man
@@ -0,0 +1,275 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAllocClassHint 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocClassHint, XSetClassHint, XGetClassHint, XClassHint \- allocate class hints structure and set or read a window's WM_CLASS property
+.SH SYNTAX
+XClassHint *XAllocClassHint\^(\|)
+.LP
+XSetClassHint\^(\^\fIdisplay\fP, \fIw\fP, \fIclass_hints\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XClassHint *\fIclass_hints\fP\^;
+.LP
+Status XGetClassHint\^(\^\fIdisplay\fP, \fIw\fP, \fIclass_hints_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP;
+.br
+ XClassHint *\fIclass_hints_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIclass_hints\fP 1i
+Specifies the
+.ZN XClassHint
+structure that is to be used.
+.IP \fIclass_hints_return\fP 1i
+Returns the
+.ZN XClassHint
+structure.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XAllocClassHint
+function allocates and returns a pointer to a
+.ZN XClassHint
+structure.
+Note that the pointer fields in the
+.ZN XClassHint
+structure are initially set to NULL.
+If insufficient memory is available,
+.ZN XAllocClassHint
+returns NULL.
+To free the memory allocated to this structure,
+use
+.ZN XFree .
+.LP
+The
+.ZN XSetClassHint
+function sets the class hint for the specified window.
+If the strings are not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+.LP
+.ZN XSetClassHint
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetClassHint
+function returns the class hint of the specified window to the members
+of the supplied structure.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned strings are in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+It returns a nonzero status on success;
+otherwise, it returns a zero status.
+To free res_name and res_class when finished with the strings,
+use
+.ZN XFree
+on each individually.
+.LP
+.ZN XGetClassHint
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_CLASS\s+1
+Set by application programs to allow window and session
+managers to obtain the application's resources from the resource database.
+.SH STRUCTURES
+The
+.ZN XClassHint
+structure contains:
+.LP
+.IN "XClassHint" "" "@DEF@"
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ char *res_name;
+ char *res_class;
+} XClassHint;
+.De
+.LP
+The res_name member contains the application name,
+and the res_class member contains the application class.
+Note that the name set in this property may differ from the name set as WM_NAME.
+That is, WM_NAME specifies what should be displayed in the title bar and,
+therefore, can contain temporal information (for example, the name of
+a file currently in an editor's buffer).
+On the other hand,
+the name specified as part of WM_CLASS is the formal name of the application
+that should be used when retrieving the application's resources from the
+resource database.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocColor.man b/man/XAllocColor.man
new file mode 100644
index 00000000..5f968467
--- /dev/null
+++ b/man/XAllocColor.man
@@ -0,0 +1,493 @@
+'\" e
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" e
+.TH XAllocColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocColor, XAllocNamedColor, XAllocColorCells, XAllocColorPlanes, XFreeColors \- allocate and free colors
+.SH SYNTAX
+Status XAllocColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIscreen_in_out\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XColor *\fIscreen_in_out\fP\^;
+.LP
+Status XAllocNamedColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \
+\fIcolor_name\fP\^, \fIscreen_def_return\fP\^, \fIexact_def_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\fIcolor_name\fP\^;
+.br
+ XColor *\fIscreen_def_return\fP\^, *\fIexact_def_return\fP\^;
+.LP
+Status XAllocColorCells\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcontig\fP\^, \
+\fIplane_masks_return\fP\^, \fInplanes\fP\^,
+.br
+ \fIpixels_return\fP\^, \fInpixels\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ Bool \fIcontig\fP\^;
+.br
+ unsigned long \fIplane_masks_return\fP[\^]\^;
+.br
+ unsigned int \fInplanes\fP\^;
+.br
+ unsigned long \fIpixels_return\fP[\^]\^;
+.br
+ unsigned int \fInpixels\fP\^;
+.LP
+Status XAllocColorPlanes\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcontig\fP\^, \fIpixels_return\fP\^, \fIncolors\fP\^, \fInreds\fP\^, \fIngreens\fP\^,
+.br
+ \fInblues\fP\^, \fIrmask_return\fP\^, \fIgmask_return\fP\^, \fIbmask_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ Bool \fIcontig\fP\^;
+.br
+ unsigned long \fIpixels_return\fP[\^]\^;
+.br
+ int \fIncolors\fP\^;
+.br
+ int \fInreds\fP\^, \fIngreens\fP\^, \fInblues\fP\^;
+.br
+ unsigned long *\fIrmask_return\fP\^, *\fIgmask_return\fP\^, *\fIbmask_return\fP\^;
+.LP
+XFreeColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIpixels\fP\^, \fInpixels\fP\^, \fIplanes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ unsigned long \fIpixels\fP\^[\^];
+.br
+ int \fInpixels\fP\^;
+.br
+ unsigned long \fIplanes\fP\^;
+.SH ARGUMENTS
+.IP \fIcolor_name\fP 1i
+Specifies the color name string (for example, red) whose color
+definition structure you want returned.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.IP \fIcontig\fP 1i
+Specifies a Boolean value that indicates whether the planes must be contiguous.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIexact_def_return\fP 1i
+Returns the exact RGB values.
+.IP \fIncolors\fP 1i
+Specifies the number of pixel values that are to be returned in the
+pixels_return array.
+.IP \fInpixels\fP 1i
+Specifies the number of pixels.
+.IP \fInplanes\fP 1i
+Specifies the number of plane masks that are to be returned in the plane masks
+array.
+.IP \fInreds\fP 1i
+.br
+.ns
+.IP \fIngreens\fP 1i
+.br
+.ns
+.IP \fInblues\fP 1i
+.br
+.ns
+Specify the number of red, green, and blue planes.
+The value you pass must be nonnegative.
+.IP \fIpixels\fP 1i
+Specifies an array of pixel values.
+.IP \fIpixels_return\fP 1i
+Returns an array of pixel values.
+.IP \fIplane_mask_return\fP 1i
+Returns an array of plane masks.
+.\" *** JIM: NEED MORE INFO FOR THIS. ***
+.IP \fIplanes\fP 1i
+Specifies the planes you want to free.
+.IP \fIrmask_return\fP 1i
+.br
+.ns
+.IP \fIgmask_return\fP 1i
+.br
+.ns
+.IP \fIbmask_return\fP 1i
+Return bit masks for the red, green, and blue planes.
+.IP \fIscreen_def_return\fP 1i
+Returns the closest RGB values provided by the hardware.
+.IP \fIscreen_in_out\fP 1i
+Specifies and returns the values actually used in the colormap.
+.SH DESCRIPTION
+The
+.ZN XAllocColor
+function allocates a read-only colormap entry corresponding to the closest
+RGB value supported by the hardware.
+.ZN XAllocColor
+returns the pixel value of the color closest to the specified
+RGB elements supported by the hardware
+and returns the RGB value actually used.
+The corresponding colormap cell is read-only.
+In addition,
+.ZN XAllocColor
+returns nonzero if it succeeded or zero if it failed.
+.IN "Color map"
+.IN "Color" "allocation"
+.IN "Allocation" "colormap"
+.IN "read-only colormap cells"
+Multiple clients that request the same effective RGB value can be assigned
+the same read-only entry, thus allowing entries to be shared.
+When the last client deallocates a shared cell, it is deallocated.
+.ZN XAllocColor
+does not use or affect the flags in the
+.ZN XColor
+structure.
+.LP
+.ZN XAllocColor
+can generate a
+.ZN BadColor
+error.
+.LP
+The
+.ZN XAllocNamedColor
+function looks up the named color with respect to the screen that is
+associated with the specified colormap.
+It returns both the exact database definition and
+the closest color supported by the screen.
+The allocated color cell is read-only.
+The pixel value is returned in screen_def_return.
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+If screen_def_return and exact_def_return
+point to the same structure, the pixel field will be set correctly,
+but the color values are undefined.
+.ZN XAllocNamedColor
+returns nonzero if a cell is allocated;
+otherwise, it returns zero.
+.LP
+.ZN XAllocNamedColor
+can generate a
+.ZN BadColor
+error.
+.LP
+.EQ
+delim %%
+.EN
+The
+.ZN XAllocColorCells
+function allocates read/write color cells.
+The number of colors must be positive and the number of planes nonnegative,
+or a
+.ZN BadValue
+error results.
+If ncolors and nplanes are requested,
+then ncolors pixels
+and nplane plane masks are returned.
+No mask will have any bits set to 1 in common with
+any other mask or with any of the pixels.
+By ORing together each pixel with zero or more masks,
+ncolors * %2 sup nplanes% distinct pixels can be produced.
+All of these are
+allocated writable by the request.
+For
+.ZN GrayScale
+or
+.ZN PseudoColor ,
+each mask has exactly one bit set to 1.
+For
+.ZN DirectColor ,
+each has exactly three bits set to 1.
+If contig is
+.ZN True
+and if all masks are ORed
+together, a single contiguous set of bits set to 1 will be formed for
+.ZN GrayScale
+or
+.ZN PseudoColor
+and three contiguous sets of bits set to 1 (one within each
+pixel subfield) for
+.ZN DirectColor .
+The RGB values of the allocated
+entries are undefined.
+.ZN XAllocColorCells
+returns nonzero if it succeeded or zero if it failed.
+.LP
+.ZN XAllocColorCells
+can generate
+.ZN BadColor
+and
+.ZN BadValue
+errors.
+.LP
+.EQ
+delim %%
+.EN
+The specified ncolors must be positive;
+and nreds, ngreens, and nblues must be nonnegative,
+or a
+.ZN BadValue
+error results.
+If ncolors colors, nreds reds, ngreens greens, and nblues blues are requested,
+ncolors pixels are returned; and the masks have nreds, ngreens, and
+nblues bits set to 1, respectively.
+If contig is
+.ZN True ,
+each mask will have
+a contiguous set of bits set to 1.
+No mask will have any bits set to 1 in common with
+any other mask or with any of the pixels.
+For
+.ZN DirectColor ,
+each mask
+will lie within the corresponding pixel subfield.
+By ORing together
+subsets of masks with each pixel value,
+ncolors * %2 sup (nreds+ngreens+nblues)% distinct pixel values can be produced.
+All of these are allocated by the request.
+However, in the
+colormap, there are only ncolors * %2 sup nreds% independent red entries,
+ncolors * %2 sup ngreens% independent green entries,
+and ncolors * %2 sup nblues% independent blue entries.
+This is true even for
+.ZN PseudoColor .
+When the colormap entry of a pixel
+value is changed (using
+.ZN XStoreColors ,
+.ZN XStoreColor ,
+or
+.ZN XStoreNamedColor ),
+the pixel is decomposed according to the masks,
+and the corresponding independent entries are updated.
+.ZN XAllocColorPlanes
+returns nonzero if it succeeded or zero if it failed.
+.LP
+.ZN XAllocColorPlanes
+can generate
+.ZN BadColor
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XFreeColors
+function frees the cells represented by pixels whose values are in the
+pixels array.
+The planes argument should not have any bits set to 1 in common with any of the
+pixels.
+The set of all pixels is produced by ORing together subsets of
+the planes argument with the pixels.
+The request frees all of these pixels that
+were allocated by the client (using
+.IN XAllocColor
+.IN XAllocNamedColor
+.IN XAllocColorCells
+.IN XAllocColorPlanes
+.ZN XAllocColor ,
+.ZN XAllocNamedColor ,
+.ZN XAllocColorCells ,
+and
+.ZN XAllocColorPlanes ).
+Note that freeing an
+individual pixel obtained from
+.ZN XAllocColorPlanes
+may not actually allow
+it to be reused until all of its related pixels are also freed.
+Similarly,
+a read-only entry is not actually freed until it has been freed by all clients,
+and if a client allocates the same read-only entry multiple times,
+it must free the entry that many times before the entry is actually freed.
+.LP
+All specified pixels that are allocated by the client in the colormap are
+freed, even if one or more pixels produce an error.
+If a specified pixel is not a valid index into the colormap, a
+.ZN BadValue
+error results.
+If a specified pixel is not allocated by the
+client (that is, is unallocated or is only allocated by another client)
+or if the colormap was created with all entries writable (by passing
+.ZN AllocAll
+to
+.ZN XCreateColormap ),
+a
+.ZN BadAccess
+error results.
+If more than one pixel is in error,
+the one that gets reported is arbitrary.
+.LP
+.ZN XFreeColors
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to free a color map entry that it did not already allocate.
+.TP 1i
+.ZN BadAccess
+A client attempted
+to store into a read-only color map entry.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateColormap(3X11),
+XQueryColor(3X11),
+XStoreColors(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocIconSize.man b/man/XAllocIconSize.man
new file mode 100644
index 00000000..9d719601
--- /dev/null
+++ b/man/XAllocIconSize.man
@@ -0,0 +1,274 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAllocIconSize 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocIconSize, XSetIconSizes, XGetIconSizes, XIconSize \- allocate icon size structure and set or read a window's WM_ICON_SIZES property
+.SH SYNTAX
+XIconSize *XAllocIconSize\^(\|)
+.LP
+XSetIconSizes\^(\^\fIdisplay\fP, \fIw\fP, \fIsize_list\fP, \fIcount\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XIconSize *\fIsize_list\fP\^;
+.br
+ int \fIcount\fP\^;
+.LP
+Status XGetIconSizes\^(\^\fIdisplay\fP, \fIw\fP, \fIsize_list_return\fP, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XIconSize **\fIsize_list_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIcount\fP 1i
+Specifies the number of items in the size list.
+.IP \fIcount_return\fP 1i
+Returns the number of items in the size list.
+.IP \fIsize_list\fP 1i
+Specifies the size list.
+.IP \fIsize_list_return\fP 1i
+Returns the size list.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XAllocIconSize
+function allocates and returns a pointer to a
+.ZN XIconSize
+structure.
+Note that all fields in the
+.ZN XIconSize
+structure are initially set to zero.
+If insufficient memory is available,
+.ZN XAllocIconSize
+returns NULL.
+To free the memory allocated to this structure,
+use
+.ZN XFree .
+.LP
+The
+.ZN XSetIconSizes
+function is used only by window managers to set the supported icon sizes.
+.LP
+.ZN XSetIconSizes
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetIconSizes
+function returns zero if a window manager has not set icon sizes;
+otherwise, it return nonzero.
+.ZN XGetIconSizes
+should be called by an application that
+wants to find out what icon sizes would be most appreciated by the
+window manager under which the application is running.
+The application
+should then use
+.ZN XSetWMHints
+to supply the window manager with an icon pixmap or window in one of the
+supported sizes.
+To free the data allocated in size_list_return, use
+.ZN XFree .
+.LP
+.ZN XGetIconSizes
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_ICON_SIZES\s+1
+The window manager may set this property on the root window to
+specify the icon sizes it supports.
+The C type of this property is
+.ZN XIconSize .
+.SH STRUCTURES
+The
+.ZN XIconSize
+structure contains:
+.LP
+.IN "XIconSize" "" "@DEF@"
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+} XIconSize;
+.De
+.LP
+The width_inc and height_inc members define an arithmetic progression of
+sizes (minimum to maximum) that represent the supported icon sizes.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocSizeHints.man b/man/XAllocSizeHints.man
new file mode 100644
index 00000000..082a2f47
--- /dev/null
+++ b/man/XAllocSizeHints.man
@@ -0,0 +1,531 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XAllocSizeHints 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocSizeHints, XSetWMNormalHints, XGetWMNormalHints, XSetWMSizeHints, XGetWMSizeHints, XSizeHints \- allocate size hints structure and set or read a window's WM_NORMAL_HINTS property
+.SH SYNTAX
+XSizeHints *XAllocSizeHints\^(\|)
+.LP
+void XSetWMNormalHints\^(\^\fIdisplay\fP, \fIw\fP, \fIhints\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XSizeHints *\fIhints\fP\^;
+.LP
+Status XGetWMNormalHints\^(\^\fIdisplay\fP, \fIw\fP, \fIhints_return\fP, \
+\fIsupplied_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XSizeHints *\fIhints_return\fP\^;
+.br
+ long *\fIsupplied_return\fP\^;
+.LP
+void XSetWMSizeHints\^(\^\fIdisplay\fP, \fIw\fP, \fIhints\fP, \fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XSizeHints *\fIhints\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.LP
+Status XGetWMSizeHints\^(\^\fIdisplay\fP, \fIw\fP, \fIhints_return\fP, \
+\fIsupplied_return\fP, \fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XSizeHints *\fIhints_return\fP\^;
+.br
+ long *\fIsupplied_return\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIhints\fP 1i
+Specifies the size hints for the window in its normal state.
+.IP \fIhints\fP 1i
+Specifies the
+.ZN XSizeHints
+structure to be used.
+.IP \fIhints_return\fP 1i
+Returns the size hints for the window in its normal state.
+.IP \fIproperty\fP 1i
+Specifies the property name.
+.IP \fIsupplied_return\fP 1i
+Returns the hints that were supplied by the user.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XAllocSizeHints
+function allocates and returns a pointer to a
+.ZN XSizeHints
+structure.
+Note that all fields in the
+.ZN XSizeHints
+structure are initially set to zero.
+If insufficient memory is available,
+.ZN XAllocSizeHints
+returns NULL.
+To free the memory allocated to this structure,
+use
+.ZN XFree .
+.LP
+The
+.ZN XSetWMNormalHints
+function replaces the size hints for the WM_NORMAL_HINTS property
+on the specified window.
+If the property does not already exist,
+.ZN XSetWMNormalHints
+sets the size hints for the WM_NORMAL_HINTS property on the specified window.
+The property is stored with a type of WM_SIZE_HINTS and a format of 32.
+.LP
+.ZN XSetWMNormalHints
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetWMNormalHints
+function returns the size hints stored in the WM_NORMAL_HINTS property
+on the specified window.
+If the property is of type WM_SIZE_HINTS, is of format 32,
+and is long enough to contain either an old (pre-ICCCM)
+or new size hints structure,
+.ZN XGetWMNormalHints
+sets the various fields of the
+.ZN XSizeHints
+structure, sets the supplied_return argument to the list of fields
+that were supplied by the user (whether or not they contained defined values),
+and returns a nonzero status.
+Otherwise, it returns a zero status.
+.LP
+If
+.ZN XGetWMNormalHints
+returns successfully and a pre-ICCCM size hints property is read,
+the supplied_return argument will contain the following bits:
+.LP
+.Ds
+(USPosition|USSize|PPosition|PSize|PMinSize|
+ PMaxSize|PResizeInc|PAspect)
+.De
+.LP
+If the property is large enough to contain the base size
+and window gravity fields as well,
+the supplied_return argument will also contain the following bits:
+.LP
+.Ds
+PBaseSize|PWinGravity
+.De
+.LP
+.ZN XGetWMNormalHints
+can generate a
+PN BadWindow
+error.
+.LP
+The
+.ZN XSetWMSizeHints
+function replaces the size hints for the specified property
+on the named window.
+If the specified property does not already exist,
+.ZN XSetWMSizeHints
+sets the size hints for the specified property
+on the named window.
+The property is stored with a type of WM_SIZE_HINTS and a format of 32.
+To set a window's normal size hints,
+you can use the
+.ZN XSetWMNormalHints
+function.
+.LP
+.ZN XSetWMSizeHints
+can generate
+.ZN BadAlloc ,
+.ZN BadAtom ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetWMSizeHints
+function returns the size hints stored in the specified property
+on the named window.
+If the property is of type WM_SIZE_HINTS, is of format 32,
+and is long enough to contain either an old (pre-ICCCM)
+or new size hints structure,
+.ZN XGetWMSizeHints
+sets the various fields of the
+.ZN XSizeHints
+structure, sets the supplied_return argument to the
+list of fields that were supplied by the user
+(whether or not they contained defined values),
+and returns a nonzero status.
+Otherwise, it returns a zero status.
+To get a window's normal size hints,
+you can use the
+.ZN XGetWMNormalHints
+function.
+.LP
+If
+.ZN XGetWMSizeHints
+returns successfully and a pre-ICCCM size hints property is read,
+the supplied_return argument will contain the following bits:
+.LP
+.Ds
+(USPosition|USSize|PPosition|PSize|PMinSize|
+ PMaxSize|PResizeInc|PAspect)
+.De
+.LP
+If the property is large enough to contain the base size
+and window gravity fields as well,
+the supplied_return argument will also contain the following bits:
+.LP
+.Ds
+PBaseSize|PWinGravity
+.De
+.LP
+.ZN XGetWMSizeHints
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_NORMAL_HINTS\s+1
+Size hints for a window in its normal state.
+The C type of this property is
+.ZN XSizeHints .
+.SH STRUCTURES
+The
+.ZN XSizeHints
+structure contains:
+.LP
+/* Size hints mask bits */
+.TS
+lw(.5i) lw(1.1i) lw(1.5i) lw(3.1i).
+T{
+#define
+T} T{
+.ZN USPosition
+T} T{
+(1L << 0)
+T} T{
+/* user specified x, y */
+T}
+T{
+#define
+T} T{
+.ZN USSize
+T} T{
+(1L << 1)
+T} T{
+/* user specified width, height */
+T}
+T{
+#define
+T} T{
+.ZN PPosition
+T} T{
+(1L << 2)
+T} T{
+/* program specified position */
+T}
+T{
+#define
+T} T{
+.ZN PSize
+T} T{
+(1L << 3)
+T} T{
+/* program specified size */
+T}
+T{
+#define
+T} T{
+.ZN PMinSize
+T} T{
+(1L << 4)
+T} T{
+/* program specified minimum size */
+T}
+T{
+#define
+T} T{
+.ZN PMaxSize
+T} T{
+(1L << 5)
+T} T{
+/* program specified maximum size */
+T}
+T{
+#define
+T} T{
+.ZN PResizeInc
+T} T{
+(1L << 6)
+T} T{
+/* program specified resize increments */
+T}
+T{
+#define
+T} T{
+.ZN PAspect
+T} T{
+(1L << 7)
+T} T{
+/* program specified min and max aspect ratios */
+T}
+T{
+#define
+T} T{
+.ZN PBaseSize
+T} T{
+(1L << 8)
+T}
+T{
+#define
+T} T{
+.ZN PWinGravity
+T} T{
+(1L << 9)
+T}
+T{
+#define
+T} T{
+.ZN PAllHints
+T} T{
+(PPosition|PSize|
+.br
+PMinSize|PMaxSize|
+.br
+PResizeInc|PAspect)
+T} T{
+T}
+.TE
+.IN "XSizeHints" "" "@DEF@"
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+/* Values */
+
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ int x, y; /* Obsolete */
+ int width, height; /* Obsolete */
+ int min_width, min_height;
+ int max_width, max_height;
+ int width_inc, height_inc;
+ struct {
+ int x; /* numerator */
+ int y; /* denominator */
+ } min_aspect, max_aspect;
+ int base_width, base_height;
+ int win_gravity;
+ /* this structure may be extended in the future */
+} XSizeHints;
+.De
+.LP
+The x, y, width, and height members are now obsolete
+and are left solely for compatibility reasons.
+The min_width and min_height members specify the
+minimum window size that still allows the application to be useful.
+The max_width and max_height members specify the maximum window size.
+The width_inc and height_inc members define an arithmetic progression of
+sizes (minimum to maximum) into which the window prefers to be resized.
+The min_aspect and max_aspect members are expressed
+as ratios of x and y,
+and they allow an application to specify the range of aspect
+ratios it prefers.
+The base_width and base_height members define the desired size of the window.
+The window manager will interpret the position of the window
+and its border width to position the point of the outer rectangle
+of the overall window specified by the win_gravity member.
+The outer rectangle of the window includes any borders or decorations
+supplied by the window manager.
+In other words,
+if the window manager decides to place the window where the client asked,
+the position on the parent window's border named by the win_gravity
+will be placed where the client window would have been placed
+in the absence of a window manager.
+.LP
+Note that use of the
+.ZN PAllHints
+macro is highly discouraged.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocStandardColormap.man b/man/XAllocStandardColormap.man
new file mode 100644
index 00000000..e7c2173a
--- /dev/null
+++ b/man/XAllocStandardColormap.man
@@ -0,0 +1,421 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XAllocStandardColormap 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocStandardColormap, XSetRGBColormaps, XGetRGBColormaps, XStandardColormap \- allocate, set, or read a standard colormap structure
+.SH SYNTAX
+XStandardColormap *XAllocStandardColormap\^(\|)
+.LP
+void XSetRGBColormaps\^(\^\fIdisplay\fP, \fIw\fP, \fIstd_colormap\fP, \
+\fIcount\fP, \fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XStandardColormap *\fIstd_colormap\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.LP
+Status XGetRGBColormaps\^(\^\fIdisplay\fP, \fIw\fP, \fIstd_colormap_return\fP, \
+\fIcount_return\fP, \fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XStandardColormap **\fIstd_colormap_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Cn colormaps
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.ds Cn colormaps
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIproperty\fP 1i
+Specifies the property name.
+.IP \fIstd_colormap\fP 1i
+Specifies the
+.ZN XStandardColormap
+structure to be used.
+.IP \fIstd_colormap_return\fP 1i
+Returns the
+.ZN XStandardColormap
+structure.
+.SH DESCRIPTION
+The
+.ZN XAllocStandardColormap
+function allocates and returns a pointer to a
+.ZN XStandardColormap
+structure.
+Note that all fields in the
+.ZN XStandardColormap
+structure are initially set to zero.
+If insufficient memory is available,
+.ZN XAllocStandardColormap
+returns NULL.
+To free the memory allocated to this structure,
+use
+.ZN XFree .
+.LP
+The
+.ZN XSetRGBColormaps
+function replaces the RGB colormap definition in the specified property
+on the named window.
+If the property does not already exist,
+.ZN XSetRGBColormaps
+sets the RGB colormap definition in the specified property
+on the named window.
+The property is stored with a type of RGB_COLOR_MAP and a format of 32.
+Note that it is the caller's responsibility to honor the ICCCM
+restriction that only RGB_DEFAULT_MAP contain more than one definition.
+.LP
+The
+.ZN XSetRGBColormaps
+function usually is only used by window or session managers.
+To create a standard colormap,
+follow this procedure:
+.IP 1. 5
+Open a new connection to the same server.
+.IP 2. 5
+Grab the server.
+.IP 3. 5
+See if the property is on the property list of the root window for the screen.
+.IP 4. 5
+If the desired property is not present:
+.RS
+.IP \(bu 5
+Create a colormap (unless you are using the default colormap of the screen).
+.IP \(bu 5
+Determine the color characteristics of the visual.
+.IP \(bu 5
+Allocate cells in the colormap (or create it with
+.ZN AllocAll ).
+.IP \(bu 5
+Call
+.ZN XStoreColors
+to store appropriate color values in the colormap.
+.IP \(bu 5
+Fill in the descriptive members in the
+.ZN XStandardColormap
+structure.
+.IP \(bu 5
+Attach the property to the root window.
+.IP \(bu 5
+Use
+.ZN XSetCloseDownMode
+to make the resource permanent.
+.RE
+.IP 5. 5
+Ungrab the server.
+.LP
+.ZN XSetRGBColormaps
+can generate
+.ZN BadAlloc ,
+.ZN BadAtom ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetRGBColormaps
+function returns the RGB colormap definitions stored
+in the specified property on the named window.
+If the property exists, is of type RGB_COLOR_MAP, is of format 32,
+and is long enough to contain a colormap definition,
+.ZN XGetRGBColormaps
+allocates and fills in space for the returned colormaps
+and returns a nonzero status.
+If the visualid is not present,
+.ZN XGetRGBColormaps
+assumes the default visual for the screen on which the window is located;
+if the killid is not present,
+.ZN None
+is assumed, which indicates that the resources cannot be released.
+Otherwise,
+none of the fields are set, and
+.ZN XGetRGBColormaps
+returns a zero status.
+Note that it is the caller's responsibility to honor the ICCCM
+restriction that only RGB_DEFAULT_MAP contain more than one definition.
+.LP
+.ZN XGetRGBColormaps
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.SH STRUCTURES
+The
+.ZN XStandardColormap
+structure contains:
+.LP
+/* Hints */
+.TS
+lw(.5i) lw(2i) lw(1i).
+T{
+#define
+T} T{
+.ZN ReleaseByFreeingColormap
+T} T{
+( (XID) 1L)
+T}
+.TE
+/* Values */
+.IN "XStandardColormap" "" "@DEF@"
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ Colormap colormap;
+ unsigned long red_max;
+ unsigned long red_mult;
+ unsigned long green_max;
+ unsigned long green_mult;
+ unsigned long blue_max;
+ unsigned long blue_mult;
+ unsigned long base_pixel;
+ VisualID visualid;
+ XID killid;
+} XStandardColormap;
+.De
+.LP
+The colormap member is the colormap created by the
+.ZN XCreateColormap
+function.
+The red_max, green_max, and blue_max members give the maximum
+red, green, and blue values, respectively.
+Each color coefficient ranges from zero to its max, inclusive.
+For example,
+a common colormap allocation is 3/3/2 (3 planes for red, 3
+planes for green, and 2 planes for blue).
+This colormap would have red_max = 7, green_max = 7,
+and blue_max = 3.
+An alternate allocation that uses only 216 colors is red_max = 5,
+green_max = 5, and blue_max = 5.
+.LP
+The red_mult, green_mult, and blue_mult members give the
+scale factors used to compose a full pixel value.
+(See the discussion of the base_pixel members for further information.)
+For a 3/3/2 allocation, red_mult might be 32,
+green_mult might be 4, and blue_mult might be 1.
+For a 6-colors-each allocation, red_mult might be 36,
+green_mult might be 6, and blue_mult might be 1.
+.LP
+The base_pixel member gives the base pixel value used to
+compose a full pixel value.
+Usually, the base_pixel is obtained from a call to the
+.ZN XAllocColorPlanes
+function.
+Given integer red, green, and blue coefficients in their appropriate
+ranges, one then can compute a corresponding pixel value by
+using the following expression:
+.LP
+.Ds
+.TA .5i 1.5i
+.ta .5i 1.5i
+(r * red_mult + g * green_mult + b * blue_mult + base_pixel) & 0xFFFFFFFF
+.De
+.LP
+For
+.ZN GrayScale
+colormaps,
+only the colormap, red_max, red_mult,
+and base_pixel members are defined.
+The other members are ignored.
+To compute a
+.ZN GrayScale
+pixel value, use the following expression:
+.LP
+.Ds
+.TA .5i 1.5i
+.ta .5i 1.5i
+(gray * red_mult + base_pixel) & 0xFFFFFFFF
+.De
+.LP
+Negative multipliers can be represented by converting the 2's
+complement representation of the multiplier into an unsigned long and
+storing the result in the appropriate _mult field.
+The step of masking by 0xFFFFFFFF effectively converts the resulting
+positive multiplier into a negative one.
+The masking step will take place automatically on many machine architectures,
+depending on the size of the integer type used to do the computation,
+.LP
+The visualid member gives the ID number of the visual from which the
+colormap was created.
+The killid member gives a resource ID that indicates whether
+the cells held by this standard colormap are to be released
+by freeing the colormap ID or by calling the
+.ZN XKillClient
+function on the indicated resource.
+(Note that this method is necessary for allocating out of an existing colormap.)
+.LP
+The properties containing the
+.ZN XStandardColormap
+information have
+the type RGB_COLOR_MAP.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocColor(3X11),
+XCreateColormap(3X11),
+XFree(3X11),
+XSetCloseDownMode(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllocWMHints.man b/man/XAllocWMHints.man
new file mode 100644
index 00000000..6331ada2
--- /dev/null
+++ b/man/XAllocWMHints.man
@@ -0,0 +1,425 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XAllocWMHints 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllocWMHints, XSetWMHints, XGetWMHints, XWMHints \- allocate window manager hints structure and set or read a window's WM_HINTS property
+.SH SYNTAX
+XWMHints *XAllocWMHints\^(\|)
+.LP
+XSetWMHints\^(\^\fIdisplay\fP, \fIw\fP, \fIwmhints\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XWMHints *\fIwmhints\fP\^;
+
+.LP
+XWMHints *XGetWMHints\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIwmhints\fP 1i
+Specifies the
+.ZN XWMHints
+structure to be used.
+.SH DESCRIPTION
+The
+.ZN XAllocWMHints
+function allocates and returns a pointer to a
+.ZN XWMHints
+structure.
+Note that all fields in the
+.ZN XWMHints
+structure are initially set to zero.
+If insufficient memory is available,
+.ZN XAllocWMHints
+returns NULL.
+To free the memory allocated to this structure,
+use
+.ZN XFree .
+.LP
+The
+.ZN XSetWMHints
+function sets the window manager hints that include icon information and location,
+the initial state of the window, and whether the application relies on the
+window manager to get keyboard input.
+.LP
+.ZN XSetWMHints
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetWMHints
+function reads the window manager hints and
+returns NULL if no WM_HINTS property was set on the window
+or returns a pointer to a
+.ZN XWMHints
+structure if it succeeds.
+When finished with the data,
+free the space used for it by calling
+.ZN XFree .
+.LP
+.ZN XGetWMHints
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_HINTS\s+1
+Additional hints set by the client for use by the window manager.
+The C type of this property is
+.ZN XWMHints .
+.SH STRUCTURES
+The
+.ZN XWMHints
+structure contains:
+.LP
+/* Window manager hints mask bits */
+.TS
+lw(.5i) lw(2.5i) lw(2.5i).
+T{
+#define
+T} T{
+.ZN InputHint
+T} T{
+(1L << 0)
+T}
+T{
+#define
+T} T{
+.ZN StateHint
+T} T{
+(1L << 1)
+T}
+T{
+#define
+T} T{
+.ZN IconPixmapHint
+T} T{
+(1L << 2)
+T}
+T{
+#define
+T} T{
+.ZN IconWindowHint
+T} T{
+(1L << 3)
+T}
+T{
+#define
+T} T{
+.ZN IconPositionHint
+T} T{
+(1L << 4)
+T}
+T{
+#define
+T} T{
+.ZN IconMaskHint
+T} T{
+(1L << 5)
+T}
+T{
+#define
+T} T{
+.ZN WindowGroupHint
+T} T{
+(1L << 6)
+T}
+T{
+#define
+T} T{
+.ZN UrgencyHint
+T} T{
+(1L << 8)
+T}
+T{
+#define
+T} T{
+.ZN AllHints
+T} T{
+(InputHint|StateHint|IconPixmapHint|
+.br
+IconWindowHint|IconPositionHint|
+.br
+IconMaskHint|WindowGroupHint)
+T}
+.TE
+.IN "XWMHints" "" "@DEF@"
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+/* Values */
+
+typedef struct {
+ long flags; /* marks which fields in this structure are defined */
+ Bool input; /* does this application rely on the window manager to
+ get keyboard input? */
+ int initial_state; /* see below */
+ Pixmap icon_pixmap; /* pixmap to be used as icon */
+ Window icon_window; /* window to be used as icon */
+ int icon_x, icon_y; /* initial position of icon */
+ Pixmap icon_mask; /* pixmap to be used as mask for icon_pixmap */
+ XID window_group; /* id of related window group */
+ /* this structure may be extended in the future */
+} XWMHints;
+.De
+.LP
+The input member is used to communicate to the window manager the input focus
+model used by the application.
+Applications that expect input but never explicitly set focus to any
+of their subwindows (that is, use the push model of focus management),
+such as X Version 10 style applications that use real-estate
+driven focus, should set this member to
+.ZN True .
+Similarly, applications
+that set input focus to their subwindows only when it is given to their
+top-level window by a window manager should also set this member to
+.ZN True .
+Applications that manage their own input focus by explicitly setting
+focus to one of their subwindows whenever they want keyboard input
+(that is, use the pull model of focus management) should set this member to
+.ZN False .
+Applications that never expect any keyboard input also should set this member
+to
+.ZN False .
+.LP
+Pull model window managers should make it possible for push model
+applications to get input by setting input focus to the top-level windows of
+applications whose input member is
+.ZN True .
+Push model window managers should
+make sure that pull model applications do not break them
+by resetting input focus to
+.ZN PointerRoot
+when it is appropriate (for example, whenever an application whose
+input member is
+.ZN False
+sets input focus to one of its subwindows).
+.LP
+The definitions for the initial_state flag are:
+.TS
+lw(.5i) lw(2i) lw(.2i) lw(2.8i).
+T{
+#define
+T} T{
+.ZN WithdrawnState
+T} T{
+0
+T} T{
+T}
+T{
+#define
+T} T{
+.ZN NormalState
+T} T{
+1
+T} T{
+/* most applications start this way */
+T}
+T{
+#define
+T} T{
+.ZN IconicState
+T} T{
+3
+T} T{
+/* application wants to start as an icon */
+T}
+.TE
+The icon_mask specifies which pixels of the icon_pixmap should be used as the
+icon.
+This allows for nonrectangular icons.
+Both icon_pixmap and icon_mask must be bitmaps.
+The icon_window lets an application provide a window for use as an icon
+for window managers that support such use.
+The window_group lets you specify that this window belongs to a group
+of other windows.
+For example, if a single application manipulates multiple
+top-level windows, this allows you to provide enough
+information that a window manager can iconify all of the windows
+rather than just the one window.
+.LP
+The
+.ZN UrgencyHint
+flag, if set in the flags field, indicates that the client deems the window
+contents to be urgent, requiring the timely response of the user. The
+window manager will make some effort to draw the user's attention to this
+window while this flag is set. The client must provide some means by which the
+user can cause the urgency flag to be cleared (either mitigating
+the condition that made the window urgent or merely shutting off the alarm)
+or the window to be withdrawn.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XAllowEvents.man b/man/XAllowEvents.man
new file mode 100644
index 00000000..545aaf33
--- /dev/null
+++ b/man/XAllowEvents.man
@@ -0,0 +1,192 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAllowEvents 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAllowEvents \- release queued events
+.SH SYNTAX
+XAllowEvents\^(\^\fIdisplay\fP, \fIevent_mode\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIevent_mode\fP\^;
+.br
+ Time \fItime\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mode\fP 1i
+Specifies the event mode.
+You can pass
+.ZN AsyncPointer ,
+.ZN SyncPointer ,
+.ZN AsyncKeyboard ,
+.ZN SyncKeyboard ,
+.ZN ReplayPointer ,
+.ZN ReplayKeyboard ,
+.ZN AsyncBoth ,
+or
+.ZN SyncBoth .
+.IP \fItime\fP 1i
+Specifies the time.
+You can pass either a timestamp or
+.ZN CurrentTime .
+.SH DESCRIPTION
+The
+.ZN XAllowEvents
+function releases some queued events if the client has caused a device
+to freeze.
+It has no effect if the specified time is earlier than the last-grab
+time of the most recent active grab for the client or if the specified time
+is later than the current X server time.
+.LP
+.ZN XAllowEvents
+can generate a
+.ZN BadValue
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XAnyEvent.man b/man/XAnyEvent.man
new file mode 100644
index 00000000..5a6196e3
--- /dev/null
+++ b/man/XAnyEvent.man
@@ -0,0 +1,270 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XAnyEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XAnyEvent, XEvent \- generic X event structures
+.SH STRUCTURES
+All the event structures declared in
+.Pn < X11/Xlib.h >
+have the following common members:
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type;
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+} XAnyEvent;
+.De
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The
+.ZN XEvent
+structure is a union of the individual structures declared for each event type:
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef union _XEvent {
+ int type; /* must not be changed */
+ XAnyEvent xany;
+ XKeyEvent xkey;
+ XButtonEvent xbutton;
+ XMotionEvent xmotion;
+ XCrossingEvent xcrossing;
+ XFocusChangeEvent xfocus;
+ XExposeEvent xexpose;
+ XGraphicsExposeEvent xgraphicsexpose;
+ XNoExposeEvent xnoexpose;
+ XVisibilityEvent xvisibility;
+ XCreateWindowEvent xcreatewindow;
+ XDestroyWindowEvent xdestroywindow;
+ XUnmapEvent xunmap;
+ XMapEvent xmap;
+ XMapRequestEvent xmaprequest;
+ XReparentEvent xreparent;
+ XConfigureEvent xconfigure;
+ XGravityEvent xgravity;
+ XResizeRequestEvent xresizerequest;
+ XConfigureRequestEvent xconfigurerequest;
+ XCirculateEvent xcirculate;
+ XCirculateRequestEvent xcirculaterequest;
+ XPropertyEvent xproperty;
+ XSelectionClearEvent xselectionclear;
+ XSelectionRequestEvent xselectionrequest;
+ XSelectionEvent xselection;
+ XColormapEvent xcolormap;
+ XClientMessageEvent xclient;
+ XMappingEvent xmapping;
+ XErrorEvent xerror;
+ XKeymapEvent xkeymap;
+ long pad[24];
+} XEvent;
+.De
+.LP
+An
+.ZN XEvent
+structure's first entry always is the type member,
+which is set to the event type.
+The second member always is the serial number of the protocol request
+that generated the event.
+The third member always is send_event,
+which is a
+.ZN Bool
+that indicates if the event was sent by a different client.
+The fourth member always is a display,
+which is the display that the event was read from.
+Except for keymap events,
+the fifth member always is a window,
+which has been carefully selected to be useful to toolkit dispatchers.
+To avoid breaking toolkits,
+the order of these first five entries is not to change.
+Most events also contain a time member,
+which is the time at which an event occurred.
+In addition, a pointer to the generic event must be cast before it
+is used to access any other information in the structure.
+.SH "SEE ALSO"
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XButtonEvent.man b/man/XButtonEvent.man
new file mode 100644
index 00000000..062f3115
--- /dev/null
+++ b/man/XButtonEvent.man
@@ -0,0 +1,354 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XButtonEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XButtonEvent, XKeyEvent, XMotionEvent \- KeyPress, KeyRelease, ButtonPress, ButtonRelease, and MotionNotify event structures
+.SH STRUCTURES
+The structures for
+.ZN KeyPress ,
+.ZN KeyRelease ,
+.ZN ButtonPress ,
+.ZN ButtonRelease ,
+and
+.ZN MotionNotify
+events contain:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ButtonPress or ButtonRelease */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* ``event'' window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int button; /* detail */
+ Bool same_screen; /* same screen flag */
+} XButtonEvent;
+typedef XButtonEvent XButtonPressedEvent;
+typedef XButtonEvent XButtonReleasedEvent;
+.De
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* KeyPress or KeyRelease */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* ``event'' window it is reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ unsigned int keycode; /* detail */
+ Bool same_screen; /* same screen flag */
+} XKeyEvent;
+typedef XKeyEvent XKeyPressedEvent;
+typedef XKeyEvent XKeyReleasedEvent;
+.De
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* MotionNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* ``event'' window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ unsigned int state; /* key or button mask */
+ char is_hint; /* detail */
+ Bool same_screen; /* same screen flag */
+} XMotionEvent;
+typedef XMotionEvent XPointerMovedEvent;
+.De
+.LP
+When you receive these events,
+their structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+These structures have the following common members:
+window, root, subwindow, time, x, y, x_root, y_root, state, and same_screen.
+The window member is set to the window on which the
+event was generated and is referred to as the event window.
+As long as the conditions previously discussed are met,
+this is the window used by the X server to report the event.
+The root member is set to the source window's root window.
+The x_root and y_root members are set to the pointer's coordinates
+relative to the root window's origin at the time of the event.
+.LP
+The same_screen member is set to indicate whether the event
+window is on the same screen
+as the root window and can be either
+.ZN True
+or
+.ZN False .
+If
+.ZN True ,
+the event and root windows are on the same screen.
+If
+.ZN False ,
+the event and root windows are not on the same screen.
+.LP
+If the source window is an inferior of the event window,
+the subwindow member of the structure is set to the child of the event window
+that is the source window or the child of the event window that is
+an ancestor of the source window.
+Otherwise, the X server sets the subwindow member to
+.ZN None .
+The time member is set to the time when the event was generated
+and is expressed in milliseconds.
+.LP
+If the event window is on the same screen as the root window,
+the x and y members
+are set to the coordinates relative to the event window's origin.
+Otherwise, these members are set to zero.
+.LP
+The state member is set to indicate the logical state of the pointer buttons
+and modifier keys just prior to the event,
+which is the bitwise inclusive OR of one or more of the
+button or modifier key masks:
+.ZN Button1Mask ,
+.ZN Button2Mask ,
+.ZN Button3Mask ,
+.ZN Button4Mask ,
+.ZN Button5Mask ,
+.ZN ShiftMask ,
+.ZN LockMask ,
+.ZN ControlMask ,
+.ZN Mod1Mask ,
+.ZN Mod2Mask ,
+.ZN Mod3Mask ,
+.ZN Mod4Mask ,
+and
+.ZN Mod5Mask .
+.LP
+Each of these structures also has a member that indicates the detail.
+For the
+.ZN XKeyPressedEvent
+and
+.ZN XKeyReleasedEvent
+structures, this member is called a keycode.
+It is set to a number that represents a physical key on the keyboard.
+The keycode is an arbitrary representation for any key on the keyboard
+(see sections 12.7 and 16.1).
+.LP
+For the
+.ZN XButtonPressedEvent
+and
+.ZN XButtonReleasedEvent
+structures, this member is called button.
+It represents the pointer button that changed state and can be the
+.ZN Button1 ,
+.ZN Button2 ,
+.ZN Button3 ,
+.ZN Button4 ,
+or
+.ZN Button5
+value.
+For the
+.ZN XPointerMovedEvent
+structure, this member is called is_hint.
+It can be set to
+.ZN NotifyNormal
+or
+.ZN NotifyHint .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XChangeKeyboardControl.man b/man/XChangeKeyboardControl.man
new file mode 100644
index 00000000..c78cd78e
--- /dev/null
+++ b/man/XChangeKeyboardControl.man
@@ -0,0 +1,466 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XChangeKeyboardControl 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XChangeKeyboardControl, XGetKeyboardControl, XAutoRepeatOn, XAutoRepeatOff, XBell, XQueryKeymap, XKeyboardControl \- manipulate keyboard settings and keyboard control structure
+.SH SYNTAX
+XChangeKeyboardControl\^(\^\fIdisplay\fP, \fIvalue_mask\fP\^, \fIvalues\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned long \fIvalue_mask\fP\^;
+.br
+ XKeyboardControl *\fIvalues\fP\^;
+.LP
+XGetKeyboardControl\^(\^\fIdisplay\fP, \fIvalues_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XKeyboardState *\fIvalues_return\fP\^;
+.LP
+XAutoRepeatOn\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XAutoRepeatOff\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XBell\^(\^\fIdisplay\fP, \fIpercent\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIpercent\fP\^;
+.LP
+XQueryKeymap\^(\^\fIdisplay\fP, \fIkeys_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char \fIkeys_return\fP[32]\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIkeys_return\fP 1i
+Returns an array of bytes that identifies which keys are pressed down.
+Each bit represents one key of the keyboard.
+.IP \fIpercent\fP 1i
+Specifies the volume for the bell,
+which can range from \-100 to 100 inclusive.
+.IP \fIvalue_mask\fP 1i
+Specifies which controls to change.
+This mask is the bitwise inclusive OR of the valid control mask bits.
+.IP \fIvalues\fP 1i
+Specifies one value for each bit set to 1 in the mask.
+.IP \fIvalues_return\fP 1i
+Returns the current keyboard controls in the specified
+.ZN XKeyboardState
+structure.
+.SH DESCRIPTION
+The
+.ZN XChangeKeyboardControl
+function controls the keyboard characteristics defined by the
+.ZN XKeyboardControl
+structure.
+The value_mask argument specifies which values are to be changed.
+.LP
+.ZN XChangeKeyboardControl
+can generate
+.ZN BadMatch
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetKeyboardControl
+function returns the current control values for the keyboard to the
+.ZN XKeyboardState
+structure.
+.LP
+The
+.ZN XAutoRepeatOn
+function turns on auto-repeat for the keyboard on the specified display.
+.LP
+The
+.ZN XAutoRepeatOff
+function turns off auto-repeat for the keyboard on the specified display.
+.LP
+The
+.ZN XBell
+function rings the bell on the keyboard on the specified display, if possible.
+The specified volume is relative to the base volume for the keyboard.
+If the value for the percent argument is not in the range \-100 to 100
+inclusive, a
+.ZN BadValue
+error results.
+The volume at which the bell rings
+when the percent argument is nonnegative is:
+.IP
+base \- [(base * percent) / 100] + percent
+.LP
+The volume at which the bell rings
+when the percent argument is negative is:
+.IP
+base + [(base * percent) / 100]
+.LP
+To change the base volume of the bell, use
+.ZN XChangeKeyboardControl .
+.LP
+.ZN XBell
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XQueryKeymap
+function returns a bit vector for the logical state of the keyboard,
+where each bit set to 1 indicates that the corresponding key is currently
+pressed down.
+The vector is represented as 32 bytes.
+Byte N (from 0) contains the bits for keys 8N to 8N + 7
+with the least significant bit in the byte representing key 8N.
+.LP
+Note that the logical state of a device (as seen by client applications)
+may lag the physical state if device event processing is frozen.
+.SH STRUCTURES
+The
+.ZN XKeyboardControl
+structure contains:
+.LP
+.LP
+/* Mask bits for ChangeKeyboardControl */
+.TS
+lw(.5i) lw(2.5i) lw(.8i).
+T{
+#define
+T} T{
+.ZN KBKeyClickPercent
+T} T{
+(1L<<0)
+T}
+T{
+#define
+T} T{
+.ZN KBBellPercent
+T} T{
+(1L<<1)
+T}
+T{
+#define
+T} T{
+.ZN KBBellPitch
+T} T{
+(1L<<2)
+T}
+T{
+#define
+T} T{
+.ZN KBBellDuration
+T} T{
+(1L<<3)
+T}
+T{
+#define
+T} T{
+.ZN KBLed
+T} T{
+(1L<<4)
+T}
+T{
+#define
+T} T{
+.ZN KBLedMode
+T} T{
+(1L<<5)
+T}
+T{
+#define
+T} T{
+.ZN KBKey
+T} T{
+(1L<<6)
+T}
+T{
+#define
+T} T{
+.ZN KBAutoRepeatMode
+T} T{
+(1L<<7)
+T}
+.TE
+.IN "XKeyboardControl" "" "@DEF@"
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+/* Values */
+
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ int bell_pitch;
+ int bell_duration;
+ int led;
+ int led_mode; /* LedModeOn, LedModeOff */
+ int key;
+ int auto_repeat_mode; /* AutoRepeatModeOff, AutoRepeatModeOn,
+ AutoRepeatModeDefault */
+} XKeyboardControl;
+.De
+.LP
+The key_click_percent member sets the volume for key clicks between 0 (off)
+and 100 (loud) inclusive, if possible.
+A setting of \-1 restores the default.
+Other negative values generate a
+.ZN BadValue
+error.
+.LP
+The bell_percent sets the base volume for the bell between 0 (off) and 100
+(loud) inclusive, if possible.
+A setting of \-1 restores the default.
+Other negative values generate a
+.ZN BadValue
+error.
+The bell_pitch member sets the pitch (specified in Hz) of the bell, if possible.
+A setting of \-1 restores the default.
+Other negative values generate a
+.ZN BadValue
+error.
+The bell_duration member sets the duration of the
+bell specified in milliseconds, if possible.
+A setting of \-1 restores the default.
+Other negative values generate a
+.ZN BadValue
+error.
+.LP
+If both the led_mode and led members are specified,
+the state of that LED is changed, if possible.
+The led_mode member can be set to
+.ZN LedModeOn
+or
+.ZN LedModeOff .
+If only led_mode is specified, the state of
+all LEDs are changed, if possible.
+At most 32 LEDs numbered from one are supported.
+No standard interpretation of LEDs is defined.
+If led is specified without led_mode, a
+.ZN BadMatch
+error results.
+.LP
+If both the auto_repeat_mode and key members are specified,
+the auto_repeat_mode of that key is changed (according to
+.ZN AutoRepeatModeOn ,
+.ZN AutoRepeatModeOff ,
+or
+.ZN AutoRepeatModeDefault ),
+if possible.
+If only auto_repeat_mode is
+specified, the global auto_repeat_mode for the entire keyboard is
+changed, if possible, and does not affect the per-key settings.
+If a key is specified without an auto_repeat_mode, a
+.ZN BadMatch
+error results.
+Each key has an individual mode of whether or not it should auto-repeat
+and a default setting for the mode.
+In addition,
+there is a global mode of whether auto-repeat should be enabled or not
+and a default setting for that mode.
+When global mode is
+.ZN AutoRepeatModeOn ,
+keys should obey their individual auto-repeat modes.
+When global mode is
+.ZN AutoRepeatModeOff ,
+no keys should auto-repeat.
+An auto-repeating key generates alternating
+.ZN KeyPress
+and
+.ZN KeyRelease
+events.
+When a key is used as a modifier,
+it is desirable for the key not to auto-repeat,
+regardless of its auto-repeat setting.
+.LP
+The
+.ZN XKeyboardState
+structure contains:
+.LP
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ int key_click_percent;
+ int bell_percent;
+ unsigned int bell_pitch, bell_duration;
+ unsigned long led_mask;
+ int global_auto_repeat;
+ char auto_repeats[32];
+} XKeyboardState;
+.De
+.LP
+For the LEDs,
+the least significant bit of led_mask corresponds to LED one,
+and each bit set to 1 in led_mask indicates an LED that is lit.
+The global_auto_repeat member can be set to
+.ZN AutoRepeatModeOn
+or
+.ZN AutoRepeatModeOff .
+The auto_repeats member is a bit vector.
+Each bit set to 1 indicates that auto-repeat is enabled
+for the corresponding key.
+The vector is represented as 32 bytes.
+Byte N (from 0) contains the bits for keys 8N to 8N + 7
+with the least significant bit in the byte representing key 8N.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XChangeKeyboardMapping(3X11),
+XSetPointerMapping(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XChangeKeyboardMapping.man b/man/XChangeKeyboardMapping.man
new file mode 100644
index 00000000..02f39054
--- /dev/null
+++ b/man/XChangeKeyboardMapping.man
@@ -0,0 +1,488 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XChangeKeyboardMapping 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XChangeKeyboardMapping, XGetKeyboardMapping, XDisplayKeycodes, XSetModifierMapping, XGetModifierMapping, XNewModifiermap, XInsertModifiermapEntry, XDeleteModifiermapEntry, XFreeModifierMap XModifierKeymap \- manipulate keyboard encoding and keyboard encoding structure
+.SH SYNTAX
+XChangeKeyboardMapping(\^\fIdisplay\fP, \fIfirst_keycode\fP, \fIkeysyms_per_keycode\fP, \fIkeysyms\fP, \fInum_codes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIfirst_keycode\fP\^;
+.br
+ int \fIkeysyms_per_keycode\fP\^;
+.br
+ KeySym *\fIkeysyms\fP\^;
+.br
+ int \fInum_codes\fP\^;
+.LP
+KeySym *XGetKeyboardMapping(\^\fIdisplay\fP, \fIfirst_keycode\fP, \fIkeycode_count\fP,
+.br
+ \fIkeysyms_per_keycode_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ KeyCode \fIfirst_keycode\fP\^;
+.br
+ int \fIkeycode_count\fP\^;
+.br
+ int *\fIkeysyms_per_keycode_return\fP\^;
+.LP
+XDisplayKeycodes\^(\^\fIdisplay\fP\^, \fImin_keycodes_return\fP\^, \
+\fImax_keycodes_return\fP\^)
+.br
+ Display *\^\fIdisplay\fP\^;
+.br
+ int *\^\fImin_keycodes_return\fP\^, *\^\fImax_keycodes_return\fP\^;
+.LP
+int XSetModifierMapping(\^\fIdisplay\fP, \fImodmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XModifierKeymap *\fImodmap\fP\^;
+.LP
+XModifierKeymap *XGetModifierMapping(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+
+.LP
+XModifierKeymap *XNewModifiermap(\^\fImax_keys_per_mod\fP\^)
+.br
+ int \fImax_keys_per_mod\fP\^;
+.LP
+XModifierKeymap *XInsertModifiermapEntry\^(\^\fImodmap\fP, \
+\fIkeycode_entry\fP, \fImodifier\fP\^)
+.br
+ XModifierKeymap *\fImodmap\fP\^;
+.br
+ KeyCode \fIkeycode_entry\fP\^;
+.br
+ int \fImodifier\fP\^;
+.LP
+XModifierKeymap *XDeleteModifiermapEntry\^(\^\fImodmap\fP, \
+\fIkeycode_entry\fP, \fImodifier\fP\^)
+.br
+ XModifierKeymap *\fImodmap\fP\^;
+.br
+ KeyCode \fIkeycode_entry\fP\^;
+.br
+ int \fImodifier\fP\^;
+.LP
+XFreeModifiermap(\^\fImodmap\fP\^)
+.br
+ XModifierKeymap *\fImodmap\fP;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Kc changed or returned
+.IP \fIfirst_keycode\fP 1i
+Specifies the first KeyCode that is to be \*(Kc.
+.IP \fIkeycode_count\fP 1i
+Specifies the number of KeyCodes that are to be returned.
+.IP \fIkeycode_entry\fP 1i
+Specifies the KeyCode.
+.IP \fIkeysyms\fP 1i
+Specifies an array of KeySyms.
+.IP \fIkeysyms_per_keycode\fP 1i
+Specifies the number of KeySyms per KeyCode.
+.IP \fIkeysyms_per_keycode_return\fP 1i
+Returns the number of KeySyms per KeyCode.
+.IP \fImax_keys_per_mod\fP 1i
+Specifies the number of KeyCode entries preallocated to the modifiers
+in the map.
+.IP \fImax_keycodes_return\fP 1i
+Returns the maximum number of KeyCodes.
+.IP \fImin_keycodes_return\fP 1i
+Returns the minimum number of KeyCodes.
+.IP \fImodifier\fP 1i
+Specifies the modifier.
+.IP \fImodmap\fP 1i
+Specifies the
+.ZN XModifierKeymap
+structure.
+.IP \fInum_codes\fP 1i
+Specifies the number of KeyCodes that are to be changed.
+.SH DESCRIPTION
+The
+.ZN XChangeKeyboardMapping
+function defines the symbols for the specified number of KeyCodes
+starting with first_keycode.
+The symbols for KeyCodes outside this range remain unchanged.
+The number of elements in keysyms must be:
+.LP
+.Ds
+num_codes * keysyms_per_keycode
+.De
+.LP
+The specified first_keycode must be greater than or equal to min_keycode
+returned by
+.ZN XDisplayKeycodes ,
+or a
+.ZN BadValue
+error results.
+In addition, the following expression must be less than or equal to
+max_keycode as returned by
+.ZN XDisplayKeycodes ,
+or a
+.ZN BadValue
+error results:
+.LP
+.Ds
+first_keycode + num_codes \- 1
+.De
+.LP
+KeySym number N, counting from zero, for KeyCode K has the following index
+in keysyms, counting from zero:
+.LP
+.Ds
+(K \- first_keycode) * keysyms_per_keycode + N
+.De
+.LP
+The specified keysyms_per_keycode can be chosen arbitrarily by the client
+to be large enough to hold all desired symbols.
+A special KeySym value of
+.ZN NoSymbol
+should be used to fill in unused elements
+for individual KeyCodes.
+It is legal for
+.ZN NoSymbol
+to appear in nontrailing positions
+of the effective list for a KeyCode.
+.ZN XChangeKeyboardMapping
+generates a
+.ZN MappingNotify
+event.
+.LP
+There is no requirement that the X server interpret this mapping.
+It is merely stored for reading and writing by clients.
+.LP
+.ZN XChangeKeyboardMapping
+can generate
+.ZN BadAlloc
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetKeyboardMapping
+function returns the symbols for the specified number of KeyCodes
+starting with first_keycode.
+The value specified in first_keycode must be greater than
+or equal to min_keycode as returned by
+.ZN XDisplayKeycodes ,
+or a
+.ZN BadValue
+error results.
+In addition, the following expression must be less than or equal
+to max_keycode as returned by
+.ZN XDisplayKeycodes :
+.LP
+.Ds
+first_keycode + keycode_count \- 1
+.De
+.LP
+If this is not the case, a
+.ZN BadValue
+error results.
+The number of elements in the KeySyms list is:
+.LP
+.Ds
+keycode_count * keysyms_per_keycode_return
+.De
+.LP
+KeySym number N, counting from zero, for KeyCode K has the following index
+in the list, counting from zero:
+.Ds
+(K \- first_code) * keysyms_per_code_return + N
+.De
+.LP
+The X server arbitrarily chooses the keysyms_per_keycode_return value
+to be large enough to report all requested symbols.
+A special KeySym value of
+.ZN NoSymbol
+is used to fill in unused elements for
+individual KeyCodes.
+To free the storage returned by
+.ZN XGetKeyboardMapping ,
+use
+.ZN XFree .
+.LP
+.ZN XGetKeyboardMapping
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XDisplayKeycodes
+function returns the min-keycodes and max-keycodes supported by the
+specified display.
+The minimum number of KeyCodes returned is never less than 8,
+and the maximum number of KeyCodes returned is never greater than 255.
+Not all KeyCodes in this range are required to have corresponding keys.
+.LP
+The
+.ZN XSetModifierMapping
+function specifies the KeyCodes of the keys (if any) that are to be used
+as modifiers.
+If it succeeds,
+the X server generates a
+.ZN MappingNotify
+event, and
+.ZN XSetModifierMapping
+returns
+.ZN MappingSuccess .
+X permits at most 8 modifier keys.
+If more than 8 are specified in the
+.ZN XModifierKeymap
+structure, a
+.ZN BadLength
+error results.
+.LP
+The modifiermap member of the
+.ZN XModifierKeymap
+structure contains 8 sets of max_keypermod KeyCodes,
+one for each modifier in the order
+.ZN Shift ,
+.ZN Lock ,
+.ZN Control ,
+.ZN Mod1 ,
+.ZN Mod2 ,
+.ZN Mod3 ,
+.ZN Mod4 ,
+and
+.ZN Mod5 .
+Only nonzero KeyCodes have meaning in each set,
+and zero KeyCodes are ignored.
+In addition, all of the nonzero KeyCodes must be in the range specified by
+min_keycode and max_keycode in the
+.ZN Display
+structure,
+or a
+.ZN BadValue
+error results.
+.LP
+An X server can impose restrictions on how modifiers can be changed,
+for example,
+if certain keys do not generate up transitions in hardware,
+if auto-repeat cannot be disabled on certain keys,
+or if multiple modifier keys are not supported.
+If some such restriction is violated,
+the status reply is
+.ZN MappingFailed ,
+and none of the modifiers are changed.
+If the new KeyCodes specified for a modifier differ from those
+currently defined and any (current or new) keys for that modifier are
+in the logically down state,
+.ZN XSetModifierMapping
+returns
+.ZN MappingBusy ,
+and none of the modifiers is changed.
+.LP
+.ZN XSetModifierMapping
+can generate
+.ZN BadAlloc
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetModifierMapping
+function returns a pointer to a newly created
+.ZN XModifierKeymap
+structure that contains the keys being used as modifiers.
+The structure should be freed after use by calling
+.ZN XFreeModifiermap .
+If only zero values appear in the set for any modifier,
+that modifier is disabled.
+.LP
+The
+.ZN XNewModifiermap
+function returns a pointer to
+.ZN XModifierKeymap
+structure for later use.
+.LP
+The
+.ZN XInsertModifiermapEntry
+function adds the specified KeyCode to the set that controls the specified
+modifier and returns the resulting
+.ZN XModifierKeymap
+structure (expanded as needed).
+.LP
+The
+.ZN XDeleteModifiermapEntry
+function deletes the specified KeyCode from the set that controls the
+specified modifier and returns a pointer to the resulting
+.ZN XModifierKeymap
+structure.
+.LP
+The
+.ZN XFreeModifiermap
+function frees the specified
+.ZN XModifierKeymap
+structure.
+.SH STRUCTURES
+The
+.ZN XModifierKeymap
+structure contains:
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ int max_keypermod; /* This server's max number of keys per modifier */
+ KeyCode *modifiermap; /* An 8 by max_keypermod array of the modifiers */
+} XModifierKeymap;
+.De
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XFree(3X11),
+XSetPointerMapping(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XChangePointerControl.man b/man/XChangePointerControl.man
new file mode 100644
index 00000000..edf0e95a
--- /dev/null
+++ b/man/XChangePointerControl.man
@@ -0,0 +1,226 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XChangePointerControl 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XChangePointerControl, XGetPointerControl \- control pointer
+.SH SYNTAX
+XChangePointerControl\^(\^\fIdisplay\fP, \fIdo_accel\fP\^, \fIdo_threshold\fP\^, \fIaccel_numerator\fP\^,
+.br
+ \fIaccel_denominator\fP\^, \fIthreshold\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Bool \fIdo_accel\fP\^, \fIdo_threshold\fP\^;
+.br
+ int \fIaccel_numerator\fP\^, \fIaccel_denominator\fP\^;
+.br
+ int \fIthreshold\fP\^;
+.LP
+XGetPointerControl\^(\^\fIdisplay\fP, \fIaccel_numerator_return\fP\^, \fIaccel_denominator_return\fP\^,
+.br
+ \fIthreshold_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fIaccel_numerator_return\fP\^, *\fIaccel_denominator_return\fP\^;
+.br
+ int *\fIthreshold_return\fP\^;
+.SH ARGUMENTS
+.IP \fIaccel_denominator\fP 1i
+Specifies the denominator for the acceleration multiplier.
+.IP \fIaccel_denominator_return\fP 1i
+Returns the denominator for the acceleration multiplier.
+.IP \fIaccel_numerator\fP 1i
+Specifies the numerator for the acceleration multiplier.
+.IP \fIaccel_numerator_return\fP 1i
+Returns the numerator for the acceleration multiplier.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIdo_accel\fP 1i
+Specifies a Boolean value that controls whether the values for
+the accel_numerator or accel_denominator are used.
+.IP \fIdo_threshold\fP 1i
+Specifies a Boolean value that controls whether the value for the
+threshold is used.
+.IP \fIthreshold\fP 1i
+Specifies the acceleration threshold.
+.IP \fIthreshold_return\fP 1i
+Returns the acceleration threshold.
+.SH DESCRIPTION
+The
+.ZN XChangePointerControl
+function defines how the pointing device moves.
+The acceleration, expressed as a fraction, is a
+multiplier for movement.
+For example,
+specifying 3/1 means the pointer moves three times as fast as normal.
+The fraction may be rounded arbitrarily by the X server.
+Acceleration
+only takes effect if the pointer moves more than threshold pixels at
+once and only applies to the amount beyond the value in the threshold argument.
+Setting a value to \-1 restores the default.
+The values of the do_accel and do_threshold arguments must be
+.ZN True
+for the pointer values to be set,
+or the parameters are unchanged.
+Negative values (other than \-1) generate a
+.ZN BadValue
+error, as does a zero value
+for the accel_denominator argument.
+.LP
+.ZN XChangePointerControl
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XGetPointerControl
+function returns the pointer's current acceleration multiplier
+and acceleration threshold.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XChangeSaveSet.man b/man/XChangeSaveSet.man
new file mode 100644
index 00000000..511a4644
--- /dev/null
+++ b/man/XChangeSaveSet.man
@@ -0,0 +1,239 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XChangeSaveSet 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XChangeSaveSet, XAddToSaveSet, XRemoveFromSaveSet \- change a client's save set
+.SH SYNTAX
+XChangeSaveSet\^(\^\fIdisplay\fP, \fIw\fP\^, \fIchange_mode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIchange_mode\fP\^;
+.LP
+XAddToSaveSet\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XRemoveFromSaveSet\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIchange_mode\fP 1i
+Specifies the mode.
+You can pass
+.ZN SetModeInsert
+or
+.ZN SetModeDelete .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Wi that you want to add or delete from the client's save-set
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+Depending on the specified mode,
+.ZN XChangeSaveSet
+either inserts or deletes the specified window from the client's save-set.
+The specified window must have been created by some other client,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XChangeSaveSet
+can generate
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XAddToSaveSet
+function adds the specified window to the client's save-set.
+The specified window must have been created by some other client,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XAddToSaveSet
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XRemoveFromSaveSet
+function removes the specified window from the client's save-set.
+The specified window must have been created by some other client,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XRemoveFromSaveSet
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XReparentWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XChangeWindowAttributes.man b/man/XChangeWindowAttributes.man
new file mode 100644
index 00000000..5e8da053
--- /dev/null
+++ b/man/XChangeWindowAttributes.man
@@ -0,0 +1,440 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XChangeWindowAttributes 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XChangeWindowAttributes, XSetWindowBackground, XSetWindowBackgroundPixmap, XSetWindowBorder, XSetWindowBorderPixmap, XSetWindowColormap \- change window attributes
+.SH SYNTAX
+XChangeWindowAttributes\^(\^\fIdisplay\fP, \fIw\fP\^, \fIvaluemask\fP\^, \fIattributes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned long \fIvaluemask\fP\^;
+.br
+ XSetWindowAttributes *\fIattributes\fP\^;
+.LP
+XSetWindowBackground\^(\^\fIdisplay\fP, \fIw\fP\^, \fIbackground_pixel\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned long \fIbackground_pixel\fP\^;
+.LP
+XSetWindowBackgroundPixmap\^(\^\fIdisplay\fP, \fIw\fP\^, \fIbackground_pixmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Pixmap \fIbackground_pixmap\fP\^;
+.LP
+XSetWindowBorder\^(\^\fIdisplay\fP, \fIw\fP\^, \fIborder_pixel\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned long \fIborder_pixel\fP\^;
+.LP
+XSetWindowBorderPixmap\^(\^\fIdisplay\fP, \fIw\fP\^, \fIborder_pixmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Pixmap \fIborder_pixmap\fP\^;
+.LP
+XSetWindowColormap\^(\^\fIdisplay\fP, \fIw\fP\^, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.SH ARGUMENTS
+.IP \fIattributes\fP 1i
+Specifies the structure from which the values (as specified by the value mask)
+are to be taken.
+The value mask should have the appropriate bits
+set to indicate which attributes have been set in the structure.
+.IP \fIbackground_pixel\fP 1i
+Specifies the pixel that is to be used for the background.
+.IP \fIbackground_pixmap\fP 1i
+Specifies the background pixmap,
+.ZN ParentRelative ,
+or
+.ZN None .
+.IP \fIborder_pixel\fP 1i
+Specifies the entry in the colormap.
+.IP \fIborder_pixmap\fP 1i
+Specifies the border pixmap or
+.ZN CopyFromParent .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIvaluemask\fP 1i
+Specifies which window attributes are defined in the attributes
+argument.
+This mask is the bitwise inclusive OR of the valid attribute mask bits.
+If valuemask is zero,
+the attributes are ignored and are not referenced.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.SH DESCRIPTION
+Depending on the valuemask,
+the
+.ZN XChangeWindowAttributes
+function uses the window attributes in the
+.ZN XSetWindowAttributes
+structure to change the specified window attributes.
+Changing the background does not cause the window contents to be
+changed.
+To repaint the window and its background, use
+.ZN XClearWindow .
+Setting the border or changing the background such that the
+border tile origin changes causes the border to be repainted.
+Changing the background of a root window to
+.ZN None
+or
+.ZN ParentRelative
+restores the default background pixmap.
+Changing the border of a root window to
+.ZN CopyFromParent
+restores the default border pixmap.
+Changing the win-gravity does not affect the current position of the
+window.
+Changing the backing-store of an obscured window to
+.ZN WhenMapped
+or
+.ZN Always ,
+or changing the backing-planes, backing-pixel, or
+save-under of a mapped window may have no immediate effect.
+Changing the colormap of a window (that is, defining a new map, not
+changing the contents of the existing map) generates a
+.ZN ColormapNotify
+event.
+Changing the colormap of a visible window may have no
+immediate effect on the screen because the map may not be installed
+(see
+.ZN XInstallColormap ).
+Changing the cursor of a root window to
+.ZN None
+restores the default
+cursor.
+Whenever possible, you are encouraged to share colormaps.
+.LP
+Multiple clients can select input on the same window.
+Their event masks are maintained separately.
+When an event is generated,
+it is reported to all interested clients.
+However, only one client at a time can select for
+.ZN SubstructureRedirectMask ,
+.ZN ResizeRedirectMask ,
+and
+.ZN ButtonPressMask .
+If a client attempts to select any of these event masks
+and some other client has already selected one,
+a
+.ZN BadAccess
+error results.
+There is only one do-not-propagate-mask for a window,
+not one per client.
+.LP
+.ZN XChangeWindowAttributes
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+.ZN BadCursor ,
+.ZN BadMatch ,
+.ZN BadPixmap ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowBackground
+function sets the background of the window to the specified pixel value.
+Changing the background does not cause the window contents to be changed.
+.ZN XSetWindowBackground
+uses a pixmap of undefined size filled with the pixel value you passed.
+If you try to change the background of an
+.ZN InputOnly
+window, a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetWindowBackground
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowBackgroundPixmap
+function sets the background pixmap of the window to the specified pixmap.
+The background pixmap can immediately be freed if no further explicit
+references to it are to be made.
+If
+.ZN ParentRelative
+is specified,
+the background pixmap of the window's parent is used,
+or on the root window, the default background is restored.
+If you try to change the background of an
+.ZN InputOnly
+window, a
+.ZN BadMatch
+error results.
+If the background is set to
+.ZN None ,
+the window has no defined background.
+.LP
+.ZN XSetWindowBackgroundPixmap
+can generate
+.ZN BadMatch ,
+.ZN BadPixmap ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowBorder
+function sets the border of the window to the pixel value you specify.
+If you attempt to perform this on an
+.ZN InputOnly
+window, a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetWindowBorder
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowBorderPixmap
+function sets the border pixmap of the window to the pixmap you specify.
+The border pixmap can be freed immediately if no further explicit
+references to it are to be made.
+If you specify
+.ZN CopyFromParent ,
+a copy of the parent window's border pixmap is used.
+If you attempt to perform this on an
+.ZN InputOnly
+window, a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetWindowBorderPixmap
+can generate
+.ZN BadMatch ,
+.ZN BadPixmap ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowColormap
+function sets the specified colormap of the specified window.
+The colormap must have the same visual type as the window,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetWindowColormap
+can generate
+.ZN BadColor ,
+.ZN BadMatch ,
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to free a color map entry that it did not already allocate.
+.TP 1i
+.ZN BadAccess
+A client attempted
+to store into a read-only color map entry.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window locks this attribute.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XInstallColormap(3X11),
+XMapWindow(3X11),
+XRaiseWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCirculateEvent.man b/man/XCirculateEvent.man
new file mode 100644
index 00000000..7f95a454
--- /dev/null
+++ b/man/XCirculateEvent.man
@@ -0,0 +1,230 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCirculateEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCirculateEvent \- CirculateNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN CirculateNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* CirculateNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the restacked window or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the window that was restacked.
+The place member is set to the window's position after the restack occurs and
+is either
+.ZN PlaceOnTop
+or
+.ZN PlaceOnBottom .
+If it is
+.ZN PlaceOnTop ,
+the window is now on top of all siblings.
+If it is
+.ZN PlaceOnBottom ,
+the window is now below all siblings.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCirculateRequestEvent.man b/man/XCirculateRequestEvent.man
new file mode 100644
index 00000000..0d94cbf2
--- /dev/null
+++ b/man/XCirculateRequestEvent.man
@@ -0,0 +1,225 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCirculateRequestEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCirculateRequestEvent \- CirculateRequest event structure
+.SH STRUCTURES
+The structure for
+.ZN CirculateRequest
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* CirculateRequest */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int place; /* PlaceOnTop, PlaceOnBottom */
+} XCirculateRequestEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The parent member is set to the parent window.
+The window member is set to the subwindow to be restacked.
+The place member is set to what the new position in the stacking order should be
+and is either
+.ZN PlaceOnTop
+or
+.ZN PlaceOnBottom .
+If it is
+.ZN PlaceOnTop ,
+the subwindow should be on top of all siblings.
+If it is
+.ZN PlaceOnBottom ,
+the subwindow should be below all siblings.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XClearArea.man b/man/XClearArea.man
new file mode 100644
index 00000000..e7333610
--- /dev/null
+++ b/man/XClearArea.man
@@ -0,0 +1,267 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XClearArea 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XClearArea, XClearWindow \- clear area or window
+.SH SYNTAX
+XClearArea\^(\^\fIdisplay\fP, \fIw\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIexposures\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ Bool \fIexposures\fP\^;
+.LP
+XClearWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIexposures\fP 1i
+Specifies a Boolean value that indicates if
+.ZN Expose
+events are to be generated.
+.IP \fIw\fP 1i
+Specifies the window.
+.ds Wh , which are the dimensions of the rectangle
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which are relative to the origin of the window \
+and specify the upper-left corner of the rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XClearArea
+function paints a rectangular area in the specified window according to the
+specified dimensions with the window's background pixel or pixmap.
+The subwindow-mode effectively is
+.ZN ClipByChildren .
+If width is zero, it
+is replaced with the current width of the window minus x.
+If height is
+zero, it is replaced with the current height of the window minus y.
+If the window has a defined background tile,
+the rectangle clipped by any children is filled with this tile.
+If the window has
+background
+.ZN None ,
+the contents of the window are not changed.
+In either
+case, if exposures is
+.ZN True ,
+one or more
+.ZN Expose
+events are generated for regions of the rectangle that are either visible or are
+being retained in a backing store.
+If you specify a window whose class is
+.ZN InputOnly ,
+a
+.ZN BadMatch
+error results.
+.LP
+.ZN XClearArea
+can generate
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XClearWindow
+function clears the entire area in the specified window and is
+equivalent to
+.ZN XClearArea
+(display, w, 0, 0, 0, 0,
+.ZN False ).
+If the window has a defined background tile, the rectangle is tiled with a
+plane-mask of all ones and
+.ZN GXcopy
+function.
+If the window has
+background
+.ZN None ,
+the contents of the window are not changed.
+If you specify a window whose class is
+.ZN InputOnly ,
+a
+.ZN BadMatch
+error results.
+.LP
+.ZN XClearWindow
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XCopyArea(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XClientMessageEvent.man b/man/XClientMessageEvent.man
new file mode 100644
index 00000000..56f319a4
--- /dev/null
+++ b/man/XClientMessageEvent.man
@@ -0,0 +1,228 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XClientMessageEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XClientMessageEvent \- ClientMessage event structure
+.SH STRUCTURES
+The structure for
+.ZN ClientMessage
+events contains:
+.LP
+.Ds 0
+.TA .5i 1i 3i
+.ta .5i 1i 3i
+typedef struct {
+ int type; /* ClientMessage */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom message_type;
+ int format;
+ union {
+ char b[20];
+ short s[10];
+ long l[5];
+ } data;
+} XClientMessageEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The message_type member is set to an atom that indicates how the data
+should be interpreted by the receiving client.
+The format member is set to 8, 16, or 32 and specifies whether the data
+should be viewed as a list of bytes, shorts, or longs.
+The data member is a union that contains the members b, s, and l.
+The b, s, and l members represent data of twenty 8-bit values,
+ten 16-bit values, and five 32-bit values.
+Particular message types might not make use of all these values.
+The X server places no interpretation on the values in the window,
+message_type, or data members.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XColormapEvent.man b/man/XColormapEvent.man
new file mode 100644
index 00000000..478e6c63
--- /dev/null
+++ b/man/XColormapEvent.man
@@ -0,0 +1,239 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XColormapEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XColormapEvent \- ColormapNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN ColormapNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ColormapNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Colormap colormap; /* colormap or None */
+ Bool new;
+ int state; /* ColormapInstalled, ColormapUninstalled */
+} XColormapEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window whose associated
+colormap is changed, installed, or uninstalled.
+For a colormap that is changed, installed, or uninstalled,
+the colormap member is set to the colormap associated with the window.
+For a colormap that is changed by a call to
+.ZN XFreeColormap ,
+the colormap member is set to
+.ZN None .
+The new member is set to indicate whether the colormap
+for the specified window was changed or installed or uninstalled
+and can be
+.ZN True
+or
+.ZN False .
+If it is
+.ZN True ,
+the colormap was changed.
+If it is
+.ZN False ,
+the colormap was installed or uninstalled.
+The state member is always set to indicate whether the colormap is installed or
+uninstalled and can be
+.ZN ColormapInstalled
+or
+.ZN ColormapUninstalled .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCreateColormap(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XConfigureEvent.man b/man/XConfigureEvent.man
new file mode 100644
index 00000000..a06fe210
--- /dev/null
+++ b/man/XConfigureEvent.man
@@ -0,0 +1,248 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XConfigureEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XConfigureEvent \- ConfigureNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN ConfigureNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ConfigureNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ Bool override_redirect;
+} XConfigureEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the reconfigured window or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the window whose size, position,
+border, and/or stacking
+order was changed.
+.LP
+The x and y members are set to the coordinates relative to the parent window's
+origin and indicate the position of the upper-left outside corner of the window.
+The width and height members are set to the inside size of the window,
+not including
+the border.
+The border_width member is set to the width of the window's border, in pixels.
+.LP
+The above member is set to the sibling window and is used
+for stacking operations.
+If the X server sets this member to
+.ZN None ,
+the window whose state was changed is on the bottom of the stack
+with respect to sibling windows.
+However, if this member is set to a sibling window,
+the window whose state was changed is placed on top of this sibling window.
+.LP
+The override_redirect member is set to the override-redirect attribute of the
+window.
+Window manager clients normally should ignore this window if the
+override_redirect member
+is
+.ZN True .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XConfigureRequestEvent.man b/man/XConfigureRequestEvent.man
new file mode 100644
index 00000000..128268ec
--- /dev/null
+++ b/man/XConfigureRequestEvent.man
@@ -0,0 +1,231 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XConfigureRequestEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XConfigureRequestEvent \- ConfigureRequest event structure
+.SH STRUCTURES
+The structure for
+.ZN ConfigureRequest
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ConfigureRequest */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+ int x, y;
+ int width, height;
+ int border_width;
+ Window above;
+ int detail; /* Above, Below, TopIf, BottomIf, Opposite */
+ unsigned long value_mask;
+} XConfigureRequestEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The parent member is set to the parent window.
+The window member is set to the window whose size, position, border width,
+and/or stacking order is to be reconfigured.
+The value_mask member indicates which components were specified in the
+.ZN ConfigureWindow
+protocol request.
+The corresponding values are reported as given in the request.
+The remaining values are filled in from the current geometry of the window,
+except in the case of above (sibling) and detail (stack-mode),
+which are reported as
+.ZN None
+and
+.ZN Above ,
+respectively, if they are not given in the request.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XConfigureWindow.man b/man/XConfigureWindow.man
new file mode 100644
index 00000000..d0aa0d68
--- /dev/null
+++ b/man/XConfigureWindow.man
@@ -0,0 +1,486 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XConfigureWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XConfigureWindow, XMoveWindow, XResizeWindow, XMoveResizeWindow, XSetWindowBorderWidth, XWindowChanges \- configure windows and window changes structure
+.SH SYNTAX
+XConfigureWindow\^(\^\fIdisplay\fP, \fIw\fP\^, \fIvalue_mask\fP\^, \fIvalues\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned int \fIvalue_mask\fP\^;
+.br
+ XWindowChanges *\fIvalues\fP\^;
+.LP
+XMoveWindow\^(\^\fIdisplay\fP, \fIw\fP\^, \fIx\fP\^, \fIy\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.LP
+XResizeWindow\^(\^\fIdisplay\fP, \fIw\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.LP
+XMoveResizeWindow\^(\^\fIdisplay\fP, \fIw\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.LP
+XSetWindowBorderWidth\^(\^\fIdisplay\fP, \fIw\fP, \fIwidth\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ unsigned int \fIwidth\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIvalue_mask\fP 1i
+Specifies which values are to be set using information in
+the values structure.
+This mask is the bitwise inclusive OR of the valid configure window values bits.
+.IP \fIvalues\fP 1i
+Specifies the
+.ZN XWindowChanges
+structure.
+.ds Wi to be reconfigured, moved, or resized.
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.IP \fIwidth\fP 1i
+Specifies the width of the window border.
+.ds Wh , which are the interior dimensions of the window
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which define the new location of the top-left pixel \
+of the window's border or the window itself if it has no border \
+or define the new position of the window relative to its parent
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XConfigureWindow
+function uses the values specified in the
+.ZN XWindowChanges
+structure to reconfigure a window's size, position, border, and stacking order.
+Values not specified are taken from the existing geometry of the window.
+.LP
+If a sibling is specified without a stack_mode or if the window
+is not actually a sibling,
+a
+.ZN BadMatch
+error results.
+Note that the computations for
+.ZN BottomIf ,
+.ZN TopIf ,
+and
+.ZN Opposite
+are performed with respect to the window's final geometry (as controlled by the
+other arguments passed to
+.ZN XConfigureWindow ),
+not its initial geometry.
+Any backing store contents of the window, its
+inferiors, and other newly visible windows are either discarded or
+changed to reflect the current screen contents
+(depending on the implementation).
+.LP
+.ZN XConfigureWindow
+can generate
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XMoveWindow
+function moves the specified window to the specified x and y coordinates,
+but it does not change the window's size, raise the window, or
+change the mapping state of the window.
+Moving a mapped window may or may not lose the window's contents
+depending on if the window is obscured by nonchildren
+and if no backing store exists.
+If the contents of the window are lost,
+the X server generates
+.ZN Expose
+events.
+Moving a mapped window generates
+.ZN Expose
+events on any formerly obscured windows.
+.LP
+If the override-redirect flag of the window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates a
+.ZN ConfigureRequest
+event, and no further processing is
+performed.
+Otherwise, the window is moved.
+.LP
+.ZN XMoveWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XResizeWindow
+function changes the inside dimensions of the specified window, not including
+its borders.
+This function does not change the window's upper-left coordinate or
+the origin and does not restack the window.
+Changing the size of a mapped window may lose its contents and generate
+.ZN Expose
+events.
+If a mapped window is made smaller,
+changing its size generates
+.ZN Expose
+events on windows that the mapped window formerly obscured.
+.LP
+If the override-redirect flag of the window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates a
+.ZN ConfigureRequest
+event, and no further processing is performed.
+If either width or height is zero,
+a
+.ZN BadValue
+error results.
+.LP
+.ZN XResizeWindow
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XMoveResizeWindow
+function changes the size and location of the specified window
+without raising it.
+Moving and resizing a mapped window may generate an
+.ZN Expose
+event on the window.
+Depending on the new size and location parameters,
+moving and resizing a window may generate
+.ZN Expose
+events on windows that the window formerly obscured.
+.LP
+If the override-redirect flag of the window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates a
+.ZN ConfigureRequest
+event, and no further processing is performed.
+Otherwise, the window size and location are changed.
+.LP
+.ZN XMoveResizeWindow
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XSetWindowBorderWidth
+function sets the specified window's border width to the specified width.
+.LP
+.ZN XSetWindowBorderWidth
+can generate a
+.ZN BadWindow
+error.
+.SH STRUCTURES
+The
+.ZN XWindowChanges
+structure contains:
+.LP
+.LP
+/* Configure window value mask bits */
+.TS
+lw(.5i) lw(2.5i) lw(.8i).
+T{
+#define
+T} T{
+.ZN CWX
+T} T{
+(1<<0)
+T}
+T{
+#define
+T} T{
+.ZN CWY
+T} T{
+(1<<1)
+T}
+T{
+#define
+T} T{
+.ZN CWWidth
+T} T{
+(1<<2)
+T}
+T{
+#define
+T} T{
+.ZN CWHeight
+T} T{
+(1<<3)
+T}
+T{
+#define
+T} T{
+.ZN CWBorderWidth
+T} T{
+(1<<4)
+T}
+T{
+#define
+T} T{
+.ZN CWSibling
+T} T{
+(1<<5)
+T}
+T{
+#define
+T} T{
+.ZN CWStackMode
+T} T{
+(1<<6)
+T}
+.TE
+.IN "XWindowChanges" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+/* Values */
+
+typedef struct {
+ int x, y;
+ int width, height;
+ int border_width;
+ Window sibling;
+ int stack_mode;
+} XWindowChanges;
+.De
+.LP
+The x and y members are used to set the window's x and y coordinates,
+which are relative to the parent's origin
+and indicate the position of the upper-left outer corner of the window.
+The width and height members are used to set the inside size of the window,
+not including the border, and must be nonzero, or a
+.ZN BadValue
+error results.
+Attempts to configure a root window have no effect.
+.LP
+The border_width member is used to set the width of the border in pixels.
+Note that setting just the border width leaves the outer-left corner of the window
+in a fixed position but moves the absolute position of the window's origin.
+If you attempt to set the border-width attribute of an
+.ZN InputOnly
+window nonzero, a
+.ZN BadMatch
+error results.
+.LP
+The sibling member is used to set the sibling window for stacking operations.
+The stack_mode member is used to set how the window is to be restacked
+and can be set to
+.ZN Above ,
+.ZN Below ,
+.ZN TopIf ,
+.ZN BottomIf ,
+or
+.ZN Opposite .
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XMapWindow(3X11),
+XRaiseWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCopyArea.man b/man/XCopyArea.man
new file mode 100644
index 00000000..89554599
--- /dev/null
+++ b/man/XCopyArea.man
@@ -0,0 +1,326 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCopyArea 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCopyArea, XCopyPlane \- copy areas
+.SH SYNTAX
+XCopyArea\^(\^\fIdisplay\fP, \fIsrc\fP\^, \fIdest\fP\^, \fIgc\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIdest_x\fP\^, \fIdest_y\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fIsrc\fP\^, \fIdest\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ int \fIdest_x\fP\^, \fIdest_y\fP\^;
+.LP
+XCopyPlane\^(\^\fIdisplay\fP, \fIsrc\fP\^, \fIdest\fP\^, \fIgc\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIdest_x\fP\^, \fIdest_y\fP\^, \fIplane\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fIsrc\fP\^, \fIdest\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ int \fIdest_x\fP\^, \fIdest_y\fP\^;
+.br
+ unsigned long \fIplane\fP\^;
+.SH ARGUMENTS
+.ds Dx , which are relative to the origin of the destination rectangle \
+and specify its upper-left corner
+.IP \fIdest_x\fP 1i
+.br
+.ns
+.IP \fIdest_y\fP 1i
+Specify the x and y coordinates\*(Dx.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIplane\fP 1i
+Specifies the bit plane.
+You must set exactly one bit to 1.
+.IP \fIsrc\fP 1i
+.br
+.ns
+.IP \fIdest\fP 1i
+Specify the source and destination rectangles to be combined.
+.IP \fIsrc_x\fP 1i
+.br
+.ns
+.IP \fIsrc_y\fP 1i
+Specify the x and y coordinates,
+which are relative to the origin of the source rectangle
+and specify its upper-left corner.
+.ds Wh , which are the dimensions of both the source \
+and destination rectangles
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.SH DESCRIPTION
+The
+.ZN XCopyArea
+function combines the specified rectangle of src with the specified rectangle
+of dest.
+The drawables must have the same root and depth,
+or a
+.ZN BadMatch
+error results.
+.LP
+If regions of the source rectangle are obscured and have not been
+retained in backing store
+or if regions outside the boundaries of the source drawable are specified,
+those regions are not copied.
+Instead, the
+following occurs on all corresponding destination regions that are either
+visible or are retained in backing store.
+If the destination is a window with a background other than
+.ZN None ,
+corresponding regions
+of the destination are tiled with that background
+(with plane-mask of all ones and
+.ZN GXcopy
+function).
+Regardless of tiling or whether the destination is a window or a pixmap,
+if graphics-exposures is
+.ZN True ,
+then
+.ZN GraphicsExpose
+events for all corresponding destination regions are generated.
+If graphics-exposures is
+.ZN True
+but no
+.ZN GraphicsExpose
+events are generated, a
+.ZN NoExpose
+event is generated.
+Note that by default graphics-exposures is
+.ZN True
+in new GCs.
+.LP
+This function uses these GC components: function, plane-mask,
+subwindow-mode, graphics-exposures, clip-x-origin,
+clip-y-origin, and clip-mask.
+.LP
+.ZN XCopyArea
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.LP
+The
+.ZN XCopyPlane
+function uses a single bit plane of the specified source rectangle
+combined with the specified GC to modify the specified rectangle of dest.
+The drawables must have the same root but need not have the same depth.
+If the drawables do not have the same root, a
+.ZN BadMatch
+error results.
+If plane does not have exactly one bit set to 1 and the value of plane
+is not less than %2 sup n%, where \fIn\fP is the depth of src, a
+.ZN BadValue
+error results.
+.LP
+Effectively,
+.ZN XCopyPlane
+forms a pixmap of the same depth as the rectangle of dest and with a
+size specified by the source region.
+It uses the foreground/background pixels in the GC (foreground
+everywhere the bit plane in src contains a bit set to 1,
+background everywhere the bit plane in src contains a bit set to 0)
+and the equivalent of a
+.ZN CopyArea
+protocol request is performed with all the same exposure semantics.
+This can also be thought of as using the specified region of the source
+bit plane as a stipple with a fill-style of
+.ZN FillOpaqueStippled
+for filling a rectangular area of the destination.
+.LP
+This function uses these GC components: function, plane-mask, foreground,
+background, subwindow-mode, graphics-exposures, clip-x-origin, clip-y-origin,
+and clip-mask.
+.LP
+.ZN XCopyPlane
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XClearArea(3X11)
+.br
+\fIXlib \- C Language X Interface\fP
diff --git a/man/XCreateColormap.man b/man/XCreateColormap.man
new file mode 100644
index 00000000..a9ef6eec
--- /dev/null
+++ b/man/XCreateColormap.man
@@ -0,0 +1,379 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateColormap 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateColormap, XCopyColormapAndFree, XFreeColormap, XColor \- create, copy, or destroy colormaps and color structure
+.SH SYNTAX
+Colormap XCreateColormap\^(\^\fIdisplay\fP, \fIw\fP\^, \fIvisual\fP\^, \fIalloc\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Visual *\fIvisual\fP\^;
+.br
+ int \fIalloc\fP\^;
+.LP
+Colormap XCopyColormapAndFree\^(\^\fIdisplay\fP, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.LP
+XFreeColormap\^(\^\fIdisplay\fP, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.SH ARGUMENTS
+.IP \fIalloc\fP 1i
+Specifies the colormap entries to be allocated.
+You can pass
+.ZN AllocNone
+or
+.ZN AllocAll .
+.ds Cm that you want to create, copy, set, or destroy
+.IP \fIcolormap\fP 1i
+Specifies the colormap \*(Cm.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIvisual\fP 1i
+Specifies a visual type supported on the screen.
+If the visual type is not one supported by the screen,
+a
+.ZN BadMatch
+error results.
+.ds Wi on whose screen you want to create a colormap
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XCreateColormap
+function creates a colormap of the specified visual type for the screen
+on which the specified window resides and returns the colormap ID
+associated with it.
+Note that the specified window is only used to determine the screen.
+.LP
+The initial values of the colormap entries are undefined for the
+visual classes
+.ZN GrayScale ,
+.ZN PseudoColor ,
+and
+.ZN DirectColor .
+For
+.ZN StaticGray ,
+.ZN StaticColor ,
+and
+.ZN TrueColor ,
+the entries have defined values,
+but those values are specific to the visual and are not defined by X.
+For
+.ZN StaticGray ,
+.ZN StaticColor ,
+and
+.ZN TrueColor ,
+alloc must be
+.ZN AllocNone ,
+or a
+.ZN BadMatch
+error results.
+For the other visual classes,
+if alloc is
+.ZN AllocNone ,
+the colormap initially has no allocated entries,
+and clients can allocate them.
+For information about the visual types,
+see section 3.1.
+.LP
+If alloc is
+.ZN AllocAll ,
+the entire colormap is allocated writable.
+The initial values of all allocated entries are undefined.
+For
+.ZN GrayScale
+and
+.ZN PseudoColor ,
+the effect is as if an
+.ZN XAllocColorCells
+call returned all pixel values from zero to N \- 1,
+where N is the colormap entries value in the specified visual.
+For
+.ZN DirectColor ,
+the effect is as if an
+.ZN XAllocColorPlanes
+call returned a pixel value of zero and red_mask, green_mask,
+and blue_mask values containing the same bits as the corresponding
+masks in the specified visual.
+However, in all cases,
+none of these entries can be freed by using
+.ZN XFreeColors .
+.LP
+.ZN XCreateColormap
+can generate
+.ZN BadAlloc ,
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XCopyColormapAndFree
+function creates a colormap of the same visual type and for the same screen
+as the specified colormap and returns the new colormap ID.
+It also moves all of the client's existing allocation from the specified
+colormap to the new colormap with their color values intact
+and their read-only or writable characteristics intact and frees those entries
+in the specified colormap.
+Color values in other entries in the new colormap are undefined.
+If the specified colormap was created by the client with alloc set to
+.ZN AllocAll ,
+the new colormap is also created with
+.ZN AllocAll ,
+all color values for all entries are copied from the specified colormap,
+and then all entries in the specified colormap are freed.
+If the specified colormap was not created by the client with
+.ZN AllocAll ,
+the allocations to be moved are all those pixels and planes
+that have been allocated by the client using
+.ZN XAllocColor ,
+.ZN XAllocNamedColor ,
+.ZN XAllocColorCells ,
+or
+.ZN XAllocColorPlanes
+and that have not been freed since they were allocated.
+.LP
+.ZN XCopyColormapAndFree
+can generate
+.ZN BadAlloc
+and
+.ZN BadColor
+errors.
+.LP
+The
+.ZN XFreeColormap
+function deletes the association between the colormap resource ID
+and the colormap and frees the colormap storage.
+However, this function has no effect on the default colormap for a screen.
+If the specified colormap is an installed map for a screen,
+it is uninstalled (see
+.ZN XUninstallColormap ).
+If the specified colormap is defined as the colormap for a window (by
+.ZN XCreateWindow ,
+.ZN XSetWindowColormap ,
+or
+.ZN XChangeWindowAttributes ),
+.ZN XFreeColormap
+changes the colormap associated with the window to
+.ZN None
+and generates a
+.ZN ColormapNotify
+event.
+X does not define the colors displayed for a window with a colormap of
+.ZN None .
+.LP
+.ZN XFreeColormap
+can generate a
+.ZN BadColor
+error.
+.SH STRUCTURES
+The
+.ZN XColor
+structure contains:
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ unsigned long pixel; /* pixel value */
+ unsigned short red, green, blue; /* rgb values */
+ char flags; /* DoRed, DoGreen, DoBlue */
+ char pad;
+} XColor;
+.De
+.LP
+The red, green, and blue values are always in the range 0 to 65535
+inclusive, independent of the number of bits actually used in the
+display hardware.
+The server scales these values down to the range used by the hardware.
+Black is represented by (0,0,0),
+and white is represented by (65535,65535,65535).
+.IN "Color"
+In some functions,
+the flags member controls which of the red, green, and blue members is used
+and can be the inclusive OR of zero or more of
+.ZN DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue .
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocColor(3X11),
+XChangeWindowAtrributes(3X11),
+XCreateWindow(3X11),
+XQueryColor(3X11),
+XStoreColors(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateFontCursor.man b/man/XCreateFontCursor.man
new file mode 100644
index 00000000..0fb62b1c
--- /dev/null
+++ b/man/XCreateFontCursor.man
@@ -0,0 +1,337 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateFontCursor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateFontCursor, XCreatePixmapCursor, XCreateGlyphCursor \- create cursors
+.SH SYNTAX
+#include <X11/cursorfont.h>
+.sp 6p
+Cursor XCreateFontCursor\^(\^\fIdisplay\fP, \fIshape\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned int \fIshape\fP\^;
+.LP
+Cursor XCreatePixmapCursor\^(\^\fIdisplay\fP, \fIsource\fP\^, \fImask\fP\^, \fIforeground_color\fP\^, \fIbackground_color\fP\^, \fIx\fP\^, \fIy\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Pixmap \fIsource\fP\^;
+.br
+ Pixmap \fImask\fP\^;
+.br
+ XColor *\fIforeground_color\fP\^;
+.br
+ XColor *\fIbackground_color\fP\^;
+.br
+ unsigned int \fIx\fP\^, \fIy\fP\^;
+.LP
+Cursor XCreateGlyphCursor\^(\^\fIdisplay\fP, \fIsource_font\fP\^, \fImask_font\fP\^, \fIsource_char\fP\^, \fImask_char\fP\^,
+.br
+ \fIforeground_color\fP\^, \fIbackground_color\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Font \fIsource_font\fP\^, \fImask_font\fP\^;
+.br
+ unsigned int \fIsource_char\fP\^, \fImask_char\fP\^;
+.br
+ XColor *\fIforeground_color\fP\^;
+.br
+ XColor *\fIbackground_color\fP\^;
+.SH ARGUMENTS
+.IP \fIbackground_color\fP 1i
+Specifies the RGB values for the background of the source.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIforeground_color\fP 1i
+Specifies the RGB values for the foreground of the source.
+.IP \fImask\fP 1i
+Specifies the cursor's source bits to be displayed or
+.ZN None .
+.IP \fImask_char\fP 1i
+Specifies the glyph character for the mask.
+.IP \fImask_font\fP 1i
+Specifies the font for the mask glyph or
+.ZN None .
+.IP \fIshape\fP 1i
+Specifies the shape of the cursor.
+.IP \fIsource\fP 1i
+Specifies the shape of the source cursor.
+.\" *** JIM: NEED TO CHECK THIS. ***
+.IP \fIsource_char\fP 1i
+Specifies the character glyph for the source.
+.IP \fIsource_font\fP 1i
+Specifies the font for the source glyph.
+.ds Xy , which indicate the hotspot relative to the source's origin
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+X provides a set of standard cursor shapes in a special font named
+cursor.
+Applications are encouraged to use this interface for their cursors
+because the font can be customized for the individual display type.
+The shape argument specifies which glyph of the standard fonts
+to use.
+.LP
+The hotspot comes from the information stored in the cursor font.
+The initial colors of a cursor are a black foreground and a white
+background (see
+.ZN XRecolorCursor ).
+.LP
+.ZN XCreateFontCursor
+can generate
+.ZN BadAlloc
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XCreatePixmapCursor
+function creates a cursor and returns the cursor ID associated with it.
+The foreground and background RGB values must be specified using
+foreground_color and background_color,
+even if the X server only has a
+.ZN StaticGray
+or
+.ZN GrayScale
+screen.
+The foreground color is used for the pixels set to 1 in the
+source, and the background color is used for the pixels set to 0.
+Both source and mask, if specified, must have depth one (or a
+.ZN BadMatch
+error results) but can have any root.
+The mask argument defines the shape of the cursor.
+The pixels set to 1 in the mask define which source pixels are displayed,
+and the pixels set to 0 define which pixels are ignored.
+If no mask is given,
+all pixels of the source are displayed.
+The mask, if present, must be the same size as the pixmap defined by the
+source argument, or a
+.ZN BadMatch
+error results.
+The hotspot must be a point within the source,
+or a
+.ZN BadMatch
+error results.
+.LP
+The components of the cursor can be transformed arbitrarily to meet
+display limitations.
+The pixmaps can be freed immediately if no further explicit references
+to them are to be made.
+Subsequent drawing in the source or mask pixmap has an undefined effect on the
+cursor.
+The X server might or might not make a copy of the pixmap.
+.LP
+.ZN XCreatePixmapCursor
+can generate
+.ZN BadAlloc
+and
+.ZN BadPixmap
+errors.
+.LP
+The
+.ZN XCreateGlyphCursor
+function is similar to
+.ZN XCreatePixmapCursor
+except that the source and mask bitmaps are obtained from the specified
+font glyphs.
+The source_char must be a defined glyph in source_font,
+or a
+.ZN BadValue
+error results.
+If mask_font is given,
+mask_char must be a defined glyph in mask_font,
+or a
+.ZN BadValue
+error results.
+The mask_font and character are optional.
+The origins of the source_char and mask_char (if defined) glyphs are
+positioned coincidently and define the hotspot.
+The source_char and mask_char need not have the same bounding box metrics,
+and there is no restriction on the placement of the hotspot relative to the bounding
+boxes.
+If no mask_char is given, all pixels of the source are displayed.
+You can free the fonts immediately by calling
+.ZN XFreeFont
+if no further explicit references to them are to be made.
+.LP
+For 2-byte matrix fonts,
+the 16-bit value should be formed with the byte1
+member in the most significant byte and the byte2 member in the
+least significant byte.
+.LP
+.ZN XCreateGlyphCursor
+can generate
+.ZN BadAlloc ,
+.ZN BadFont ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XDefineCursor(3X11),
+XLoadFont(3X11),
+XRecolorCursor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateFontSet.man b/man/XCreateFontSet.man
new file mode 100644
index 00000000..842c0e3a
--- /dev/null
+++ b/man/XCreateFontSet.man
@@ -0,0 +1,387 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateFontSet 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateFontSet, XFreeFontSet \- create and free an international text drawing font set
+.SH SYNTAX
+XFontSet XCreateFontSet\^(\^\fIdisplay\fP\^, \fIbase_font_name_list\fP\^, \fImissing_charset_list_return\fP\^,
+.br
+ \fImissing_charset_count_return\fP\^, \fIdef_string_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIbase_font_name_list\fP\^;
+.br
+ char ***\fImissing_charset_list_return\fP\^;
+.br
+ int *\fImissing_charset_count_return\fP\^;
+.br
+ char **\fIdef_string_return\fP\^;
+.LP
+void XFreeFontSet\^(\^\fIdisplay\fP\^, \fIfont_set\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XFontSet \fIfont_set\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIbase_font_name_list\fP 1i
+Specifies the base font names.
+.IP \fIdef_string_return\fP 1i
+Returns the string drawn for missing charsets.
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fImissing_charset_count_return\fP 1i
+Returns the number of missing charsets.
+.IP \fImissing_charset_list_return\fP 1i
+Returns the missing charsets.
+.SH DESCRIPTION
+The
+.ZN XCreateFontSet
+function creates a font set for the specified display.
+The font set is bound to the current locale when
+.ZN XCreateFontSet
+is called.
+The font set may be used in subsequent calls to obtain font
+and character information and to image text in the locale of the font set.
+.LP
+The base_font_name_list argument is a list of base font names
+that Xlib uses to load the fonts needed for the locale.
+The base font names are a comma-separated list.
+The string is null-terminated
+and is assumed to be in the Host Portable Character Encoding;
+otherwise, the result is implementation-dependent.
+White space immediately on either side of a separating comma is ignored.
+.LP
+Use of XLFD font names permits Xlib to obtain the fonts needed for a
+variety of locales from a single locale-independent base font name.
+The single base font name should name a family of fonts whose members
+are encoded in the various charsets needed by the locales of interest.
+.LP
+An XLFD base font name can explicitly name a charset needed for the locale.
+This allows the user to specify an exact font for use with a charset required
+by a locale, fully controlling the font selection.
+.LP
+If a base font name is not an XLFD name,
+Xlib will attempt to obtain an XLFD name from the font properties
+for the font.
+If this action is successful in obtaining an XLFD name, the
+.ZN XBaseFontNameListOfFontSet
+function will return this XLFD name instead of the client-supplied name.
+.LP
+Xlib uses the following algorithm to select the fonts
+that will be used to display text with the
+.ZN XFontSet .
+.LP
+For each font charset required by the locale,
+the base font name list is searched for the first appearance of one
+of the following cases that names a set of fonts that exist at the server:
+.IP \(bu 5
+The first XLFD-conforming base font name that specifies the required
+charset or a superset of the required charset in its
+.ZN CharSetRegistry
+and
+.ZN CharSetEncoding
+fields.
+The implementation may use a base font name whose specified charset
+is a superset of the required charset, for example,
+an ISO8859-1 font for an ASCII charset.
+.IP \(bu 5
+The first set of one or more XLFD-conforming base font names
+that specify one or more charsets that can be remapped to support the
+required charset.
+The Xlib implementation may recognize various mappings
+from a required charset to one or more other charsets
+and use the fonts for those charsets.
+For example, JIS Roman is ASCII with tilde and backslash replaced
+by yen and overbar;
+Xlib may load an ISO8859-1 font to support this character set
+if a JIS Roman font is not available.
+.IP \(bu 5
+The first XLFD-conforming font name or the first non-XLFD font name
+for which an XLFD font name can be obtained, combined with the
+required charset (replacing the
+.ZN CharSetRegistry
+and
+.ZN CharSetEncoding
+fields in the XLFD font name).
+As in case 1,
+the implementation may use a charset that is a superset
+of the required charset.
+.IP \(bu 5
+The first font name that can be mapped in some implementation-dependent
+manner to one or more fonts that support imaging text in the charset.
+.LP
+For example, assume that a locale required the charsets:
+.LP
+.Ds 0
+ISO8859-1
+JISX0208.1983
+JISX0201.1976
+GB2312-1980.0
+.De
+.LP
+The user could supply a base_font_name_list that explicitly specifies the
+charsets, ensuring that specific fonts are used if they exist.
+For example:
+.LP
+.Ds 0
+"-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240-JISX0208.1983-0,\\
+-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120-JISX0201.1976-0,\\
+-GB-Fixed-Medium-R-Normal--26-180-100-100-C-240-GB2312-1980.0,\\
+-Adobe-Courier-Bold-R-Normal--25-180-75-75-M-150-ISO8859-1"
+.De
+.LP
+Alternatively, the user could supply a base_font_name_list
+that omits the charsets,
+letting Xlib select font charsets required for the locale.
+For example:
+.LP
+.Ds 0
+"-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-240,\\
+-JIS-Fixed-Medium-R-Normal--26-180-100-100-C-120,\\
+-GB-Fixed-Medium-R-Normal--26-180-100-100-C-240,\\
+-Adobe-Courier-Bold-R-Normal--25-180-100-100-M-150"
+.De
+.LP
+Alternatively, the user could simply supply a single base font name
+that allows Xlib to select from all available fonts
+that meet certain minimum XLFD property requirements.
+For example:
+.LP
+.Ds 0
+"-*-*-*-R-Normal--*-180-100-100-*-*"
+.De
+.LP
+If
+.ZN XCreateFontSet
+is unable to create the font set,
+either because there is insufficient memory or because the current locale
+is not supported,
+.ZN XCreateFontSet
+returns NULL, missing_charset_list_return is set to NULL,
+and missing_charset_count_return
+is set to zero.
+If fonts exist for all of the charsets required by the current locale,
+.ZN XCreateFontSet
+returns a valid
+.ZN XFontSet ,
+missing_charset_list_return is set to NULL,
+and missing_charset_count_return is set to zero.
+.LP
+If no font exists for one or more of the required charsets,
+.ZN XCreateFontSet
+sets missing_charset_list_return to a
+list of one or more null-terminated charset names for which no font exists
+and sets missing_charset_count_return to the number of missing fonts.
+The charsets are from the list of the required charsets for
+the encoding of the locale and do not include any charsets to which Xlib
+may be able to remap a required charset.
+.LP
+If no font exists for any of the required charsets
+or if the locale definition in Xlib requires that a font exist
+for a particular charset and a font is not found for that charset,
+.ZN XCreateFontSet
+returns NULL.
+Otherwise,
+.ZN XCreateFontSet
+returns a valid
+.ZN XFontSet
+to font_set.
+.LP
+When an Xmb/wc drawing or measuring function is called with an
+.ZN XFontSet
+that has missing charsets, some characters in the locale will not be
+drawable.
+If def_string_return is non-NULL,
+.ZN XCreateFontSet
+returns a pointer to a string that represents the glyphs
+that are drawn with this
+.ZN XFontSet
+when the charsets of the available fonts do not include all font glyphs
+required to draw a codepoint.
+The string does not necessarily consist of valid characters
+in the current locale and is not necessarily drawn with
+the fonts loaded for the font set,
+but the client can draw and measure the default glyphs
+by including this string in a string being drawn or measured with the
+.ZN XFontSet .
+.LP
+If the string returned to def_string_return is the empty string ("\^"),
+no glyphs are drawn, and the escapement is zero.
+The returned string is null-terminated.
+It is owned by Xlib and should not be modified or freed by the client.
+It will be freed by a call to
+.ZN XFreeFontSet
+with the associated
+.ZN XFontSet .
+Until freed, its contents will not be modified by Xlib.
+.LP
+The client is responsible for constructing an error message from the
+missing charset and default string information and may choose to continue
+operation in the case that some fonts did not exist.
+.LP
+The returned
+.ZN XFontSet
+and missing charset list should be freed with
+.ZN XFreeFontSet
+and
+.ZN XFreeStringList ,
+respectively.
+The client-supplied base_font_name_list may be freed
+by the client after calling
+.ZN XCreateFontSet .
+.LP
+The
+.ZN XFreeFontSet
+function frees the specified font set.
+The associated base font name list, font name list,
+.ZN XFontStruct
+list, and
+.ZN XFontSetExtents ,
+if any, are freed.
+.SH "SEE ALSO"
+XExtentsofFontSet(3X11),
+XFontsOfFontSet(3X11),
+XFontSetExtents(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateGC.man b/man/XCreateGC.man
new file mode 100644
index 00000000..bcf83393
--- /dev/null
+++ b/man/XCreateGC.man
@@ -0,0 +1,1211 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XCreateGC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateGC, XCopyGC, XChangeGC, XGetGCValues, XFreeGC, XGContextFromGC, XGCValues \- create or free graphics contexts and graphics context structure
+.SH SYNTAX
+GC XCreateGC\^(\^\fIdisplay\fP, \fId\fP\^, \fIvaluemask\fP\^, \fIvalues\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ unsigned long \fIvaluemask\fP\^;
+.br
+ XGCValues *\^\fIvalues\fP\^;
+.LP
+XCopyGC\^(\^\fIdisplay\fP, \fIsrc\fP\^, \fIvaluemask\fP\^, \fIdest\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIsrc\fP\^, \fIdest\fP\^;
+.br
+ unsigned long \fIvaluemask\fP\^;
+.LP
+XChangeGC\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIvaluemask\fP\^, \fIvalues\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIvaluemask\fP\^;
+.br
+ XGCValues *\^\fIvalues\fP\^;
+.LP
+Status XGetGCValues\^(\^\fIdisplay\fP, \fIgc\fP, \fIvaluemask\fP, \
+\fIvalues_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIvaluemask\fP\^;
+.br
+ XGCValues *\fIvalues_return\fP\^;
+.LP
+XFreeGC\^(\^\fIdisplay\fP, \fIgc\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.LP
+GContext XGContextFromGC\^(\^\fIgc\fP\^)
+.br
+ GC \fIgc\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdest\fP 1i
+Specifies the destination GC.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIsrc\fP 1i
+Specifies the components of the source GC.
+.ds Vm set, copied, changed, or returned
+.IP \fIvaluemask\fP 1i
+Specifies which components in the GC are to be \*(Vm.
+This argument is the bitwise inclusive OR of zero or more of the valid
+GC component mask bits.
+.IP \fIvalues\fP 1i
+Specifies any values as specified by the valuemask.
+.IP \fIvalues_return\fP 1i
+Returns the GC values in the specified
+.ZN XGCValues
+structure.
+.SH DESCRIPTION
+The
+.ZN XCreateGC
+function creates a graphics context and returns a GC.
+The GC can be used with any destination drawable having the same root
+and depth as the specified drawable.
+Use with other drawables results in a
+.ZN BadMatch
+error.
+.LP
+.ZN XCreateGC
+can generate
+.ZN BadAlloc ,
+.ZN BadDrawable ,
+.ZN BadFont ,
+.ZN BadMatch ,
+.ZN BadPixmap ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XCopyGC
+function copies the specified components from the source GC
+to the destination GC.
+The source and destination GCs must have the same root and depth,
+or a
+.ZN BadMatch
+error results.
+The valuemask specifies which component to copy, as for
+.ZN XCreateGC .
+.LP
+.ZN XCopyGC
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.LP
+The
+.ZN XChangeGC
+function changes the components specified by valuemask for
+the specified GC.
+The values argument contains the values to be set.
+The values and restrictions are the same as for
+.ZN XCreateGC .
+Changing the clip-mask overrides any previous
+.ZN XSetClipRectangles
+request on the context.
+Changing the dash-offset or dash-list
+overrides any previous
+.ZN XSetDashes
+request on the context.
+The order in which components are verified and altered is server dependent.
+If an error is generated, a subset of the components may have been altered.
+.LP
+.ZN XChangeGC
+can generate
+.ZN BadAlloc ,
+.ZN BadFont ,
+.ZN BadGC ,
+.ZN BadMatch ,
+.ZN BadPixmap ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetGCValues
+function returns the components specified by valuemask for the specified GC.
+If the valuemask contains a valid set of GC mask bits
+.Pn ( GCFunction ,
+.ZN GCPlaneMask ,
+.ZN GCForeground ,
+.ZN GCBackground ,
+.ZN GCLineWidth ,
+.ZN GCLineStyle ,
+.ZN GCCapStyle ,
+.ZN GCJoinStyle ,
+.ZN GCFillStyle ,
+.ZN GCFillRule ,
+.ZN GCTile ,
+.ZN GCStipple ,
+.ZN GCTileStipXOrigin ,
+.ZN GCTileStipYOrigin ,
+.ZN GCFont ,
+.ZN GCSubwindowMode ,
+.ZN GCGraphicsExposures ,
+.ZN GCClipXOrigin ,
+.ZN GCCLipYOrigin ,
+.ZN GCDashOffset ,
+or
+.ZN GCArcMode )
+and no error occurs,
+.ZN XGetGCValues
+sets the requested components in values_return and returns a nonzero status.
+Otherwise, it returns a zero status.
+Note that the clip-mask and dash-list (represented by the
+.ZN GCClipMask
+and
+.ZN GCDashList
+bits, respectively, in the valuemask)
+cannot be requested.
+Also note that an invalid resource ID (with one or more of the three
+most significant bits set to 1) will be returned for
+.ZN GCFont ,
+.ZN GCTile ,
+and
+.ZN GCStipple
+if the component has never been explicitly set by the client.
+.LP
+The
+.ZN XFreeGC
+function destroys the specified GC as well as all the associated storage.
+.LP
+.ZN XFreeGC
+can generate a
+.ZN BadGC
+error.
+.SH STRUCTURES
+The
+.ZN XGCValues
+structure contains:
+.LP
+.LP
+/* GC attribute value mask bits */
+.TS
+lw(.5i) lw(2.5i) lw(.75i).
+#define\
+ T{
+.ZN GCFunction
+T} T{
+(1L<<0)
+T}
+#define\
+ T{
+.ZN GCPlaneMask
+T} T{
+(1L<<1)
+T}
+#define\
+ T{
+.ZN GCForeground
+T} T{
+(1L<<2)
+T}
+#define\
+ T{
+.ZN GCBackground
+T} T{
+(1L<<3)
+T}
+#define\
+ T{
+.ZN GCLineWidth
+T} T{
+(1L<<4)
+T}
+#define\
+ T{
+.ZN GCLineStyle
+T} T{
+(1L<<5)
+T}
+#define\
+ T{
+.ZN GCCapStyle
+T} T{
+(1L<<6)
+T}
+#define\
+ T{
+.ZN GCJoinStyle
+T} T{
+(1L<<7)
+T}
+#define\
+ T{
+.ZN GCFillStyle
+T} T{
+(1L<<8)
+T}
+#define\
+ T{
+.ZN GCFillRule
+T} T{
+(1L<<9)
+T}
+#define\
+ T{
+.ZN GCTile
+T} T{
+(1L<<10)
+T}
+#define\
+ T{
+.ZN GCStipple
+T} T{
+(1L<<11)
+T}
+#define\
+ T{
+.ZN GCTileStipXOrigin
+T} T{
+(1L<<12)
+T}
+#define\
+ T{
+.ZN GCTileStipYOrigin
+T} T{
+(1L<<13)
+T}
+#define\
+ T{
+.ZN GCFont
+T} T{
+(1L<<14)
+T}
+#define\
+ T{
+.ZN GCSubwindowMode
+T} T{
+(1L<<15)
+T}
+#define\
+ T{
+.ZN GCGraphicsExposures
+T} T{
+(1L<<16)
+T}
+#define\
+ T{
+.ZN GCClipXOrigin
+T} T{
+(1L<<17)
+T}
+#define\
+ T{
+.ZN GCClipYOrigin
+T} T{
+(1L<<18)
+T}
+#define\
+ T{
+.ZN GCClipMask
+T} T{
+(1L<<19)
+T}
+#define\
+ T{
+.ZN GCDashOffset
+T} T{
+(1L<<20)
+T}
+#define\
+ T{
+.ZN GCDashList
+T} T{
+(1L<<21)
+T}
+#define\
+ T{
+.ZN GCArcMode
+T} T{
+(1L<<22)
+T}
+.TE
+.IN "XGCValues" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+/* Values */
+
+typedef struct {
+ int function; /* logical operation */
+ unsigned long plane_mask; /* plane mask */
+ unsigned long foreground; /* foreground pixel */
+ unsigned long background; /* background pixel */
+ int line_width; /* line width (in pixels) */
+ int line_style; /* LineSolid, LineOnOffDash, LineDoubleDash */
+ int cap_style; /* CapNotLast, CapButt, CapRound, CapProjecting */
+ int join_style; /* JoinMiter, JoinRound, JoinBevel */
+ int fill_style; /* FillSolid, FillTiled, FillStippled FillOpaqueStippled*/
+ int fill_rule; /* EvenOddRule, WindingRule */
+ int arc_mode; /* ArcChord, ArcPieSlice */
+ Pixmap tile; /* tile pixmap for tiling operations */
+ Pixmap stipple; /* stipple 1 plane pixmap for stippling */
+ int ts_x_origin; /* offset for tile or stipple operations */
+ int ts_y_origin;
+ Font font; /* default text font for text operations */
+ int subwindow_mode; /* ClipByChildren, IncludeInferiors */
+ Bool graphics_exposures; /* boolean, should exposures be generated */
+ int clip_x_origin; /* origin for clipping */
+ int clip_y_origin;
+ Pixmap clip_mask; /* bitmap clipping; other calls for rects */
+ int dash_offset; /* patterned/dashed line information */
+ char dashes;
+} XGCValues;
+.De
+.LP
+The function attributes of a GC are used when you update a section of
+a drawable (the destination) with bits from somewhere else (the source).
+The function in a GC defines how the new destination bits are to be
+computed from the source bits and the old destination bits.
+.ZN GXcopy
+is typically the most useful because it will work on a color display,
+but special applications may use other functions,
+particularly in concert with particular planes of a color display.
+The 16 GC functions, defined in
+.hN X11/X.h ,
+are:
+.\" are listed in Table 5-1 along with the
+.\"the associated hexadecimal code
+.\" and operation.
+.\".CP T 1
+.\"Display Functions
+.TS H
+lw(1.5i) cw(.5i) lw(2i).
+_
+.sp 6p
+.B
+Function Name Value Operation
+.sp 6p
+_
+.sp 6p
+.TH
+T{
+.ZN GXclear
+T} T{
+0x0
+T} T{
+0
+T}
+T{
+.ZN GXand
+T} T{
+0x1
+T} T{
+src AND dst
+T}
+T{
+.ZN GXandReverse
+T} T{
+0x2
+T} T{
+src AND NOT dst
+T}
+T{
+.ZN GXcopy
+T} T{
+0x3
+T} T{
+src
+T}
+T{
+.ZN GXandInverted
+T} T{
+0x4
+T} T{
+(NOT src) AND dst
+T}
+T{
+.ZN GXnoop
+T} T{
+0x5
+T} T{
+dst
+T}
+T{
+.ZN GXxor
+T} T{
+0x6
+T} T{
+src XOR dst
+T}
+T{
+.ZN GXor
+T} T{
+0x7
+T} T{
+src OR dst
+T}
+T{
+.ZN GXnor
+T} T{
+0x8
+T} T{
+(NOT src) AND (NOT dst)
+T}
+T{
+.ZN GXequiv
+T} T{
+0x9
+T} T{
+(NOT src) XOR dst
+T}
+T{
+.ZN GXinvert
+T} T{
+0xa
+T} T{
+NOT dst
+T}
+T{
+.ZN GXorReverse
+T} T{
+0xb
+T} T{
+src OR (NOT dst)
+T}
+T{
+.ZN GXcopyInverted
+T} T{
+0xc
+T} T{
+NOT src
+T}
+T{
+.ZN GXorInverted
+T} T{
+0xd
+T} T{
+(NOT src) OR dst
+T}
+T{
+.ZN GXnand
+T} T{
+0xe
+T} T{
+(NOT src) OR (NOT dst)
+T}
+T{
+.ZN GXset
+T} T{
+0xf
+T} T{
+1
+T}
+.sp 6p
+_
+.TE
+.LP
+Many graphics operations depend on either pixel values or planes in a GC.
+.IN "Pixel value"
+The planes attribute is of type long, and it specifies which planes of the
+destination are to be modified, one bit per plane.
+.IN "Plane" "mask"
+A monochrome display has only one plane and
+will be the least significant bit of the word.
+As planes are added to the display hardware, they will occupy more
+significant bits in the plane mask.
+.LP
+In graphics operations, given a source and destination pixel,
+the result is computed bitwise on corresponding bits of the pixels.
+That is, a Boolean operation is performed in each bit plane.
+The plane_mask restricts the operation to a subset of planes.
+A macro constant
+.ZN AllPlanes
+can be used to refer to all planes of the screen simultaneously.
+The result is computed by the following:
+.LP
+.Ds
+((src FUNC dst) AND plane-mask) OR (dst AND (NOT plane-mask))
+.De
+.LP
+Range checking is not performed on the values for foreground,
+background, or plane_mask.
+They are simply truncated to the appropriate
+number of bits.
+The line-width is measured in pixels and either can be greater than or equal to
+one (wide line) or can be the special value zero (thin line).
+.LP
+Wide lines are drawn centered on the path described by the graphics request.
+Unless otherwise specified by the join-style or cap-style,
+the bounding box of a wide line with endpoints [x1, y1], [x2, y2] and
+width w is a rectangle with vertices at the following real coordinates:
+.LP
+.Ds
+.TA .5i 2.5i
+.ta .5i 2.5i
+[x1-(w*sn/2), y1+(w*cs/2)], [x1+(w*sn/2), y1-(w*cs/2)],
+[x2-(w*sn/2), y2+(w*cs/2)], [x2+(w*sn/2), y2-(w*cs/2)]
+.De
+.LP
+Here sn is the sine of the angle of the line,
+and cs is the cosine of the angle of the line.
+A pixel is part of the line and so is drawn
+if the center of the pixel is fully inside the bounding box
+(which is viewed as having infinitely thin edges).
+If the center of the pixel is exactly on the bounding box,
+it is part of the line if and only if the interior is immediately to its right
+(x increasing direction).
+Pixels with centers on a horizontal edge are a special case and are part of
+the line if and only if the interior or the boundary is immediately below
+(y increasing direction) and the interior or the boundary is immediately
+to the right (x increasing direction).
+.LP
+Thin lines (zero line-width) are one-pixel-wide lines drawn using an
+unspecified, device-dependent algorithm.
+There are only two constraints on this algorithm.
+.IP 1. 5
+If a line is drawn unclipped from [x1,y1] to [x2,y2] and
+if another line is drawn unclipped from [x1+dx,y1+dy] to [x2+dx,y2+dy],
+a point [x,y] is touched by drawing the first line
+if and only if the point [x+dx,y+dy] is touched by drawing the second line.
+.IP 2. 5
+The effective set of points comprising a line cannot be affected by clipping.
+That is, a point is touched in a clipped line if and only if the point
+lies inside the clipping region and the point would be touched
+by the line when drawn unclipped.
+.LP
+A wide line drawn from [x1,y1] to [x2,y2] always draws the same pixels
+as a wide line drawn from [x2,y2] to [x1,y1], not counting cap-style
+and join-style.
+It is recommended that this property be true for thin lines,
+but this is not required.
+A line-width of zero may differ from a line-width of one in which pixels are
+drawn.
+This permits the use of many manufacturers' line drawing hardware,
+which may run many times faster than the more precisely specified
+wide lines.
+.LP
+In general,
+drawing a thin line will be faster than drawing a wide line of width one.
+However, because of their different drawing algorithms,
+thin lines may not mix well aesthetically with wide lines.
+If it is desirable to obtain precise and uniform results across all displays,
+a client should always use a line-width of one rather than a line-width of zero.
+.LP
+The line-style defines which sections of a line are drawn:
+.TS
+lw(1.3i) lw(4.5i).
+T{
+.ZN LineSolid
+T} T{
+The full path of the line is drawn.
+T}
+.sp 6p
+T{
+.ZN LineDoubleDash
+T} T{
+The full path of the line is drawn,
+but the even dashes are filled differently
+from the odd dashes (see fill-style) with
+.ZN CapButt
+style used where even and odd dashes meet.
+T}
+.sp 6p
+T{
+.ZN LineOnOffDash
+T} T{
+Only the even dashes are drawn,
+and cap-style applies to
+all internal ends of the individual dashes,
+except
+.ZN CapNotLast
+is treated as
+.ZN CapButt .
+T}
+.TE
+.LP
+The cap-style defines how the endpoints of a path are drawn:
+.IN "Graphics context" "path"
+.TS
+lw(1.3i) lw(4.5i).
+T{
+.ZN CapNotLast
+T} T{
+This is equivalent to
+.ZN CapButt
+except that for a line-width of zero the final endpoint is not drawn.
+T}
+.sp 6p
+T{
+.ZN CapButt
+T} T{
+The line is square at the endpoint (perpendicular to the slope of the line)
+with no projection beyond.
+T}
+.sp 6p
+T{
+.ZN CapRound
+T} T{
+The line has a circular arc with the diameter equal to the line-width,
+centered on the endpoint.
+(This is equivalent to
+.ZN CapButt
+for line-width of zero).
+T}
+.sp 6p
+T{
+.ZN CapProjecting
+T} T{
+The line is square at the end, but the path continues beyond the endpoint
+for a distance equal to half the line-width.
+(This is equivalent to
+.ZN CapButt
+for line-width of zero).
+T}
+.TE
+.LP
+The join-style defines how corners are drawn for wide lines:
+.TS
+lw(1.3i) lw(4.5i).
+T{
+.ZN JoinMiter
+T} T{
+The outer edges of two lines extend to meet at an angle.
+However, if the angle is less than 11 degrees,
+then a
+.ZN JoinBevel
+join-style is used instead.
+T}
+.sp 6p
+T{
+.ZN JoinRound
+T} T{
+The corner is a circular arc with the diameter equal to the line-width,
+centered on the joinpoint.
+T}
+.sp 6p
+T{
+.ZN JoinBevel
+T} T{
+The corner has
+.ZN CapButt
+endpoint styles with the triangular notch filled.
+T}
+.TE
+.LP
+For a line with coincident endpoints (x1=x2, y1=y2),
+when the cap-style is applied to both endpoints,
+the semantics depends on the line-width and the cap-style:
+.TS
+lw(1.3i) lw(.5i) lw(4i).
+T{
+.ZN CapNotLast
+T} T{
+thin
+T} T{
+The results are device dependent,
+but the desired effect is that nothing is drawn.
+T}
+.sp 6p
+T{
+.ZN CapButt
+T} T{
+thin
+T} T{
+The results are device dependent,
+but the desired effect is that a single pixel is drawn.
+T}
+.sp 6p
+T{
+.ZN CapRound
+T} T{
+thin
+T} T{
+The results are the same as for
+.ZN CapButt /thin.
+T}
+.sp 6p
+T{
+.ZN CapProjecting
+T} T{
+thin
+T} T{
+The results are the same as for
+.ZN CapButt /thin.
+T}
+.sp 6p
+T{
+.ZN CapButt
+T} T{
+wide
+T} T{
+Nothing is drawn.
+T}
+.sp 6p
+T{
+.ZN CapRound
+T} T{
+wide
+T} T{
+The closed path is a circle, centered at the endpoint, and
+with the diameter equal to the line-width.
+T}
+.sp 6p
+T{
+.ZN CapProjecting
+T} T{
+wide
+T} T{
+The closed path is a square, aligned with the coordinate axes, centered at the
+endpoint, and with the sides equal to the line-width.
+T}
+.TE
+.LP
+For a line with coincident endpoints (x1=x2, y1=y2),
+when the join-style is applied at one or both endpoints,
+the effect is as if the line was removed from the overall path.
+However, if the total path consists of or is reduced to a single point joined
+with itself, the effect is the same as when the cap-style is applied at both
+endpoints.
+.LP
+The tile/stipple represents an infinite two-dimensional plane,
+with the tile/stipple replicated in all dimensions.
+When that plane is superimposed on the drawable
+for use in a graphics operation, the upper-left corner
+of some instance of the tile/stipple is at the coordinates within
+the drawable specified by the tile/stipple origin.
+The tile/stipple and clip origins are interpreted relative to the
+origin of whatever destination drawable is specified in a graphics
+request.
+The tile pixmap must have the same root and depth as the GC,
+or a
+.ZN BadMatch
+error results.
+The stipple pixmap must have depth one and must have the same root as the
+GC, or a
+.ZN BadMatch
+error results.
+For stipple operations where the fill-style is
+.ZN FillStippled
+but not
+.ZN FillOpaqueStippled ,
+the stipple pattern is tiled in a
+single plane and acts as an additional clip mask to be ANDed with the clip-mask.
+Although some sizes may be faster to use than others,
+any size pixmap can be used for tiling or stippling.
+.LP
+The fill-style defines the contents of the source for line, text, and
+fill requests.
+For all text and fill requests (for example,
+.ZN XDrawText ,
+.ZN XDrawText16 ,
+.ZN XFillRectangle ,
+.ZN XFillPolygon ,
+and
+.ZN XFillArc );
+for line requests
+with line-style
+.ZN LineSolid
+(for example,
+.ZN XDrawLine ,
+.ZN XDrawSegments ,
+.ZN XDrawRectangle ,
+.ZN XDrawArc );
+and for the even dashes for line requests with line-style
+.ZN LineOnOffDash
+or
+.ZN LineDoubleDash ,
+the following apply:
+.TS
+lw(1.8i) lw(4i).
+T{
+.ZN FillSolid
+T} T{
+Foreground
+T}
+.sp 6p
+T{
+.ZN FillTiled
+T} T{
+Tile
+T}
+.sp 6p
+T{
+.ZN FillOpaqueStippled
+T} T{
+A tile with the same width and height as stipple,
+but with background everywhere stipple has a zero
+and with foreground everywhere stipple has a one
+T}
+.sp 6p
+T{
+.ZN FillStippled
+T} T{
+Foreground masked by stipple
+T}
+.TE
+.LP
+When drawing lines with line-style
+.ZN LineDoubleDash ,
+the odd dashes are controlled by the fill-style in the following manner:
+.TS
+lw(1.8i) lw(4i).
+T{
+.ZN FillSolid
+T} T{
+Background
+T}
+.sp 6p
+T{
+.ZN FillTiled
+T} T{
+Same as for even dashes
+T}
+.sp 6p
+T{
+.ZN FillOpaqueStippled
+T} T{
+Same as for even dashes
+T}
+.sp 6p
+T{
+.ZN FillStippled
+T} T{
+Background masked by stipple
+T}
+.TE
+.LP
+Storing a pixmap in a GC might or might not result in a copy
+being made.
+If the pixmap is later used as the destination for a graphics request,
+the change might or might not be reflected in the GC.
+If the pixmap is used simultaneously in a graphics request both as
+a destination and as a tile or stipple,
+the results are undefined.
+.LP
+For optimum performance,
+you should draw as much as possible with the same GC
+(without changing its components).
+The costs of changing GC components relative to using different GCs
+depend on the display hardware and the server implementation.
+It is quite likely that some amount of GC information will be
+cached in display hardware and that such hardware can only cache a small number
+of GCs.
+.LP
+The dashes value is actually a simplified form of the
+more general patterns that can be set with
+.ZN XSetDashes .
+Specifying a
+value of N is equivalent to specifying the two-element list [N, N] in
+.ZN XSetDashes .
+The value must be nonzero,
+or a
+.ZN BadValue
+error results.
+.LP
+The clip-mask restricts writes to the destination drawable.
+If the clip-mask is set to a pixmap,
+it must have depth one and have the same root as the GC,
+or a
+.ZN BadMatch
+error results.
+If clip-mask is set to
+.ZN None ,
+the pixels are always drawn regardless of the clip origin.
+The clip-mask also can be set by calling the
+.ZN XSetClipRectangles
+or
+.ZN XSetRegion
+functions.
+Only pixels where the clip-mask has a bit set to 1 are drawn.
+Pixels are not drawn outside the area covered by the clip-mask
+or where the clip-mask has a bit set to 0.
+The clip-mask affects all graphics requests.
+The clip-mask does not clip sources.
+The clip-mask origin is interpreted relative to the origin of whatever
+destination drawable is specified in a graphics request.
+.LP
+You can set the subwindow-mode to
+.ZN ClipByChildren
+or
+.ZN IncludeInferiors .
+For
+.ZN ClipByChildren ,
+both source and destination windows are
+additionally clipped by all viewable
+.ZN InputOutput
+children.
+For
+.ZN IncludeInferiors ,
+neither source nor destination window is clipped by inferiors.
+This will result in including subwindow contents in the source
+and drawing through subwindow boundaries of the destination.
+The use of
+.ZN IncludeInferiors
+on a window of one depth with mapped
+inferiors of differing depth is not illegal, but the semantics are
+undefined by the core protocol.
+.LP
+The fill-rule defines what pixels are inside (drawn) for
+paths given in
+.ZN XFillPolygon
+requests and can be set to
+.ZN EvenOddRule
+or
+.ZN WindingRule .
+For
+.ZN EvenOddRule ,
+a point is inside if
+an infinite ray with the point as origin crosses the path an odd number
+of times.
+For
+.ZN WindingRule ,
+a point is inside if an infinite ray with the
+point as origin crosses an unequal number of clockwise and
+counterclockwise directed path segments.
+A clockwise directed path segment is one that crosses the ray from left to
+right as observed from the point.
+A counterclockwise segment is one that crosses the ray from right to left
+as observed from the point.
+The case where a directed line segment is coincident with the ray is
+uninteresting because you can simply choose a different ray that is not
+coincident with a segment.
+.LP
+For both
+.ZN EvenOddRule
+and
+.ZN WindingRule ,
+a point is infinitely small,
+and the path is an infinitely thin line.
+A pixel is inside if the center point of the pixel is inside
+and the center point is not on the boundary.
+If the center point is on the boundary,
+the pixel is inside if and only if the polygon interior is immediately to
+its right (x increasing direction).
+Pixels with centers on a horizontal edge are a special case
+and are inside if and only if the polygon interior is immediately below
+(y increasing direction).
+.LP
+The arc-mode controls filling in the
+.ZN XFillArcs
+function and can be set to
+.ZN ArcPieSlice
+or
+.ZN ArcChord .
+For
+.ZN ArcPieSlice ,
+the arcs are pie-slice filled.
+For
+.ZN ArcChord ,
+the arcs are chord filled.
+.LP
+The graphics-exposure flag controls
+.ZN GraphicsExpose
+event generation
+for
+.ZN XCopyArea
+and
+.ZN XCopyPlane
+requests (and any similar requests defined by extensions).
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+AllPlanes(3X11),
+XCopyArea(3X11),
+XCreateRegion(3X11),
+XDrawArc(3X11),
+XDrawLine(3X11),
+XDrawRectangle(3X11),
+XDrawText(3X11),
+XFillRectangle(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateIC.man b/man/XCreateIC.man
new file mode 100644
index 00000000..27626f31
--- /dev/null
+++ b/man/XCreateIC.man
@@ -0,0 +1,223 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateIC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateIC, XDestroyIC, XIMOfIC \- create, destroy, and obtain the input method of an input context
+.SH SYNTAX
+XIC XCreateIC\^(\^\fIim\fP\^, ...)
+.br
+ XIM \fIim\fP\^;
+.LP
+void XDestroyIC\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.LP
+XIM XIMOfIC\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.SH ARGUMENTS
+.IP \fIic\fP 1i
+Specifies the input context.
+.IP \fIim\fP 1i
+Specifies the input method.
+.ds Al \ to set XIC values
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XCreateIC
+function creates a context within the specified input method.
+.LP
+Some of the arguments are mandatory at creation time, and
+the input context will not be created if those arguments are not provided.
+The mandatory arguments are the input style and the set of text callbacks
+(if the input style selected requires callbacks).
+All other input context values can be set later.
+.LP
+.ZN XCreateIC
+returns a NULL value if no input context could be created.
+A NULL value could be returned for any of the following reasons:
+.IP \(bu 5
+A required argument was not set.
+.IP \(bu 5
+A read-only argument was set (for example,
+.ZN XNFilterEvents ).
+.IP \(bu 5
+The argument name is not recognized.
+.IP \(bu 5
+The input method encountered an input method implementation-dependent error.
+.LP
+The
+.ZN XCreateIC
+can generate
+.ZN BadAtom ,
+.ZN BadColor ,
+.ZN BadPixmap ,
+and
+.ZN BadWindow
+errors.
+.LP
+.ZN XDestroyIC
+destroys the specified input context.
+.LP
+The
+.ZN XIMOfIC
+function returns the input method associated with the specified input context.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XOpenIM(3X11),
+XSetICFocus(3X11),
+XSetICValues(3X11),
+XmbResetIC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateOC.man b/man/XCreateOC.man
new file mode 100644
index 00000000..144ca548
--- /dev/null
+++ b/man/XCreateOC.man
@@ -0,0 +1,234 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateOC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateOC, XDestroyOC, XSetOCValues, XGetOCValues, XOMOfOC \- create output contexts
+.SH SYNTAX
+XOC XCreateOC\^(\^\fIom\fP\^, ...)
+.br
+ XOM \fIom\fP\^;
+.LP
+void XDestroyOC\^(\^\fIoc\fP\^)
+.br
+ XOC \fIoc\fP\^;
+.LP
+char * XSetOCValues\^(\^\fIoc\fP\^, ...)
+.br
+ XOC \fIoc\fP\^;
+.LP
+char * XGetOCValues\^(\^\fIoc\fP\^, ...)
+.br
+ XOC \fIoc\fP\^;
+.LP
+XOM XOMOfOC\^(\^\fIoc\fP\^)
+.br
+ XOC \fIoc\fP\^;
+.SH ARGUMENTS
+.IP \fIoc\fP 1i
+Specifies the output context.
+.IP \fIom\fP 1i
+Specifies the output method.
+.ds Al \ to set or get XOC values
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XCreateOC
+function creates an output context within the specified output method.
+.LP
+The base font names argument is mandatory at creation time, and
+the output context will not be created unless it is provided.
+All other output context values can be set later.
+.LP
+.ZN XCreateOC
+returns NULL if no output context could be created.
+NULL can be returned for any of the following reasons:
+.IP \(bu 5
+A required argument was not set.
+.IP \(bu 5
+A read-only argument was set.
+.IP \(bu 5
+An argument name is not recognized.
+.IP \(bu 5
+The output method encountered an output method implementation-dependent error.
+.LP
+The
+.ZN XDestroyOC
+function destroys the specified output context.
+.LP
+The
+.ZN XSetOCValues
+function returns NULL if no error occurred;
+otherwise,
+it returns the name of the first argument that could not be set.
+An argument might not be set for any of the following reasons:
+.IP \(bu 5
+The argument is read-only.
+.IP \(bu 5
+The argument name is not recognized.
+.IP \(bu 5
+An implementation-dependent error occurs.
+.LP
+Each value to be set must be an appropriate datum,
+matching the data type imposed by the semantics of the argument.
+.LP
+The
+.ZN XGetOCValues
+function returns NULL if no error occurred; otherwise,
+it returns the name of the first argument that could not be obtained.
+An argument might not be obtained for any of the following reasons:
+.IP \(bu 5
+The argument name is not recognized.
+.IP \(bu 5
+An implementation-dependent error occurs.
+.LP
+Each argument value
+following a name must point to a location where the value is to be stored.
+.LP
+The
+.ZN XOMOfOC
+function returns the output method associated with the
+specified output context.
+.SH "SEE ALSO"
+XCreateOM(3X11),
+XCreateFontSet(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreatePixmap.man b/man/XCreatePixmap.man
new file mode 100644
index 00000000..b2748461
--- /dev/null
+++ b/man/XCreatePixmap.man
@@ -0,0 +1,238 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreatePixmap 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreatePixmap, XFreePixmap \- create or destroy pixmaps
+.SH SYNTAX
+Pixmap XCreatePixmap\^(\^\fIdisplay\fP, \fId\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIdepth\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned int \fIdepth\fP\^;
+.LP
+XFreePixmap\^(\^\fIdisplay\fP, \fIpixmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Pixmap \fIpixmap\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies which screen the pixmap is created on.
+.IP \fIdepth\fP 1i
+Specifies the depth of the pixmap.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIpixmap\fP 1i
+Specifies the pixmap.
+.ds Wh , which define the dimensions of the pixmap
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.SH DESCRIPTION
+The
+.ZN XCreatePixmap
+function creates a pixmap of the width, height, and depth you specified
+and returns a pixmap ID that identifies it.
+It is valid to pass an
+.ZN InputOnly
+window to the drawable argument.
+The width and height arguments must be nonzero,
+or a
+.ZN BadValue
+error results.
+The depth argument must be one of the depths supported by the screen
+of the specified drawable,
+or a
+.ZN BadValue
+error results.
+.LP
+The server uses the specified drawable to determine on which screen
+to create the pixmap.
+The pixmap can be used only on this screen
+and only with other drawables of the same depth (see
+.ZN XCopyPlane
+for an exception to this rule).
+The initial contents of the pixmap are undefined.
+.LP
+.ZN XCreatePixmap
+can generate
+.ZN BadAlloc ,
+.ZN BadDrawable ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XFreePixmap
+function first deletes the association between the pixmap ID and the pixmap.
+Then, the X server frees the pixmap storage when there are no references to it.
+The pixmap should never be referenced again.
+.LP
+.ZN XFreePixmap
+can generate a
+.ZN BadPixmap
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCopyArea(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateRegion.man b/man/XCreateRegion.man
new file mode 100644
index 00000000..70e8a0ff
--- /dev/null
+++ b/man/XCreateRegion.man
@@ -0,0 +1,185 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateRegion 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateRegion, XSetRegion, XDestroyRegion \- create or destroy regions
+.SH SYNTAX
+Region XCreateRegion\^()
+.LP
+XSetRegion\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIr\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Region \fIr\fP\^;
+.LP
+XDestroyRegion\^(\^\fIr\fP\^)
+.br
+ Region \fIr\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIr\fP 1i
+Specifies the region.
+.SH DESCRIPTION
+The
+.ZN XCreateRegion
+function creates a new empty region.
+.LP
+The
+.ZN XSetRegion
+function sets the clip-mask in the GC to the specified region.
+The region is specified relative to the drawable's origin.
+The resulting GC clip origin is implementation-dependent.
+Once it is set in the GC,
+the region can be destroyed.
+.LP
+The
+.ZN XDestroyRegion
+function deallocates the storage associated with a specified region.
+.SH "SEE ALSO"
+XEmptyRegion(3X11),
+XIntersectRegion(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateWindow.man b/man/XCreateWindow.man
new file mode 100644
index 00000000..9faaa355
--- /dev/null
+++ b/man/XCreateWindow.man
@@ -0,0 +1,532 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XCreateWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateWindow, XCreateSimpleWindow, XSetWindowAttributes \- create windows and window attributes structure
+.SH SYNTAX
+Window XCreateWindow\^(\^\fIdisplay\fP, \fIparent\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIborder_width\fP\^, \fIdepth\fP\^,
+.br
+ \fIclass\fP\^, \fIvisual\fP\^, \fIvaluemask\fP\^, \fIattributes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIparent\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned int \fIborder_width\fP\^;
+.br
+ int \fIdepth\fP\^;
+.br
+ unsigned int \fIclass\fP\^;
+.br
+ Visual *\fIvisual\fP\^
+.br
+ unsigned long \fIvaluemask\fP\^;
+.br
+ XSetWindowAttributes *\fIattributes\fP\^;
+.LP
+Window XCreateSimpleWindow\^(\^\fIdisplay\fP, \fIparent\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIborder_width\fP\^,
+.br
+ \fIborder\fP\^, \fIbackground\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIparent\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned int \fIborder_width\fP\^;
+.br
+ unsigned long \fIborder\fP\^;
+.br
+ unsigned long \fIbackground\fP\^;
+.SH ARGUMENTS
+.IP \fIattributes\fP 1i
+Specifies the structure from which the values (as specified by the value mask)
+are to be taken.
+The value mask should have the appropriate bits
+set to indicate which attributes have been set in the structure.
+.IP \fIbackground\fP 1i
+Specifies the background pixel value of the window.
+
+.IP \fIborder\fP 1i
+Specifies the border pixel value of the window.
+.IP \fIborder_width\fP 1i
+Specifies the width of the created window's border in pixels.
+.IP \fIclass\fP 1i
+Specifies the created window's class.
+You can pass
+.ZN InputOutput ,
+.ZN InputOnly ,
+or
+.ZN CopyFromParent .
+A class of
+.ZN CopyFromParent
+means the class
+is taken from the parent.
+.IP \fIdepth\fP 1i
+Specifies the window's depth.
+A depth of
+.ZN CopyFromParent
+means the depth is taken from the parent.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIparent\fP 1i
+Specifies the parent window.
+.IP \fIvaluemask\fP 1i
+Specifies which window attributes are defined in the attributes
+argument.
+This mask is the bitwise inclusive OR of the valid attribute mask bits.
+If valuemask is zero,
+the attributes are ignored and are not referenced.
+.IP \fIvisual\fP 1i
+Specifies the visual type.
+A visual of
+.ZN CopyFromParent
+means the visual type is taken from the
+parent.
+.ds Wh , which are the created window's inside dimensions \
+and do not include the created window's borders
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which are the top-left outside corner of the window's \
+borders and are relative to the inside of the parent window's borders
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XCreateWindow
+function creates an unmapped subwindow for a specified parent window,
+returns the window ID of the created window,
+and causes the X server to generate a
+.ZN CreateNotify
+event.
+The created window is placed on top in the stacking order
+with respect to siblings.
+.LP
+The coordinate system has the X axis horizontal and the Y axis vertical
+with the origin [0, 0] at the upper-left corner.
+Coordinates are integral,
+in terms of pixels,
+and coincide with pixel centers.
+Each window and pixmap has its own coordinate system.
+For a window,
+the origin is inside the border at the inside, upper-left corner.
+.LP
+The border_width for an
+.ZN InputOnly
+window must be zero, or a
+.ZN BadMatch
+error results.
+For class
+.ZN InputOutput ,
+the visual type and depth must be a combination supported for the screen,
+or a
+.ZN BadMatch
+error results.
+The depth need not be the same as the parent,
+but the parent must not be a window of class
+.ZN InputOnly ,
+or a
+.ZN BadMatch
+error results.
+For an
+.ZN InputOnly
+window,
+the depth must be zero, and the visual must be one supported by the screen.
+If either condition is not met,
+a
+.ZN BadMatch
+error results.
+The parent window, however, may have any depth and class.
+If you specify any invalid window attribute for a window, a
+.ZN BadMatch
+error results.
+.LP
+The created window is not yet displayed (mapped) on the user's display.
+To display the window, call
+.ZN XMapWindow .
+The new window initially uses the same cursor as
+its parent.
+A new cursor can be defined for the new window by calling
+.ZN XDefineCursor .
+.IN "Cursor" "Initial State"
+.IN "XDefineCursor"
+The window will not be visible on the screen unless it and all of its
+ancestors are mapped and it is not obscured by any of its ancestors.
+.LP
+.ZN XCreateWindow
+can generate
+.ZN BadAlloc
+.ZN BadColor ,
+.ZN BadCursor ,
+.ZN BadMatch ,
+.ZN BadPixmap ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XCreateSimpleWindow
+function creates an unmapped
+.ZN InputOutput
+subwindow for a specified parent window, returns the
+window ID of the created window, and causes the X server to generate a
+.ZN CreateNotify
+event.
+The created window is placed on top in the stacking order with respect to
+siblings.
+Any part of the window that extends outside its parent window is clipped.
+The border_width for an
+.ZN InputOnly
+window must be zero, or a
+.ZN BadMatch
+error results.
+.ZN XCreateSimpleWindow
+inherits its depth, class, and visual from its parent.
+All other window attributes, except background and border,
+have their default values.
+.LP
+.ZN XCreateSimpleWindow
+can generate
+.ZN BadAlloc ,
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.SH STRUCTURES
+The
+.ZN XSetWindow Attributes
+structure contains:
+.LP
+.LP
+/* Window attribute value mask bits */
+.TS
+lw(.5i) lw(2.5i) lw(.8i).
+T{
+#define
+T} T{
+.ZN CWBackPixmap
+T} T{
+(1L<<0)
+T}
+T{
+#define
+T} T{
+.ZN CWBackPixel
+T} T{
+(1L<<1)
+T}
+T{
+#define
+T} T{
+.ZN CWBorderPixmap
+T} T{
+(1L<<2)
+T}
+T{
+#define
+T} T{
+.ZN CWBorderPixel
+T} T{
+(1L<<3)
+T}
+T{
+#define
+T} T{
+.ZN CWBitGravity
+T} T{
+(1L<<4)
+T}
+T{
+#define
+T} T{
+.ZN CWWinGravity
+T} T{
+(1L<<5)
+T}
+T{
+#define
+T} T{
+.ZN CWBackingStore
+T} T{
+(1L<<6)
+T}
+T{
+#define
+T} T{
+.ZN CWBackingPlanes
+T} T{
+(1L<<7)
+T}
+T{
+#define
+T} T{
+.ZN CWBackingPixel
+T} T{
+(1L<<8)
+T}
+T{
+#define
+T} T{
+.ZN CWOverrideRedirect
+T} T{
+(1L<<9)
+T}
+T{
+#define
+T} T{
+.ZN CWSaveUnder
+T} T{
+(1L<<10)
+T}
+T{
+#define
+T} T{
+.ZN CWEventMask
+T} T{
+(1L<<11)
+T}
+T{
+#define
+T} T{
+.ZN CWDontPropagate
+T} T{
+(1L<<12)
+T}
+T{
+#define
+T} T{
+.ZN CWColormap
+T} T{
+(1L<<13)
+T}
+T{
+#define
+T} T{
+.ZN CWCursor
+T} T{
+(1L<<14)
+T}
+.TE
+.IN "XSetWindowAttributes" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+/* Values */
+
+typedef struct {
+ Pixmap background_pixmap; /* background, None, or ParentRelative */
+ unsigned long background_pixel; /* background pixel */
+ Pixmap border_pixmap; /* border of the window or CopyFromParent */
+ unsigned long border_pixel; /* border pixel value */
+ int bit_gravity; /* one of bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes; /* planes to be preserved if possible */
+ unsigned long backing_pixel; /* value to use in restoring planes */
+ Bool save_under; /* should bits under be saved? (popups) */
+ long event_mask; /* set of events that should be saved */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override_redirect */
+ Colormap colormap; /* color map to be associated with window */
+ Cursor cursor; /* cursor to be displayed (or None) */
+} XSetWindowAttributes;
+.De
+.LP
+For a detailed explanation of the members of this structure,
+see \fI\*(xL\fP\^.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadMatch
+The values do not exist for an
+.ZN InputOnly
+window.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XDefineCursor(3X11),
+XDestroyWindow(3X11),
+XMapWindow(3X11),
+XRaiseWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCreateWindowEvent.man b/man/XCreateWindowEvent.man
new file mode 100644
index 00000000..4eac91fe
--- /dev/null
+++ b/man/XCreateWindowEvent.man
@@ -0,0 +1,228 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateWindowEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCreateWindowEvent \- CreateNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN CreateNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* CreateNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent; /* parent of the window */
+ Window window; /* window id of window created */
+ int x, y; /* window location */
+ int width, height; /* size of window */
+ int border_width; /* border width */
+ Bool override_redirect; /* creation should be overridden */
+} XCreateWindowEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The parent member is set to the created window's parent.
+The window member specifies the created window.
+The x and y members are set to the created window's coordinates relative
+to the parent window's origin and indicate the position of the upper-left
+outside corner of the created window.
+The width and height members are set to the inside size of the created window
+(not including the border) and are always nonzero.
+The border_width member is set to the width of the created window's border, in pixels.
+The override_redirect member is set to the override-redirect attribute of the
+window.
+Window manager clients normally should ignore this window
+if the override_redirect member is
+.ZN True .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XCrossingEvent.man b/man/XCrossingEvent.man
new file mode 100644
index 00000000..5bf8d4fc
--- /dev/null
+++ b/man/XCrossingEvent.man
@@ -0,0 +1,325 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCrossingEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XCrossingEvent \- EnterNotify and LeaveNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN EnterNotify
+and
+.ZN LeaveNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* EnterNotify or LeaveNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* ``event'' window reported relative to */
+ Window root; /* root window that the event occurred on */
+ Window subwindow; /* child window */
+ Time time; /* milliseconds */
+ int x, y; /* pointer x, y coordinates in event window */
+ int x_root, y_root; /* coordinates relative to root */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual
+ */
+ Bool same_screen; /* same screen flag */
+ Bool focus; /* boolean focus */
+ unsigned int state; /* key or button mask */
+} XCrossingEvent;
+typedef XCrossingEvent XEnterWindowEvent;
+typedef XCrossingEvent XLeaveWindowEvent;
+.De
+.LP
+When you receive these events,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window on which the
+.ZN EnterNotify
+or
+.ZN LeaveNotify
+event was generated and is referred to as the event window.
+This is the window used by the X server to report the event,
+and is relative to the root
+window on which the event occurred.
+The root member is set to the root window of the screen
+on which the event occurred.
+.LP
+For a
+.ZN LeaveNotify
+event,
+if a child of the event window contains the initial position of the pointer,
+the subwindow component is set to that child.
+Otherwise, the X server sets the subwindow member to
+.ZN None .
+For an
+.ZN EnterNotify
+event, if a child of the event window contains the final pointer position,
+the subwindow component is set to that child or
+.ZN None .
+.LP
+The time member is set to the time when the event was generated
+and is expressed in milliseconds.
+The x and y members are set to the coordinates of the pointer position in
+the event window.
+This position is always the pointer's final position,
+not its initial position.
+If the event window is on the same
+screen as the root window, x and y are the pointer coordinates
+relative to the event window's origin.
+Otherwise, x and y are set to zero.
+The x_root and y_root members are set to the pointer's coordinates relative to the
+root window's origin at the time of the event.
+.LP
+The same_screen member is set to indicate whether the event window is on the same screen
+as the root window and can be either
+.ZN True
+or
+.ZN False .
+If
+.ZN True ,
+the event and root windows are on the same screen.
+If
+.ZN False ,
+the event and root windows are not on the same screen.
+.LP
+The focus member is set to indicate whether the event window is the focus window or an
+inferior of the focus window.
+The X server can set this member to either
+.ZN True
+or
+.ZN False .
+If
+.ZN True ,
+the event window is the focus window or an inferior of the focus window.
+If
+.ZN False ,
+the event window is not the focus window or an inferior of the focus window.
+.LP
+The state member is set to indicate the state of the pointer buttons and
+modifier keys just prior to the
+event.
+The X server can set this member to the bitwise inclusive OR of one
+or more of the button or modifier key masks:
+.ZN Button1Mask ,
+.ZN Button2Mask ,
+.ZN Button3Mask ,
+.ZN Button4Mask ,
+.ZN Button5Mask ,
+.ZN ShiftMask ,
+.ZN LockMask ,
+.ZN ControlMask ,
+.ZN Mod1Mask ,
+.ZN Mod2Mask ,
+.ZN Mod3Mask ,
+.ZN Mod4Mask ,
+.ZN Mod5Mask .
+.LP
+The mode member is set to indicate whether the events are normal events,
+pseudo-motion events
+when a grab activates, or pseudo-motion events when a grab deactivates.
+The X server can set this member to
+.ZN NotifyNormal ,
+.ZN NotifyGrab ,
+or
+.ZN NotifyUngrab .
+.LP
+The detail member is set to indicate the notify detail and can be
+.ZN NotifyAncestor ,
+.ZN NotifyVirtual ,
+.ZN NotifyInferior ,
+.ZN NotifyNonlinear ,
+or
+.ZN NotifyNonlinearVirtual .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDefineCursor.man b/man/XDefineCursor.man
new file mode 100644
index 00000000..aacdeee8
--- /dev/null
+++ b/man/XDefineCursor.man
@@ -0,0 +1,208 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDefineCursor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDefineCursor, XUndefineCursor \- define cursors
+.SH SYNTAX
+XDefineCursor\^(\^\fIdisplay\fP, \fIw\fP\^, \fIcursor\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.LP
+XUndefineCursor\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIcursor\fP 1i
+Specifies the cursor that is to be displayed or
+.ZN None .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+If a cursor is set, it will be used when the pointer is in the window.
+If the cursor is
+.ZN None ,
+it is equivalent to
+.ZN XUndefineCursor .
+.LP
+.ZN XDefineCursor
+can generate
+.ZN BadCursor
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XUndefineCursor
+function undoes the effect of a previous
+.ZN XDefineCursor
+for this window.
+When the pointer is in the window,
+the parent's cursor will now be used.
+On the root window,
+the default cursor is restored.
+.LP
+.ZN XUndefineCursor
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XCreateFontCursor(3X11),
+XRecolorCursor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDestroyWindow.man b/man/XDestroyWindow.man
new file mode 100644
index 00000000..dd413bec
--- /dev/null
+++ b/man/XDestroyWindow.man
@@ -0,0 +1,223 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDestroyWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDestroyWindow, XDestroySubwindows \- destroy windows
+.SH SYNTAX
+XDestroyWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XDestroySubwindows\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XDestroyWindow
+function destroys the specified window as well as all of its subwindows and causes
+the X server to generate a
+.ZN DestroyNotify
+event for each window.
+The window should never be referenced again.
+If the window specified by the w argument is mapped,
+it is unmapped automatically.
+The ordering of the
+.ZN DestroyNotify
+events is such that for any given window being destroyed,
+.ZN DestroyNotify
+is generated on any inferiors of the window before being generated on
+the window itself.
+The ordering among siblings and across subhierarchies is not otherwise
+constrained.
+If the window you specified is a root window, no windows are destroyed.
+Destroying a mapped window will generate
+.ZN Expose
+events on other windows that were obscured by the window being destroyed.
+.LP
+.ZN XDestroyWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XDestroySubwindows
+function destroys all inferior windows of the specified window,
+in bottom-to-top stacking order.
+It causes the X server to generate a
+.ZN DestroyNotify
+event for each window.
+If any mapped
+subwindows were actually destroyed,
+.ZN XDestroySubwindows
+causes the X server to generate
+.ZN Expose
+events on the specified window.
+This is much more efficient than deleting many windows
+one at a time because much of the work need be performed only once for all
+of the windows, rather than for each window.
+The subwindows should never be referenced again.
+.LP
+.ZN XDestroySubwindows
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XMapWindow(3X11),
+XRaiseWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDestroyWindowEvent.man b/man/XDestroyWindowEvent.man
new file mode 100644
index 00000000..fabfe00f
--- /dev/null
+++ b/man/XDestroyWindowEvent.man
@@ -0,0 +1,218 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDestroyWindowEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDestroyWindowEvent \- DestroyNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN DestroyNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* DestroyNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+} XDestroyWindowEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the destroyed window or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the window that is destroyed.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawArc.man b/man/XDrawArc.man
new file mode 100644
index 00000000..37236458
--- /dev/null
+++ b/man/XDrawArc.man
@@ -0,0 +1,349 @@
+'\" e
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" e
+.TH XDrawArc 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawArc, XDrawArcs, XArc \- draw arcs and arc structure
+.SH SYNTAX
+XDrawArc\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIangle1\fP\^, \fIangle2\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ int \fIangle1\fP\^, \fIangle2\fP\^;
+.LP
+XDrawArcs\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIarcs\fP\^, \fInarcs\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XArc *\fIarcs\fP\^;
+.br
+ int \fInarcs\fP\^;
+.SH ARGUMENTS
+.IP \fIangle1\fP 1i
+Specifies the start of the arc relative to the three-o'clock position
+from the center, in units of degrees * 64.
+.IP \fIangle2\fP 1i
+Specifies the path and extent of the arc relative to the start of the
+arc, in units of degrees * 64.
+.IP \fIarcs\fP 1i
+Specifies an array of arcs.
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fInarcs\fP 1i
+Specifies the number of arcs in the array.
+.ds Wh , which are the major and minor axes of the arc
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which are relative to the origin of the drawable \
+and specify the upper-left corner of the bounding rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+.EQ
+delim %%
+.EN
+.ZN XDrawArc
+draws a single circular or elliptical arc, and
+.ZN XDrawArcs
+draws multiple circular or elliptical arcs.
+Each arc is specified by a rectangle and two angles.
+The center of the circle or ellipse is the center of the
+rectangle, and the major and minor axes are specified by the width and height.
+Positive angles indicate counterclockwise motion,
+and negative angles indicate clockwise motion.
+If the magnitude of angle2 is greater than 360 degrees,
+.ZN XDrawArc
+or
+.ZN XDrawArcs
+truncates it to 360 degrees.
+.LP
+For an arc specified as %[ ~x, ~y, ~width , ~height, ~angle1, ~angle2 ]%,
+the origin of the major and minor axes is at
+% [ x +^ {width over 2} , ~y +^ {height over 2} ]%,
+and the infinitely thin path describing the entire circle or ellipse
+intersects the horizontal axis at % [ x, ~y +^ {height over 2} ]% and
+% [ x +^ width , ~y +^ { height over 2 }] %
+and intersects the vertical axis at % [ x +^ { width over 2 } , ~y ]% and
+% [ x +^ { width over 2 }, ~y +^ height ]%.
+These coordinates can be fractional
+and so are not truncated to discrete coordinates.
+The path should be defined by the ideal mathematical path.
+For a wide line with line-width lw,
+the bounding outlines for filling are given
+by the two infinitely thin paths consisting of all points whose perpendicular
+distance from the path of the circle/ellipse is equal to lw/2
+(which may be a fractional value).
+The cap-style and join-style are applied the same as for a line
+corresponding to the tangent of the circle/ellipse at the endpoint.
+.LP
+For an arc specified as % [ ~x, ~y, ~width, ~height, ~angle1, ~angle2 ]%,
+the angles must be specified
+in the effectively skewed coordinate system of the ellipse (for a
+circle, the angles and coordinate systems are identical). The
+relationship between these angles and angles expressed in the normal
+coordinate system of the screen (as measured with a protractor) is as
+follows:
+.LP
+.Ds
+% roman "skewed-angle" ~ = ~ atan left ( tan ( roman "normal-angle" )
+ * width over height right ) +^ adjust%
+.De
+.LP
+The skewed-angle and normal-angle are expressed in radians (rather
+than in degrees scaled by 64) in the range % [ 0 , ~2 pi ]% and where atan
+returns a value in the range % [ - pi over 2 , ~pi over 2 ] %
+and adjust is:
+.LP
+.Ds
+.TA 1i 2i
+.ta 1i 2i
+%0% for normal-angle in the range % [ 0 , ~pi over 2 ]%
+%pi% for normal-angle in the range % [ pi over 2 , ~{3 pi} over 2 ]%
+%2 pi% for normal-angle in the range % [ {3 pi} over 2 , ~2 pi ]%
+.De
+.LP
+For any given arc,
+.ZN XDrawArc
+and
+.ZN XDrawArcs
+do not draw a pixel more than once.
+If two arcs join correctly and if the line-width is greater than zero
+and the arcs intersect,
+.ZN XDrawArc
+and
+.ZN XDrawArcs
+do not draw a pixel more than once.
+Otherwise,
+the intersecting pixels of intersecting arcs are drawn multiple times.
+Specifying an arc with one endpoint and a clockwise extent draws the same pixels
+as specifying the other endpoint and an equivalent counterclockwise extent,
+except as it affects joins.
+.LP
+If the last point in one arc coincides with the first point in the following
+arc, the two arcs will join correctly.
+If the first point in the first arc coincides with the last point in the last
+arc, the two arcs will join correctly.
+By specifying one axis to be zero, a horizontal or vertical line can be
+drawn.
+Angles are computed based solely on the coordinate system and ignore the
+aspect ratio.
+.LP
+Both functions use these GC components:
+function, plane-mask, line-width, line-style, cap-style, join-style,
+fill-style, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+tile-stipple-y-origin, dash-offset, and dash-list.
+.LP
+.ZN XDrawArc
+and
+.ZN XDrawArcs
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH STRUCTURES
+The
+.ZN XArc
+structure contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+ short angle1, angle2; /* Degrees * 64 */
+} XArc;
+.De
+.LP
+All x and y members are signed integers.
+The width and height members are 16-bit unsigned integers.
+You should be careful not to generate coordinates and sizes
+out of the 16-bit ranges, because the protocol only has 16-bit fields
+for these values.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.SH "SEE ALSO"
+XDrawLine(3X11),
+XDrawPoint(3X11),
+XDrawRectangle(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawImageString.man b/man/XDrawImageString.man
new file mode 100644
index 00000000..2470f5b1
--- /dev/null
+++ b/man/XDrawImageString.man
@@ -0,0 +1,270 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawImageString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawImageString, XDrawImageString16 \- draw image text
+.SH SYNTAX
+XDrawImageString\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fIlength\fP\^;
+.LP
+XDrawImageString16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XChar2b *\fIstring\fP\^;
+.br
+ int \fIlength\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIlength\fP 1i
+Specifies the number of characters in the string argument.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.ds Xy , which are relative to the origin of the specified drawable \
+and define the origin of the first character
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XDrawImageString16
+function is similar to
+.ZN XDrawImageString
+except that it uses 2-byte or 16-bit characters.
+Both functions also use both the foreground and background pixels
+of the GC in the destination.
+.LP
+The effect is first to fill a
+destination rectangle with the background pixel defined in the GC and then
+to paint the text with the foreground pixel.
+The upper-left corner of the filled rectangle is at:
+.LP
+.Ds
+[x, y \- font-ascent]
+.De
+.LP
+The width is:
+.LP
+.Ds
+overall-width
+.De
+.LP
+The height is:
+.LP
+.Ds
+font-ascent + font-descent
+.De
+.LP
+The overall-width, font-ascent, and font-descent
+are as would be returned by
+.ZN XQueryTextExtents
+using gc and string.
+The function and fill-style defined in the GC are ignored for these functions.
+The effective function is
+.ZN GXcopy ,
+and the effective fill-style is
+.ZN FillSolid .
+.LP
+For fonts defined with 2-byte matrix indexing
+and used with
+.ZN XDrawImageString ,
+each byte is used as a byte2 with a byte1 of zero.
+.LP
+Both functions use these GC components:
+plane-mask, foreground, background, font, subwindow-mode, clip-x-origin,
+clip-y-origin, and clip-mask.
+.LP
+.ZN XDrawImageString
+and
+.ZN XDrawImageString16
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.SH "SEE ALSO"
+XDrawString(3X11),
+XDrawText(3X11),
+XLoadFont(3X11),
+XTextExtents(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawLine.man b/man/XDrawLine.man
new file mode 100644
index 00000000..637aa45d
--- /dev/null
+++ b/man/XDrawLine.man
@@ -0,0 +1,333 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawLine 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawLine, XDrawLines, XDrawSegments, XSegment \- draw lines, polygons, and line structure
+.SH SYNTAX
+XDrawLine\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx1\fP\^, \fIy1\fP\^, \fIx2\fP\^, \fIy2\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx1\fP\^, \fIy1\fP\^, \fIx2\fP\^, \fIy2\fP\^;
+.LP
+XDrawLines\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XPoint *\fIpoints\fP\^;
+.br
+ int \fInpoints\fP\^;
+.br
+ int \fImode\fP\^;
+.LP
+XDrawSegments\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIsegments\fP\^, \fInsegments\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XSegment *\fIsegments\fP\^;
+.br
+ int \fInsegments\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fImode\fP 1i
+Specifies the coordinate mode.
+You can pass
+.ZN CoordModeOrigin
+or
+.ZN CoordModePrevious .
+.IP \fInpoints\fP 1i
+Specifies the number of points in the array.
+.IP \fInsegments\fP 1i
+Specifies the number of segments in the array.
+.IP \fIpoints\fP 1i
+Specifies an array of points.
+.IP \fIsegments\fP 1i
+Specifies an array of segments.
+.IP \fIx1\fP 1i
+.br
+.ns
+.IP \fIy1\fP 1i
+.br
+.ns
+.IP \fIx2\fP 1i
+.br
+.ns
+.IP \fIy2\fP 1i
+Specify the points (x1, y1) and (x2, y2) to be connected.
+.SH DESCRIPTION
+The
+.ZN XDrawLine
+function uses the components of the specified GC to
+draw a line between the specified set of points (x1, y1) and (x2, y2).
+It does not perform joining at coincident endpoints.
+For any given line,
+.ZN XDrawLine
+does not draw a pixel more than once.
+If lines intersect, the intersecting pixels are drawn multiple times.
+.LP
+The
+.ZN XDrawLines
+function uses the components of the specified GC to draw
+npoints\-1 lines between each pair of points (point[i], point[i+1])
+in the array of
+.ZN XPoint
+structures.
+It draws the lines in the order listed in the array.
+The lines join correctly at all intermediate points, and if the first and last
+points coincide, the first and last lines also join correctly.
+For any given line,
+.ZN XDrawLines
+does not draw a pixel more than once.
+If thin (zero line-width) lines intersect,
+the intersecting pixels are drawn multiple times.
+If wide lines intersect, the intersecting pixels are drawn only once, as though
+the entire
+.ZN PolyLine
+protocol request were a single, filled shape.
+.ZN CoordModeOrigin
+treats all coordinates as relative to the origin,
+and
+.ZN CoordModePrevious
+treats all coordinates after the first as relative to the previous point.
+.LP
+The
+.ZN XDrawSegments
+function draws multiple, unconnected lines.
+For each segment,
+.ZN XDrawSegments
+draws a
+line between (x1, y1) and (x2, y2).
+It draws the lines in the order listed in the array of
+.ZN XSegment
+structures and does not perform joining at coincident endpoints.
+For any given line,
+.ZN XDrawSegments
+does not draw a pixel more than once.
+If lines intersect, the intersecting pixels are drawn multiple times.
+.LP
+All three functions use these GC components:
+function, plane-mask, line-width,
+line-style, cap-style, fill-style, subwindow-mode,
+clip-x-origin, clip-y-origin, and clip-mask.
+The
+.ZN XDrawLines
+function also uses the join-style GC component.
+All three functions also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+tile-stipple-y-origin, dash-offset, and dash-list.
+.LP
+.ZN XDrawLine ,
+.ZN XDrawLines ,
+and
+.ZN XDrawSegments
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.ZN XDrawLines
+can also generate a
+.ZN BadValue
+error.
+.SH STRUCTURES
+The
+.ZN XSegment
+structure contains:
+.LP
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ short x1, y1, x2, y2;
+} XSegment;
+.De
+.LP
+All x and y members are signed integers.
+The width and height members are 16-bit unsigned integers.
+You should be careful not to generate coordinates and sizes
+out of the 16-bit ranges, because the protocol only has 16-bit fields
+for these values.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XDrawArc(3X11),
+XDrawPoint(3X11),
+XDrawRectangle(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawPoint.man b/man/XDrawPoint.man
new file mode 100644
index 00000000..f06b8657
--- /dev/null
+++ b/man/XDrawPoint.man
@@ -0,0 +1,268 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawPoint 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawPoint, XDrawPoints, XPoint \- draw points and points structure
+.SH SYNTAX
+XDrawPoint\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.LP
+XDrawPoints\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XPoint *\fIpoints\fP\^;
+.br
+ int \fInpoints\fP\^;
+.br
+ int \fImode\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fImode\fP 1i
+Specifies the coordinate mode.
+You can pass
+.ZN CoordModeOrigin
+or
+.ZN CoordModePrevious .
+.IP \fInpoints\fP 1i
+Specifies the number of points in the array.
+.IP \fIpoints\fP 1i
+Specifies an array of points.
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates where you want the point drawn.
+.SH DESCRIPTION
+The
+.ZN XDrawPoint
+function uses the foreground pixel and function components of the
+GC to draw a single point into the specified drawable;
+.ZN XDrawPoints
+draws multiple points this way.
+.ZN CoordModeOrigin
+treats all coordinates as relative to the origin,
+and
+.ZN CoordModePrevious
+treats all coordinates after the first as relative to the previous point.
+.ZN XDrawPoints
+draws the points in the order listed in the array.
+.LP
+Both functions use these GC components: function, plane-mask,
+foreground, subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
+.LP
+.ZN XDrawPoint
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.ZN XDrawPoints
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.SH STRUCTURES
+The
+.ZN XPoint
+structure contains:
+.LP
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ short x, y;
+} XPoint;
+.De
+.LP
+All x and y members are signed integers.
+The width and height members are 16-bit unsigned integers.
+You should be careful not to generate coordinates and sizes
+out of the 16-bit ranges, because the protocol only has 16-bit fields
+for these values.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XDrawArc(3X11),
+XDrawLine(3X11),
+XDrawRectangle(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawRectangle.man b/man/XDrawRectangle.man
new file mode 100644
index 00000000..a9417bcf
--- /dev/null
+++ b/man/XDrawRectangle.man
@@ -0,0 +1,267 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawRectangle 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawRectangle, XDrawRectangles, XRectangle \- draw rectangles and rectangles structure
+.SH SYNTAX
+XDrawRectangle\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.LP
+XDrawRectangles\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIrectangles\fP\^, \fInrectangles\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XRectangle \fIrectangles\fP\^[\^]\^;
+.br
+ int \fInrectangles\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fInrectangles\fP 1i
+Specifies the number of rectangles in the array.
+.IP \fIrectangles\fP 1i
+Specifies an array of rectangles.
+.ds Wh , which specify the dimensions of the rectangle
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which specify the upper-left corner of the rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XDrawRectangle
+and
+.ZN XDrawRectangles
+functions draw the outlines of the specified rectangle or rectangles as
+if a five-point
+.ZN PolyLine
+protocol request were specified for each rectangle:
+.IP
+[x,y] [x+width,y] [x+width,y+height] [x,y+height] [x,y]
+.LP
+For the specified rectangle or rectangles,
+these functions do not draw a pixel more than once.
+.ZN XDrawRectangles
+draws the rectangles in the order listed in the array.
+If rectangles intersect,
+the intersecting pixels are drawn multiple times.
+.LP
+Both functions use these GC components:
+function, plane-mask, line-width,
+line-style, cap-style, join-style, fill-style,
+subwindow-mode, clip-x-origin, clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+tile-stipple-y-origin, dash-offset, and dash-list.
+.LP
+.ZN XDrawRectangle
+and
+.ZN XDrawRectangles
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH STRUCTURES
+The
+.ZN XRectangle
+structure contains:
+.LP
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ short x, y;
+ unsigned short width, height;
+} XRectangle;
+.De
+.LP
+All x and y members are signed integers.
+The width and height members are 16-bit unsigned integers.
+You should be careful not to generate coordinates and sizes
+out of the 16-bit ranges, because the protocol only has 16-bit fields
+for these values.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.SH "SEE ALSO"
+XDrawArc(3X11),
+XDrawLine(3X11),
+XDrawPoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawString.man b/man/XDrawString.man
new file mode 100644
index 00000000..564a87c7
--- /dev/null
+++ b/man/XDrawString.man
@@ -0,0 +1,236 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawString, XDrawString16 \- draw text characters
+.SH SYNTAX
+XDrawString\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fIlength\fP\^;
+.LP
+XDrawString16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XChar2b *\fIstring\fP\^;
+.br
+ int \fIlength\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIlength\fP 1i
+Specifies the number of characters in the string argument.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.ds Xy , which are relative to the origin of the specified drawable \
+and define the origin of the first character
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+Each character image, as defined by the font in the GC, is treated as an
+additional mask for a fill operation on the drawable.
+The drawable is modified only where the font character has a bit set to 1.
+For fonts defined with 2-byte matrix indexing
+and used with
+.ZN XDrawString16 ,
+each byte is used as a byte2 with a byte1 of zero.
+.LP
+Both functions use these GC components:
+function, plane-mask, fill-style, font, subwindow-mode, clip-x-origin,
+clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+and tile-stipple-y-origin.
+.LP
+.ZN XDrawString
+and
+.ZN XDrawString16
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.SH "SEE ALSO"
+XDrawImageString(3X11),
+XDrawText(3X11),
+XLoadFont(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XDrawText.man b/man/XDrawText.man
new file mode 100644
index 00000000..4363d909
--- /dev/null
+++ b/man/XDrawText.man
@@ -0,0 +1,308 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XDrawText 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XDrawText, XDrawText16, XTextItem, XTextItem16 \- draw polytext text and text drawing structures
+.SH SYNTAX
+XDrawText\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XTextItem *\fIitems\fP\^;
+.br
+ int \fInitems\fP\^;
+.LP
+XDrawText16\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XTextItem16 *\fIitems\fP\^;
+.br
+ int \fInitems\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIitems\fP 1i
+Specifies an array of text items.
+.IP \fInitems\fP 1i
+Specifies the number of text items in the array.
+.ds Xy , which are relative to the origin of the specified drawable \
+and define the origin of the first character
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XDrawText16
+function is similar to
+.ZN XDrawText
+except that it uses 2-byte or 16-bit characters.
+Both functions allow complex spacing and font shifts between counted strings.
+.LP
+Each text item is processed in turn.
+A font member other than
+.ZN None
+in an item causes the font to be stored in the GC
+and used for subsequent text.
+A text element delta specifies an additional change
+in the position along the x axis before the string is drawn.
+The delta is always added to the character origin
+and is not dependent on any characteristics of the font.
+Each character image, as defined by the font in the GC, is treated as an
+additional mask for a fill operation on the drawable.
+The drawable is modified only where the font character has a bit set to 1.
+If a text item generates a
+.ZN BadFont
+error, the previous text items may have been drawn.
+.LP
+For fonts defined with linear indexing rather than 2-byte matrix indexing,
+each
+.ZN XChar2b
+structure is interpreted as a 16-bit number with byte1 as the
+most significant byte.
+.LP
+Both functions use these GC components:
+function, plane-mask, fill-style, font, subwindow-mode,
+clip-x-origin, clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+and tile-stipple-y-origin.
+.LP
+.ZN XDrawText
+and
+.ZN XDrawText16
+can generate
+.ZN BadDrawable ,
+.ZN BadFont ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH STRUCTURES
+The
+.ZN XTextItem
+and
+.ZN XTextItem16
+structures contain:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* Font to print it in, None don't change */
+} XTextItem;
+.De
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ XChar2b *chars; /* pointer to two-byte characters */
+ int nchars; /* number of characters */
+ int delta; /* delta between strings */
+ Font font; /* font to print it in, None don't change */
+} XTextItem16;
+.De
+.LP
+If the font member is not
+.ZN None ,
+the font is changed before printing and also is stored in the GC.
+If an error was generated during text drawing,
+the previous items may have been drawn.
+The baseline of the characters are drawn starting at the x and y
+coordinates that you pass in the text drawing functions.
+.LP
+For example, consider the background rectangle drawn by
+.ZN XDrawImageString .
+If you want the upper-left corner of the background rectangle
+to be at pixel coordinate (x,y), pass the (x,y + ascent)
+as the baseline origin coordinates to the text functions.
+The ascent is the font ascent, as given in the
+.ZN XFontStruct
+structure.
+If you want the lower-left corner of the background rectangle
+to be at pixel coordinate (x,y), pass the (x,y \- descent + 1)
+as the baseline origin coordinates to the text functions.
+The descent is the font descent, as given in the
+.ZN XFontStruct
+structure.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.SH "SEE ALSO"
+XDrawImageString(3X11),
+XDrawString(3X11),
+XLoadFont(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XEmptyRegion.man b/man/XEmptyRegion.man
new file mode 100644
index 00000000..d7afd204
--- /dev/null
+++ b/man/XEmptyRegion.man
@@ -0,0 +1,220 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XEmptyRegion 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XEmptyRegion, XEqualRegion, XPointInRegion, XRectInRegion \- determine if regions are empty or equal
+.SH SYNTAX
+Bool XEmptyRegion\^(\^\fIr\fP\^)
+.br
+ Region \fIr\fP\^;
+.LP
+Bool XEqualRegion\^(\^\fIr1\fP\^, \fIr2\fP\^)
+.br
+ Region \fIr1\fP\^, \fIr2\fP\^;
+.LP
+Bool XPointInRegion\^(\^\fIr\fP\^, \fIx\fP\^, \fIy\fP\^)
+.br
+ Region \fIr\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.LP
+int XRectInRegion\^(\^\fIr\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Region \fIr\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.SH ARGUMENTS
+.IP \fIr\fP 1i
+Specifies the region.
+.IP \fIr1\fP 1i
+.br
+.ns
+.IP \fIr2\fP 1i
+Specify the two regions.
+.ds Wh , which define the rectangle
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which define the point \
+or the coordinates of the upper-left corner of the rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XEmptyRegion
+function returns
+.ZN True
+if the region is empty.
+.LP
+The
+.ZN XEqualRegion
+function returns
+.ZN True
+if the two regions have the same offset, size, and shape.
+.LP
+The
+.ZN XPointInRegion
+function returns
+.ZN True
+if the point (x, y) is contained in the region r.
+.LP
+The
+.ZN XRectInRegion
+function returns
+.ZN RectangleIn
+if the rectangle is entirely in the specified region,
+.ZN RectangleOut
+if the rectangle is entirely out of the specified region,
+and
+.ZN RectanglePart
+if the rectangle is partially in the specified region.
+.SH "SEE ALSO"
+XCreateRegion(3X11),
+XIntersectRegion(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XErrorEvent.man b/man/XErrorEvent.man
new file mode 100644
index 00000000..e9ee1603
--- /dev/null
+++ b/man/XErrorEvent.man
@@ -0,0 +1,202 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XErrorEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XErrorEvent \- X error event structure
+.SH STRUCTURES
+The
+.ZN XErrorEvent
+structure contains:
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ int type;
+ Display *display; /* Display the event was read from */
+ unsigned long serial; /* serial number of failed request */
+ unsigned char error_code; /* error code of failed request */
+ unsigned char request_code; /* Major op-code of failed request */
+ unsigned char minor_code; /* Minor op-code of failed request */
+ XID resourceid; /* resource id */
+} XErrorEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The serial member is the number of requests, starting from one,
+sent over the network connection since it was opened.
+It is the number that was the value of
+.ZN NextRequest
+immediately before the failing call was made.
+The request_code member is a protocol request
+of the procedure that failed, as defined in
+.hN X11/Xproto.h .
+.SH "SEE ALSO"
+AllPlanes(3X11),
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XExposeEvent.man b/man/XExposeEvent.man
new file mode 100644
index 00000000..29523deb
--- /dev/null
+++ b/man/XExposeEvent.man
@@ -0,0 +1,231 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XExposeEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XExposeEvent \- Expose event structure
+.SH STRUCTURES
+The structure for
+.ZN Expose
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* Expose */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int x, y;
+ int width, height;
+ int count; /* if nonzero, at least this many more */
+} XExposeEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the exposed (damaged) window.
+The x and y members are set to the coordinates relative to the window's origin
+and indicate the upper-left corner of the rectangle.
+The width and height members are set to the size (extent) of the rectangle.
+The count member is set to the number of
+.ZN Expose
+events that are to follow.
+If count is zero, no more
+.ZN Expose
+events follow for this window.
+However, if count is nonzero, at least that number of
+.ZN Expose
+events (and possibly more) follow for this window.
+Simple applications that do not want to optimize redisplay by distinguishing
+between subareas of its window can just ignore all
+.ZN Expose
+events with nonzero counts and perform full redisplays
+on events with zero counts.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XExtentsOfFontSet.man b/man/XExtentsOfFontSet.man
new file mode 100644
index 00000000..7fec44c9
--- /dev/null
+++ b/man/XExtentsOfFontSet.man
@@ -0,0 +1,173 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XExtentsOfFontSet 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XExtentsOfFontSet \- obtain the maximum extents structure for a font set
+.SH SYNTAX
+XFontSetExtents *XExtentsOfFontSet\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.SH ARGUMENTS
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.SH DESCRIPTION
+The
+.ZN XExtentsOfFontSet
+function returns an
+.ZN XFontSetExtents
+structure for the fonts used by the Xmb and Xwc layers
+for the given font set.
+.LP
+The
+.ZN XFontSetExtents
+structure is owned by Xlib and should not be modified
+or freed by the client.
+It will be freed by a call to
+.ZN XFreeFontSet
+with the associated
+.ZN XFontSet .
+Until freed, its contents will not be modified by Xlib.
+.SH "SEE ALSO"
+XCreateFontSet(3X11),
+XFontsOfFontSet(3X11),
+XFontSetExtents(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFillRectangle.man b/man/XFillRectangle.man
new file mode 100644
index 00000000..f05ae5a6
--- /dev/null
+++ b/man/XFillRectangle.man
@@ -0,0 +1,440 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFillRectangle 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFillRectangle, XFillRectangles, XFillPolygon, XFillArc, XFillArcs \- fill rectangles, polygons, or arcs
+.SH SYNTAX
+XFillRectangle\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.LP
+XFillRectangles\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIrectangles\fP\^, \fInrectangles\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XRectangle *\fIrectangles\fP\^;
+.br
+ int \fInrectangles\fP\^;
+.LP
+XFillPolygon\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIpoints\fP\^, \fInpoints\fP\^, \fIshape\fP\^, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XPoint *\fIpoints\fP\^;
+.br
+ int \fInpoints\fP\^;
+.br
+ int \fIshape\fP\^;
+.br
+ int \fImode\fP\^;
+.LP
+XFillArc\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIangle1\fP\^, \fIangle2\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ int \fIangle1\fP\^, \fIangle2\fP\^;
+.LP
+XFillArcs\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIarcs\fP\^, \fInarcs\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XArc *\fIarcs\fP\^;
+.br
+ int \fInarcs\fP\^;
+.SH ARGUMENTS
+.IP \fIangle1\fP 1i
+Specifies the start of the arc relative to the three-o'clock position
+from the center, in units of degrees * 64.
+.IP \fIangle2\fP 1i
+Specifies the path and extent of the arc relative to the start of the
+arc, in units of degrees * 64.
+.IP \fIarcs\fP 1i
+Specifies an array of arcs.
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fImode\fP 1i
+Specifies the coordinate mode.
+You can pass
+.ZN CoordModeOrigin
+or
+.ZN CoordModePrevious .
+.IP \fInarcs\fP 1i
+Specifies the number of arcs in the array.
+.IP \fInpoints\fP 1i
+Specifies the number of points in the array.
+.IP \fInrectangles\fP 1i
+Specifies the number of rectangles in the array.
+.IP \fIpoints\fP 1i
+Specifies an array of points.
+.IP \fIrectangles\fP 1i
+Specifies an array of rectangles.
+.IP \fIshape\fP 1i
+Specifies a shape that helps the server to improve performance.
+You can pass
+.ZN Complex ,
+.ZN Convex ,
+or
+.ZN Nonconvex .
+.ds Wh , which are the dimensions of the rectangle to be filled \
+or the major and minor axes of the arc
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which are relative to the origin of the drawable \
+and specify the upper-left corner of the rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XFillRectangle
+and
+.ZN XFillRectangles
+functions fill the specified rectangle or rectangles
+as if a four-point
+.ZN FillPolygon
+protocol request were specified for each rectangle:
+.LP
+.Ds
+[x,y] [x+width,y] [x+width,y+height] [x,y+height]
+.De
+.LP
+Each function uses the x and y coordinates,
+width and height dimensions, and GC you specify.
+.LP
+.ZN XFillRectangles
+fills the rectangles in the order listed in the array.
+For any given rectangle,
+.ZN XFillRectangle
+and
+.ZN XFillRectangles
+do not draw a pixel more than once.
+If rectangles intersect, the intersecting pixels are
+drawn multiple times.
+.LP
+Both functions use these GC components:
+function, plane-mask, fill-style, subwindow-mode,
+clip-x-origin, clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+and tile-stipple-y-origin.
+.LP
+.ZN XFillRectangle
+and
+.ZN XFillRectangles
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.LP
+.ZN XFillPolygon
+fills the region closed by the specified path.
+The path is closed
+automatically if the last point in the list does not coincide with the
+first point.
+.ZN XFillPolygon
+does not draw a pixel of the region more than once.
+.ZN CoordModeOrigin
+treats all coordinates as relative to the origin,
+and
+.ZN CoordModePrevious
+treats all coordinates after the first as relative to the previous point.
+.LP
+Depending on the specified shape, the following occurs:
+.IP \(bu 5
+If shape is
+.ZN Complex ,
+the path may self-intersect.
+Note that contiguous coincident points in the path are not treated
+as self-intersection.
+.IP \(bu 5
+If shape is
+.ZN Convex ,
+for every pair of points inside the polygon,
+the line segment connecting them does not intersect the path.
+If known by the client,
+specifying
+.ZN Convex
+can improve performance.
+If you specify
+.ZN Convex
+for a path that is not convex,
+the graphics results are undefined.
+.IP \(bu 5
+If shape is
+.ZN Nonconvex ,
+the path does not self-intersect, but the shape is not
+wholly convex.
+If known by the client,
+specifying
+.ZN Nonconvex
+instead of
+.ZN Complex
+may improve performance.
+If you specify
+.ZN Nonconvex
+for a self-intersecting path, the graphics results are undefined.
+.LP
+The fill-rule of the GC controls the filling behavior of
+self-intersecting polygons.
+.LP
+This function uses these GC components:
+function, plane-mask, fill-style, fill-rule, subwindow-mode, clip-x-origin,
+clip-y-origin, and clip-mask.
+It also uses these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+and tile-stipple-y-origin.
+.LP
+.ZN XFillPolygon
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.LP
+For each arc,
+.ZN XFillArc
+or
+.ZN XFillArcs
+fills the region closed by the infinitely thin path
+described by the specified arc and, depending on the
+arc-mode specified in the GC, one or two line segments.
+For
+.ZN ArcChord ,
+the single line segment joining the endpoints of the arc is used.
+For
+.ZN ArcPieSlice ,
+the two line segments joining the endpoints of the arc with the center
+point are used.
+.ZN XFillArcs
+fills the arcs in the order listed in the array.
+For any given arc,
+.ZN XFillArc
+and
+.ZN XFillArcs
+do not draw a pixel more than once.
+If regions intersect,
+the intersecting pixels are drawn multiple times.
+.LP
+Both functions use these GC components:
+function, plane-mask, fill-style, arc-mode, subwindow-mode, clip-x-origin,
+clip-y-origin, and clip-mask.
+They also use these GC mode-dependent components:
+foreground, background, tile, stipple, tile-stipple-x-origin,
+and tile-stipple-y-origin.
+.LP
+.ZN XFillArc
+and
+.ZN XFillArcs
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+and
+.ZN BadMatch
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XDrawArc(3X11),
+XDrawPoint(3X11),
+XDrawRectangle(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFilterEvent.man b/man/XFilterEvent.man
new file mode 100644
index 00000000..b915de33
--- /dev/null
+++ b/man/XFilterEvent.man
@@ -0,0 +1,188 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFilterEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFilterEvent \- filter X events for an input method
+.SH SYNTAX
+Bool XFilterEvent\^(\^\fIevent\fP\^, \fIw\fP\^)
+.br
+ XEvent *\fIevent\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.ds Ev event to filter
+.IP \fIevent\fP 1i
+Specifies the \*(Ev.
+.ds Wi for which the filter is to be applied
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+If the window argument is
+.ZN None ,
+.ZN XFilterEvent
+applies the filter to the window specified in the
+.ZN XEvent
+structure.
+The window argument is provided so that layers above Xlib
+that do event redirection can indicate to which window an event
+has been redirected.
+.LP
+If
+.ZN XFilterEvent
+returns
+.ZN True ,
+then some input method has filtered the event,
+and the client should discard the event.
+If
+.ZN XFilterEvent
+returns
+.ZN False ,
+then the client should continue processing the event.
+.LP
+If a grab has occurred in the client and
+.ZN XFilterEvent
+returns
+.ZN True ,
+the client should ungrab the keyboard.
+.SH "SEE ALSO"
+XNextEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFlush.man b/man/XFlush.man
new file mode 100644
index 00000000..f8d9bcaa
--- /dev/null
+++ b/man/XFlush.man
@@ -0,0 +1,274 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFlush 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFlush, XSync, XEventsQueued, XPending \- handle output buffer or event queue
+.SH SYNTAX
+XFlush\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XSync\^(\^\fIdisplay\fP, \fIdiscard\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Bool \fIdiscard\fP\^;
+.LP
+int XEventsQueued\^(\^\fIdisplay\fP, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fImode\fP\^;
+.LP
+int XPending\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdiscard\fP 1i
+Specifies a Boolean value that indicates whether
+.ZN XSync
+discards all events on the event queue.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fImode\fP 1i
+Specifies the mode.
+You can pass
+.ZN QueuedAlready ,
+.ZN QueuedAfterFlush ,
+or
+.ZN QueuedAfterReading .
+.SH DESCRIPTION
+The
+.ZN XFlush
+function
+flushes the output buffer.
+Most client applications need not use this function because the output
+buffer is automatically flushed as needed by calls to
+.ZN XPending ,
+.ZN XNextEvent ,
+and
+.ZN XWindowEvent .
+.IN "XPending"
+.IN "XNextEvent"
+.IN "XWindowEvent"
+Events generated by the server may be enqueued into the library's event queue.
+.LP
+The
+.ZN XSync
+function
+flushes the output buffer and then waits until all requests have been received
+and processed by the X server.
+Any errors generated must be handled by the error handler.
+For each protocol error received by Xlib,
+.ZN XSync
+calls the client application's error handling routine (see section 11.8.2).
+Any events generated by the server are enqueued into the library's
+event queue.
+.LP
+Finally, if you passed
+.ZN False ,
+.ZN XSync
+does not discard the events in the queue.
+If you passed
+.ZN True ,
+.ZN XSync
+discards all events in the queue,
+including those events that were on the queue before
+.ZN XSync
+was called.
+Client applications seldom need to call
+.ZN XSync .
+.LP
+If mode is
+.ZN QueuedAlready ,
+.ZN XEventsQueued
+returns the number of events
+already in the event queue (and never performs a system call).
+If mode is
+.ZN QueuedAfterFlush ,
+.ZN XEventsQueued
+returns the number of events already in the queue if the number is nonzero.
+If there are no events in the queue,
+.ZN XEventsQueued
+flushes the output buffer,
+attempts to read more events out of the application's connection,
+and returns the number read.
+If mode is
+.ZN QueuedAfterReading ,
+.ZN XEventsQueued
+returns the number of events already in the queue if the number is nonzero.
+If there are no events in the queue,
+.ZN XEventsQueued
+attempts to read more events out of the application's connection
+without flushing the output buffer and returns the number read.
+.LP
+.ZN XEventsQueued
+always returns immediately without I/O if there are events already in the
+queue.
+.ZN XEventsQueued
+with mode
+.ZN QueuedAfterFlush
+is identical in behavior to
+.ZN XPending .
+.ZN XEventsQueued
+with mode
+.ZN QueuedAlready
+is identical to the
+.ZN XQLength
+function.
+.LP
+The
+.ZN XPending
+function returns the number of events that have been received from the
+X server but have not been removed from the event queue.
+.ZN XPending
+is identical to
+.ZN XEventsQueued
+with the mode
+.ZN QueuedAfterFlush
+specified.
+.SH "SEE ALSO"
+AllPlanes(3X11),
+XIfEvent(3X11),
+XNextEvent(3X11),
+XPutBackEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFocusChangeEvent.man b/man/XFocusChangeEvent.man
new file mode 100644
index 00000000..ee35f5fc
--- /dev/null
+++ b/man/XFocusChangeEvent.man
@@ -0,0 +1,265 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFocusChangeEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFocusChangeEvent \- FocusIn and FocusOut event structure
+.SH STRUCTURES
+The structure for
+.ZN FocusIn
+and
+.ZN FocusOut
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* FocusIn or FocusOut */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* window of event */
+ int mode; /* NotifyNormal, NotifyGrab, NotifyUngrab */
+ int detail;
+ /*
+ * NotifyAncestor, NotifyVirtual, NotifyInferior,
+ * NotifyNonlinear,NotifyNonlinearVirtual, NotifyPointer,
+ * NotifyPointerRoot, NotifyDetailNone
+ */
+} XFocusChangeEvent;
+typedef XFocusChangeEvent XFocusInEvent;
+typedef XFocusChangeEvent XFocusOutEvent;
+.De
+.LP
+When you receive these events,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window on which the
+.ZN FocusIn
+or
+.ZN FocusOut
+event was generated.
+This is the window used by the X server to report the event.
+The mode member is set to indicate whether the focus events
+are normal focus events,
+focus events while grabbed,
+focus events
+when a grab activates, or focus events when a grab deactivates.
+The X server can set the mode member to
+.ZN NotifyNormal ,
+.ZN NotifyWhileGrabbed ,
+.ZN NotifyGrab ,
+or
+.ZN NotifyUngrab .
+.LP
+All
+.ZN FocusOut
+events caused by a window unmap are generated after any
+.ZN UnmapNotify
+event; however, the X protocol does not constrain the ordering of
+.ZN FocusOut
+events with respect to
+generated
+.ZN EnterNotify ,
+.ZN LeaveNotify ,
+.ZN VisibilityNotify ,
+and
+.ZN Expose
+events.
+.LP
+Depending on the event mode,
+the detail member is set to indicate the notify detail and can be
+.ZN NotifyAncestor ,
+.ZN NotifyVirtual ,
+.ZN NotifyInferior ,
+.ZN NotifyNonlinear ,
+.ZN NotifyNonlinearVirtual ,
+.ZN NotifyPointer ,
+.ZN NotifyPointerRoot ,
+or
+.ZN NotifyDetailNone .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFontSetExtents.man b/man/XFontSetExtents.man
new file mode 100644
index 00000000..8237b444
--- /dev/null
+++ b/man/XFontSetExtents.man
@@ -0,0 +1,192 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFontSetExtents 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFontSetExtents \- XFontSetExtents structure
+.SH STRUCTURES
+The
+.ZN XFontSetExtents
+structure contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ XRectangle max_ink_extent; /* over all drawable characters */
+ XRectangle max_logical_extent; /* over all drawable characters */
+} XFontSetExtents;
+.De
+.LP
+The
+.ZN XRectangle
+structures used to return font set metrics are the usual Xlib screen-oriented
+rectangles
+with x, y giving the upper left corner, and width and height always positive.
+.LP
+The max_ink_extent member gives the maximum extent, over all drawable characters, of
+the rectangles that bound the character glyph image drawn in the
+foreground color, relative to a constant origin.
+See
+.ZN XmbTextExtents
+and
+.ZN XwcTextExtents
+for detailed semantics.
+.LP
+The max_logical_extent member gives the maximum extent,
+over all drawable characters, of the rectangles
+that specify minimum spacing to other graphical features,
+relative to a constant origin.
+Other graphical features drawn by the client, for example,
+a border surrounding the text, should not intersect this rectangle.
+The max_logical_extent member should be used to compute minimum
+interline spacing and the minimum area that must be allowed
+in a text field to draw a given number of arbitrary characters.
+.LP
+Due to context-dependent rendering,
+appending a given character to a string may change
+the string's extent by an amount other than that character's
+individual extent.
+.SH "SEE ALSO"
+XCreateFontSet(3X11),
+XExtentsOfFontSet(3X11),
+XFontsOfFontSet(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFontsOfFontSet.man b/man/XFontsOfFontSet.man
new file mode 100644
index 00000000..3ed12222
--- /dev/null
+++ b/man/XFontsOfFontSet.man
@@ -0,0 +1,301 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFontsOfFontSet 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFontsOfFontSet, XBaseFontNameListOfFontSet, XLocaleOfFontSet, XContextDependentDrawing, XContextualDrawing, XDirectionalDependentDrawing \- obtain fontset information
+.SH SYNTAX
+int XFontsOfFontSet\^(\^\fIfont_set\fP\^, \fIfont_struct_list_return\fP\^, \fIfont_name_list_return\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ XFontStruct ***\fIfont_struct_list_return\fP\^;
+.br
+ char ***\fIfont_name_list_return\fP\^;
+.LP
+char *XBaseFontNameListOfFontSet\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.LP
+char *XLocaleOfFontSet\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.LP
+Bool XContextDependentDrawing\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.LP
+Bool XContextualDrawing\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.LP
+Bool XDirectionalDependentDrawing\^(\^\fIfont_set\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.SH ARGUMENTS
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fIfont_name_list_return\fP 1i
+Returns the list of font names.
+.IP \fIfont_struct_list_return\fP 1i
+Returns the list of font structs.
+.SH DESCRIPTION
+The
+.ZN XFontsOfFontSet
+function returns a list of one or more
+.ZN XFontStructs
+and font names for the fonts used by the Xmb and Xwc layers
+for the given font set.
+A list of pointers to the
+.ZN XFontStruct
+structures is returned to font_struct_list_return.
+A list of pointers to null-terminated, fully specified font name strings
+in the locale of the font set is returned to font_name_list_return.
+The font_name_list order corresponds to the font_struct_list order.
+The number of
+.ZN XFontStruct
+structures and font names is returned as the value of the function.
+.LP
+Because it is not guaranteed that a given character will be imaged using a
+single font glyph,
+there is no provision for mapping a character or default string
+to the font properties, font ID, or direction hint for the font
+for the character.
+The client may access the
+.ZN XFontStruct
+list to obtain these values for all the fonts currently in use.
+.LP
+Xlib does not guarantee that fonts are loaded from the server
+at the creation of an
+.ZN XFontSet .
+Xlib may choose to cache font data, loading it only as needed to draw text
+or compute text dimensions.
+Therefore, existence of the per_char metrics in the
+.ZN XFontStruct
+structures in the
+.ZN XFontStructSet
+is undefined.
+Also, note that all properties in the
+.ZN XFontStruct
+structures are in the STRING encoding.
+.LP
+The
+.ZN XFontStruct
+and font name lists are owned by Xlib
+and should not be modified or freed by the client.
+They will be freed by a call to
+.ZN XFreeFontSet
+with the associated
+.ZN XFontSet .
+Until freed, their contents will not be modified by Xlib.
+.LP
+The
+.ZN XBaseFontNameListOfFontSet
+function returns the original base font name list supplied
+by the client when the
+.ZN XFontSet
+was created.
+A null-terminated string containing a list of
+comma-separated font names is returned
+as the value of the function.
+White space may appear immediately on either side of separating commas.
+.LP
+If
+.ZN XCreateFontSet
+obtained an XLFD name from the font properties for the font specified
+by a non-XLFD base name, the
+.ZN XBaseFontNameListOfFontSet
+function will return the XLFD name instead of the non-XLFD base name.
+.LP
+The base font name list is owned by Xlib and should not be modified or
+freed by the client.
+It will be freed by a call to
+.ZN XFreeFontSet
+with the associated
+.ZN XFontSet .
+Until freed, its contents will not be modified by Xlib.
+.LP
+The
+.ZN XLocaleOfFontSet
+function
+returns the name of the locale bound to the specified
+.ZN XFontSet ,
+as a null-terminated string.
+.LP
+The returned locale name string is owned by Xlib
+and should not be modified or freed by the client.
+It may be freed by a call to
+.ZN XFreeFontSet
+with the associated
+.ZN XFontSet .
+Until freed, it will not be modified by Xlib.
+.LP
+The
+.ZN XContextDependentDrawing
+function returns
+.ZN True
+if the drawing functions implement implicit text directionality or
+if text drawn with the font_set might include context-dependent drawing;
+otherwise, it returns
+.ZN False .
+.LP
+The
+.ZN XContextualDrawing
+function returns
+.ZN True
+if text drawn with the font set might include context-dependent drawing;
+otherwise, it returns
+.ZN False .
+.LP
+The
+.ZN XDirectionalDependentDrawing
+function returns
+.ZN True
+if the drawing functions implement implicit text directionality;
+otherwise, it returns
+.ZN False .
+.SH "SEE ALSO"
+XCreateFontSet(3X11),
+XCreateOM(3X11),
+XCreateOC(3X11),
+XExtentsOfFontSet(3X11),
+XFontSetExtents(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XFree.man b/man/XFree.man
new file mode 100644
index 00000000..9e76a995
--- /dev/null
+++ b/man/XFree.man
@@ -0,0 +1,159 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XFree 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XFree \- free client data
+.SH SYNTAX
+XFree\^(\^\fIdata\fP\^)
+.br
+ void *\fIdata\fP\^;
+.SH ARGUMENTS
+.IP \fIdata\fP 1i
+Specifies the data that is to be freed.
+.SH DESCRIPTION
+The
+.ZN XFree
+function is a general-purpose Xlib routine that frees the specified data.
+You must use it to free any objects that were allocated by Xlib,
+unless an alternate function is explicitly specified for the object.
+A NULL pointer cannot be passed to this function.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XGetVisualInfo.man b/man/XGetVisualInfo.man
new file mode 100644
index 00000000..f92825a7
--- /dev/null
+++ b/man/XGetVisualInfo.man
@@ -0,0 +1,328 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XGetVisualInfo 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGetVisualInfo, XMatchVisualInfo, XVisualIDFromVisual, XVisualInfo \- obtain visual information and visual structure
+.SH SYNTAX
+XVisualInfo *XGetVisualInfo\^(\^\fIdisplay\fP, \fIvinfo_mask\fP, \fIvinfo_template\fP, \fInitems_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ long \fIvinfo_mask\fP\^;
+.br
+ XVisualInfo *\fIvinfo_template\fP\^;
+.br
+ int *\fInitems_return\fP\^;
+.LP
+Status XMatchVisualInfo\^(\^\fIdisplay\fP, \fIscreen\fP, \fIdepth\fP, \fIclass\fP, \fIvinfo_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIscreen\fP\^;
+.br
+ int \fIdepth\fP\^;
+.br
+ int \fIclass\fP\^;
+.br
+ XVisualInfo *\fIvinfo_return\fP\^;
+.LP
+VisualID XVisualIDFromVisual\^(\^\fIvisual\fP\^)
+.br
+ Visual *\^\fIvisual\fP\^;
+.SH ARGUMENTS
+.IP \fIclass\fP 1i
+Specifies the class of the screen.
+.IP \fIdepth\fP 1i
+Specifies the depth of the screen.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInitems_return\fP 1i
+Returns the number of matching visual structures.
+.IP \fIscreen\fP 1i
+Specifies the screen.
+.IP \fIvisual\fP 1i
+Specifies the visual type.
+.IP \fIvinfo_mask\fP 1i
+Specifies the visual mask value.
+.IP \fIvinfo_return\fP 1i
+Returns the matched visual information.
+.IP \fIvinfo_template\fP 1i
+Specifies the visual attributes that are to be used in matching the visual
+structures.
+.SH DESCRIPTION
+The
+.ZN XGetVisualInfo
+function returns a list of visual structures that have attributes
+equal to the attributes specified by vinfo_template.
+If no visual structures match the template using the specified vinfo_mask,
+.ZN XGetVisualInfo
+returns a NULL.
+To free the data returned by this function, use
+.ZN XFree .
+.LP
+The
+.ZN XMatchVisualInfo
+function returns the visual information for a visual that matches the specified
+depth and class for a screen.
+Because multiple visuals that match the specified depth and class can exist,
+the exact visual chosen is undefined.
+If a visual is found,
+.ZN XMatchVisualInfo
+returns nonzero and the information on the visual to vinfo_return.
+Otherwise, when a visual is not found,
+.ZN XMatchVisualInfo
+returns zero.
+.LP
+The
+.ZN XVisualIDFromVisual
+function returns the visual ID for the specified visual type.
+.SH STRUCTURES
+The
+.ZN XVisualInfo
+structure contains:
+.LP
+.LP
+/* Visual information mask bits */
+.TS
+lw(.5i) lw(2.5i) lw(.8i).
+T{
+#define
+T} T{
+.ZN VisualNoMask
+T} T{
+0x0
+T}
+T{
+#define
+T} T{
+.ZN VisualIDMask
+T} T{
+0x1
+T}
+T{
+#define
+T} T{
+.ZN VisualScreenMask
+T} T{
+0x2
+T}
+T{
+#define
+T} T{
+.ZN VisualDepthMask
+T} T{
+0x4
+T}
+T{
+#define
+T} T{
+.ZN VisualClassMask
+T} T{
+0x8
+T}
+T{
+#define
+T} T{
+.ZN VisualRedMaskMask
+T} T{
+0x10
+T}
+T{
+#define
+T} T{
+.ZN VisualGreenMaskMask
+T} T{
+0x20
+T}
+T{
+#define
+T} T{
+.ZN VisualBlueMaskMask
+T} T{
+0x40
+T}
+T{
+#define
+T} T{
+.ZN VisualColormapSizeMask
+T} T{
+0x80
+T}
+T{
+#define
+T} T{
+.ZN VisualBitsPerRGBMask
+T} T{
+0x100
+T}
+T{
+#define
+T} T{
+.ZN VisualAllMask
+T} T{
+0x1FF
+T}
+.TE
+.IN "XVisualInfo" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+/* Values */
+
+typedef struct {
+ Visual *visual;
+ VisualID visualid;
+ int screen;
+ unsigned int depth;
+ int class;
+ unsigned long red_mask;
+ unsigned long green_mask;
+ unsigned long blue_mask;
+ int colormap_size;
+ int bits_per_rgb;
+} XVisualInfo;
+.De
+.SH "SEE ALSO"
+XFree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGetWindowAttributes.man b/man/XGetWindowAttributes.man
new file mode 100644
index 00000000..10d34caf
--- /dev/null
+++ b/man/XGetWindowAttributes.man
@@ -0,0 +1,408 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XGetWindowAttributes 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGetWindowAttributes, XGetGeometry, XWindowAttributes \- get current window attribute or geometry and current window attributes structure
+.SH SYNTAX
+Status XGetWindowAttributes\^(\^\fIdisplay\fP, \fIw\fP\^, \fIwindow_attributes_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XWindowAttributes *\fIwindow_attributes_return\fP\^;
+.LP
+Status XGetGeometry\^(\^\fIdisplay\fP, \fId\fP\^, \^\fIroot_return\fP\^, \fIx_return\fP\^, \fIy_return\fP\^, \fIwidth_return\fP\^,
+.br
+ \fIheight_return\fP\^, \fIborder_width_return\fP\^, \fIdepth_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ Window *\fIroot_return\fP\^;
+.br
+ int *\fIx_return\fP\^, *\fIy_return\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP\^, *\fIheight_return\fP\^;
+.br
+ unsigned int *\fIborder_width_return\fP\^;
+.br
+ unsigned int *\fIdepth_return\fP\^;
+.SH ARGUMENTS
+.IP \fIborder_width_return\fP 1i
+Returns the border width in pixels.
+.ds Dr , which can be a window or a pixmap
+.IP \fId\fP 1i
+Specifies the drawable\*(Dr.
+.IP \fIdepth_return\fP 1i
+Returns the depth of the drawable (bits per pixel for the object).
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIroot_return\fP 1i
+Returns the root window.
+.ds Wi whose current attributes you want to obtain
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.IP \fIwidth_return\fP 1i
+.br
+.ns
+.IP \fIheight_return\fP 1i
+Return the drawable's dimensions (width and height).
+.IP \fIwindow_attributes_return\fP 1i
+Returns the specified window's attributes in the
+.ZN XWindowAttributes
+structure.
+.IP \fIx_return\fP 1i
+.br
+.ns
+.IP \fIy_return\fP 1i
+Return the x and y coordinates that define the location of the drawable.
+For a window,
+these coordinates specify the upper-left outer corner relative to
+its parent's origin.
+For pixmaps, these coordinates are always zero.
+.SH DESCRIPTION
+The
+.ZN XGetWindowAttributes
+function returns the current attributes for the specified window to an
+.ZN XWindowAttributes
+structure.
+.LP
+.ZN XGetWindowAttributes
+can generate
+.ZN BadDrawable
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetGeometry
+function returns the root window and the current geometry of the drawable.
+The geometry of the drawable includes the x and y coordinates, width and height,
+border width, and depth.
+These are described in the argument list.
+It is legal to pass to this function a window whose class is
+.ZN InputOnly .
+.SH STRUCTURES
+The
+.ZN XWindowAttributes
+structure contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int x, y; /* location of window */
+ int width, height; /* width and height of window */
+ int border_width; /* border width of window */
+ int depth; /* depth of window */
+ Visual *visual; /* the associated visual structure */
+ Window root; /* root of screen containing window */
+ int class; /* InputOutput, InputOnly*/
+ int bit_gravity; /* one of the bit gravity values */
+ int win_gravity; /* one of the window gravity values */
+ int backing_store; /* NotUseful, WhenMapped, Always */
+ unsigned long backing_planes; /* planes to be preserved if possible */
+ unsigned long backing_pixel; /* value to be used when restoring planes */
+ Bool save_under; /* boolean, should bits under be saved? */
+ Colormap colormap; /* color map to be associated with window */
+ Bool map_installed; /* boolean, is color map currently installed*/
+ int map_state; /* IsUnmapped, IsUnviewable, IsViewable */
+ long all_event_masks; /* set of events all people have interest in*/
+ long your_event_mask; /* my event mask */
+ long do_not_propagate_mask; /* set of events that should not propagate */
+ Bool override_redirect; /* boolean value for override-redirect */
+ Screen *screen; /* back pointer to correct screen */
+} XWindowAttributes;
+.De
+.LP
+The x and y members are set to the upper-left outer
+corner relative to the parent window's origin.
+The width and height members are set to the inside size of the window,
+not including the border.
+The border_width member is set to the window's border width in pixels.
+The depth member is set to the depth of the window
+(that is, bits per pixel for the object).
+The visual member is a pointer to the screen's associated
+.ZN Visual
+structure.
+The root member is set to the root window of the screen containing the window.
+The class member is set to the window's class and can be either
+.ZN InputOutput
+or
+.ZN InputOnly .
+.LP
+The bit_gravity member is set to the window's bit gravity
+and can be one of the following:
+.LP
+.TS
+lw(1.5i) lw(1.5i).
+T{
+.ZN ForgetGravity
+T} T{
+.ZN EastGravity
+T}
+T{
+.ZN NorthWestGravity
+T} T{
+.ZN SouthWestGravity
+T}
+T{
+.ZN NorthGravity
+T} T{
+.ZN SouthGravity
+T}
+T{
+.ZN NorthEastGravity
+T} T{
+.ZN SouthEastGravity
+T}
+T{
+.ZN WestGravity
+T} T{
+.ZN StaticGravity
+T}
+.ZN CenterGravity
+.TE
+.LP
+The win_gravity member is set to the window's window gravity
+and can be one of the following:
+.LP
+.TS
+lw(1.5i) lw(1.5i).
+T{
+.ZN UnmapGravity
+T} T{
+.ZN EastGravity
+T}
+T{
+.ZN NorthWestGravity
+T} T{
+.ZN SouthWestGravity
+T}
+T{
+.ZN NorthGravity
+T} T{
+.ZN SouthGravity
+T}
+T{
+.ZN NorthEastGravity
+T} T{
+.ZN SouthEastGravity
+T}
+T{
+.ZN WestGravity
+T} T{
+.ZN StaticGravity
+T}
+.ZN CenterGravity
+.TE
+.LP
+For additional information on gravity,
+see section 3.3.
+.LP
+The backing_store member is set to indicate how the X server should maintain
+the contents of a window
+and can be
+.ZN WhenMapped ,
+.ZN Always ,
+or
+.ZN NotUseful .
+The backing_planes member is set to indicate (with bits set to 1) which bit
+planes of the window hold dynamic data that must be preserved in backing_stores
+and during save_unders.
+The backing_pixel member is set to indicate what values to use
+for planes not set in backing_planes.
+.LP
+The save_under member is set to
+.ZN True
+or
+.ZN False .
+The colormap member is set to the colormap for the specified window and can be
+a colormap ID or
+.ZN None .
+The map_installed member is set to indicate whether the colormap is
+currently installed and can be
+.ZN True
+or
+.ZN False .
+The map_state member is set to indicate the state of the window and can be
+.ZN IsUnmapped ,
+.ZN IsUnviewable ,
+or
+.ZN IsViewable .
+.ZN IsUnviewable
+is used if the window is mapped but some ancestor is unmapped.
+.LP
+The all_event_masks member is set to the bitwise inclusive OR of all event
+masks selected on the window by all clients.
+The your_event_mask member is set to the bitwise inclusive OR of all event
+masks selected by the querying client.
+The do_not_propagate_mask member is set to the bitwise inclusive OR of the
+set of events that should not propagate.
+.LP
+The override_redirect member is set to indicate whether this window overrides
+structure control facilities and can be
+.ZN True
+or
+.ZN False .
+Window manager clients should ignore the window if this member is
+.ZN True .
+.LP
+The screen member is set to a screen pointer that gives you a back pointer
+to the correct screen.
+This makes it easier to obtain the screen information without
+having to loop over the root window fields to see which field matches.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XQueryPointer(3X11),
+XQueryTree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGetWindowProperty.man b/man/XGetWindowProperty.man
new file mode 100644
index 00000000..1926216e
--- /dev/null
+++ b/man/XGetWindowProperty.man
@@ -0,0 +1,521 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGetWindowProperty 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGetWindowProperty, XListProperties, XChangeProperty, XRotateWindowProperties, XDeleteProperty \- obtain and change window properties
+.SH SYNTAX
+int XGetWindowProperty\^(\^\fIdisplay\fP, \fIw\fP\^, \fIproperty\fP\^, \fIlong_offset\fP\^, \fIlong_length\fP\^, \fIdelete\fP\^, \fIreq_type\fP\^,
+.br
+ \fIactual_type_return\fP\^, \fIactual_format_return\fP\^, \fInitems_return\fP\^, \fIbytes_after_return\fP\^,
+.br
+ \fIprop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.br
+ long \fIlong_offset\fP\^, \fIlong_length\fP\^;
+.br
+ Bool \fIdelete\fP\^;
+.br
+ Atom \fIreq_type\fP\^;
+.br
+ Atom *\fIactual_type_return\fP\^;
+.br
+ int *\fIactual_format_return\fP\^;
+.br
+ unsigned long *\fInitems_return\fP\^;
+.br
+ unsigned long *\fIbytes_after_return\fP\^;
+.br
+ unsigned char **\fIprop_return\fP\^;
+.LP
+Atom *XListProperties\^(\^\fIdisplay\fP, \fIw\fP\^, \fInum_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int *\fInum_prop_return\fP\^;
+.LP
+XChangeProperty\^(\^\fIdisplay\fP, \fIw\fP\^, \fIproperty\fP\^, \fItype\fP\^, \fIformat\fP\^, \fImode\fP\^, \fIdata\fP\^, \fInelements\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom \fIproperty\fP\^, \fItype\fP\^;
+.br
+ int \fIformat\fP\^;
+.br
+ int \fImode\fP\^;
+.br
+ unsigned char *\fIdata\fP\^;
+.br
+ int \fInelements\fP\^;
+.LP
+XRotateWindowProperties\^(\^\fIdisplay\fP, \fIw\fP, \fIproperties\fP, \fInum_prop\fP, \fInpositions\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom \fIproperties\fP\^[]\^;
+.br
+ int \fInum_prop\fP\^;
+.br
+ int \fInpositions\fP\^;
+.LP
+XDeleteProperty\^(\^\fIdisplay\fP, \fIw\fP\^, \fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.SH ARGUMENTS
+.IP \fIactual_format_return\fP 1i
+Returns the actual format of the property.
+.IP \fIactual_type_return\fP 1i
+Returns the atom identifier that defines the actual type of the property.
+.IP \fIbytes_after_return\fP 1i
+Returns the number of bytes remaining to be read in the property if
+a partial read was performed.
+.IP \fIdata\fP 1i
+Specifies the property data.
+.IP \fIdelete\fP 1i
+Specifies a Boolean value that determines whether the property is deleted.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIformat\fP 1i
+Specifies whether the data should be viewed as a list
+of 8-bit, 16-bit, or 32-bit quantities.
+Possible values are 8, 16, and 32.
+This information allows the X server to correctly perform
+byte-swap operations as necessary.
+If the format is 16-bit or 32-bit,
+you must explicitly cast your data pointer to an (unsigned char *) in the call
+to
+.ZN XChangeProperty .
+.IP \fIlong_length\fP 1i
+Specifies the length in 32-bit multiples of the data to be retrieved.
+.IP \fIlong_offset\fP 1i
+Specifies the offset in the specified property (in 32-bit quantities)
+where the data is to be retrieved.
+.\" Changed name of this file to prop_mode.a on 1/13/87
+.IP \fImode\fP 1i
+Specifies the mode of the operation.
+You can pass
+.ZN PropModeReplace ,
+.ZN PropModePrepend ,
+or
+.ZN PropModeAppend .
+.IP \fInelements\fP 1i
+Specifies the number of elements of the specified data format.
+.IP \fInitems_return\fP 1i
+Returns the actual number of 8-bit, 16-bit, or 32-bit items
+stored in the prop_return data.
+.IP \fInum_prop\fP 1i
+Specifies the length of the properties array.
+.IP \fInum_prop_return\fP 1i
+Returns the length of the properties array.
+.IP \fInpositions\fP 1i
+Specifies the rotation amount.
+.IP \fIprop_return\fP 1i
+Returns the data in the specified format.
+.IP \fIproperty\fP 1i
+Specifies the property name.
+.IP \fIproperties\fP 1i
+Specifies the array of properties that are to be rotated.
+.IP \fIreq_type\fP 1i
+Specifies the atom identifier associated with the property type or
+.ZN AnyPropertyType .
+.IP \fItype\fP 1i
+Specifies the type of the property.
+The X server does not interpret the type but simply
+passes it back to an application that later calls
+.ZN XGetWindowProperty .
+.ds Wi whose property you want to obtain, change, rotate or delete
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XGetWindowProperty
+function returns the actual type of the property; the actual format of the property;
+the number of 8-bit, 16-bit, or 32-bit items transferred; the number of bytes remaining
+to be read in the property; and a pointer to the data actually returned.
+.ZN XGetWindowProperty
+sets the return arguments as follows:
+.IP \(bu 5
+If the specified property does not exist for the specified window,
+.ZN XGetWindowProperty
+returns
+.ZN None
+to actual_type_return and the value zero to
+actual_format_return and bytes_after_return.
+The nitems_return argument is empty.
+In this case, the delete argument is ignored.
+.IP \(bu 5
+If the specified property exists
+but its type does not match the specified type,
+.ZN XGetWindowProperty
+returns the actual property type to actual_type_return,
+the actual property format (never zero) to actual_format_return,
+and the property length in bytes
+(even if the actual_format_return is 16 or 32)
+to bytes_after_return.
+It also ignores the delete argument.
+The nitems_return argument is empty.
+.IP \(bu 5
+If the specified property exists and either you assign
+.ZN AnyPropertyType
+to the req_type argument or the specified type matches the actual property type,
+.ZN XGetWindowProperty
+returns the actual property type to actual_type_return and the actual
+property format (never zero) to actual_format_return.
+It also returns a value to bytes_after_return and nitems_return, by
+defining the following
+values:
+.IP
+.nf
+ N = actual length of the stored property in bytes
+ (even if the format is 16 or 32)
+ I = 4 * long_offset
+ T = N - I
+ L = MINIMUM(T, 4 * long_length)
+ A = N - (I + L)
+.fi
+.IP
+The returned value starts at byte index I in the property (indexing
+from zero), and its length in bytes is L.
+If the value for long_offset causes L to be negative,
+a
+.ZN BadValue
+error results.
+The value of bytes_after_return is A,
+giving the number of trailing unread bytes in the stored property.
+.LP
+If the returned format is 8, the returned data is represented as a
+.ZN char
+array.
+If the returned format is 16, the returned data is represented as a
+.ZN short
+array and should be cast to that type to obtain the elements.
+If the returned format is 32, the returned data is represented as a
+.ZN long
+array and should be cast to that type to obtain the elements.
+.LP
+.ZN XGetWindowProperty
+always allocates one extra byte in prop_return
+(even if the property is zero length)
+and sets it to zero so that simple properties consisting of characters
+do not have to be copied into yet another string before use.
+.LP
+If delete is
+.ZN True
+and bytes_after_return is zero,
+.ZN XGetWindowProperty
+deletes the property
+from the window and generates a
+.ZN PropertyNotify
+event on the window.
+.LP
+The function returns
+.ZN Success
+if it executes successfully.
+To free the resulting data,
+use
+.ZN XFree .
+.LP
+.ZN XGetWindowProperty
+can generate
+.ZN BadAtom ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XListProperties
+function returns a pointer to an array of atom properties that are defined for
+the specified window or returns NULL if no properties were found.
+To free the memory allocated by this function, use
+.ZN XFree .
+.LP
+.ZN XListProperties
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XChangeProperty
+function alters the property for the specified window and
+causes the X server to generate a
+.ZN PropertyNotify
+event on that window.
+.ZN XChangeProperty
+performs the following:
+.IP \(bu 5
+If mode is
+.ZN PropModeReplace ,
+.ZN XChangeProperty
+discards the previous property value and stores the new data.
+.IP \(bu 5
+If mode is
+.ZN PropModePrepend
+or
+.ZN PropModeAppend ,
+.ZN XChangeProperty
+inserts the specified data before the beginning of the existing data
+or onto the end of the existing data, respectively.
+The type and format must match the existing property value,
+or a
+.ZN BadMatch
+error results.
+If the property is undefined,
+it is treated as defined with the correct type and
+format with zero-length data.
+.LP
+If the specified format is 8, the property data must be a
+.ZN char
+array.
+If the specified format is 16, the property data must be a
+.ZN short
+array.
+If the specified format is 32, the property data must be a
+.ZN long
+array.
+.LP
+The lifetime of a property is not tied to the storing client.
+Properties remain until explicitly deleted, until the window is destroyed,
+or until the server resets.
+For a discussion of what happens when the connection to the X server is closed,
+see section 2.6.
+The maximum size of a property is server dependent and can vary dynamically
+depending on the amount of memory the server has available.
+(If there is insufficient space, a
+.ZN BadAlloc
+error results.)
+.LP
+.ZN XChangeProperty
+can generate
+.ZN BadAlloc ,
+.ZN BadAtom ,
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XRotateWindowProperties
+function allows you to rotate properties on a window and causes
+the X server to generate
+.ZN PropertyNotify
+events.
+If the property names in the properties array are viewed as being numbered
+starting from zero and if there are num_prop property names in the list,
+then the value associated with property name I becomes the value associated
+with property name (I + npositions) mod N for all I from zero to N \- 1.
+The effect is to rotate the states by npositions places around the virtual ring
+of property names (right for positive npositions,
+left for negative npositions).
+If npositions mod N is nonzero,
+the X server generates a
+.ZN PropertyNotify
+event for each property in the order that they are listed in the array.
+If an atom occurs more than once in the list or no property with that
+name is defined for the window,
+a
+.ZN BadMatch
+error results.
+If a
+.ZN BadAtom
+or
+.ZN BadMatch
+error results,
+no properties are changed.
+.LP
+.ZN XRotateWindowProperties
+can generate
+.ZN BadAtom ,
+.ZN BadMatch ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XDeleteProperty
+function deletes the specified property only if the
+property was defined on the specified window
+and causes the X server to generate a
+.ZN PropertyNotify
+event on the window unless the property does not exist.
+.LP
+.ZN XDeleteProperty
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XFree(3X11),
+XInternAtom(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGrabButton.man b/man/XGrabButton.man
new file mode 100644
index 00000000..ce1cb120
--- /dev/null
+++ b/man/XGrabButton.man
@@ -0,0 +1,330 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGrabButton 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGrabButton, XUngrabButton \- grab pointer buttons
+.SH SYNTAX
+XGrabButton\^(\^\fIdisplay\fP, \fIbutton\fP\^, \fImodifiers\fP\^, \fIgrab_window\fP\^, \fIowner_events\fP\^, \fIevent_mask\fP\^,
+.br
+ \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^, \fIconfine_to\fP\^, \fIcursor\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned int \fIbutton\fP\^;
+.br
+ unsigned int \fImodifiers\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.br
+ Bool \fIowner_events\fP\^;
+.br
+ unsigned int \fIevent_mask\fP\^;
+.br
+ int \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^;
+.br
+ Window \fIconfine_to\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.LP
+XUngrabButton\^(\^\fIdisplay\fP, \fIbutton\fP\^, \fImodifiers\fP\^, \fIgrab_window\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned int \fIbutton\fP\^;
+.br
+ unsigned int \fImodifiers\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.SH ARGUMENTS
+.ds Bu grabbed or released
+.IP \fIbutton\fP 1i
+Specifies the pointer button that is to be \*(Bu or
+.ZN AnyButton .
+.IP \fIconfine_to\fP 1i
+Specifies the window to confine the pointer in or
+.ZN None .
+.IP \fIcursor\fP 1i
+Specifies the cursor that is to be displayed or
+.ZN None .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies which pointer events are reported to the client.
+The mask is the bitwise inclusive OR of the valid pointer event mask bits.
+.IP \fIgrab_window\fP 1i
+Specifies the grab window.
+.IP \fIkeyboard_mode\fP 1i
+Specifies further processing of keyboard events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fImodifiers\fP 1i
+Specifies the set of keymasks or
+.ZN AnyModifier .
+The mask is the bitwise inclusive OR of the valid keymask bits.
+.IP \fIowner_events\fP 1i
+Specifies a Boolean value that indicates whether the pointer
+events are to be reported as usual or reported with respect to the grab window
+if selected by the event mask.
+.IP \fIpointer_mode\fP 1i
+Specifies further processing of pointer events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.SH DESCRIPTION
+The
+.ZN XGrabButton
+function establishes a passive grab.
+In the future,
+the pointer is actively grabbed (as for
+.ZN XGrabPointer ),
+the last-pointer-grab time is set to the time at which the button was pressed
+(as transmitted in the
+.ZN ButtonPress
+event), and the
+.ZN ButtonPress
+event is reported if all of the following conditions are true:
+.IP \(bu 5
+The pointer is not grabbed, and the specified button is logically pressed
+when the specified modifier keys are logically down,
+and no other buttons or modifier keys are logically down.
+.IP \(bu 5
+The grab_window contains the pointer.
+.IP \(bu 5
+The confine_to window (if any) is viewable.
+.IP \(bu 5
+A passive grab on the same button/key combination does not exist
+on any ancestor of grab_window.
+.LP
+The interpretation of the remaining arguments is as for
+.ZN XGrabPointer .
+The active grab is terminated automatically when the logical state of the
+pointer has all buttons released
+(independent of the state of the logical modifier keys).
+.LP
+Note that the logical state of a device (as seen by client applications)
+may lag the physical state if device event processing is frozen.
+.LP
+This request overrides all previous grabs by the same client on the same
+button/key combinations on the same window.
+A modifiers of
+.ZN AnyModifier
+is equivalent to issuing the grab request for all
+possible modifier combinations (including the combination of no modifiers).
+It is not required that all modifiers specified have currently assigned
+KeyCodes.
+A button of
+.ZN AnyButton
+is equivalent to
+issuing the request for all possible buttons.
+Otherwise, it is not required that the specified button currently be assigned
+to a physical button.
+.LP
+If some other client has already issued a
+.ZN XGrabButton
+with the same button/key combination on the same window, a
+.ZN BadAccess
+error results.
+When using
+.ZN AnyModifier
+or
+.ZN AnyButton ,
+the request fails completely,
+and a
+.ZN BadAccess
+error results (no grabs are
+established) if there is a conflicting grab for any combination.
+.ZN XGrabButton
+has no effect on an active grab.
+.LP
+.ZN XGrabButton
+can generate
+.ZN BadCursor ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XUngrabButton
+function releases the passive button/key combination on the specified window if
+it was grabbed by this client.
+A modifiers of
+.ZN AnyModifier
+is
+equivalent to issuing
+the ungrab request for all possible modifier combinations, including
+the combination of no modifiers.
+A button of
+.ZN AnyButton
+is equivalent to issuing the
+request for all possible buttons.
+.ZN XUngrabButton
+has no effect on an active grab.
+.LP
+.ZN XUngrabButton
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllowEvents(3X11),
+XGrabPointer(3X11),
+XGrabKey(3X11),
+XGrabKeyboard(3X11),
+.br
+\fI\*(xL\fP
diff --git a/man/XGrabKey.man b/man/XGrabKey.man
new file mode 100644
index 00000000..f9b3f6a5
--- /dev/null
+++ b/man/XGrabKey.man
@@ -0,0 +1,312 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGrabKey 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGrabKey, XUngrabKey \- grab keyboard keys
+.SH SYNTAX
+XGrabKey\^(\^\fIdisplay\fP, \fIkeycode\fP\^, \fImodifiers\fP\^, \fIgrab_window\fP\^, \fIowner_events\fP\^, \fIpointer_mode\fP\^,
+.br
+ \fIkeyboard_mode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIkeycode\fP\^;
+.br
+ unsigned int \fImodifiers\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.br
+ Bool \fIowner_events\fP\^;
+.br
+ int \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^;
+.LP
+XUngrabKey\^(\^\fIdisplay\fP, \fIkeycode\fP\^, \fImodifiers\fP\^, \fIgrab_window\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIkeycode\fP\^;
+.br
+ unsigned int \fImodifiers\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgrab_window\fP 1i
+Specifies the grab window.
+.IP \fIkeyboard_mode\fP 1i
+Specifies further processing of keyboard events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fIkeycode\fP 1i
+Specifies the KeyCode or
+.ZN AnyKey .
+.IP \fImodifiers\fP 1i
+Specifies the set of keymasks or
+.ZN AnyModifier .
+The mask is the bitwise inclusive OR of the valid keymask bits.
+.IP \fIowner_events\fP 1i
+Specifies a Boolean value that indicates whether the keyboard events
+are to be reported as usual.
+.IP \fIpointer_mode\fP 1i
+Specifies further processing of pointer events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.SH DESCRIPTION
+The
+.ZN XGrabKey
+function establishes a passive grab on the keyboard.
+In the future,
+the keyboard is actively grabbed (as for
+.ZN XGrabKeyboard ),
+the last-keyboard-grab time is set to the time at which the key was pressed
+(as transmitted in the
+.ZN KeyPress
+event), and the
+.ZN KeyPress
+event is reported if all of the following conditions are true:
+.IP \(bu 5
+The keyboard is not grabbed and the specified key
+(which can itself be a modifier key) is logically pressed
+when the specified modifier keys are logically down,
+and no other modifier keys are logically down.
+.IP \(bu 5
+Either the grab_window is an ancestor of (or is) the focus window,
+or the grab_window is a descendant of the focus window and contains the pointer.
+.IP \(bu 5
+A passive grab on the same key combination does not exist
+on any ancestor of grab_window.
+.LP
+The interpretation of the remaining arguments is as for
+.ZN XGrabKeyboard .
+The active grab is terminated automatically when the logical state of the
+keyboard has the specified key released
+(independent of the logical state of the modifier keys).
+.LP
+Note that the logical state of a device (as seen by client applications)
+may lag the physical state if device event processing is frozen.
+.LP
+A modifiers argument of
+.ZN AnyModifier
+is equivalent to issuing the request for all
+possible modifier combinations (including the combination of no
+modifiers).
+It is not required that all modifiers specified have
+currently assigned KeyCodes.
+A keycode argument of
+.ZN AnyKey
+is equivalent to issuing
+the request for all possible KeyCodes.
+Otherwise, the specified keycode must be in
+the range specified by min_keycode and max_keycode in the connection
+setup,
+or a
+.ZN BadValue
+error results.
+.LP
+If some other client has issued a
+.ZN XGrabKey
+with the same key combination on the same window, a
+.ZN BadAccess
+error results.
+When using
+.ZN AnyModifier
+or
+.ZN AnyKey ,
+the request fails completely,
+and a
+.ZN BadAccess
+error results (no grabs are established)
+if there is a conflicting grab for any combination.
+.LP
+.ZN XGrabKey
+can generate
+.ZN BadAccess ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XUngrabKey
+function releases the key combination on the specified window if it was grabbed
+by this client.
+It has no effect on an active grab.
+A modifiers of
+.ZN AnyModifier
+is equivalent to issuing
+the request for all possible modifier combinations
+(including the combination of no modifiers).
+A keycode argument of
+.ZN AnyKey
+is equivalent to issuing the request for all possible key codes.
+.LP
+.ZN XUngrabKey
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to grab a key/button combination already grabbed by another client.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllowAccess(3X11),
+XGrabButton(3X11),
+XGrabKeyboard(3X11),
+XGrabPointer(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGrabKeyboard.man b/man/XGrabKeyboard.man
new file mode 100644
index 00000000..c7694e92
--- /dev/null
+++ b/man/XGrabKeyboard.man
@@ -0,0 +1,307 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGrabKeyboard 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGrabKeyboard, XUngrabKeyboard \- grab the keyboard
+.SH SYNTAX
+int XGrabKeyboard\^(\^\fIdisplay\fP, \fIgrab_window\fP\^, \fIowner_events\fP\^, \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.br
+ Bool \fIowner_events\fP\^;
+.br
+ int \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^;
+.br
+ Time \fItime\fP\^;
+.LP
+XUngrabKeyboard\^(\^\fIdisplay\fP, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Time \fItime\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgrab_window\fP 1i
+Specifies the grab window.
+.IP \fIkeyboard_mode\fP 1i
+Specifies further processing of keyboard events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fIowner_events\fP 1i
+Specifies a Boolean value that indicates whether the keyboard events
+are to be reported as usual.
+.IP \fIpointer_mode\fP 1i
+Specifies further processing of pointer events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fItime\fP 1i
+Specifies the time.
+You can pass either a timestamp or
+.ZN CurrentTime .
+.SH DESCRIPTION
+The
+.ZN XGrabKeyboard
+function actively grabs control of the keyboard and generates
+.ZN FocusIn
+and
+.ZN FocusOut
+events.
+Further key events are reported only to the
+grabbing client.
+.ZN XGrabKeyboard
+overrides any active keyboard grab by this client.
+If owner_events is
+.ZN False ,
+all generated key events are reported with
+respect to grab_window.
+If owner_events is
+.ZN True
+and if a generated
+key event would normally be reported to this client, it is reported
+normally; otherwise, the event is reported with respect to the
+grab_window.
+Both
+.ZN KeyPress
+and
+.ZN KeyRelease
+events are always reported,
+independent of any event selection made by the client.
+.LP
+If the keyboard_mode argument is
+.ZN GrabModeAsync ,
+keyboard event processing continues
+as usual.
+If the keyboard is currently frozen by this client,
+then processing of keyboard events is resumed.
+If the keyboard_mode argument is
+.ZN GrabModeSync ,
+the state of the keyboard (as seen by client applications) appears to freeze,
+and the X server generates no further keyboard events until the
+grabbing client issues a releasing
+.ZN XAllowEvents
+call or until the keyboard grab is released.
+Actual keyboard changes are not lost while the keyboard is frozen;
+they are simply queued in the server for later processing.
+.LP
+If pointer_mode is
+.ZN GrabModeAsync ,
+pointer event processing is unaffected
+by activation of the grab.
+If pointer_mode is
+.ZN GrabModeSync ,
+the state of the pointer (as seen by client applications) appears to freeze,
+and the X server generates no further pointer events
+until the grabbing client issues a releasing
+.ZN XAllowEvents
+call or until the keyboard grab is released.
+Actual pointer changes are not lost while the pointer is frozen;
+they are simply queued in the server for later processing.
+.LP
+If the keyboard is actively grabbed by some other client,
+.ZN XGrabKeyboard
+fails and returns
+.ZN AlreadyGrabbed .
+If grab_window is not viewable,
+it fails and returns
+.ZN GrabNotViewable .
+If the keyboard is frozen by an active grab of another client,
+it fails and returns
+.ZN GrabFrozen .
+If the specified time is earlier than the last-keyboard-grab time
+or later than the current X server time,
+it fails and returns
+.ZN GrabInvalidTime .
+Otherwise, the last-keyboard-grab time is set to the specified time
+.Pn ( CurrentTime
+is replaced by the current X server time).
+.LP
+.ZN XGrabKeyboard
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XUngrabKeyboard
+function
+releases the keyboard and any queued events if this client has it actively grabbed from
+either
+.ZN XGrabKeyboard
+or
+.ZN XGrabKey .
+.ZN XUngrabKeyboard
+does not release the keyboard and any queued events
+if the specified time is earlier than
+the last-keyboard-grab time or is later than the current X server time.
+It also generates
+.ZN FocusIn
+and
+.ZN FocusOut
+events.
+The X server automatically performs an
+.ZN UngrabKeyboard
+request if the event window for an
+active keyboard grab becomes not viewable.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllowEvents(3X11),
+XGrabButton(3X11),
+XGrabKey(3X11),
+XGrabPointer(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGrabPointer.man b/man/XGrabPointer.man
new file mode 100644
index 00000000..4a6e58dd
--- /dev/null
+++ b/man/XGrabPointer.man
@@ -0,0 +1,388 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGrabPointer 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGrabPointer, XUngrabPointer, XChangeActivePointerGrab \- grab the pointer
+.SH SYNTAX
+int XGrabPointer\^(\^\fIdisplay\fP, \fIgrab_window\fP\^, \fIowner_events\fP\^, \fIevent_mask\fP\^, \fIpointer_mode\fP\^,
+ \fIkeyboard_mode\fP\^, \fIconfine_to\fP\^, \fIcursor\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIgrab_window\fP\^;
+.br
+ Bool \fIowner_events\fP\^;
+.br
+ unsigned int \fIevent_mask\fP\^;
+.br
+ int \fIpointer_mode\fP\^, \fIkeyboard_mode\fP\^;
+.br
+ Window \fIconfine_to\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.br
+ Time \fItime\fP\^;
+.LP
+XUngrabPointer\^(\^\fIdisplay\fP, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Time \fItime\fP\^;
+.LP
+XChangeActivePointerGrab\^(\^\fIdisplay\fP, \fIevent_mask\fP\^, \fIcursor\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned int \fIevent_mask\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.br
+ Time \fItime\fP\^;
+.SH ARGUMENTS
+.IP \fIconfine_to\fP 1i
+Specifies the window to confine the pointer in or
+.ZN None .
+.IP \fIcursor\fP 1i
+Specifies the cursor that is to be displayed during the grab or
+.ZN None .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies which pointer events are reported to the client.
+The mask is the bitwise inclusive OR of the valid pointer event mask bits.
+.IP \fIgrab_window\fP 1i
+Specifies the grab window.
+.IP \fIkeyboard_mode\fP 1i
+Specifies further processing of keyboard events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fIowner_events\fP 1i
+Specifies a Boolean value that indicates whether the pointer
+events are to be reported as usual or reported with respect to the grab window
+if selected by the event mask.
+.IP \fIpointer_mode\fP 1i
+Specifies further processing of pointer events.
+You can pass
+.ZN GrabModeSync
+or
+.ZN GrabModeAsync .
+.IP \fItime\fP 1i
+Specifies the time.
+You can pass either a timestamp or
+.ZN CurrentTime .
+.SH DESCRIPTION
+The
+.ZN XGrabPointer
+function actively grabs control of the pointer and returns
+.ZN GrabSuccess
+if the grab was successful.
+Further pointer events are reported only to the grabbing client.
+.ZN XGrabPointer
+overrides any active pointer grab by this client.
+If owner_events is
+.ZN False ,
+all generated pointer events
+are reported with respect to grab_window and are reported only if
+selected by event_mask.
+If owner_events is
+.ZN True
+and if a generated
+pointer event would normally be reported to this client,
+it is reported as usual.
+Otherwise, the event is reported with respect to the
+grab_window and is reported only if selected by event_mask.
+For either value of owner_events, unreported events are discarded.
+.LP
+If the pointer_mode is
+.ZN GrabModeAsync ,
+pointer event processing continues as usual.
+If the pointer is currently frozen by this client,
+the processing of events for the pointer is resumed.
+If the pointer_mode is
+.ZN GrabModeSync ,
+the state of the pointer, as seen by
+client applications,
+appears to freeze, and the X server generates no further pointer events
+until the grabbing client calls
+.ZN XAllowEvents
+or until the pointer grab is released.
+Actual pointer changes are not lost while the pointer is frozen;
+they are simply queued in the server for later processing.
+.LP
+If the keyboard_mode is
+.ZN GrabModeAsync ,
+keyboard event processing is unaffected by activation of the grab.
+If the keyboard_mode is
+.ZN GrabModeSync ,
+the state of the keyboard, as seen by
+client applications,
+appears to freeze, and the X server generates no further keyboard events
+until the grabbing client calls
+.ZN XAllowEvents
+or until the pointer grab is released.
+Actual keyboard changes are not lost while the pointer is frozen;
+they are simply queued in the server for later processing.
+.LP
+If a cursor is specified, it is displayed regardless of what
+window the pointer is in.
+If
+.ZN None
+is specified,
+the normal cursor for that window is displayed
+when the pointer is in grab_window or one of its subwindows;
+otherwise, the cursor for grab_window is displayed.
+.LP
+If a confine_to window is specified,
+the pointer is restricted to stay contained in that window.
+The confine_to window need have no relationship to the grab_window.
+If the pointer is not initially in the confine_to window,
+it is warped automatically to the closest edge
+just before the grab activates and enter/leave events are generated as usual.
+If the confine_to window is subsequently reconfigured,
+the pointer is warped automatically, as necessary,
+to keep it contained in the window.
+.LP
+The time argument allows you to avoid certain circumstances that come up
+if applications take a long time to respond or if there are long network
+delays.
+Consider a situation where you have two applications, both
+of which normally grab the pointer when clicked on.
+If both applications specify the timestamp from the event,
+the second application may wake up faster and successfully grab the pointer
+before the first application.
+The first application then will get an indication that the other application
+grabbed the pointer before its request was processed.
+.LP
+.ZN XGrabPointer
+generates
+.ZN EnterNotify
+and
+.ZN LeaveNotify
+events.
+.LP
+Either if grab_window or confine_to window is not viewable
+or if the confine_to window lies completely outside the boundaries of the root
+window,
+.ZN XGrabPointer
+fails and returns
+.ZN GrabNotViewable .
+If the pointer is actively grabbed by some other client,
+it fails and returns
+.ZN AlreadyGrabbed .
+If the pointer is frozen by an active grab of another client,
+it fails and returns
+.ZN GrabFrozen .
+If the specified time is earlier than the last-pointer-grab time or later
+than the current X server time, it fails and returns
+.ZN GrabInvalidTime .
+Otherwise, the last-pointer-grab time is set to the specified time
+.Pn ( CurrentTime
+is replaced by the current X server time).
+.LP
+.ZN XGrabPointer
+can generate
+.ZN BadCursor ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XUngrabPointer
+function releases the pointer and any queued events
+if this client has actively grabbed the pointer from
+.ZN XGrabPointer ,
+.ZN XGrabButton ,
+or from a normal button press.
+.ZN XUngrabPointer
+does not release the pointer if the specified
+time is earlier than the last-pointer-grab time or is later than the
+current X server time.
+It also generates
+.ZN EnterNotify
+and
+.ZN LeaveNotify
+events.
+The X server performs an
+.ZN UngrabPointer
+request automatically if the event window or confine_to window
+for an active pointer grab becomes not viewable
+or if window reconfiguration causes the confine_to window to lie completely
+outside the boundaries of the root window.
+.LP
+The
+.ZN XChangeActivePointerGrab
+function changes the specified dynamic parameters if the pointer is actively
+grabbed by the client and if the specified time is no earlier than the
+last-pointer-grab time and no later than the current X server time.
+This function has no effect on the passive parameters of a
+.ZN XGrabButton .
+The interpretation of event_mask and cursor is the same as described in
+.ZN XGrabPointer .
+.LP
+.ZN XChangeActivePointerGrab
+can generate a
+.ZN BadCursor
+and
+.ZN BadValue
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllowEvents(3X11),
+XGrabButton(3X11),
+XGrabKey(3X11),
+XGrabKeyboard(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGrabServer.man b/man/XGrabServer.man
new file mode 100644
index 00000000..b75b4c7a
--- /dev/null
+++ b/man/XGrabServer.man
@@ -0,0 +1,172 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGrabServer 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGrabServer, XUngrabServer \- grab the server
+.SH SYNTAX
+XGrabServer\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XUngrabServer\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.SH DESCRIPTION
+The
+.ZN XGrabServer
+function disables processing of requests and close downs on all other
+connections than the one this request arrived on.
+You should not grab the X server any more than is absolutely necessary.
+.LP
+The
+.ZN XUngrabServer
+function restarts processing of requests and close downs on other connections.
+You should avoid grabbing the X server as much as possible.
+.SH "SEE ALSO"
+XGrabButton(3X11),
+XGrabKey(3X11),
+XGrabKeyboard(3X11),
+XGrabPointer(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGraphicsExposeEvent.man b/man/XGraphicsExposeEvent.man
new file mode 100644
index 00000000..f5399303
--- /dev/null
+++ b/man/XGraphicsExposeEvent.man
@@ -0,0 +1,275 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGraphicsExposeEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGraphicsExposeEvent, XNoExposeEvent \- GraphicsExpose and NoExpose event structures
+.SH STRUCTURES
+The structures for
+.ZN GraphicsExpose
+and
+.ZN NoExpose
+events contain:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* GraphicsExpose */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int x, y;
+ int width, height;
+ int count; /* if nonzero, at least this many more */
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XGraphicsExposeEvent;
+.De
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* NoExpose */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Drawable drawable;
+ int major_code; /* core is CopyArea or CopyPlane */
+ int minor_code; /* not defined in the core */
+} XNoExposeEvent;
+.De
+.LP
+When you receive these events,
+their structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+Both structures have these common members: drawable, major_code, and minor_code.
+The drawable member is set to the drawable of the destination region on
+which the graphics request was to be performed.
+The major_code member is set to the graphics request initiated by the client
+and can be either
+.ZN X_CopyArea
+or
+.ZN X_CopyPlane .
+If it is
+.ZN X_CopyArea ,
+a call to
+.ZN XCopyArea
+initiated the request.
+If it is
+.ZN X_CopyPlane ,
+a call to
+.ZN XCopyPlane
+initiated the request.
+These constants are defined in
+.hN X11/Xproto.h .
+The minor_code member,
+like the major_code member,
+indicates which graphics request was initiated by
+the client.
+However, the minor_code member is not defined by the core
+X protocol and will be zero in these cases,
+although it may be used by an extension.
+.LP
+The
+.ZN XGraphicsExposeEvent
+structure has these additional members: x, y, width, height, and count.
+The x and y members are set to the coordinates relative to the drawable's origin
+and indicate the upper-left corner of the rectangle.
+The width and height members are set to the size (extent) of the rectangle.
+The count member is set to the number of
+.ZN GraphicsExpose
+events to follow.
+If count is zero, no more
+.ZN GraphicsExpose
+events follow for this window.
+However, if count is nonzero, at least that number of
+.ZN GraphicsExpose
+events (and possibly more) are to follow for this window.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCopyArea(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XGravityEvent.man b/man/XGravityEvent.man
new file mode 100644
index 00000000..b4d4f56b
--- /dev/null
+++ b/man/XGravityEvent.man
@@ -0,0 +1,223 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XGravityEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XGravityEvent \- GravityNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN GravityNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* GravityNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ int x, y;
+} XGravityEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the window that was moved or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the child window that was moved.
+The x and y members are set to the coordinates relative to the
+new parent window's origin
+and indicate the position of the upper-left outside corner of the
+window.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XIconifyWindow.man b/man/XIconifyWindow.man
new file mode 100644
index 00000000..fff3572b
--- /dev/null
+++ b/man/XIconifyWindow.man
@@ -0,0 +1,273 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XIconifyWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XIconifyWindow, XWithdrawWindow, XReconfigureWMWindow \- manipulate top-level windows
+.SH SYNTAX
+Status XIconifyWindow\^(\^\fIdisplay\fP, \fIw\fP, \fIscreen_number\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP;
+.br
+ int \fIscreen_number\fP\^;
+.LP
+Status XWithdrawWindow\^(\^\fIdisplay\fP, \fIw\fP, \fIscreen_number\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIscreen_number\fP\^;
+.LP
+Status XReconfigureWMWindow\^(\^\fIdisplay\fP, \fIw\fP, \fIscreen_number\fP, \
+\fIvalue_mask\fP, \fIvalues\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIscreen_number\fP\^;
+.br
+ unsigned int \fIvalue_mask\fP\^;
+.br
+ XWindowChanges *\fIvalues\fP;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen_number\fP 1i
+Specifies the appropriate screen number on the host server.
+.IP \fIvalue_mask\fP 1i
+Specifies which values are to be set using information in
+the values structure.
+This mask is the bitwise inclusive OR of the valid configure window values bits.
+.IP \fIvalues\fP 1i
+Specifies the
+.ZN XWindowChanges
+structure.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XIconifyWindow
+function sends a WM_CHANGE_STATE
+.ZN ClientMessage
+event with a format of 32 and a first data element of
+.ZN IconicState
+(as described in section 4.1.4 of the
+\fIInter-Client Communication Conventions Manual\fP)
+and a window of w
+to the root window of the specified screen
+with an event mask set to
+.ZN SubstructureNotifyMask |
+.ZN SubstructureRedirectMask .
+Window managers may elect to receive this message and
+if the window is in its normal state,
+may treat it as a request to change the window's state from normal to iconic.
+If the WM_CHANGE_STATE property cannot be interned,
+.ZN XIconifyWindow
+does not send a message and returns a zero status.
+It returns a nonzero status if the client message is sent successfully;
+otherwise, it returns a zero status.
+.LP
+The
+.ZN XWithdrawWindow
+function unmaps the specified window
+and sends a synthetic
+.ZN UnmapNotify
+event to the root window of the specified screen.
+Window managers may elect to receive this message
+and may treat it as a request to change the window's state to withdrawn.
+When a window is in the withdrawn state,
+neither its normal nor its iconic representations is visible.
+It returns a nonzero status if the
+.ZN UnmapNotify
+event is successfully sent;
+otherwise, it returns a zero status.
+.LP
+.ZN XWithdrawWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XReconfigureWMWindow
+function issues a
+.ZN ConfigureWindow
+request on the specified top-level window.
+If the stacking mode is changed and the request fails with a
+.ZN BadMatch
+error,
+the error is trapped by Xlib and a synthetic
+.ZN ConfigureRequestEvent
+containing the same configuration parameters is sent to the root
+of the specified window.
+Window managers may elect to receive this event
+and treat it as a request to reconfigure the indicated window.
+It returns a nonzero status if the request or event is successfully sent;
+otherwise, it returns a zero status.
+.LP
+.ZN XReconfigureWMWindow
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XRaiseWindow(3X11),
+XMapWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XIfEvent.man b/man/XIfEvent.man
new file mode 100644
index 00000000..a55399e4
--- /dev/null
+++ b/man/XIfEvent.man
@@ -0,0 +1,234 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XIfEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XIfEvent, XCheckIfEvent, XPeekIfEvent \- check the event queue with a predicate procedure
+.SH SYNTAX
+XIfEvent\^(\^\fIdisplay\fP, \fIevent_return\fP, \fIpredicate\fP, \fIarg\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.br
+ Bool (\^*\fIpredicate\fP\^)\^(\^)\^;
+.br
+ XPointer \fIarg\fP\^;
+.LP
+Bool XCheckIfEvent\^(\^\fIdisplay\fP, \fIevent_return\fP, \fIpredicate\fP, \fIarg\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.br
+ Bool (\^*\fIpredicate\fP\^)\^(\^)\^;
+.br
+ XPointer \fIarg\fP\^;
+.LP
+XPeekIfEvent\^(\^\fIdisplay\fP, \fIevent_return\fP, \fIpredicate\fP, \fIarg\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.br
+ Bool (\^*\fIpredicate\fP\^)\^(\^)\^;
+.br
+ XPointer \fIarg\fP\^;
+.SH ARGUMENTS
+.IP \fIarg\fP 1i
+Specifies the user-supplied argument that will be passed to the predicate procedure.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Ev \ either a copy of or
+.IP \fIevent_return\fP 1i
+Returns\*(Ev the matched event's associated structure.
+.IP \fIpredicate\fP 1i
+Specifies the procedure that is to be called to determine
+if the next event in the queue matches what you want.
+.SH DESCRIPTION
+The
+.ZN XIfEvent
+function completes only when the specified predicate
+procedure returns
+.ZN True
+for an event,
+which indicates an event in the queue matches.
+.ZN XIfEvent
+flushes the output buffer if it blocks waiting for additional events.
+.ZN XIfEvent
+removes the matching event from the queue
+and copies the structure into the client-supplied
+.ZN XEvent
+structure.
+.LP
+When the predicate procedure finds a match,
+.ZN XCheckIfEvent
+copies the matched event into the client-supplied
+.ZN XEvent
+structure and returns
+.ZN True .
+(This event is removed from the queue.)
+If the predicate procedure finds no match,
+.ZN XCheckIfEvent
+returns
+.ZN False ,
+and the output buffer will have been flushed.
+All earlier events stored in the queue are not discarded.
+.LP
+The
+.ZN XPeekIfEvent
+function returns only when the specified predicate
+procedure returns
+.ZN True
+for an event.
+After the predicate procedure finds a match,
+.ZN XPeekIfEvent
+copies the matched event into the client-supplied
+.ZN XEvent
+structure without removing the event from the queue.
+.ZN XPeekIfEvent
+flushes the output buffer if it blocks waiting for additional events.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XNextEvent(3X11),
+XPutBackEvent(3X11)
+XSendEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XInitImage.man b/man/XInitImage.man
new file mode 100644
index 00000000..0f15b6ef
--- /dev/null
+++ b/man/XInitImage.man
@@ -0,0 +1,360 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XCreateImage 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XInitImage, XCreateImage, XGetPixel, XPutPixel, XSubImage, XAddPixel, XDestroyImage \- image utilities
+.SH SYNTAX
+Status XInitImage\^(\^\fIimage\fP\^)
+.br
+ XImage *\fIimage\fP\^;
+.LP
+XImage *XCreateImage\^(\^\fIdisplay\fP, \fIvisual\fP, \fIdepth\fP, \fIformat\fP, \fIoffset\fP, \fIdata\fP, \fIwidth\fP, \fIheight\fP\^, \fIbitmap_pad\fP,
+.br
+ \fIbytes_per_line\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Visual *\fIvisual\fP\^;
+.br
+ unsigned int \fIdepth\fP\^;
+.br
+ int \fIformat\fP\^;
+.br
+ int \fIoffset\fP\^;
+.br
+ char *\fIdata\fP\^;
+.br
+ unsigned int \fIwidth\fP\^;
+.br
+ unsigned int \fIheight\fP\^;
+.br
+ int \fIbitmap_pad\fP\^;
+.br
+ int \fIbytes_per_line\fP\^;
+.LP
+unsigned long XGetPixel\^(\^\fIximage\fP, \fIx\fP, \fIy\fP\^)
+.br
+ XImage *\fIximage\fP\^;
+.br
+ int \fIx\fP\^;
+.br
+ int \fIy\fP\^;
+.LP
+XPutPixel\^(\^\fIximage\fP, \fIx\fP, \fIy\fP, \fIpixel\fP\^)
+.br
+ XImage *\fIximage\fP\^;
+.br
+ int \fIx\fP\^;
+.br
+ int \fIy\fP\^;
+.br
+ unsigned long \fIpixel\fP\^;
+.LP
+XImage *XSubImage\^(\^\fIximage\fP, \fIx\fP, \fIy\fP, \fIsubimage_width\fP, \fIsubimage_height\fP\^)
+.br
+ XImage *\fIximage\fP\^;
+.br
+ int \fIx\fP\^;
+.br
+ int \fIy\fP\^;
+.br
+ unsigned int \fIsubimage_width\fP\^;
+.br
+ unsigned int \fIsubimage_height\fP\^;
+.LP
+XAddPixel\^(\^\fIximage\fP, \fIvalue\fP\^)
+.br
+ XImage *\fIximage\fP\^;
+.br
+ long \fIvalue\fP\^;
+.LP
+XDestroyImage\^(\^\fIximage\fP\^)
+.br
+ XImage *\^\fIximage\fP\^;
+.SH ARGUMENTS
+.IP \fIbitmap_pad\fP 1i
+Specifies the quantum of a scanline (8, 16, or 32).
+In other words, the start of one scanline is separated in client memory from
+the start of the next scanline by an integer multiple of this many bits.
+.IP \fIbytes_per_line\fP 1i
+Specifies the number of bytes in the client image between
+the start of one scanline and the start of the next.
+.IP \fIdata\fP 1i
+Specifies the image data.
+.IP \fIdepth\fP 1i
+Specifies the depth of the image.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIformat\fP 1i
+Specifies the format for the image.
+You can pass
+.ZN XYBitmap ,
+.ZN XYPixmap ,
+or
+.ZN ZPixmap .
+.IP \fIheight\fP 1i
+Specifies the height of the image, in pixels.
+.IP \fIoffset\fP 1i
+Specifies the number of pixels to ignore at the beginning of the scanline.
+.IP \fIpixel\fP 1i
+Specifies the new pixel value.
+.IP \fIsubimage_height\fP 1i
+Specifies the height of the new subimage, in pixels.
+.IP \fIsubimage_width\fP 1i
+Specifies the width of the new subimage, in pixels.
+.IP \fIvalue\fP 1i
+Specifies the constant value that is to be added.
+.IP \fIvisual\fP 1i
+Specifies the
+.ZN Visual
+structure.
+.IP \fIwidth\fP 1i
+Specifies the width of the image, in pixels.
+.IP \fIximage\fP 1i
+Specifies the image.
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates.
+.SH DESCRIPTION
+The
+.ZN XInitImage
+function initializes the internal image manipulation routines of an
+image structure, based on the values of the various structure members.
+All fields other than the manipulation routines must already be initialized.
+If the bytes_per_line member is zero,
+.ZN XInitImage
+will assume the image data is contiguous in memory and set the
+bytes_per_line member to an appropriate value based on the other
+members; otherwise, the value of bytes_per_line is not changed.
+All of the manipulation routines are initialized to functions
+that other Xlib image manipulation functions need to operate on the
+type of image specified by the rest of the structure.
+.LP
+This function must be called for any image constructed by the client
+before passing it to any other Xlib function.
+Image structures created or returned by Xlib do not need to be
+initialized in this fashion.
+.LP
+This function returns a nonzero status if initialization of the
+structure is successful. It returns zero if it detected some error
+or inconsistency in the structure, in which case the image is not changed.
+.LP
+The
+.ZN XCreateImage
+function allocates the memory needed for an
+.ZN XImage
+structure for the
+specified display but does not allocate space for the image itself.
+Rather, it initializes the structure byte-order, bit-order, and bitmap-unit
+values from the display and returns a pointer to the
+.ZN XImage
+structure.
+The red, green, and blue mask values are defined for Z format images only
+and are derived from the
+.ZN Visual
+structure passed in.
+Other values also are passed in.
+The offset permits the rapid displaying of the image without requiring each
+scanline to be shifted into position.
+If you pass a zero value in bytes_per_line,
+Xlib assumes that the scanlines are contiguous
+in memory and calculates the value of bytes_per_line itself.
+.LP
+Note that when the image is created using
+.ZN XCreateImage ,
+.ZN XGetImage ,
+or
+.ZN XSubImage ,
+the destroy procedure that the
+.ZN XDestroyImage
+function calls frees both the image structure
+and the data pointed to by the image structure.
+.LP
+The basic functions used to get a pixel, set a pixel, create a subimage,
+and add a constant value to an image are defined in the image object.
+The functions in this section are really macro invocations of the functions
+in the image object and are defined in
+.hN X11/Xutil.h .
+.LP
+The
+.ZN XGetPixel
+function returns the specified pixel from the named image.
+The pixel value is returned in normalized format (that is,
+the least significant byte of the long is the least significant byte
+of the pixel).
+The image must contain the x and y coordinates.
+.LP
+The
+.ZN XPutPixel
+function overwrites the pixel in the named image with the specified pixel value.
+The input pixel value must be in normalized format
+(that is, the least significant byte of the long is the least significant
+byte of the pixel).
+The image must contain the x and y coordinates.
+.LP
+The
+.ZN XSubImage
+function creates a new image that is a subsection of an existing one.
+It allocates the memory necessary for the new
+.ZN XImage
+structure
+and returns a pointer to the new image.
+The data is copied from the source image,
+and the image must contain the rectangle defined by x, y, subimage_width,
+and subimage_height.
+.LP
+The
+.ZN XAddPixel
+function adds a constant value to every pixel in an image.
+It is useful when you have a base pixel value from allocating
+color resources and need to manipulate the image to that form.
+.LP
+The
+.ZN XDestroyImage
+function deallocates the memory associated with the
+.ZN XImage
+structure.
+.SH "SEE ALSO"
+XPutImage(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XInitThreads.man b/man/XInitThreads.man
new file mode 100644
index 00000000..1812f640
--- /dev/null
+++ b/man/XInitThreads.man
@@ -0,0 +1,205 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XInitThreads 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XInitThreads, XLockDisplay, XUnlockDisplay \- multi-threading support
+.SH SYNTAX
+Status XInitThreads\^(\|);
+.LP
+void XLockDisplay\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+void XUnlockDisplay\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.SH DESCRIPTION
+The
+.ZN XInitThreads
+function initializes Xlib support for concurrent threads.
+This function must be the first Xlib function a
+multi-threaded program calls, and it must complete
+before any other Xlib call is made.
+This function returns a nonzero status if initialization was
+successful; otherwise, it returns zero.
+On systems that do not support threads, this function always returns zero.
+.LP
+It is only necessary to call this function if multiple threads
+might use Xlib concurrently. If all calls to Xlib functions
+are protected by some other access mechanism (for example,
+a mutual exclusion lock in a toolkit or through explicit client
+programming), Xlib thread initialization is not required.
+It is recommended that single-threaded programs not call this function.
+
+.LP
+The
+.ZN XLockDisplay
+function locks out all other threads from using the specified display.
+Other threads attempting to use the display will block until
+the display is unlocked by this thread.
+Nested calls to
+.ZN XLockDisplay
+work correctly; the display will not actually be unlocked until
+.ZN XUnlockDisplay
+has been called the same number of times as
+.ZN XLockDisplay .
+This function has no effect unless Xlib was successfully initialized
+for threads using
+.ZN XInitThreads .
+.LP
+The
+.ZN XUnlockDisplay
+function allows other threads to use the specified display again.
+Any threads that have blocked on the display are allowed to continue.
+Nested locking works correctly; if
+.ZN XLockDisplay
+has been called multiple times by a thread, then
+.ZN XUnlockDisplay
+must be called an equal number of times before the display is
+actually unlocked.
+This function has no effect unless Xlib was successfully initialized
+for threads using
+.ZN XInitThreads .
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XInstallColormap.man b/man/XInstallColormap.man
new file mode 100644
index 00000000..b6337037
--- /dev/null
+++ b/man/XInstallColormap.man
@@ -0,0 +1,256 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XInstallColormap 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XInstallColormap, XUninstallColormap, XListInstalledColormaps \- control colormaps
+.SH SYNTAX
+XInstallColormap\^(\^\fIdisplay\fP, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.LP
+XUninstallColormap\^(\^\fIdisplay\fP, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.LP
+Colormap *XListInstalledColormaps\^(\^\fIdisplay\fP, \fIw\fP, \fInum_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int *\fInum_return\fP\^;
+.SH ARGUMENTS
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInum_return\fP 1i
+Returns the number of currently installed colormaps.
+.ds Wi that determines the screen
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XInstallColormap
+function installs the specified colormap for its associated screen.
+All windows associated with this colormap immediately display with
+true colors.
+You associated the windows with this colormap when you created them by calling
+.ZN XCreateWindow ,
+.ZN XCreateSimpleWindow ,
+.ZN XChangeWindowAttributes ,
+or
+.ZN XSetWindowColormap .
+.LP
+If the specified colormap is not already an installed colormap,
+the X server generates a
+.ZN ColormapNotify
+event on each window that has that colormap.
+In addition, for every other colormap that is installed as
+a result of a call to
+.ZN XInstallColormap ,
+the X server generates a
+.ZN ColormapNotify
+event on each window that has that colormap.
+.LP
+.ZN XInstallColormap
+can generate a
+.ZN BadColor
+error.
+.LP
+The
+.ZN XUninstallColormap
+function removes the specified colormap from the required
+list for its screen.
+As a result,
+the specified colormap might be uninstalled,
+and the X server might implicitly install or uninstall additional colormaps.
+Which colormaps get installed or uninstalled is server dependent
+except that the required list must remain installed.
+.LP
+If the specified colormap becomes uninstalled,
+the X server generates a
+.ZN ColormapNotify
+event on each window that has that colormap.
+In addition, for every other colormap that is installed or uninstalled as a
+result of a call to
+.ZN XUninstallColormap ,
+the X server generates a
+.ZN ColormapNotify
+event on each window that has that colormap.
+.LP
+.ZN XUninstallColormap
+can generate a
+.ZN BadColor
+error.
+.LP
+The
+.ZN XListInstalledColormaps
+function returns a list of the currently installed colormaps for the screen
+of the specified window.
+The order of the colormaps in the list is not significant
+and is no explicit indication of the required list.
+When the allocated list is no longer needed,
+free it by using
+.ZN XFree .
+.LP
+.ZN XListInstalledColormaps
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAtrributes(3X11),
+XCreateColormap(3X11),
+XCreateWindow(3X11),
+XFree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XInternAtom.man b/man/XInternAtom.man
new file mode 100644
index 00000000..90036ef3
--- /dev/null
+++ b/man/XInternAtom.man
@@ -0,0 +1,302 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XInternAtom 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XInternAtom, XInternAtoms, XGetAtomName, XGetAtomNames \- create or return atom names
+.SH SYNTAX
+Atom XInternAtom\^(\^\fIdisplay\fP, \fIatom_name\fP\^, \fIonly_if_exists\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIatom_name\fP\^;
+.br
+ Bool \fIonly_if_exists\fP\^;
+.LP
+Status XInternAtoms\^(\^\fIdisplay\fP, \fInames\fP\^, \fIcount\fP\^, \fIonly_if_exists\fP, \fIatoms_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char **\fInames\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ Bool \fIonly_if_exists\fP\^;
+.br
+ Atom *\fIatoms_return\fP\^;
+.LP
+char *XGetAtomName\^(\^\fIdisplay\fP, \fIatom\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Atom \fIatom\fP\^;
+.LP
+Status XGetAtomNames\^(\^\fIdisplay\fP, \fIatoms\fP, \fIcount\fP\^, \fInames_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Atom *\fIatoms\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ char **\fInames_return\fP\^;
+.SH ARGUMENTS
+.IP \fIatom\fP 1i
+Specifies the atom for the property name you want returned.
+.IP \fIatoms\fP 1i
+Specifies the array of atoms.
+.IP \fIatom_name\fP 1i
+Specifies the name associated with the atom you want returned.
+.IP \fIatoms_return\fP 1i
+Returns the atoms.
+.ds Cn atom names in the array
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.ds Cn atoms in the array
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInames\fP 1i
+Specifies the array of atom names.
+.IP \fInames_return\fP 1i
+Returns the atom names.
+.IP \fIonly_if_exists\fP 1i
+Specifies a Boolean value that indicates whether the atom must be created.
+.SH DESCRIPTION
+The
+.ZN XInternAtom
+function returns the atom identifier associated with the specified atom_name
+string.
+If only_if_exists is
+.ZN False ,
+the atom is created if it does not exist.
+Therefore,
+.ZN XInternAtom
+can return
+.ZN None .
+If the atom name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Uppercase and lowercase matter;
+the strings ``thing'', ``Thing'', and ``thinG''
+all designate different atoms.
+The atom will remain defined even after the client's connection closes.
+It will become undefined only when the last connection to
+the X server closes.
+.LP
+.ZN XInternAtom
+can generate
+.ZN BadAlloc
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XInternAtoms
+function returns the atom identifiers associated with the specified names.
+The atoms are stored in the atoms_return array supplied by the caller.
+Calling this function is equivalent to calling
+.ZN XInternAtom
+for each of the names in turn with the specified value of only_if_exists,
+but this function minimizes the number of round-trip protocol exchanges
+between the client and the X server.
+.LP
+This function returns a nonzero status if atoms are returned for
+all of the names;
+otherwise, it returns zero.
+.LP
+.ZN XInternAtoms
+can generate
+.ZN BadAlloc
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetAtomName
+function returns the name associated with the specified atom.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned string is in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+To free the resulting string,
+call
+.ZN XFree .
+.LP
+.ZN XGetAtomName
+can generate a
+.ZN BadAtom
+error.
+.LP
+The
+.ZN XGetAtomNames
+function returns the names associated with the specified atoms.
+The names are stored in the names_return array supplied by the caller.
+Calling this function is equivalent to calling
+.ZN XGetAtomName
+for each of the atoms in turn,
+but this function minimizes the number of round-trip protocol exchanges
+between the client and the X server.
+.LP
+This function returns a nonzero status if names are returned for
+all of the atoms;
+otherwise, it returns zero.
+.LP
+.ZN XGetAtomNames
+can generate a
+.ZN BadAtom
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XFree(3X11),
+XGetWindowProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XIntersectRegion.man b/man/XIntersectRegion.man
new file mode 100644
index 00000000..42c2d775
--- /dev/null
+++ b/man/XIntersectRegion.man
@@ -0,0 +1,241 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XIntersectRegion 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XIntersectRegion, XUnionRegion, XUnionRectWithRegion, XSubtractRegion, XXorRegion, XOffsetRegion, XShrinkRegion \- region arithmetic
+.SH SYNTAX
+XIntersectRegion\^(\^\fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^)
+.br
+ Region \fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^;
+.LP
+XUnionRegion\^(\^\fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^)
+.br
+ Region \fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^;
+.LP
+XUnionRectWithRegion\^(\^\fIrectangle\fP, \fIsrc_region\fP, \
+\fIdest_region_return\fP\^)
+.br
+ XRectangle *\fIrectangle\fP\^;
+.br
+ Region \fIsrc_region\fP\^;
+.br
+ Region \fIdest_region_return\fP\^;
+.LP
+XSubtractRegion\^(\^\fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^)
+.br
+ Region \fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^;
+.LP
+XXorRegion\^(\^\fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^)
+.br
+ Region \fIsra\fP\^, \fIsrb\fP\^, \fIdr_return\fP\^;
+.LP
+XOffsetRegion\^(\^\fIr\fP\^, \fIdx\fP\^, \fIdy\fP\^)
+.br
+ Region \fIr\fP\^;
+.br
+ int \fIdx\fP\^, \fIdy\fP\^;
+.LP
+XShrinkRegion\^(\^\fIr\fP\^, \fIdx\fP\^, \fIdy\fP\^)
+.br
+ Region \fIr\fP\^;
+.br
+ int \fIdx\fP\^, \fIdy\fP\^;
+.SH ARGUMENTS
+.IP \fIdest_region_return\fP 1i
+Returns the destination region.
+.IP \fIdr_return\fP 1i
+Returns the result of the computation.
+ds Dy move or shrink
+.IP \fIdx\fP 1i
+.br
+.ns
+.IP \fIdy\fP 1i
+Specify the x and y coordinates,
+which define the amount you want to \*(Dy the specified region.
+.IP \fIr\fP 1i
+Specifies the region.
+.IP \fIrectangle\fP 1i
+Specifies the rectangle.
+.IP \fIsra\fP 1i
+.br
+.ns
+.IP \fIsrb\fP 1i
+Specify the two regions with which you want to perform the computation.
+.IP \fIsrc_region\fP 1i
+Specifies the source region to be used.
+.SH DESCRIPTION
+The
+.ZN XIntersectRegion
+function computes the intersection of two regions.
+.LP
+The
+.ZN XUnionRegion
+function computes the union of two regions.
+.LP
+The
+.ZN XUnionRectWithRegion
+function updates the destination region from a union of the specified rectangle
+and the specified source region.
+.LP
+The
+.ZN XSubtractRegion
+function subtracts srb from sra and stores the results in dr_return.
+.LP
+The
+.ZN XXorRegion
+function calculates the difference between the union and intersection
+of two regions.
+.LP
+The
+.ZN XOffsetRegion
+function moves the specified region by a specified amount.
+.LP
+The
+.ZN XShrinkRegion
+function reduces the specified region by a specified amount.
+Positive values shrink the size of the region,
+and negative values expand the region.
+.SH "SEE ALSO"
+XCreateRegion(3X11),
+XDrawRectangle(3X11),
+XEmptyRegion(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XKeymapEvent.man b/man/XKeymapEvent.man
new file mode 100644
index 00000000..896b5009
--- /dev/null
+++ b/man/XKeymapEvent.man
@@ -0,0 +1,219 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XKeymapEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XKeymapEvent \- KeymapNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN KeymapNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+/* generated on EnterWindow and FocusIn when KeymapState selected */
+typedef struct {
+ int type; /* KeymapNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ char key_vector[32];
+} XKeymapEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is not used but is present to aid some toolkits.
+The key_vector member is set to the bit vector of the keyboard.
+Each bit set to 1 indicates that the corresponding key
+is currently pressed.
+The vector is represented as 32 bytes.
+Byte N (from 0) contains the bits for keys 8N to 8N + 7
+with the least significant bit in the byte representing key 8N.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XListFonts.man b/man/XListFonts.man
new file mode 100644
index 00000000..5e4c3c93
--- /dev/null
+++ b/man/XListFonts.man
@@ -0,0 +1,279 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XListFonts 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XListFonts, XFreeFontNames, XListFontsWithInfo, XFreeFontInfo \- obtain or free font names and information
+.SH SYNTAX
+char **XListFonts\^(\^\fIdisplay\fP, \fIpattern\fP\^, \fImaxnames\fP, \fIactual_count_return\fP\^)
+.br
+ Display *\^\fIdisplay\fP\^;
+.br
+ char *\^\fIpattern\fP\^;
+.br
+ int \fImaxnames\fP\^;
+.br
+ int *\^\fIactual_count_return\fP\^;
+.LP
+XFreeFontNames\^(\^\fIlist\fP\^)
+.br
+ char *\fIlist\fP\^[\^]\^;
+.LP
+char **XListFontsWithInfo\^(\^\fIdisplay\fP, \fIpattern\fP, \fImaxnames\fP, \fIcount_return\fP, \fIinfo_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIpattern\fP\^;
+.br
+ int \fImaxnames\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.br
+ XFontStruct **\fIinfo_return\fP\^;
+.LP
+XFreeFontInfo(\^\fInames\fP, \fIfree_info\fP, \fIactual_count\fP\^)
+.br
+ char **\fInames\fP\^;
+.br
+ XFontStruct *\fIfree_info\fP;
+.br
+ int \fIactual_count\fP\^;
+.SH ARGUMENTS
+.IP \fIactual_count\fP 1i
+Specifies the actual number of font names.
+
+.IP \fIactual_count_return\fP 1i
+Returns the actual number of font names.
+.IP \fIcount_return\fP 1i
+Returns the actual number of matched font names.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIinfo_return\fP 1i
+Returns the font information.
+.IP \fIfree_info\fP 1i
+Specifies the font information.
+
+.IP \fIlist\fP 1i
+Specifies the array of strings you want to free.
+.IP \fImaxnames\fP 1i
+Specifies the maximum number of names to be returned.
+.IP \fInames\fP 1i
+Specifies the list of font names.
+
+.IP \fIpattern\fP 1i
+Specifies the null-terminated pattern string that can contain wildcard
+characters.
+.SH DESCRIPTION
+The
+.ZN XListFonts
+function returns an array of available font names
+(as controlled by the font search path; see
+.ZN XSetFontPath )
+that match the string you passed to the pattern argument.
+The pattern string can contain any characters,
+but each asterisk (*) is a wildcard for any number of characters,
+and each question mark (?) is a wildcard for a single character.
+If the pattern string is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+Each returned string is null-terminated.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned strings are in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+If there are no matching font names,
+.ZN XListFonts
+returns NULL.
+The client should call
+.ZN XFreeFontNames
+when finished with the result to free the memory.
+.LP
+The
+.ZN XFreeFontNames
+function frees the array and strings returned by
+.ZN XListFonts
+or
+.ZN XListFontsWithInfo .
+.LP
+The
+.ZN XListFontsWithInfo
+function returns a list of font names that match the specified pattern and their
+associated font information.
+The list of names is limited to size specified by maxnames.
+The information returned for each font is identical to what
+.ZN XLoadQueryFont
+would return except that the per-character metrics are not returned.
+The pattern string can contain any characters,
+but each asterisk (*) is a wildcard for any number of characters,
+and each question mark (?) is a wildcard for a single character.
+If the pattern string is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+Each returned string is null-terminated.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned strings are in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+If there are no matching font names,
+.ZN XListFontsWithInfo
+returns NULL.
+.LP
+To free only the allocated name array,
+the client should call
+.ZN XFreeFontNames .
+To free both the name array and the font information array
+or to free just the font information array,
+the client should call
+.ZN XFreeFontInfo .
+.LP
+The
+.ZN XFreeFontInfo
+function frees a font structure or an array of font structures
+and optionally an array of font names.
+If NULL is passed for names, no font names are freed.
+If a font structure for an open font (returned by
+.ZN XLoadQueryFont )
+is passed, the structure is freed,
+but the font is not closed; use
+.ZN XUnloadFont
+to close the font.
+.SH "SEE ALSO"
+XLoadFont(3X11),
+XSetFontPath(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XLoadFont.man b/man/XLoadFont.man
new file mode 100644
index 00000000..b9f96d3a
--- /dev/null
+++ b/man/XLoadFont.man
@@ -0,0 +1,562 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XLoadFont 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XLoadFont, XQueryFont, XLoadQueryFont, XFreeFont, XGetFontProperty, XUnloadFont, XCharStruct, XFontProp, XChar2b, XFontStruct \- load or unload fonts and font metric structures
+.SH SYNTAX
+Font XLoadFont\^(\^\fIdisplay\fP, \fIname\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIname\fP\^;
+.LP
+XFontStruct *XQueryFont\^(\^\fIdisplay\fP, \fIfont_ID\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIfont_ID\fP\^;
+.LP
+XFontStruct *XLoadQueryFont\^(\^\fIdisplay\fP, \fIname\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIname\fP\^;
+.LP
+XFreeFont\^(\^\fIdisplay\fP, \fIfont_struct\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.LP
+Bool XGetFontProperty\^(\^\fIfont_struct\fP\^, \^\fIatom\fP\^, \^\fIvalue_return\fP\^)
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.br
+ Atom \fIatom\fP\^;
+.br
+ unsigned long *\fIvalue_return\fP\^;
+.LP
+XUnloadFont\^(\^\fIdisplay\fP, \fIfont\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Font \fIfont\fP\^;
+.SH ARGUMENTS
+.IP \fIatom\fP 1i
+Specifies the atom for the property name you want returned.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfont\fP 1i
+Specifies the font.
+.IP \fIfont_ID\fP 1i
+Specifies the font ID or the
+.ZN GContext
+ID.
+.IP \fIfont_struct\fP 1i
+Specifies the storage associated with the font.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIname\fP 1i
+Specifies the name of the font,
+which is a null-terminated string.
+.IP \fIvalue_return\fP 1i
+Returns the value of the font property.
+.SH DESCRIPTION
+The
+.ZN XLoadFont
+function loads the specified font and returns its associated font ID.
+If the font name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+When the characters ``?'' and ``*'' are used in a font name, a
+pattern match is performed and any matching font is used.
+In the pattern,
+the ``?'' character will match any single character,
+and the ``*'' character will match any number of characters.
+A structured format for font names is specified in the X Consortium standard
+\fIX Logical Font Description Conventions\fP.
+If
+.ZN XLoadFont
+was unsuccessful at loading the specified font,
+a
+.ZN BadName
+error results.
+Fonts are not associated with a particular screen
+and can be stored as a component
+of any GC.
+When the font is no longer needed, call
+.ZN XUnloadFont .
+.LP
+.ZN XLoadFont
+can generate
+.ZN BadAlloc
+and
+.ZN BadName
+errors.
+.LP
+The
+.ZN XQueryFont
+function returns a pointer to the
+.ZN XFontStruct
+structure, which contains information associated with the font.
+You can query a font or the font stored in a GC.
+The font ID stored in the
+.ZN XFontStruct
+structure will be the
+.ZN GContext
+ID, and you need to be careful when using this ID in other functions
+(see
+.ZN XGContextFromGC ).
+If the font does not exist,
+.ZN XQueryFont
+returns NULL.
+To free this data, use
+.ZN XFreeFontInfo .
+.LP
+.ZN XLoadQueryFont
+can generate a
+.ZN BadAlloc
+error.
+.LP
+The
+.ZN XLoadQueryFont
+function provides the most common way for accessing a font.
+.ZN XLoadQueryFont
+both opens (loads) the specified font and returns a pointer to the
+appropriate
+.ZN XFontStruct
+structure.
+If the font name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+If the font does not exist,
+.ZN XLoadQueryFont
+returns NULL.
+.LP
+The
+.ZN XFreeFont
+function deletes the association between the font resource ID and the specified
+font and frees the
+.ZN XFontStruct
+structure.
+The font itself will be freed when no other resource references it.
+The data and the font should not be referenced again.
+.LP
+.ZN XFreeFont
+can generate a
+.ZN BadFont
+error.
+.LP
+Given the atom for that property,
+the
+.ZN XGetFontProperty
+function returns the value of the specified font property.
+.ZN XGetFontProperty
+also returns
+.ZN False
+if the property was not defined or
+.ZN True
+if it was defined.
+A set of predefined atoms exists for font properties,
+which can be found in
+.hN X11/Xatom.h .
+This set contains the standard properties associated with
+a font.
+Although it is not guaranteed,
+it is likely that the predefined font properties will be present.
+.LP
+The
+.ZN XUnloadFont
+function deletes the association between the font resource ID and the specified font.
+The font itself will be freed when no other resource references it.
+The font should not be referenced again.
+.LP
+.ZN XUnloadFont
+can generate a
+.ZN BadFont
+error.
+.SH STRUCTURES
+The
+.ZN XFontStruct
+structure contains all of the information for the font
+and consists of the font-specific information as well as
+a pointer to an array of
+.ZN XCharStruct
+structures for the
+characters contained in the font.
+The
+.ZN XFontStruct ,
+.ZN XFontProp ,
+and
+.ZN XCharStruct
+structures contain:
+.LP
+.IN "XCharStruct" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ short lbearing; /* origin to left edge of raster */
+ short rbearing; /* origin to right edge of raster */
+ short width; /* advance to next char's origin */
+ short ascent; /* baseline to top edge of raster */
+ short descent; /* baseline to bottom edge of raster */
+ unsigned short attributes; /* per char flags (not predefined) */
+} XCharStruct;
+.De
+.LP
+.IN "XFontProp" "" "@DEF@"
+.Ds 0
+.TA .5i 1i 3i
+.ta .5i 1i 3i
+typedef struct {
+ Atom name;
+ unsigned long card32;
+} XFontProp;
+.De
+.LP
+.IN "XChar2b" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct { /* normal 16 bit characters are two bytes */
+ unsigned char byte1;
+ unsigned char byte2;
+} XChar2b;
+.De
+.LP
+.IN "XFontStruct" "" "@DEF@"
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ XExtData *ext_data; /* hook for extension to hang data */
+ Font fid; /* Font id for this font */
+ unsigned direction; /* hint about the direction font is painted */
+ unsigned min_char_or_byte2; /* first character */
+ unsigned max_char_or_byte2; /* last character */
+ unsigned min_byte1; /* first row that exists */
+ unsigned max_byte1; /* last row that exists */
+ Bool all_chars_exist; /* flag if all characters have nonzero size */
+ unsigned default_char; /* char to print for undefined character */
+ int n_properties; /* how many properties there are */
+ XFontProp *properties; /* pointer to array of additional properties */
+ XCharStruct min_bounds; /* minimum bounds over all existing char */
+ XCharStruct max_bounds; /* maximum bounds over all existing char */
+ XCharStruct *per_char; /* first_char to last_char information */
+ int ascent; /* logical extent above baseline for spacing */
+ int descent; /* logical decent below baseline for spacing */
+} XFontStruct;
+.De
+.LP
+X supports single byte/character, two bytes/character matrix,
+and 16-bit character text operations.
+Note that any of these forms can be used with a font, but a
+single byte/character text request can only specify a single byte
+(that is, the first row of a 2-byte font).
+You should view 2-byte fonts as a two-dimensional matrix of defined
+characters: byte1 specifies the range of defined rows and
+byte2 defines the range of defined columns of the font.
+Single byte/character fonts have one row defined, and the byte2 range
+specified in the structure defines a range of characters.
+.LP
+The bounding box of a character is defined by the
+.ZN XCharStruct
+of that character.
+When characters are absent from a font,
+the default_char is used.
+When fonts have all characters of the same size,
+only the information in the
+.ZN XFontStruct
+min and max bounds are used.
+.LP
+The members of the
+.ZN XFontStruct
+have the following semantics:
+.IP \(bu 5
+The direction member can be either
+.ZN FontLeftToRight
+or
+.ZN FontRightToLeft .
+It is just a hint as to whether most
+.ZN XCharStruct
+elements
+have a positive
+.Pn ( FontLeftToRight )
+or a negative
+.Pn ( FontRightToLeft )
+character width
+metric.
+The core protocol defines no support for vertical text.
+.IP \(bu 5
+If the min_byte1 and max_byte1 members are both zero, min_char_or_byte2
+specifies the linear character index corresponding to the first element
+of the per_char array, and max_char_or_byte2 specifies the linear character
+index of the last element.
+.IP
+If either min_byte1 or max_byte1 are nonzero, both
+min_char_or_byte2 and max_char_or_byte2 are less than 256,
+and the 2-byte character index values corresponding to the
+per_char array element N (counting from 0) are:
+.IP
+.nf
+ byte1 = N/D + min_byte1
+.br
+ byte2 = N\\D + min_char_or_byte2
+.IP
+.fi
+where:
+.IP
+.nf
+ D = max_char_or_byte2 \- min_char_or_byte2 + 1
+ / = integer division
+ \\ = integer modulus
+.fi
+.IP \(bu 5
+If the per_char pointer is NULL,
+all glyphs between the first and last character indexes
+inclusive have the same information,
+as given by both min_bounds and max_bounds.
+.IP \(bu 5
+If all_chars_exist is
+.ZN True ,
+all characters in the per_char array have nonzero bounding boxes.
+.IP \(bu 5
+The default_char member specifies the character that will be used when an
+undefined or nonexistent character is printed.
+The default_char is a 16-bit character (not a 2-byte character).
+For a font using 2-byte matrix format,
+the default_char has byte1 in the most-significant byte
+and byte2 in the least significant byte.
+If the default_char itself specifies an undefined or nonexistent character,
+no printing is performed for an undefined or nonexistent character.
+.IP \(bu 5
+The min_bounds and max_bounds members contain the most extreme values of
+each individual
+.ZN XCharStruct
+component over all elements of this array
+(and ignore nonexistent characters).
+The bounding box of the font (the smallest
+rectangle enclosing the shape obtained by superimposing all of the
+characters at the same origin [x,y]) has its upper-left coordinate at:
+.Ds
+ [x + min_bounds.lbearing, y \- max_bounds.ascent]
+.De
+.IP
+Its width is:
+.Ds
+ max_bounds.rbearing \- min_bounds.lbearing
+.De
+.IP
+Its height is:
+.Ds
+ max_bounds.ascent + max_bounds.descent
+.De
+.IP \(bu 5
+The ascent member is the logical extent of the font above the baseline that is
+used for determining line spacing.
+Specific characters may extend beyond
+this.
+.IP \(bu 5
+The descent member is the logical extent of the font at or below the
+baseline that is used for determining line spacing.
+Specific characters may extend beyond this.
+.IP \(bu 5
+If the baseline is at Y-coordinate y,
+the logical extent of the font is inclusive between the Y-coordinate
+values (y \- font.ascent) and (y + font.descent \- 1).
+Typically,
+the minimum interline spacing between rows of text is given
+by ascent + descent.
+.LP
+For a character origin at [x,y],
+the bounding box of a character (that is,
+the smallest rectangle that encloses the character's shape)
+described in terms of
+.ZN XCharStruct
+components is a rectangle with its upper-left corner at:
+.LP
+.Ds
+[x + lbearing, y \- ascent]
+.De
+.LP
+Its width is:
+.LP
+.Ds
+rbearing \- lbearing
+.De
+.LP
+Its height is:
+.LP
+.Ds
+ascent + descent
+.De
+.LP
+The origin for the next character is defined to be:
+.LP
+.Ds
+[x + width, y]
+.De
+.LP
+The lbearing member defines the extent of the left edge of the character ink
+from the origin.
+The rbearing member defines the extent of the right edge of the character ink
+from the origin.
+The ascent member defines the extent of the top edge of the character ink
+from the origin.
+The descent member defines the extent of the bottom edge of the character ink
+from the origin.
+The width member defines the logical width of the character.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadName
+A font or color of the specified name does not exist.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XListFonts(3X11),
+XSetFontPath(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XLookupKeysym.man b/man/XLookupKeysym.man
new file mode 100644
index 00000000..d07dfcbb
--- /dev/null
+++ b/man/XLookupKeysym.man
@@ -0,0 +1,294 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XLookupKeysym 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XLookupKeysym, XRefreshKeyboardMapping, XLookupString, XRebindKeySym \- handle keyboard input events in Latin-1
+.SH SYNTAX
+KeySym XLookupKeysym(\^\fIkey_event\fP, \fIindex\fP\^)
+.br
+ XKeyEvent *\fIkey_event\fP\^;
+.br
+ int \fIindex\fP\^;
+.LP
+XRefreshKeyboardMapping(\^\fIevent_map\fP\^)
+.br
+ XMappingEvent *\fIevent_map\fP\^;
+.LP
+int XLookupString(\^\fIevent_struct\fP, \fIbuffer_return\fP,\
+ \fIbytes_buffer\fP, \fIkeysym_return\fP, \fIstatus_in_out\fP\^)
+.br
+ XKeyEvent *\fIevent_struct\fP\^;
+.br
+ char *\fIbuffer_return\fP\^;
+.br
+ int \fIbytes_buffer\fP\^;
+.br
+ KeySym *\fIkeysym_return\fP\^;
+.br
+ XComposeStatus *\fIstatus_in_out\fP\^;
+.LP
+XRebindKeysym(\^\fIdisplay\fP, \fIkeysym\fP, \fIlist\fP, \fImod_count\fP, \fIstring\fP, \fInum_bytes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ KeySym \fIkeysym\fP\^;
+.br
+ KeySym \fIlist\fP\^[\^]\^;
+.br
+ int \fImod_count\fP\^;
+.br
+ unsigned char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.SH ARGUMENTS
+.IP \fIbuffer_return\fP 1i
+Returns the translated characters.
+.IP \fIbytes_buffer\fP 1i
+Specifies the length of the buffer.
+No more than bytes_buffer of translation are returned.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_map\fP 1i
+Specifies the mapping event that is to be used.
+.IP \fIevent_struct\fP 1i
+Specifies the key event structure to be used.
+You can pass
+.ZN XKeyPressedEvent
+or
+.ZN XKeyReleasedEvent .
+.IP \fIindex\fP 1i
+Specifies the index into the KeySyms list for the event's KeyCode.
+.IP \fIkey_event\fP 1i
+Specifies the
+.ZN KeyPress
+or
+.ZN KeyRelease
+event.
+.IP \fIkeysym\fP 1i
+Specifies the KeySym that is to be \*(Fn.
+.IP \fIkeysym_return\fP 1i
+Returns the KeySym computed from the event if this argument is not NULL.
+.IP \fIlist\fP 1i
+Specifies the KeySyms to be used as modifiers.
+.IP \fImod_count\fP 1i
+Specifies the number of modifiers in the modifier list.
+.IP \fIstatus_in_out\fP 1i
+Specifies or returns the
+.ZN XComposeStatus
+structure or NULL.
+.IP \fIstring\fP 1i
+Specifies the string that is copied and will be returned by
+.ZN XLookupString .
+.SH DESCRIPTION
+The
+.ZN XLookupKeysym
+function uses a given keyboard event and the index you specified to return
+the KeySym from the list that corresponds to the KeyCode member in the
+.ZN XKeyPressedEvent
+or
+.ZN XKeyReleasedEvent
+structure.
+If no KeySym is defined for the KeyCode of the event,
+.ZN XLookupKeysym
+returns
+.ZN NoSymbol .
+.LP
+The
+.ZN XRefreshKeyboardMapping
+function refreshes the stored modifier and keymap information.
+You usually call this function when a
+.ZN MappingNotify
+event with a request member of
+.ZN MappingKeyboard
+or
+.ZN MappingModifier
+occurs.
+The result is to update Xlib's knowledge of the keyboard.
+.LP
+The
+.ZN XLookupString
+function translates a key event to a KeySym and a string.
+The KeySym is obtained by using the standard interpretation of the
+.ZN Shift ,
+.ZN Lock ,
+group, and numlock modifiers as defined in the X Protocol specification.
+If the KeySym has been rebound (see
+.ZN XRebindKeysym ),
+the bound string will be stored in the buffer.
+Otherwise, the KeySym is mapped, if possible, to an ISO Latin-1 character
+or (if the Control modifier is on) to an ASCII control character,
+and that character is stored in the buffer.
+.ZN XLookupString
+returns the number of characters that are stored in the buffer.
+.LP
+If present (non-NULL),
+the
+.ZN XComposeStatus
+structure records the state,
+which is private to Xlib,
+that needs preservation across calls to
+.ZN XLookupString
+to implement compose processing.
+The creation of
+.ZN XComposeStatus
+structures is implementation-dependent;
+a portable program must pass NULL for this argument.
+.LP
+The
+.ZN XRebindKeysym
+function can be used to rebind the meaning of a KeySym for the client.
+It does not redefine any key in the X server but merely
+provides an easy way for long strings to be attached to keys.
+.ZN XLookupString
+returns this string when the appropriate set of
+modifier keys are pressed and when the KeySym would have been used for
+the translation.
+No text conversions are performed;
+the client is responsible for supplying appropriately encoded strings.
+Note that you can rebind a KeySym that may not exist.
+.SH "SEE ALSO"
+XButtonEvent(3X11),
+XMapEvent(3X11),
+XStringToKeysym(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XMapEvent.man b/man/XMapEvent.man
new file mode 100644
index 00000000..79d43cce
--- /dev/null
+++ b/man/XMapEvent.man
@@ -0,0 +1,289 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XMapEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XMapEvent, XMappingEvent \- MapNotify and MappingNotify event structures
+.SH STRUCTURES
+The structure for
+.ZN MapNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* MapNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool override_redirect; /* boolean, is override set... */
+} XMapEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the window that was mapped or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the window that was mapped.
+The override_redirect member is set to the override-redirect attribute
+of the window.
+Window manager clients normally should ignore this window
+if the override-redirect attribute is
+.ZN True ,
+because these events usually are generated from pop-ups,
+which override structure control.
+.LP
+The structure for
+.ZN MappingNotify
+events is:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* MappingNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window; /* unused */
+ int request; /* one of MappingModifier, MappingKeyboard,
+ MappingPointer */
+ int first_keycode; /* first keycode */
+ int count; /* defines range of change w. first_keycode*/
+} XMappingEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The request member is set to indicate the kind of mapping change that occurred
+and can be
+.ZN MappingModifier ,
+.ZN MappingKeyboard ,
+.ZN MappingPointer .
+If it is
+.ZN MappingModifier ,
+the modifier mapping was changed.
+If it is
+.ZN MappingKeyboard ,
+the keyboard mapping was changed.
+If it is
+.ZN MappingPointer ,
+the pointer button mapping was changed.
+The first_keycode and count members are set only
+if the request member was set to
+.ZN MappingKeyboard .
+The number in first_keycode represents the first number in the range
+of the altered mapping,
+and count represents the number of keycodes altered.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XMapRequestEvent.man b/man/XMapRequestEvent.man
new file mode 100644
index 00000000..d593d2b9
--- /dev/null
+++ b/man/XMapRequestEvent.man
@@ -0,0 +1,213 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XMapRequestEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XMapRequestEvent \- MapRequest event structure
+.SH STRUCTURES
+The structure for
+.ZN MapRequest
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* MapRequest */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window parent;
+ Window window;
+} XMapRequestEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The parent member is set to the parent window.
+The window member is set to the window to be mapped.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XMapWindow.man b/man/XMapWindow.man
new file mode 100644
index 00000000..f7678e0b
--- /dev/null
+++ b/man/XMapWindow.man
@@ -0,0 +1,287 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XMapWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XMapWindow, XMapRaised, XMapSubwindows \- map windows
+.SH SYNTAX
+XMapWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XMapRaised\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XMapSubwindows\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XMapWindow
+function
+maps the window and all of its
+subwindows that have had map requests.
+Mapping a window that has an unmapped ancestor does not display the
+window but marks it as eligible for display when the ancestor becomes
+mapped.
+Such a window is called unviewable.
+When all its ancestors are mapped,
+the window becomes viewable
+and will be visible on the screen if it is not obscured by another window.
+This function has no effect if the window is already mapped.
+.LP
+If the override-redirect of the window is
+.ZN False
+and if some other client has selected
+.ZN SubstructureRedirectMask
+on the parent window, then the X server generates a
+.ZN MapRequest
+event, and the
+.ZN XMapWindow
+function does not map the window.
+Otherwise, the window is mapped, and the X server generates a
+.ZN MapNotify
+event.
+.LP
+If the window becomes viewable and no earlier contents for it are remembered,
+the X server tiles the window with its background.
+If the window's background is undefined,
+the existing screen contents are not
+altered, and the X server generates zero or more
+.ZN Expose
+events.
+If backing-store was maintained while the window was unmapped, no
+.ZN Expose
+events
+are generated.
+If backing-store will now be maintained,
+a full-window exposure is always generated.
+Otherwise, only visible regions may be reported.
+Similar tiling and exposure take place for any newly viewable inferiors.
+.LP
+.IN "XMapWindow"
+If the window is an
+.ZN InputOutput
+window,
+.ZN XMapWindow
+generates
+.ZN Expose
+events on each
+.ZN InputOutput
+window that it causes to be displayed.
+If the client maps and paints the window
+and if the client begins processing events,
+the window is painted twice.
+To avoid this,
+first ask for
+.ZN Expose
+events and then map the window,
+so the client processes input events as usual.
+The event list will include
+.ZN Expose
+for each
+window that has appeared on the screen.
+The client's normal response to
+an
+.ZN Expose
+event should be to repaint the window.
+This method usually leads to simpler programs and to proper interaction
+with window managers.
+.LP
+.ZN XMapWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XMapRaised
+function
+essentially is similar to
+.ZN XMapWindow
+in that it maps the window and all of its
+subwindows that have had map requests.
+However, it also raises the specified window to the top of the stack.
+.LP
+.ZN XMapRaised
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XMapSubwindows
+.IN "XMapSubwindows"
+function maps all subwindows for a specified window in top-to-bottom stacking
+order.
+The X server generates
+.ZN Expose
+events on each newly displayed window.
+This may be much more efficient than mapping many windows
+one at a time because the server needs to perform much of the work
+only once, for all of the windows, rather than for each window.
+.LP
+.ZN XMapSubwindows
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XRaiseWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XNextEvent.man b/man/XNextEvent.man
new file mode 100644
index 00000000..9b4f5a74
--- /dev/null
+++ b/man/XNextEvent.man
@@ -0,0 +1,351 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XNextEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XNextEvent, XPeekEvent, XWindowEvent, XCheckWindowEvent, XMaskEvent, XCheckMaskEvent, XCheckTypedEvent, XCheckTypedWindowEvent \- select events by type
+.SH SYNTAX
+XNextEvent\^(\^\fIdisplay\fP, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+XPeekEvent\^(\^\fIdisplay\fP, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+XWindowEvent\^(\^\fIdisplay\fP, \fIw\fP\^, \fIevent_mask\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+Bool XCheckWindowEvent\^(\^\fIdisplay\fP, \fIw\fP\^, \fIevent_mask\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+XMaskEvent\^(\^\fIdisplay\fP, \fIevent_mask\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+Bool XCheckMaskEvent\^(\^\fIdisplay\fP, \fIevent_mask\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+Bool XCheckTypedEvent\^(\^\fIdisplay\fP, \fIevent_type\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIevent_type\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.LP
+Bool XCheckTypedWindowEvent\^(\^\fIdisplay\fP, \fIw\fP\^, \fIevent_type\fP\^, \fIevent_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIevent_type\fP\^;
+.br
+ XEvent *\fIevent_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies the event mask.
+.IP \fIevent_return\fP 1i
+Returns the matched event's associated structure.
+.IP \fIevent_return\fP 1i
+Returns the next event in the queue.
+.IP \fIevent_return\fP 1i
+Returns a copy of the matched event's associated structure.
+.IP \fIevent_type\fP 1i
+Specifies the event type to be compared.
+
+.ds Wi \ whose event uou are interested in
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XNextEvent
+function copies the first event from the event queue into the specified
+.ZN XEvent
+structure and then removes it from the queue.
+If the event queue is empty,
+.ZN XNextEvent
+flushes the output buffer and blocks until an event is received.
+.LP
+The
+.ZN XPeekEvent
+function returns the first event from the event queue,
+but it does not remove the event from the queue.
+If the queue is empty,
+.ZN XPeekEvent
+flushes the output buffer and blocks until an event is received.
+It then copies the event into the client-supplied
+.ZN XEvent
+structure without removing it from the event queue.
+.LP
+The
+.ZN XWindowEvent
+function searches the event queue for an event that matches both the specified
+window and event mask.
+When it finds a match,
+.ZN XWindowEvent
+removes that event from the queue and copies it into the specified
+.ZN XEvent
+structure.
+The other events stored in the queue are not discarded.
+If a matching event is not in the queue,
+.ZN XWindowEvent
+flushes the output buffer and blocks until one is received.
+.LP
+The
+.ZN XCheckWindowEvent
+function searches the event queue and then the events available
+on the server connection for the first event that matches the specified window
+and event mask.
+If it finds a match,
+.ZN XCheckWindowEvent
+removes that event, copies it into the specified
+.ZN XEvent
+structure, and returns
+.ZN True .
+The other events stored in the queue are not discarded.
+If the event you requested is not available,
+.ZN XCheckWindowEvent
+returns
+.ZN False ,
+and the output buffer will have been flushed.
+.LP
+The
+.ZN XMaskEvent
+function searches the event queue for the events associated with the
+specified mask.
+When it finds a match,
+.ZN XMaskEvent
+removes that event and copies it into the specified
+.ZN XEvent
+structure.
+The other events stored in the queue are not discarded.
+If the event you requested is not in the queue,
+.ZN XMaskEvent
+flushes the output buffer and blocks until one is received.
+.LP
+The
+.ZN XCheckMaskEvent
+function searches the event queue and then any events available on the
+server connection for the first event that matches the specified mask.
+If it finds a match,
+.ZN XCheckMaskEvent
+removes that event, copies it into the specified
+.ZN XEvent
+structure, and returns
+.ZN True .
+The other events stored in the queue are not discarded.
+If the event you requested is not available,
+.ZN XCheckMaskEvent
+returns
+.ZN False ,
+and the output buffer will have been flushed.
+.LP
+The
+.ZN XCheckTypedEvent
+function searches the event queue and then any events available
+on the server connection for the first event that matches the specified type.
+If it finds a match,
+.ZN XCheckTypedEvent
+removes that event, copies it into the specified
+.ZN XEvent
+structure, and returns
+.ZN True .
+The other events in the queue are not discarded.
+If the event is not available,
+.ZN XCheckTypedEvent
+returns
+.ZN False ,
+and the output buffer will have been flushed.
+.LP
+The
+.ZN XCheckTypedWindowEvent
+function searches the event queue and then any events available
+on the server connection for the first event that matches the specified
+type and window.
+If it finds a match,
+.ZN XCheckTypedWindowEvent
+removes the event from the queue, copies it into the specified
+.ZN XEvent
+structure, and returns
+.ZN True .
+The other events in the queue are not discarded.
+If the event is not available,
+.ZN XCheckTypedWindowEvent
+returns
+.ZN False ,
+and the output buffer will have been flushed.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XIfEvent(3X11),
+XPutBackEvent(3X11),
+XSendEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XNoOp.man b/man/XNoOp.man
new file mode 100644
index 00000000..3e03378c
--- /dev/null
+++ b/man/XNoOp.man
@@ -0,0 +1,159 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XNoOp 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XNoOp \- No Operation
+.SH SYNTAX
+XNoOp\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.SH DESCRIPTION
+The
+.ZN XNoOp
+function sends a
+.ZN NoOperation
+protocol request to the X server,
+thereby exercising the connection.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XOpenDisplay.man b/man/XOpenDisplay.man
new file mode 100644
index 00000000..077c6b35
--- /dev/null
+++ b/man/XOpenDisplay.man
@@ -0,0 +1,258 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XOpenDisplay 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XOpenDisplay, XCloseDisplay \- connect or disconnect to X server
+.SH SYNTAX
+Display *XOpenDisplay\^(\^\fIdisplay_name\fP\^)
+.br
+ char *\fIdisplay_name\fP\^;
+.LP
+XCloseDisplay\^(\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIdisplay_name\fP 1i
+Specifies the hardware display name, which determines the display
+and communications domain to be used.
+On a POSIX-conformant system, if the display_name is NULL,
+it defaults to the value of the DISPLAY environment variable.
+.IN "Environment" "DISPLAY"
+.SH DESCRIPTION
+The
+.ZN XOpenDisplay
+function returns a
+.ZN Display
+structure that serves as the
+connection to the X server and that contains all the information
+about that X server.
+.ZN XOpenDisplay
+connects your application to the X server through TCP
+or DECnet communications protocols,
+or through some local inter-process communication protocol.
+.IN "Protocol" "TCP"
+.IN "Protocol" "DECnet"
+If the hostname is a host machine name and a single colon (:)
+separates the hostname and display number,
+.ZN XOpenDisplay
+connects using TCP streams.
+If the hostname is not specified,
+Xlib uses whatever it believes is the fastest transport.
+If the hostname is a host machine name and a double colon (::)
+separates the hostname and display number,
+.ZN XOpenDisplay
+connects using DECnet.
+A single X server can support any or all of these transport mechanisms
+simultaneously.
+A particular Xlib implementation can support many more of these transport
+mechanisms.
+.LP
+.IN "Display"
+If successful,
+.ZN XOpenDisplay
+returns a pointer to a
+.ZN Display
+structure,
+which is defined in
+.hN X11/Xlib.h .
+If
+.ZN XOpenDisplay
+does not succeed, it returns NULL.
+After a successful call to
+.ZN XOpenDisplay ,
+all of the screens in the display can be used by the client.
+The screen number specified in the display_name argument is returned
+by the
+.ZN DefaultScreen
+macro (or the
+.ZN XDefaultScreen
+function).
+You can access elements of the
+.ZN Display
+and
+.ZN Screen
+structures only by using the information macros or functions.
+For information about using macros and functions to obtain information from
+the
+.ZN Display
+structure,
+see section 2.2.1.
+.LP
+The
+.ZN XCloseDisplay
+function closes the connection to the X server for the display specified in the
+.ZN Display
+structure and destroys all windows, resource IDs
+.Pn ( Window ,
+.ZN Font ,
+.ZN Pixmap ,
+.ZN Colormap ,
+.ZN Cursor ,
+and
+.ZN GContext ),
+or other resources that the client has created
+on this display, unless the close-down mode of the resource has been changed
+(see
+.ZN XSetCloseDownMode ).
+Therefore, these windows, resource IDs, and other resources should never be
+referenced again or an error will be generated.
+Before exiting, you should call
+.ZN XCloseDisplay
+explicitly so that any pending errors are reported as
+.ZN XCloseDisplay
+performs a final
+.ZN XSync
+operation.
+.IN "Resource IDs"
+.IN "XCloseDisplay"
+.LP
+.ZN XCloseDisplay
+can generate a
+.ZN BadGC
+error.
+.SH "SEE ALSO"
+AllPlanes(3X11),
+XFlush(3X11),
+XSetCloseDownMode(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XOpenIM.man b/man/XOpenIM.man
new file mode 100644
index 00000000..8c30aea7
--- /dev/null
+++ b/man/XOpenIM.man
@@ -0,0 +1,339 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XOpenIM 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XOpenIM, XCloseIM, XSetIMValues, XGetIMValues, XDisplayOfIM, XLocaleOfIM, XRegisterIMInstantiateCallback, XUnregisterIMInstantiateCallback \- open, close, and otain input method information
+.SH SYNTAX
+XIM XOpenIM\^(\^\fIdisplay\fP\^, \fIdb\fP\^, \fIres_name\fP\^, \fIres_class\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XrmDatabase \fIdb\fP\^;
+.br
+ char *\fIres_name\fP\^;
+.br
+ char *\fIres_class\fP\^;
+.LP
+Status XCloseIM\^(\^\fIim\fP\^)
+.br
+ XIM \fIim\fP\^;
+.LP
+char * XSetIMValues\^(\^\fIim\fP\^, ...)
+.br
+ XIM \fIim\fP\^;
+.LP
+char * XGetIMValues\^(\^\fIim\fP\^, ...)
+.br
+ XIM \fIim\fP\^;
+.LP
+Display * XDisplayOfIM\^(\^\fIim\fP\^)
+.br
+ XIM \fIim\fP\^;
+.LP
+char * XLocaleOfIM\^(\^\fIim\fP\^)
+.br
+ XIM \fIim\fP\^;
+.LP
+Bool XRegisterIMInstantiateCallback\^(\^\fIdisplay\fP\^, \fIdb\fP\^, \fIres_name\fP\^, \fIres_class\fP\^, \fIcallback\fP\^, \fIclient_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XrmDatabase \fIdb\fP\^;
+.br
+ char *\fIres_name\fP\^;
+.br
+ char *\fIres_class\fP\^;
+.br
+ XIMProc \fIcallback\fP\^;
+.br
+ XPointer *\fIclient_data\fP\^;
+.LP
+Bool XUnregisterIMInstantiateCallback\^(\^\fIdisplay\fP\^, \fIdb\fP\^, \fIres_name\fP\^, \fIres_class\fP\^, \fIcallback\fP\^, \fIclient_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XrmDatabase \fIdb\fP\^;
+.br
+ char *\fIres_name\fP\^;
+.br
+ char *\fIres_class\fP\^;
+.br
+ XIMProc \fIcallback\fP\^;
+.br
+ XPointer *\fIclient_data\fP\^;
+.LP
+.SH ARGUMENTS
+.IP \fIcallback\fP 1i
+Specifies a pointer to the input method instantiate callback.
+.IP \fIclient_data\fP 1i
+Specifies the additional client data.
+.IP \fIdb\fP 1i
+Specifies a pointer to the resource database.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIim\fP 1i
+Specifies the input method.
+.IP \fIres_class\fP 1i
+Specifies the full class name of the application.
+.IP \fIres_name\fP 1i
+Specifies the full resource name of the application.
+.ds Al \ to set or get XIM values
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XOpenIM
+function opens an input method,
+matching the current locale and modifiers specification.
+Current locale and modifiers are bound to the input method at opening time.
+The locale associated with an input method cannot be changed dynamically.
+This implies that the strings returned by
+.ZN XmbLookupString
+or
+.ZN XwcLookupString ,
+for any input context affiliated with a given input method
+will be encoded in the locale current at the time the input method is opened.
+.LP
+The specific input method to which this call will be routed
+is identified on the basis of the current locale.
+.ZN XOpenIM
+will identify a default input method corresponding to the
+current locale.
+That default can be modified using
+.ZN XSetLocaleModifiers
+for the input method modifier.
+.LP
+The db argument is the resource database to be used by the input method
+for looking up resources that are private to the input method.
+It is not intended that this database be used to look
+up values that can be set as IC values in an input context.
+If db is NULL,
+no database is passed to the input method.
+.LP
+The res_name and res_class arguments specify the resource name
+and class of the application.
+They are intended to be used as prefixes by the input method
+when looking up resources that are common to all input contexts
+that may be created for this input method.
+The characters used for resource names and classes must be in the
+X Portable Character Set.
+The resources looked up are not fully specified
+if res_name or res_class is NULL.
+.LP
+The res_name and res_class arguments are not assumed to exist beyond
+the call to
+.ZN XOpenIM .
+The specified resource database is assumed to exist for the lifetime
+of the input method.
+.LP
+.ZN XOpenIM
+returns NULL if no input method could be opened.
+.LP
+The
+.ZN XCloseIM
+function closes the specified input method.
+.LP
+The
+.ZN XSetIMValues
+function presents a variable argument list programming interface
+for setting attributes of the specified input method.
+It returns NULL if it succeeds;
+otherwise,
+it returns the name of the first argument that could not be set.
+Xlib does not attempt to set arguments from the supplied list that
+follow the failed argument;
+all arguments in the list preceding the failed argument have been set
+correctly.
+.LP
+The
+.ZN XGetIMValues
+function presents a variable argument list programming interface
+for querying properties or features of the specified input method.
+This function returns NULL if it succeeds;
+otherwise,
+it returns the name of the first argument that could not be obtained.
+.LP
+Each XIM value argument (following a name) must point to
+a location where the XIM value is to be stored.
+That is, if the XIM value is of type T,
+the argument must be of type T*.
+If T itself is a pointer type,
+then
+.ZN XGetIMValues
+allocates memory to store the actual data,
+and the client is responsible for freeing this data by calling
+.ZN XFree
+with the returned pointer.
+.LP
+The
+.ZN XDisplayOfIM
+function returns the display associated with the specified input method.
+.LP
+The
+.ZN XLocaleOfIM
+function returns the locale associated with the specified input method.
+.LP
+The
+.ZN XRegisterIMInstantiateCallback
+function registers a callback to be invoked whenever a new input method
+becomes available for the specified display that matches the current
+locale and modifiers.
+.LP
+The function returns
+.ZN True
+ if it succeeds; otherwise, it returns
+.ZN False .
+.LP
+The
+.ZN XUnregisterIMInstantiateCallback
+function removes an input method instantiation callback previously
+registered.
+The function returns
+.ZN True
+if it succeeds; otherwise, it returns
+.ZN False .
+.SH "SEE ALSO"
+XCreateIC(3X11),
+XSetICFocus(3X11),
+XSetICValues(3X11),
+XmbResetIC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XOpenOM.man b/man/XOpenOM.man
new file mode 100644
index 00000000..a2668a5a
--- /dev/null
+++ b/man/XOpenOM.man
@@ -0,0 +1,267 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XOpenOM 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XOpenOM, XCloseOM, XSetOMValues, XGetOMValues, XDisplayOfOM, XLocaleOfOM \- open output methods
+.SH SYNTAX
+XOM XOpenOM\^(\^\fIdisplay\fP\^, \fIdb\fP\^, \fIres_name\fP\^, \fIres_class\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XrmDatabase \fIdb\fP\^;
+.br
+ char *\fIres_name\fP\^;
+.br
+ char *\fIres_class\fP\^;
+.LP
+Status XCloseOM\^(\^\fIom\fP\^)
+.br
+ XOM \fIom\fP\^;
+.LP
+char * XSetOMValues\^(\^\fIom\fP\^, ...)
+.br
+ XOM \fIom\fP\^;
+.LP
+char * XGetOMValues\^(\^\fIom\fP\^, ...)
+.br
+ XOM \fIom\fP\^;
+.LP
+Display * XDisplayOfOM\^(\^\fIom\fP\^)
+.br
+ XOM \fIom\fP\^;
+.LP
+char * XLocaleOfOM\^(\^\fIom\fP\^)
+.br
+ XOM \fIom\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIdb\fP 1i
+Specifies a pointer to the resource database.
+.IP \fIres_name\fP 1i
+Specifies the full resource name of the application.
+.IP \fIres_class\fP 1i
+Specifies the full class name of the application.
+.IP \fIom\fP 1i
+Specifies the output method.
+.ds Al \ to set or get XOM values
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XOpenOM
+function opens an output method
+matching the current locale and modifiers specification.
+The current locale and modifiers are bound to the output method
+when
+.ZN XOpenOM
+is called.
+The locale associated with an output method cannot be changed.
+.LP
+The specific output method to which this call will be routed
+is identified on the basis of the current locale and modifiers.
+.ZN XOpenOM
+will identify a default output method corresponding to the
+current locale.
+That default can be modified using
+.ZN XSetLocaleModifiers
+to set the output method modifier.
+.LP
+The db argument is the resource database to be used by the output method
+for looking up resources that are private to the output method.
+It is not intended that this database be used to look
+up values that can be set as OC values in an output context.
+If db is NULL,
+no database is passed to the output method.
+.LP
+The res_name and res_class arguments specify the resource name
+and class of the application.
+They are intended to be used as prefixes by the output method
+when looking up resources that are common to all output contexts
+that may be created for this output method.
+The characters used for resource names and classes must be in the
+X Portable Character Set.
+The resources looked up are not fully specified
+if res_name or res_class is NULL.
+.LP
+The res_name and res_class arguments are not assumed to exist beyond
+the call to
+.ZN XOpenOM .
+The specified resource database is assumed to exist for the lifetime
+of the output method.
+.LP
+.ZN XOpenOM
+returns NULL if no output method could be opened.
+.LP
+The
+.ZN XCloseOM
+function closes the specified output method.
+.LP
+The
+.ZN XSetOMValues
+function presents a variable argument list programming interface
+for setting properties or features of the specified output method.
+This function returns NULL if it succeeds;
+otherwise,
+it returns the name of the first argument that could not be obtained.
+.LP
+No standard arguments are currently defined by Xlib.
+.LP
+The
+.ZN XGetOMValues
+function presents a variable argument list programming interface
+for querying properties or features of the specified output method.
+This function returns NULL if it succeeds;
+otherwise,
+it returns the name of the first argument that could not be obtained.
+.LP
+The
+.ZN XDisplayOfOM
+function returns the display associated with the specified output method.
+.LP
+The
+.ZN XLocaleOfOM
+returns the locale associated with the specified output method.
+.SH "SEE ALSO"
+XCreateOC(3X11),
+XCreateFontSet(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XParseGeometry.man b/man/XParseGeometry.man
new file mode 100644
index 00000000..dd9e7115
--- /dev/null
+++ b/man/XParseGeometry.man
@@ -0,0 +1,304 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XParseGeometry 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XParseGeometry, XWMGeometry \- parse window geometry
+.SH SYNTAX
+int XParseGeometry\^(\^\fIparsestring\fP\^, \fIx_return\fP\^, \fIy_return\fP\^, \fIwidth_return\fP\^, \fIheight_return\fP\^)
+.br
+ char *\fIparsestring\fP\^;
+.br
+ int *\fIx_return\fP\^, *\fIy_return\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP\^, *\fIheight_return\fP\^;
+.LP
+int XWMGeometry\^(\^\fIdisplay\fP, \fIscreen\fP, \fIuser_geom\fP, \
+\fIdef_geom\fP, \fIbwidth\fP, \fIhints\fP, \fIx_return\fP, \fIy_return\fP,
+.br
+ \fIwidth_return\fP, \fIheight_return\fP, \fIgravity_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIscreen\fP\^;
+.br
+ char *\fIuser_geom\fP\^;
+.br
+ char *\fIdef_geom\fP\^;
+.br
+ unsigned int \fIbwidth\fP\^;
+.br
+ XSizeHints *\fIhints\fP\^;
+.br
+ int *\fIx_return\fP, *\fIy_return\fP\^;
+.br
+ int *\fIwidth_return\fP\^;
+.br
+ int *\fIheight_return\fP\^;
+.br
+ int *\fIgravity_return\fP\^;
+.SH ARGUMENTS
+.IP \fIposition\fP 1i
+.br
+.ns
+.IP \fIdefault_position\fP 1i
+Specify the geometry specifications.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfheight\fP 1i
+.br
+.ns
+.IP \fIfwidth\fP 1i
+Specify the font height and width in pixels (increment size).
+.IP \fIparsestring\fP 1i
+Specifies the string you want to parse.
+.IP \fIscreen\fP 1i
+Specifies the screen.
+.IP \fIwidth_return\fP 1i
+.br
+.ns
+.IP \fIheight_return\fP 1i
+Return the width and height determined.
+.IP \fIxadder\fP 1i
+.br
+.ns
+.IP \fIyadder\fP 1i
+Specify additional interior padding needed in the window.
+.IP \fIx_return\fP 1i
+.br
+.ns
+.IP \fIy_return\fP 1i
+Return the x and y offsets.
+.IP \fIbwidth\fP 1i
+Specifies the border width.
+.IP \fIhints\fP 1i
+Specifies the size hints for the window in its normal state.
+.IP \fIdef_geom\fP 1i
+Specifies the application's default geometry or NULL.
+.IP \fIgravity_return\fP 1i
+Returns the window gravity.
+.IP \fIuser_geom\fP 1i
+Specifies the user-specified geometry or NULL.
+.SH DESCRIPTION
+By convention,
+X applications use a standard string to indicate window size and placement.
+.ZN XParseGeometry
+makes it easier to conform to this standard because it allows you
+to parse the standard window geometry.
+Specifically, this function lets you parse strings of the form:
+.LP
+.\" Start marker code here
+.Ds
+[=][<\fIwidth\fP>{xX}<\fIheight\fP>][{+-}<\fIxoffset\fP>{+-}<\fIyoffset\fP>]
+.De
+.\" End marker code here
+.LP
+The fields map into the arguments associated with this function.
+(Items enclosed in <\^> are integers, items in [\^] are optional, and
+items enclosed in {\^} indicate ``choose one of.''
+Note that the brackets should not appear in the actual string.)
+If the string is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+.LP
+The
+.ZN XParseGeometry
+function returns a bitmask that indicates which of the four values (width,
+height, xoffset, and yoffset) were actually found in the string
+and whether the x and y values are negative.
+By convention, \-0 is not equal to +0, because the user needs to
+be able to say ``position the window relative to the right or bottom edge.''
+For each value found, the corresponding argument is updated.
+For each value not found, the argument is left unchanged.
+The bits are represented by
+.ZN XValue ,
+.ZN YValue ,
+.ZN WidthValue ,
+.ZN HeightValue ,
+.ZN XNegative ,
+or
+.ZN YNegative
+and are defined in
+.hN X11/Xutil.h .
+They will be set whenever one of the values is defined
+or one of the signs is set.
+.LP
+If the function returns either the
+.ZN XValue
+or
+.ZN YValue
+flag,
+you should place the window at the requested position.
+.LP
+The
+.ZN XWMGeometry
+function combines any geometry information (given in the format used by
+.ZN XParseGeometry )
+specified by the user and by the calling program with size hints
+(usually the ones to be stored in WM_NORMAL_HINTS) and returns the position,
+size, and gravity
+.Pn ( NorthWestGravity ,
+.ZN NorthEastGravity ,
+.ZN SouthEastGravity ,
+or
+.ZN SouthWestGravity )
+that describe the window.
+If the base size is not set in the
+.ZN XSizeHints
+structure,
+the minimum size is used if set.
+Otherwise, a base size of zero is assumed.
+If no minimum size is set in the hints structure,
+the base size is used.
+A mask (in the form returned by
+.ZN XParseGeometry )
+that describes which values came from the user specification
+and whether or not the position coordinates are relative
+to the right and bottom edges is returned.
+Note that these coordinates will have already been accounted for
+in the x_return and y_return values.
+.LP
+Note that invalid geometry specifications can cause a width or height
+of zero to be returned.
+The caller may pass the address of the hints win_gravity field
+as gravity_return to update the hints directly.
+.SH "SEE ALSO"
+XSetWMProperties(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XPolygonRegion.man b/man/XPolygonRegion.man
new file mode 100644
index 00000000..2b7cb976
--- /dev/null
+++ b/man/XPolygonRegion.man
@@ -0,0 +1,189 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XPolygonRegion 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XPolygonRegion, XClipBox \- generate regions
+.SH SYNTAX
+Region XPolygonRegion\^(\^\fIpoints\fP\^, \fIn\fP\^, \fIfill_rule\fP\^)
+.br
+ XPoint \fIpoints[]\fP\^;
+.br
+ int \fIn\fP\^;
+.br
+ int \fIfill_rule\fP\^;
+.LP
+XClipBox\^(\^\fIr\fP\^, \fIrect_return\fP\^)
+.br
+ Region \fIr\fP\^;
+.br
+ XRectangle *\fIrect_return\fP\^;
+.SH ARGUMENTS
+.IP \fIfill_rule\fP 1i
+Specifies the fill-rule you want to set for the specified GC.
+You can pass
+.ZN EvenOddRule
+or
+.ZN WindingRule .
+.IP \fIn\fP 1i
+Specifies the number of points in the polygon.
+.IP \fIpoints\fP 1i
+Specifies an array of points.
+.IP \fIr\fP 1i
+Specifies the region.
+.IP \fIrect_return\fP 1i
+Returns the smallest enclosing rectangle.
+.SH DESCRIPTION
+The
+.ZN XPolygonRegion
+function returns a region for the polygon defined by the points array.
+For an explanation of fill_rule,
+see
+.ZN XCreateGC .
+.LP
+The
+.ZN XClipBox
+function returns the smallest rectangle enclosing the specified region.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XDrawPoint(3X11),
+XDrawRectangle(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XPropertyEvent.man b/man/XPropertyEvent.man
new file mode 100644
index 00000000..5d290325
--- /dev/null
+++ b/man/XPropertyEvent.man
@@ -0,0 +1,243 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XPropertyEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XPropertyEvent \- PropertyNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN PropertyNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* PropertyNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom atom;
+ Time time;
+ int state; /* PropertyNewValue or PropertyDelete */
+} XPropertyEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window whose associated
+property was changed.
+The atom member is set to the property's atom and indicates which
+property was changed or desired.
+The time member is set to the server time when the property was changed.
+The state member is set to indicate whether the property was changed
+to a new value or deleted and can be
+.ZN PropertyNewValue
+or
+.ZN PropertyDelete .
+The state member is set to
+.ZN PropertyNewValue
+when a property of the window is changed using
+.ZN XChangeProperty
+or
+.ZN XRotateWindowProperties
+(even when adding zero-length data using
+.ZN XChangeProperty )
+and when replacing all or part of a property with identical data using
+.ZN XChangeProperty
+or
+.ZN XRotateWindowProperties .
+The state member is set to
+.ZN PropertyDelete
+when a property of the window is deleted using
+.ZN XDeleteProperty
+or, if the delete argument is
+.ZN True ,
+.ZN XGetWindowProperty .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGetWindowProperty(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XPutBackEvent.man b/man/XPutBackEvent.man
new file mode 100644
index 00000000..262113c5
--- /dev/null
+++ b/man/XPutBackEvent.man
@@ -0,0 +1,170 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XPutBackEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XPutBackEvent \- put events back on the queue
+.SH SYNTAX
+XPutBackEvent\^(\^\fIdisplay\fP, \fIevent\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XEvent *\fIevent\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent\fP 1i
+Specifies the event.
+.SH DESCRIPTION
+The
+.ZN XPutBackEvent
+function pushes an event back onto the head of the display's event queue
+by copying the event into the queue.
+This can be useful if you read an event and then decide that you
+would rather deal with it later.
+There is no limit to the number of times in succession that you can call
+.ZN XPutBackEvent .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XIfEvent(3X11),
+XNextEvent(3X11),
+XSendEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XPutImage.man b/man/XPutImage.man
new file mode 100644
index 00000000..1e2a7936
--- /dev/null
+++ b/man/XPutImage.man
@@ -0,0 +1,437 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XPutImage 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XPutImage, XGetImage, XGetSubImage \- transfer images
+.SH SYNTAX
+XPutImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIgc\fP\^, \fIimage\fP\^, \fIsrc_x\fP, \fIsrc_y\fP, \fIdest_x\fP\^, \fIdest_y\fP\^, \fIwidth\fP\^, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ XImage *\fIimage\fP\^;
+.br
+ int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
+.br
+ int \fIdest_x\fP\^, \fIdest_y\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.LP
+XImage *XGetImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIplane_mask\fP, \fIformat\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned long \fIplane_mask\fP\^;
+.br
+ int \fIformat\fP\^;
+.LP
+XImage *XGetSubImage\^(\^\fIdisplay\fP, \fId\fP\^, \fIx\fP\^, \fIy\fP\^, \fIwidth\fP\^, \fIheight\fP\^, \fIplane_mask\fP, \fIformat\fP\^, \fIdest_image\fP\^, \fIdest_x\fP\^,
+.br
+ \fIdest_y\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned long \fIplane_mask\fP\^;
+.br
+ int \fIformat\fP\^;
+.br
+ XImage *\fIdest_image\fP\^;
+.br
+ int \fIdest_x\fP\^, \fIdest_y\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdest_image\fP 1i
+Specifies the destination image.
+.ds Dx , which are relative to the origin of the drawable \
+and are the coordinates of the subimage \
+or which are relative to the origin of the destination rectangle, \
+specify its upper-left corner, and determine where the subimage \
+is placed in the destination image
+.IP \fIdest_x\fP 1i
+.br
+.ns
+.IP \fIdest_y\fP 1i
+Specify the x and y coordinates\*(Dx.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIformat\fP 1i
+Specifies the format for the image.
+You can pass
+.ZN XYPixmap
+or
+.ZN ZPixmap .
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIimage\fP 1i
+Specifies the image you want combined with the rectangle.
+.IP \fIplane_mask\fP 1i
+Specifies the plane mask.
+.\" *** JIM: NEED MORE INFO FOR THIS. ***
+.IP \fIsrc_x\fP 1i
+Specifies the offset in X from the left edge of the image defined
+by the
+.ZN XImage
+structure.
+.IP \fIsrc_y\fP 1i
+Specifies the offset in Y from the top edge of the image defined
+by the
+.ZN XImage
+structure.
+.ds Wh \ of the subimage, which define the dimensions of the rectangle
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.ds Xy , which are relative to the origin of the drawable \
+and define the upper-left corner of the rectangle
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XPutImage
+function
+combines an image with a rectangle of the specified drawable.
+The section of the image defined by the src_x, src_y, width, and height
+arguments is drawn on the specified part of the drawable.
+If
+.ZN XYBitmap
+format is used, the depth of the image must be one,
+or a
+.ZN BadMatch
+error results.
+The foreground pixel in the GC defines the source for the one bits in the image,
+and the background pixel defines the source for the zero bits.
+For
+.ZN XYPixmap
+and
+.ZN ZPixmap ,
+the depth of the image must match the depth of the drawable,
+or a
+.ZN BadMatch
+error results.
+.LP
+If the characteristics of the image (for example, byte_order and bitmap_unit)
+differ from what the server requires,
+.ZN XPutImage
+automatically makes the appropriate
+conversions.
+.LP
+This function uses these GC components:
+function, plane-mask, subwindow-mode, clip-x-origin, clip-y-origin,
+and clip-mask.
+It also uses these GC mode-dependent components:
+foreground and background.
+.LP
+.ZN XPutImage
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetImage
+function returns a pointer to an
+.ZN XImage
+structure.
+This structure provides you with the contents of the specified rectangle of
+the drawable in the format you specify.
+If the format argument is
+.ZN XYPixmap ,
+the image contains only the bit planes you passed to the plane_mask argument.
+If the plane_mask argument only requests a subset of the planes of the
+display, the depth of the returned image will be the number of planes
+requested.
+If the format argument is
+.ZN ZPixmap ,
+.ZN XGetImage
+returns as zero the bits in all planes not
+specified in the plane_mask argument.
+The function performs no range checking on the values in plane_mask and ignores
+extraneous bits.
+.LP
+.ZN XGetImage
+returns the depth of the image to the depth member of the
+.ZN XImage
+structure.
+The depth of the image is as specified when the drawable was created,
+except when getting a subset of the planes in
+.ZN XYPixmap
+format, when the depth is given by the number of bits set to 1 in plane_mask.
+.LP
+If the drawable is a pixmap,
+the given rectangle must be wholly contained within the pixmap,
+or a
+.ZN BadMatch
+error results.
+If the drawable is a window,
+the window must be viewable,
+and it must be the case that if there were no inferiors or overlapping windows,
+the specified rectangle of the window would be fully visible on the screen
+and wholly contained within the outside edges of the window,
+or a
+.ZN BadMatch
+error results.
+Note that the borders of the window can be included and read with
+this request.
+If the window has backing-store, the backing-store contents are
+returned for regions of the window that are obscured by noninferior
+windows.
+If the window does not have backing-store,
+the returned contents of such obscured regions are undefined.
+The returned contents of visible regions of inferiors
+of a different depth than the specified window's depth are also undefined.
+The pointer cursor image is not included in the returned contents.
+If a problem occurs,
+.ZN XGetImage
+returns NULL.
+.LP
+.ZN XGetImage
+can generate
+.ZN BadDrawable ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XGetSubImage
+function updates dest_image with the specified subimage in the same manner as
+.ZN XGetImage .
+If the format argument is
+.ZN XYPixmap ,
+the image contains only the bit planes you passed to the plane_mask argument.
+If the format argument is
+.ZN ZPixmap ,
+.ZN XGetSubImage
+returns as zero the bits in all planes not
+specified in the plane_mask argument.
+The function performs no range checking on the values in plane_mask and ignores
+extraneous bits.
+As a convenience,
+.ZN XGetSubImage
+returns a pointer to the same
+.ZN XImage
+structure specified by dest_image.
+.LP
+The depth of the destination
+.ZN XImage
+structure must be the same as that of the drawable.
+If the specified subimage does not fit at the specified location
+on the destination image, the right and bottom edges are clipped.
+If the drawable is a pixmap,
+the given rectangle must be wholly contained within the pixmap,
+or a
+.ZN BadMatch
+error results.
+If the drawable is a window,
+the window must be viewable,
+and it must be the case that if there were no inferiors or overlapping windows,
+the specified rectangle of the window would be fully visible on the screen
+and wholly contained within the outside edges of the window,
+or a
+.ZN BadMatch
+error results.
+If the window has backing-store,
+then the backing-store contents are returned for regions of the window
+that are obscured by noninferior windows.
+If the window does not have backing-store,
+the returned contents of such obscured regions are undefined.
+The returned contents of visible regions of inferiors
+of a different depth than the specified window's depth are also undefined.
+If a problem occurs,
+.ZN XGetSubImage
+returns NULL.
+.LP
+.ZN XGetSubImage
+can generate
+.ZN BadDrawable ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XQueryBestSize.man b/man/XQueryBestSize.man
new file mode 100644
index 00000000..6bd0156d
--- /dev/null
+++ b/man/XQueryBestSize.man
@@ -0,0 +1,304 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XQueryBestSize 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XQueryBestSize, XQueryBestTile, XQueryBestStipple \- determine efficient sizes
+.SH SYNTAX
+Status XQueryBestSize\^(\^\fIdisplay\fP, \fIclass\fP, \fIwhich_screen\fP, \fIwidth\fP, \fIheight\fP, \fIwidth_return\fP, \fIheight_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIclass\fP\^;
+.br
+ Drawable \fIwhich_screen\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP, *\fIheight_return\fP\^;
+.LP
+Status XQueryBestTile\^(\^\fIdisplay\fP, \fIwhich_screen\fP, \fIwidth\fP, \fIheight\fP, \fIwidth_return\fP, \fIheight_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fIwhich_screen\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP, *\fIheight_return\fP\^;
+.LP
+Status XQueryBestStipple\^(\^\fIdisplay\fP, \fIwhich_screen\fP, \fIwidth\fP, \fIheight\fP, \fIwidth_return\fP, \fIheight_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fIwhich_screen\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP, *\fIheight_return\fP\^;
+.SH ARGUMENTS
+.IP \fIclass\fP 1i
+Specifies the class that you are interested in.
+You can pass
+.ZN TileShape ,
+.ZN CursorShape ,
+or
+.ZN StippleShape .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height.
+.IP \fIwhich_screen\fP 1i
+Specifies any drawable on the screen.
+.IP \fIwidth_return\fP 1i
+.br
+.ns
+.IP \fIheight_return\fP 1i
+Return the width and height of the object best supported
+by the display hardware.
+.SH DESCRIPTION
+The
+.ZN XQueryBestSize
+function returns the best or closest size to the specified size.
+For
+.ZN CursorShape ,
+this is the largest size that can be fully displayed on the screen specified by
+which_screen.
+For
+.ZN TileShape ,
+this is the size that can be tiled fastest.
+For
+.ZN StippleShape ,
+this is the size that can be stippled fastest.
+For
+.ZN CursorShape ,
+the drawable indicates the desired screen.
+For
+.ZN TileShape
+and
+.ZN StippleShape ,
+the drawable indicates the screen and possibly the window class and depth.
+An
+.ZN InputOnly
+window cannot be used as the drawable for
+.ZN TileShape
+or
+.ZN StippleShape ,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XQueryBestSize
+can generate
+.ZN BadDrawable ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XQueryBestTile
+function returns the best or closest size, that is, the size that can be
+tiled fastest on the screen specified by which_screen.
+The drawable indicates the screen and possibly the window class and depth.
+If an
+.ZN InputOnly
+window is used as the drawable, a
+.ZN BadMatch
+error results.
+.LP
+.ZN XQueryBestTile
+can generate
+.ZN BadDrawable
+and
+.ZN BadMatch
+errors.
+.LP
+The
+.ZN XQueryBestStipple
+function returns the best or closest size, that is, the size that can be
+stippled fastest on the screen specified by which_screen.
+The drawable indicates the screen and possibly the window class and depth.
+If an
+.ZN InputOnly
+window is used as the drawable, a
+.ZN BadMatch
+error results.
+.LP
+.ZN XQueryBestStipple
+can generate
+.ZN BadDrawable
+and
+.ZN BadMatch
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadMatch
+The values do not exist for an
+.ZN InputOnly
+window.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XQueryColor.man b/man/XQueryColor.man
new file mode 100644
index 00000000..ae0cb0e9
--- /dev/null
+++ b/man/XQueryColor.man
@@ -0,0 +1,370 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XQueryColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XQueryColor, XQueryColors, XLookupColor, XParseColor \- obtain color values
+.SH SYNTAX
+XQueryColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIdef_in_out\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XColor *\fIdef_in_out\fP\^;
+.LP
+XQueryColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIdefs_in_out\fP\^, \fIncolors\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XColor \fIdefs_in_out\fP[\^]\^;
+.br
+ int \fIncolors\fP\^;
+.LP
+Status XLookupColor\^(\^\fIdisplay\fP, \fIcolormap\fP, \fIcolor_name\fP, \
+\fIexact_def_return\fP\^, \fIscreen_def_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\fIcolor_name\fP\^;
+.br
+ XColor *\fIexact_def_return\fP\^, *\fIscreen_def_return\fP\^;
+.LP
+Status XParseColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \^\fIspec\fP\^, \fIexact_def_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\fIspec\fP\^;
+.br
+ XColor *\fIexact_def_return\fP\^;
+.SH ARGUMENTS
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.IP \fIcolor_name\fP 1i
+Specifies the color name string (for example, red) whose color
+definition structure you want returned.
+.IP \fIdef_in_out\fP 1i
+Specifies and returns the RGB values for the pixel specified in the structure.
+.IP \fIdefs_in_out\fP 1i
+Specifies and returns an array of color definition structures for the pixel
+specified in the structure.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIexact_def_return\fP 1i
+Returns the exact RGB values.
+.IP \fIncolors\fP 1i
+.\"Specifies the number of color definition structures.
+Specifies the number of
+.ZN XColor
+structures in the color definition array.
+.IP \fIscreen_def_return\fP 1i
+Returns the closest RGB values provided by the hardware.
+.IP \fIspec\fP 1i
+Specifies the color name string;
+case is ignored.
+.IP \fIexact_def_return\fP 1i
+Returns the exact color value for later use and sets the
+.ZN DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue
+flags.
+.SH DESCRIPTION
+The
+.ZN XQueryColor
+function returns the current RGB value for the pixel in the
+.ZN XColor
+structure and sets the
+.ZN DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue
+flags.
+The
+.ZN XQueryColors
+function returns the RGB value for each pixel in each
+.ZN XColor
+structure and sets the
+.ZN DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue
+flags in each structure.
+
+.LP
+.ZN XQueryColor
+and
+.ZN XQueryColors
+can generate
+.ZN BadColor
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XLookupColor
+function looks up the string name of a color with respect to the screen
+associated with the specified colormap.
+It returns both the exact color values and
+the closest values provided by the screen
+with respect to the visual type of the specified colormap.
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+.ZN XLookupColor
+returns nonzero if the name is resolved;
+otherwise, it returns zero.
+.LP
+The
+.ZN XParseColor
+function looks up the string name of a color with respect to the screen
+associated with the specified colormap.
+It returns the exact color value.
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+.ZN XParseColor
+returns nonzero if the name is resolved;
+otherwise, it returns zero.
+.LP
+.ZN XLookupColor
+and
+.ZN XParseColor
+can generate
+.ZN BadColor
+error.
+.SH "COLOR NAMES"
+An RGB Device specification is identified by
+the prefix ``rgb:'' and conforms to the following syntax:
+.LP
+.\" Start marker code here
+.Ds 0
+rgb:\fI<red>/<green>/<blue>\fP
+
+ \fI<red>\fP, \fI<green>\fP, \fI<blue>\fP := \fIh\fP | \fIhh\fP | \fIhhh\fP | \fIhhhh\fP
+ \fIh\fP := single hexadecimal digits (case insignificant)
+.De
+.\" End marker code here
+.LP
+Note that \fIh\fP indicates the value scaled in 4 bits,
+\fIhh\fP the value scaled in 8 bits,
+\fIhhh\fP the value scaled in 12 bits,
+and \fIhhhh\fP the value scaled in 16 bits, respectively.
+.LP
+For backward compatibility, an older syntax for RGB Device is
+supported, but its continued use is not encouraged.
+The syntax is an initial sharp sign character followed by
+a numeric specification, in one of the following formats:
+.LP
+.\" Start marker code here
+.Ds 0
+.TA 2i
+.ta 2i
+#RGB (4 bits each)
+#RRGGBB (8 bits each)
+#RRRGGGBBB (12 bits each)
+#RRRRGGGGBBBB (16 bits each)
+.De
+.\" End marker code here
+.LP
+The R, G, and B represent single hexadecimal digits.
+When fewer than 16 bits each are specified,
+they represent the most significant bits of the value
+(unlike the ``rgb:'' syntax, in which values are scaled).
+For example, the string ``#3a7'' is the same as ``#3000a0007000''.
+.LP
+An RGB intensity specification is identified
+by the prefix ``rgbi:'' and conforms to the following syntax:
+.LP
+.\" Start marker code here
+.Ds 0
+rgbi:\fI<red>/<green>/<blue>\fP
+.De
+.\" End marker code here
+.LP
+Note that red, green, and blue are floating-point values
+between 0.0 and 1.0, inclusive.
+The input format for these values is an optional sign,
+a string of numbers possibly containing a decimal point,
+and an optional exponent field containing an E or e
+followed by a possibly signed integer string.
+.LP
+The standard device-independent string specifications have
+the following syntax:
+.LP
+.\" Start marker code here
+.Ds 0
+CIEXYZ:\fI<X>/<Y>/<Z>\fP
+CIEuvY:\fI<u>/<v>/<Y>\fP
+CIExyY:\fI<x>/<y>/<Y>\fP
+CIELab:\fI<L>/<a>/<b>\fP
+CIELuv:\fI<L>/<u>/<v>\fP
+TekHVC:\fI<H>/<V>/<C>\fP
+.De
+.\" End marker code here
+.LP
+All of the values (C, H, V, X, Y, Z, a, b, u, v, y, x) are
+floating-point values.
+The syntax for these values is an optional plus or minus sign,
+a string of digits possibly containing a decimal point,
+and an optional exponent field consisting of an ``E'' or ``e''
+followed by an optional plus or minus followed by a string of digits.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XAllocColor(3X11),
+XCreateColormap(3X11),
+XStoreColors(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XQueryPointer.man b/man/XQueryPointer.man
new file mode 100644
index 00000000..01ef3715
--- /dev/null
+++ b/man/XQueryPointer.man
@@ -0,0 +1,228 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XQueryPointer 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XQueryPointer \- get pointer coordinates
+.SH SYNTAX
+Bool XQueryPointer\^(\^\fIdisplay\fP, \fIw\fP\^, \fIroot_return\fP\^, \fIchild_return\fP\^, \fIroot_x_return\fP\^, \fIroot_y_return\fP\^,
+.br
+ \fIwin_x_return\fP\^, \fIwin_y_return\fP\^, \fImask_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window *\fIroot_return\fP\^, *\fIchild_return\fP\^;
+.br
+ int *\fIroot_x_return\fP\^, *\fIroot_y_return\fP\^;
+.br
+ int *\fIwin_x_return\fP\^, *\fIwin_y_return\fP\^;
+.br
+ unsigned int *\fImask_return\fP\^;
+.SH ARGUMENTS
+.IP \fIchild_return\fP 1i
+Returns the child window that the pointer is located in, if any.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fImask_return\fP 1i
+Returns the current state of the modifier keys and pointer buttons.
+.ds Ro that the pointer is in
+.IP \fIroot_return\fP 1i
+Returns the root window \*(Ro.
+.IP \fIroot_x_return\fP 1i
+.br
+.ns
+.IP \fIroot_y_return\fP 1i
+Return the pointer coordinates relative to the root window's origin.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIwin_x_return\fP 1i
+.br
+.ns
+.IP \fIwin_y_return\fP 1i
+Return the pointer coordinates relative to the specified window.
+.SH DESCRIPTION
+The
+.ZN XQueryPointer
+function returns the root window the pointer is logically on and the pointer
+coordinates relative to the root window's origin.
+If
+.ZN XQueryPointer
+returns
+.ZN False ,
+the pointer is not on the same screen as the specified window, and
+.ZN XQueryPointer
+returns
+.ZN None
+to child_return and zero to win_x_return and win_y_return.
+If
+.ZN XQueryPointer
+returns
+.ZN True ,
+the pointer coordinates returned to win_x_return and win_y_return
+are relative to the origin of the specified window.
+In this case,
+.ZN XQueryPointer
+returns the child that contains the pointer, if any,
+or else
+.ZN None
+to child_return.
+.LP
+.ZN XQueryPointer
+returns the current logical state of the keyboard buttons
+and the modifier keys in mask_return.
+It sets mask_return to the bitwise inclusive OR of one or more
+of the button or modifier key bitmasks to match
+the current state of the mouse buttons and the modifier keys.
+.LP
+.ZN XQueryPointer
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XGetWindowAttributes(3X11),
+XQueryTree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XQueryTree.man b/man/XQueryTree.man
new file mode 100644
index 00000000..3f1b65e8
--- /dev/null
+++ b/man/XQueryTree.man
@@ -0,0 +1,193 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XQueryTree 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XQueryTree \- query window tree information
+.SH SYNTAX
+Status XQueryTree\^(\^\fIdisplay\fP, \fIw\fP\^, \fIroot_return\fP\^, \fIparent_return\fP\^, \fIchildren_return\fP\^, \fInchildren_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window *\fIroot_return\fP\^;
+.br
+ Window *\fIparent_return\fP\^;
+.br
+ Window **\fIchildren_return\fP\^;
+.br
+ unsigned int *\fInchildren_return\fP\^;
+.SH ARGUMENTS
+.IP \fIchildren_return\fP 1i
+Returns the list of children.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInchildren_return\fP 1i
+Returns the number of children.
+.IP \fIparent_return\fP 1i
+Returns the parent window.
+.IP \fIroot_return\fP 1i
+Returns the root window.
+.ds Wi whose list of children, root, parent, and number of children \
+you want to obtain
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XQueryTree
+function returns the root ID, the parent window ID,
+a pointer to the list of children windows
+(NULL when there are no children),
+and the number of children in the list for the specified window.
+The children are listed in current stacking order, from bottom-most
+(first) to top-most (last).
+.ZN XQueryTree
+returns zero if it fails and nonzero if it succeeds.
+To free a non-NULL children list when it is no longer needed, use
+.ZN XFree .
+.SH BUGS
+This really should return a screen *, not a root window ID.
+.SH "SEE ALSO"
+XFree(3X11),
+XGetWindowAttributes(3X11),
+XQueryPointer(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XRaiseWindow.man b/man/XRaiseWindow.man
new file mode 100644
index 00000000..fea5e6bc
--- /dev/null
+++ b/man/XRaiseWindow.man
@@ -0,0 +1,370 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XRaiseWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XRaiseWindow, XLowerWindow, XCirculateSubwindows, XCirculateSubwindowsUp, XCirculateSubwindowsDown, XRestackWindows \- change window stacking order
+.SH SYNTAX
+XRaiseWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XLowerWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XCirculateSubwindows\^(\^\fIdisplay\fP, \fIw\fP\^, \fIdirection\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ int \fIdirection\fP\^;
+.LP
+XCirculateSubwindowsUp\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XCirculateSubwindowsDown\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XRestackWindows\^(\^\fIdisplay\fP, \fIwindows\fP\^, \^\fInwindows\fP\^);
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIwindows\fP\^[];
+.br
+ int \fInwindows\fP\^;
+.SH ARGUMENTS
+.IP \fIdirection\fP 1i
+Specifies the direction (up or down) that you want to circulate
+the window.
+You can pass
+.ZN RaiseLowest
+or
+.ZN LowerHighest .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInwindows\fP 1i
+Specifies the number of windows to be restacked.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIwindows\fP 1i
+Specifies an array containing the windows to be restacked.
+.SH DESCRIPTION
+The
+.ZN XRaiseWindow
+function
+raises the specified window to the top of the stack so that no sibling window
+obscures it.
+If the windows are regarded as overlapping sheets of paper stacked
+on a desk,
+then raising a window is analogous to moving the sheet to the top of
+the stack but leaving its x and y location on the desk constant.
+Raising a mapped window may generate
+.ZN Expose
+events for the window and any mapped subwindows that were formerly obscured.
+.LP
+If the override-redirect attribute of the window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates a
+.ZN ConfigureRequest
+event, and no processing is performed.
+Otherwise, the window is raised.
+.LP
+.ZN XRaiseWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XLowerWindow
+function lowers the specified window to the bottom of the stack
+so that it does not obscure any sibling
+windows.
+If the windows are regarded as overlapping sheets of paper
+stacked on a desk, then lowering a window is analogous to moving the
+sheet to the bottom of the stack but leaving its x and y location on
+the desk constant.
+Lowering a mapped window will generate
+.ZN Expose
+events on any windows it formerly obscured.
+.LP
+If the override-redirect attribute of the window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates a
+.ZN ConfigureRequest
+event, and no processing is performed.
+Otherwise, the window is lowered to the bottom of the
+stack.
+.LP
+.ZN XLowerWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XCirculateSubwindows
+function circulates children of the specified window in the specified
+direction.
+If you specify
+.ZN RaiseLowest ,
+.ZN XCirculateSubwindows
+raises the lowest mapped child (if any) that is occluded
+by another child to the top of the stack.
+If you specify
+.ZN LowerHighest ,
+.ZN XCirculateSubwindows
+lowers the highest mapped child (if any) that occludes another child
+to the bottom of the stack.
+Exposure processing is then performed on formerly obscured windows.
+If some other client has selected
+.ZN SubstructureRedirectMask
+on the window, the X server generates a
+.ZN CirculateRequest
+event, and no further processing is performed.
+If a child is actually restacked,
+the X server generates a
+.ZN CirculateNotify
+event.
+.LP
+.ZN XCirculateSubwindows
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XCirculateSubwindowsUp
+function raises the lowest mapped child of the specified window that
+is partially
+or completely
+occluded by another child.
+Completely unobscured children are not affected.
+This is a convenience function equivalent to
+.ZN XCirculateSubwindows
+with
+.ZN RaiseLowest
+specified.
+.LP
+.ZN XCirculateSubwindowsUp
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XCirculateSubwindowsDown
+function lowers the highest mapped child of the specified window that partially
+or completely occludes another child.
+Completely unobscured children are not affected.
+This is a convenience function equivalent to
+.ZN XCirculateSubwindows
+with
+.ZN LowerHighest
+specified.
+.LP
+.ZN XCirculateSubwindowsDown
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XRestackWindows
+function restacks the windows in the order specified,
+from top to bottom.
+The stacking order of the first window in the windows array is unaffected,
+but the other windows in the array are stacked underneath the first window,
+in the order of the array.
+The stacking order of the other windows is not affected.
+For each window in the window array that is not a child of the specified window,
+a
+.ZN BadMatch
+error results.
+.LP
+If the override-redirect attribute of a window is
+.ZN False
+and some
+other client has selected
+.ZN SubstructureRedirectMask
+on the parent, the X server generates
+.ZN ConfigureRequest
+events for each window whose override-redirect flag is not set,
+and no further processing is performed.
+Otherwise, the windows will be restacked in top-to-bottom order.
+.LP
+.ZN XRestackWindows
+can generate
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XMapWindow(3X11),
+XUnmapWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XReadBitmapFile.man b/man/XReadBitmapFile.man
new file mode 100644
index 00000000..4c384e0a
--- /dev/null
+++ b/man/XReadBitmapFile.man
@@ -0,0 +1,395 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XReadBitmapFile 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XReadBitmapFile, XReadBitmapFileData, XWriteBitmapFile, XCreatePixmapFromBitmapData, XCreateBitmapFromData \- manipulate bitmaps
+.SH SYNTAX
+int XReadBitmapFile(\^\fIdisplay\fP, \fId\fP, \fIfilename\fP, \fIwidth_return\fP, \fIheight_return\fP, \fIbitmap_return\fP, \fIx_hot_return\fP,
+.br
+ \fIy_hot_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ char *\fIfilename\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP, *\fIheight_return\fP\^;
+.br
+ Pixmap *\fIbitmap_return\fP\^;
+.br
+ int *\fIx_hot_return\fP, *\fIy_hot_return\fP\^;
+.LP
+int XReadBitmapFileData(\^\fIfilename\fP, \fIwidth_return\fP, \fIheight_return\fP, \fIdata_return\fP, \fIx_hot_return\fP, \fIy_hot_return\fP\^)
+.br
+ char *\fIfilename\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP, *\fIheight_return\fP\^;
+.br
+ unsigned char *\fIdata_return\fP\^;
+.br
+ int *\fIx_hot_return\fP, *\fIy_hot_return\fP\^;
+.LP
+int XWriteBitmapFile(\^\fIdisplay\fP, \fIfilename\fP, \fIbitmap\fP, \fIwidth\fP, \fIheight\fP, \fIx_hot\fP, \fIy_hot\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIfilename\fP\^;
+.br
+ Pixmap \fIbitmap\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.br
+ int \fIx_hot\fP, \fIy_hot\fP\^;
+.LP
+Pixmap XCreatePixmapFromBitmapData\^(\^\fIdisplay\fP, \fId\fP, \fIdata\fP, \fIwidth\fP, \fIheight\fP, \fIfg\fP, \fIbg\fP, \fIdepth\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ char *\fIdata\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.br
+ unsigned long \fIfg\fP, \fIbg\fP\^;
+.br
+ unsigned int \fIdepth\fP\^;
+.LP
+Pixmap XCreateBitmapFromData(\^\fIdisplay\fP, \fId\fP, \fIdata\fP, \fIwidth\fP, \fIheight\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ char *\fIdata\fP\^;
+.br
+ unsigned int \fIwidth\fP, \fIheight\fP\^;
+.SH ARGUMENTS
+.IP \fIbitmap\fP 1i
+Specifies the bitmap.
+.IP \fIbitmap_return\fP 1i
+Returns the bitmap that is created.
+.ds Dr \ that indicates the screen
+.IP \fId\fP 1i
+Specifies the drawable\*(Dr.
+.IP \fIdata\fP 1i
+Specifies the data in bitmap format.
+.IP \fIdata\fP 1i
+Specifies the location of the bitmap data.
+.IP \fIdata_return\fP 1i
+Returns the bitmap data.
+.IP \fIdepth\fP 1i
+Specifies the depth of the pixmap.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfg\fP 1i
+.br
+.ns
+.IP \fIbg\fP 1i
+Specify the foreground and background pixel values to use.
+.IP \fIfilename\fP 1i
+Specifies the file name to use.
+The format of the file name is operating-system dependent.
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height.
+.IP \fIwidth_return\fP 1i
+.br
+.ns
+.IP \fIheight_return\fP 1i
+Return the width and height values of the read in bitmap file.
+.IP \fIx_hot\fP 1i
+.br
+.ns
+.IP \fIy_hot\fP 1i
+Specify where to place the hotspot coordinates (or \-1,\-1 if none are present)
+in the file.
+.IP \fIx_hot_return\fP 1i
+.br
+.ns
+.IP \fIy_hot_return\fP 1i
+Return the hotspot coordinates.
+.SH DESCRIPTION
+The
+.ZN XReadBitmapFile
+function reads in a file containing a bitmap.
+The file is parsed in the encoding of the current locale.
+The ability to read other than the standard format
+is implementation-dependent.
+If the file cannot be opened,
+.ZN XReadBitmapFile
+returns
+.ZN BitmapOpenFailed .
+If the file can be opened but does not contain valid bitmap data,
+it returns
+.ZN BitmapFileInvalid .
+If insufficient working storage is allocated,
+it returns
+.ZN BitmapNoMemory .
+If the file is readable and valid,
+it returns
+.ZN BitmapSuccess .
+.LP
+.ZN XReadBitmapFile
+returns the bitmap's height and width, as read
+from the file, to width_return and height_return.
+It then creates a pixmap of the appropriate size,
+reads the bitmap data from the file into the pixmap,
+and assigns the pixmap to the caller's variable bitmap.
+The caller must free the bitmap using
+.ZN XFreePixmap
+when finished.
+If \fIname\fP_x_hot and \fIname\fP_y_hot exist,
+.ZN XReadBitmapFile
+returns them to x_hot_return and y_hot_return;
+otherwise, it returns \-1,\-1.
+.LP
+.ZN XReadBitmapFile
+can generate
+.ZN BadAlloc
+and
+.ZN BadDrawable
+errors.
+.LP
+The
+.ZN XReadBitmapFileData
+function reads in a file containing a bitmap, in the same manner as
+.ZN XReadBitmapFile ,
+but returns the data directly rather than creating a pixmap in the server.
+The bitmap data is returned in data_return; the client must free this
+storage when finished with it by calling
+.ZN XFree .
+The status and other return values are the same as for
+.ZN XReadBitmapFile .
+.LP
+The
+.ZN XWriteBitmapFile
+function writes a bitmap out to a file in the X Version 11 format.
+The name used in the output file is derived from the file name
+by deleting the directory prefix.
+The file is written in the encoding of the current locale.
+If the file cannot be opened for writing,
+it returns
+.ZN BitmapOpenFailed .
+If insufficient memory is allocated,
+.ZN XWriteBitmapFile
+returns
+.ZN BitmapNoMemory ;
+otherwise, on no error,
+it returns
+.ZN BitmapSuccess .
+If x_hot and y_hot are not \-1, \-1,
+.ZN XWriteBitmapFile
+writes them out as the hotspot coordinates for the bitmap.
+.LP
+.ZN XWriteBitmapFile
+can generate
+.ZN BadDrawable
+and
+.ZN BadMatch
+errors.
+.LP
+The
+.ZN XCreatePixmapFromBitmapData
+function creates a pixmap of the given depth and then does a bitmap-format
+.ZN XPutImage
+of the data into it.
+The depth must be supported by the screen of the specified drawable,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XCreatePixmapFromBitmapData
+can generate
+.ZN BadAlloc
+and
+.ZN BadMatch
+errors.
+.LP
+The
+.ZN XCreateBitmapFromData
+function allows you to include in your C program (using
+.ZN #include )
+a bitmap file that was written out by
+.ZN XWriteBitmapFile
+(X version 11 format only) without reading in the bitmap file.
+The following example creates a gray bitmap:
+.LP
+.Ds 0
+#include "gray.bitmap"
+.sp 6p
+Pixmap bitmap;
+bitmap = XCreateBitmapFromData(display, window, gray_bits, gray_width, gray_height);
+.De
+.LP
+If insufficient working storage was allocated,
+.ZN XCreateBitmapFromData
+returns
+.ZN None .
+It is your responsibility to free the
+bitmap using
+.ZN XFreePixmap
+when finished.
+.LP
+.ZN XCreateBitmapFromData
+can generate a
+.ZN BadAlloc
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.TP 1i
+.ZN BadMatch
+An
+.ZN InputOnly
+window is used as a Drawable.
+.SH "SEE ALSO"
+XCreatePixmap(3X11),
+XPutImage(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XRecolorCursor.man b/man/XRecolorCursor.man
new file mode 100644
index 00000000..801777f2
--- /dev/null
+++ b/man/XRecolorCursor.man
@@ -0,0 +1,245 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XRecolorCursor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XRecolorCursor, XFreeCursor, XQueryBestCursor \- manipulate cursors
+.SH SYNTAX
+XRecolorCursor\^(\^\fIdisplay\fP, \fIcursor\fP\^, \fIforeground_color\fP\^, \fIbackground_color\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.br
+ XColor *\fIforeground_color\fP\^, *\fIbackground_color\fP\^;
+.LP
+XFreeCursor\^(\^\fIdisplay\fP, \fIcursor\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Cursor \fIcursor\fP\^;
+.LP
+Status XQueryBestCursor\^(\^\fIdisplay\fP, \fId\fP, \fIwidth\fP\^, \fIheight\fP\^, \fIwidth_return\fP\^, \fIheight_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ unsigned int \fIwidth\fP\^, \fIheight\fP\^;
+.br
+ unsigned int *\fIwidth_return\fP\^, *\fIheight_return\fP\^;
+.SH ARGUMENTS
+.IP \fIbackground_color\fP 1i
+Specifies the RGB values for the background of the source.
+.IP \fIcursor\fP 1i
+Specifies the cursor.
+.ds Dr , which indicates the screen
+.IP \fId\fP 1i
+Specifies the drawable\*(Dr.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIforeground_color\fP 1i
+Specifies the RGB values for the foreground of the source.
+.ds Wh of the cursor that you want the size information for
+.IP \fIwidth\fP 1i
+.br
+.ns
+.IP \fIheight\fP 1i
+Specify the width and height\*(Wh.
+.IP \fIwidth_return\fP 1i
+.br
+.ns
+.IP \fIheight_return\fP 1i
+Return the best width and height that is closest to the specified width
+and height.
+.SH DESCRIPTION
+The
+.ZN XRecolorCursor
+function changes the color of the specified cursor, and
+if the cursor is being displayed on a screen,
+the change is visible immediately.
+The pixel members of the
+.ZN XColor
+structures are ignored; only the RGB values are used.
+.LP
+.ZN XRecolorCursor
+can generate a
+.ZN BadCursor
+error.
+.LP
+The
+.ZN XFreeCursor
+function deletes the association between the cursor resource ID
+and the specified cursor.
+The cursor storage is freed when no other resource references it.
+The specified cursor ID should not be referred to again.
+.LP
+.ZN XFreeCursor
+can generate a
+.ZN BadCursor
+error.
+.LP
+Some displays allow larger cursors than other displays.
+The
+.ZN XQueryBestCursor
+function provides a way to find out what size cursors are actually
+possible on the display.
+.IN "Cursor" "limitations"
+It returns the largest size that can be displayed.
+Applications should be prepared to use smaller cursors on displays that
+cannot support large ones.
+.LP
+.ZN XQueryBestCursor
+can generate a
+.ZN BadDrawable
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadDrawable
+A value for a Drawable argument does not name a defined Window or Pixmap.
+.SH "SEE ALSO"
+XCreateColormap(3X11),
+XCreateFontCursor(3X11),
+XDefineCusor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XReparentEvent.man b/man/XReparentEvent.man
new file mode 100644
index 00000000..7eb9a111
--- /dev/null
+++ b/man/XReparentEvent.man
@@ -0,0 +1,230 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XReparentEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XReparentEvent \- ReparentNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN ReparentNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ReparentNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Window parent;
+ int x, y;
+ Bool override_redirect;
+} XReparentEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the reparented window
+or to the old or the new parent, depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+The window member is set to the window that was reparented.
+The parent member is set to the new parent window.
+The x and y members are set to the reparented window's coordinates relative
+to the new parent window's
+origin and define the upper-left outer corner of the reparented window.
+The override_redirect member is set to the override-redirect attribute of the
+window specified by the window member.
+Window manager clients normally should ignore this window
+if the override_redirect member is
+.ZN True .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XReparentWindow.man b/man/XReparentWindow.man
new file mode 100644
index 00000000..6685c4f4
--- /dev/null
+++ b/man/XReparentWindow.man
@@ -0,0 +1,233 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XReparentWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XReparentWindow \- reparent windows
+.SH SYNTAX
+XReparentWindow\^(\^\fIdisplay\fP, \fIw\fP\^, \fIparent\fP\^, \fIx\fP\^, \fIy\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window \fIparent\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIparent\fP 1i
+Specifies the parent window.
+.IP \fIw\fP 1i
+Specifies the window.
+.ds Xy of the position in the new parent window
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+If the specified window is mapped,
+.ZN XReparentWindow
+automatically performs an
+.ZN UnmapWindow
+request on it, removes it from its current position in the hierarchy,
+and inserts it as the child of the specified parent.
+The window is placed in the stacking order on top with respect to
+sibling windows.
+.LP
+After reparenting the specified window,
+.ZN XReparentWindow
+causes the X server to generate a
+.ZN ReparentNotify
+event.
+The override_redirect member returned in this event is
+set to the window's corresponding attribute.
+Window manager clients usually should ignore this window if this member
+is set to
+.ZN True .
+Finally, if the specified window was originally mapped,
+the X server automatically performs a
+.ZN MapWindow
+request on it.
+.LP
+The X server performs normal exposure processing on formerly obscured
+windows.
+The X server might not generate
+.ZN Expose
+events for regions from the initial
+.ZN UnmapWindow
+request that are immediately obscured by the final
+.ZN MapWindow
+request.
+A
+.ZN BadMatch
+error results if:
+.IP \(bu 5
+The new parent window is not on the same screen as
+the old parent window.
+.IP \(bu 5
+The new parent window is the specified window or an inferior of the
+specified window.
+.IP \(bu 5
+The new parent is
+.ZN InputOnly ,
+and the window is not.
+.IP \(bu 5
+The specified window has a
+.ZN ParentRelative
+background, and the new parent window is not the same depth as the
+specified window.
+.LP
+.ZN XReparentWindow
+can generate
+.ZN BadMatch
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeSaveSet(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XResizeRequestEvent.man b/man/XResizeRequestEvent.man
new file mode 100644
index 00000000..080e85d9
--- /dev/null
+++ b/man/XResizeRequestEvent.man
@@ -0,0 +1,215 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XResizeRequestEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XResizeRequestEvent \- ResizeRequest event structure
+.SH STRUCTURES
+The structure for
+.ZN ResizeRequest
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* ResizeRequest */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int width, height;
+} XResizeRequestEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window whose size another
+client attempted to change.
+The width and height members are set to the inside size of the window,
+excluding the border.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XResourceManagerString.man b/man/XResourceManagerString.man
new file mode 100644
index 00000000..566d59d8
--- /dev/null
+++ b/man/XResourceManagerString.man
@@ -0,0 +1,186 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XResourceManagerString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XResourceManagerString, XScreenResourceString \- obtain server resource properties
+.SH SYNTAX
+char *XResourceManagerString\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+char *XScreenResourceString\^(\^\fIscreen\fP\^)
+.br
+ Screen *\fIscreen\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen\fP 1i
+Specifies the screen.
+.SH DESCRIPTION
+The
+.ZN XResourceManagerString
+function returns the RESOURCE_MANAGER property from the server's root
+window of screen zero, which was returned when the connection was opened using
+.ZN XOpenDisplay .
+The property is converted from type STRING to the current locale.
+The conversion is identical to that produced by
+.ZN XmbTextPropertyToTextList
+for a single element STRING property.
+The returned string is owned by Xlib and should not be freed by the client.
+The property value must be in a format that is acceptable to
+.ZN XrmGetStringDatabase .
+If no property exists, NULL is returned.
+.LP
+The
+.ZN XScreenResourceString
+function returns the SCREEN_RESOURCES property from the root window of the
+specified screen.
+The property is converted from type STRING to the current locale.
+The conversion is identical to that produced by
+.ZN XmbTextPropertyToTextList
+for a single element STRING property.
+The property value must be in a format that is acceptable to
+.ZN XrmGetStringDatabase .
+If no property exists, NULL is returned.
+The caller is responsible for freeing the returned string by using
+.ZN XFree .
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSaveContext.man b/man/XSaveContext.man
new file mode 100644
index 00000000..428479c5
--- /dev/null
+++ b/man/XSaveContext.man
@@ -0,0 +1,222 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSaveContext 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSaveContext, XFindContext, XDeleteContext, XUniqueContext \- associative look-up routines
+.SH SYNTAX
+int XSaveContext(\^\fIdisplay\fP, \fIrid\fP, \fIcontext\fP, \fIdata\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIrid\fP\^;
+.br
+ XContext \fIcontext\fP\^;
+.br
+ XPointer \fIdata\fP\^;
+.LP
+int XFindContext(\^\fIdisplay\fP, \fIrid\fP, \fIcontext\fP, \fIdata_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIrid\fP\^;
+.br
+ XContext \fIcontext\fP\^;
+.br
+ XPointer *\fIdata_return\fP\^;
+.LP
+int XDeleteContext(\^\fIdisplay\fP, \fIrid\fP, \fIcontext\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIrid\fP;
+.br
+ XContext \fIcontext\fP;
+.LP
+XContext XUniqueContext(\^)
+.SH ARGUMENTS
+.IP \fIcontext\fP 1i
+Specifies the context type to which the data belongs.
+.IP \fIdata\fP 1i
+Specifies the data to be associated with the window and type.
+.IP \fIdata_return\fP 1i
+Returns the data.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIrid\fP 1i
+Specifies the resource ID with which the data is associated.
+.SH DESCRIPTION
+If an entry with the specified resource ID and type already exists,
+.ZN XSaveContext
+overrides it with the specified context.
+The
+.ZN XSaveContext
+function returns a nonzero error code if an error has occurred
+and zero otherwise.
+Possible errors are
+.ZN XCNOMEM
+(out of memory).
+.LP
+Because it is a return value,
+the data is a pointer.
+The
+.ZN XFindContext
+function returns a nonzero error code if an error has occurred
+and zero otherwise.
+Possible errors are
+.ZN XCNOENT
+(context-not-found).
+.LP
+The
+.ZN XDeleteContext
+function deletes the entry for the given resource ID
+and type from the data structure.
+This function returns the same error codes that
+.ZN XFindContext
+returns if called with the same arguments.
+.ZN XDeleteContext
+does not free the data whose address was saved.
+.LP
+The
+.ZN XUniqueContext
+function creates a unique context type that may be used in subsequent calls to
+.ZN XSaveContext .
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSelectInput.man b/man/XSelectInput.man
new file mode 100644
index 00000000..42b9ed81
--- /dev/null
+++ b/man/XSelectInput.man
@@ -0,0 +1,215 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSelectInput 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSelectInput \- select input events
+.SH SYNTAX
+XSelectInput\^(\^\fIdisplay\fP, \fIw\fP\^, \fIevent_mask\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies the event mask.
+.ds Wi whose events you are interested in
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XSelectInput
+function requests that the X server report the events associated with the
+specified event mask.
+Initially, X will not report any of these events.
+Events are reported relative to a window.
+If a window is not interested in a device event, it usually propagates to
+the closest ancestor that is interested,
+unless the do_not_propagate mask prohibits it.
+.IN "Event" "propagation"
+.LP
+Setting the event-mask attribute of a window overrides any previous call
+for the same window but not for other clients.
+Multiple clients can select for the same events on the same window
+with the following restrictions:
+.IP \(bu 5
+Multiple clients can select events on the same window because their event masks
+are disjoint.
+When the X server generates an event, it reports it
+to all interested clients.
+.IP \(bu 5
+Only one client at a time can select
+.ZN CirculateRequest ,
+.ZN ConfigureRequest ,
+or
+.ZN MapRequest
+events, which are associated with
+the event mask
+.ZN SubstructureRedirectMask .
+.IP \(bu 5
+Only one client at a time can select
+a
+.ZN ResizeRequest
+event, which is associated with
+the event mask
+.ZN ResizeRedirectMask .
+.IP \(bu 5
+Only one client at a time can select a
+.ZN ButtonPress
+event, which is associated with
+the event mask
+.ZN ButtonPressMask .
+.LP
+The server reports the event to all interested clients.
+.LP
+.ZN XSelectInput
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSelectionClearEvent.man b/man/XSelectionClearEvent.man
new file mode 100644
index 00000000..4313f17c
--- /dev/null
+++ b/man/XSelectionClearEvent.man
@@ -0,0 +1,220 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSelectionClearEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSelectionClearEvent \- SelectionClear event structure
+.SH STRUCTURES
+The structure for
+.ZN SelectionClear
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* SelectionClear */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ Atom selection;
+ Time time;
+} XSelectionClearEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The selection member is set to the selection atom.
+The time member is set to the last change time recorded for the
+selection.
+The window member is the window that was specified by the current owner
+(the owner losing the selection) in its
+.ZN XSetSelectionOwner
+call.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XSetSelectionOwner(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSelectionEvent.man b/man/XSelectionEvent.man
new file mode 100644
index 00000000..0df21cbb
--- /dev/null
+++ b/man/XSelectionEvent.man
@@ -0,0 +1,228 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSelectionEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSelectionEvent \- SelectionNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN SelectionNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* SelectionNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property; /* atom or None */
+ Time time;
+} XSelectionEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The requestor member is set to the window associated with
+the requestor of the selection.
+The selection member is set to the atom that indicates the selection.
+For example, PRIMARY is used for the primary selection.
+The target member is set to the atom that indicates the converted type.
+For example, PIXMAP is used for a pixmap.
+The property member is set to the atom that indicates which
+property the result was stored on.
+If the conversion failed,
+the property member is set to
+.ZN None .
+The time member is set to the time the conversion took place and
+can be a timestamp or
+.ZN CurrentTime .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSelectionRequestEvent.man b/man/XSelectionRequestEvent.man
new file mode 100644
index 00000000..2b28167f
--- /dev/null
+++ b/man/XSelectionRequestEvent.man
@@ -0,0 +1,232 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSelectionRequestEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSelectionRequestEvent \- SelectionRequest event structure
+.SH STRUCTURES
+The structure for
+.ZN SelectionRequest
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* SelectionRequest */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window owner;
+ Window requestor;
+ Atom selection;
+ Atom target;
+ Atom property;
+ Time time;
+} XSelectionRequestEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The owner member is set to the window
+that was specified by the current owner in its
+.ZN XSetSelectionOwner
+call.
+The requestor member is set to the window requesting the selection.
+The selection member is set to the atom that names the selection.
+For example, PRIMARY is used to indicate the primary selection.
+The target member is set to the atom that indicates the type
+the selection is desired in.
+The property member can be a property name or
+.ZN None .
+The time member is set to the timestamp or
+.ZN CurrentTime
+value from the
+.ZN ConvertSelection
+request.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSetSelectionOwner(3X11),
+XUnmapEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSendEvent.man b/man/XSendEvent.man
new file mode 100644
index 00000000..59fcd4cd
--- /dev/null
+++ b/man/XSendEvent.man
@@ -0,0 +1,330 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSendEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSendEvent, XDisplayMotionBufferSize, XGetMotionEvents, XTimeCoord \- send events and pointer motion history structure
+.SH SYNTAX
+Status XSendEvent\^(\^\fIdisplay\fP, \fIw\fP\^, \fIpropagate\fP\^, \fIevent_mask\fP\^, \fIevent_send\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Bool \fIpropagate\fP\^;
+.br
+ long \fIevent_mask\fP\^;
+.br
+ XEvent *\fIevent_send\fP\^;
+.LP
+unsigned long XDisplayMotionBufferSize\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XTimeCoord *XGetMotionEvents\^(\^\fIdisplay\fP, \fIw\fP\^, \fIstart\fP\^, \fIstop\fP\^, \fInevents_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Time \fIstart\fP\^, \fIstop\fP\^;
+.br
+ int *\fInevents_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIevent_mask\fP 1i
+Specifies the event mask.
+.IP \fIevent_send\fP 1i
+Specifies the event that is to be sent.
+.IP \fInevents_return\fP 1i
+Returns the number of events from the motion history buffer.
+.IP \fIpropagate\fP 1i
+Specifies a Boolean value.
+.IP \fIstart\fP 1i
+.br
+.ns
+.IP \fIstop\fP 1i
+Specify the time interval in which the events are returned from the motion
+history buffer.
+You can pass a timestamp or
+.ZN CurrentTime .
+.ds Wi the window the event is to be sent to,
+.ZN PointerWindow , \
+or \
+.ZN InputFocus .
+.IP \fIw\fP 1i
+Specifies the window \*(Wi.
+.SH DESCRIPTION
+The
+.ZN XSendEvent
+function identifies the destination window,
+determines which clients should receive the specified events,
+and ignores any active grabs.
+This function requires you to pass an event mask.
+For a discussion of the valid event mask names,
+see section 10.3.
+This function uses the w argument to identify the destination window as follows:
+.IP \(bu 5
+If w is
+.ZN PointerWindow ,
+the destination window is the window that contains the pointer.
+.IP \(bu 5
+If w is
+.ZN InputFocus
+and if the focus window contains the pointer,
+the destination window is the window that contains the pointer;
+otherwise, the destination window is the focus window.
+.LP
+To determine which clients should receive the specified events,
+.ZN XSendEvent
+uses the propagate argument as follows:
+.IP \(bu 5
+If event_mask is the empty set,
+the event is sent to the client that created the destination window.
+If that client no longer exists,
+no event is sent.
+.IP \(bu 5
+If propagate is
+.ZN False ,
+the event is sent to every client selecting on destination any of the event
+types in the event_mask argument.
+.IP \(bu 5
+If propagate is
+.ZN True
+and no clients have selected on destination any of
+the event types in event-mask, the destination is replaced with the
+closest ancestor of destination for which some client has selected a
+type in event-mask and for which no intervening window has that type in its
+do-not-propagate-mask.
+If no such window exists or if the window is
+an ancestor of the focus window and
+.ZN InputFocus
+was originally specified
+as the destination, the event is not sent to any clients.
+Otherwise, the event is reported to every client selecting on the final
+destination any of the types specified in event_mask.
+.LP
+The event in the
+.ZN XEvent
+structure must be one of the core events or one of the events
+defined by an extension (or a
+.ZN BadValue
+error results) so that the X server can correctly byte-swap
+the contents as necessary.
+The contents of the event are
+otherwise unaltered and unchecked by the X server except to force send_event to
+.ZN True
+in the forwarded event and to set the serial number in the event correctly;
+therefore these fields
+and the display field are ignored by
+.ZN XSendEvent .
+.LP
+.ZN XSendEvent
+returns zero if the conversion to wire protocol format failed
+and returns nonzero otherwise.
+.ZN XSendEvent
+can generate
+.ZN BadValue
+and
+.ZN BadWindow
+errors.
+.LP
+The server may retain the recent history of the pointer motion
+and do so to a finer granularity than is reported by
+.ZN MotionNotify
+events.
+The
+.ZN XGetMotionEvents
+function makes this history available.
+.LP
+The
+.ZN XGetMotionEvents
+function returns all events in the motion history buffer that fall between the
+specified start and stop times, inclusive, and that have coordinates
+that lie within the specified window (including its borders) at its present
+placement.
+If the server does not support motion history,
+if the start time is later than the stop time,
+or if the start time is in the future,
+no events are returned;
+.ZN XGetMotionEvents
+returns NULL.
+If the stop time is in the future, it is equivalent to specifying
+.ZN CurrentTime .
+.ZN XGetMotionEvents
+can generate a
+.ZN BadWindow
+error.
+.SH STRUCTURES
+The
+.ZN XTimeCoord
+structure contains:
+.LP
+.Ds 0
+.TA .5i
+.ta .5i
+typedef struct {
+ Time time;
+ short x, y;
+} XTimeCoord;
+.De
+.LP
+The time member is set to the time, in milliseconds.
+The x and y members are set to the coordinates of the pointer and
+are reported relative to the origin
+of the specified window.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XIfEvent(3X11),
+XNextEvent(3X11),
+XPutBackEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetArcMode.man b/man/XSetArcMode.man
new file mode 100644
index 00000000..4c0346ab
--- /dev/null
+++ b/man/XSetArcMode.man
@@ -0,0 +1,255 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetArcMode 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetArcMode, XSetSubwindowMode, XSetGraphicsExposure \- GC convenience routines
+.SH SYNTAX
+XSetArcMode\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIarc_mode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIarc_mode\fP\^;
+.LP
+XSetSubwindowMode\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIsubwindow_mode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIsubwindow_mode\fP\^;
+.LP
+XSetGraphicsExposures\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIgraphics_exposures\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Bool \fIgraphics_exposures\fP\^;
+.SH ARGUMENTS
+.IP \fIarc_mode\fP 1i
+Specifies the arc mode.
+You can pass
+.ZN ArcChord
+or
+.ZN ArcPieSlice .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIgraphics_exposures\fP 1i
+Specifies a Boolean value that indicates whether you want
+.ZN GraphicsExpose
+and
+.ZN NoExpose
+events to be reported when calling
+.ZN XCopyArea
+and
+.ZN XCopyPlane
+with this GC.
+.IP \fIsubwindow_mode\fP 1i
+Specifies the subwindow mode.
+You can pass
+.ZN ClipByChildren
+or
+.ZN IncludeInferiors .
+.SH DESCRIPTION
+The
+.ZN XSetArcMode
+function sets the arc mode in the specified GC.
+.LP
+.ZN XSetArcMode
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetSubwindowMode
+function sets the subwindow mode in the specified GC.
+.LP
+.ZN XSetSubwindowMode
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetGraphicsExposures
+function sets the graphics-exposures flag in the specified GC.
+.LP
+.ZN XSetGraphicsExposures
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCopyArea(3X11),
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetClipOrigin.man b/man/XSetClipOrigin.man
new file mode 100644
index 00000000..7c1ad162
--- /dev/null
+++ b/man/XSetClipOrigin.man
@@ -0,0 +1,312 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetClipOrigin 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetClipOrigin, XSetClipMask, XSetClipRectangles \- GC convenience routines
+.SH SYNTAX
+XSetClipOrigin\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIclip_x_origin\fP\^, \fIclip_y_origin\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIclip_x_origin\fP\^, \fIclip_y_origin\fP\^;
+.LP
+XSetClipMask\^(\^\fIdisplay\fP, \fIgc\fP, \fIpixmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Pixmap \fIpixmap\fP\^;
+.LP
+XSetClipRectangles\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIclip_x_origin\fP\^, \fIclip_y_origin\fP\^, \fIrectangles\fP\^, \fIn\fP\^, \fIordering\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIclip_x_origin\fP\^, \fIclip_y_origin\fP\^;
+.br
+ XRectangle \fIrectangles\fP[]\^;
+.br
+ int \fIn\fP\^;
+.br
+ int \fIordering\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIclip_x_origin\fP 1i
+.br
+.ns
+.IP \fIclip_y_origin\fP 1i
+Specify the x and y coordinates of the clip-mask origin.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIn\fP 1i
+Specifies the number of rectangles.
+.IP \fIordering\fP 1i
+Specifies the ordering relations on the rectangles.
+You can pass
+.ZN Unsorted ,
+.ZN YSorted ,
+.ZN YXSorted ,
+or
+.ZN YXBanded .
+.IP \fIpixmap\fP 1i
+Specifies the pixmap or
+.ZN None .
+.IP \fIrectangles\fP 1i
+Specifies an array of rectangles that define the clip-mask.
+.SH DESCRIPTION
+The
+.ZN XSetClipOrigin
+function sets the clip origin in the specified GC.
+The clip-mask origin is interpreted relative to the origin of whatever
+destination drawable is specified in the graphics request.
+.LP
+.ZN XSetClipOrigin
+can generate
+.ZN BadAlloc
+and
+.ZN BadGC
+errors.
+.LP
+The
+.ZN XSetClipMask
+function sets the clip-mask in the specified GC to the specified pixmap.
+If the clip-mask is set to
+.ZN None ,
+the pixels are are always drawn (regardless of the clip-origin).
+.LP
+.ZN XSetClipMask
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetClipRectangles
+function changes the clip-mask in the specified GC
+to the specified list of rectangles and sets the clip origin.
+The output is clipped to remain contained within the
+rectangles.
+The clip-origin is interpreted relative to the origin of
+whatever destination drawable is specified in a graphics request.
+The rectangle coordinates are interpreted relative to the clip-origin.
+The rectangles should be nonintersecting, or the graphics results will be
+undefined.
+Note that the list of rectangles can be empty,
+which effectively disables output.
+This is the opposite of passing
+.ZN None
+as the clip-mask in
+.ZN XCreateGC ,
+.ZN XChangeGC ,
+and
+.ZN XSetClipMask .
+.LP
+If known by the client, ordering relations on the rectangles can be
+specified with the ordering argument.
+This may provide faster operation
+by the server.
+If an incorrect ordering is specified, the X server may generate a
+.ZN BadMatch
+error, but it is not required to do so.
+If no error is generated, the graphics
+results are undefined.
+.ZN Unsorted
+means the rectangles are in arbitrary order.
+.ZN YSorted
+means that the rectangles are nondecreasing in their Y origin.
+.ZN YXSorted
+additionally constrains
+.ZN YSorted
+order in that all
+rectangles with an equal Y origin are nondecreasing in their X
+origin.
+.ZN YXBanded
+additionally constrains
+.ZN YXSorted
+by requiring that,
+for every possible Y scanline, all rectangles that include that
+scanline have an identical Y origins and Y extents.
+.LP
+.ZN XSetClipRectangles
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XDrawRectangle(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetCloseDownMode.man b/man/XSetCloseDownMode.man
new file mode 100644
index 00000000..0b55b317
--- /dev/null
+++ b/man/XSetCloseDownMode.man
@@ -0,0 +1,226 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetCloseDownMode 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetCloseDownMode, XKillClient \- control clients
+.SH SYNTAX
+XSetCloseDownMode\^(\^\fIdisplay\fP, \fIclose_mode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIclose_mode\fP\^;
+.LP
+XKillClient\^(\^\fIdisplay\fP, \fIresource\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIresource\fP\^;
+.SH ARGUMENTS
+.IP \fIclose_mode\fP 1i
+Specifies the client close-down mode.
+You can pass
+.ZN DestroyAll ,
+.ZN RetainPermanent ,
+or
+.ZN RetainTemporary .
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIresource\fP 1i
+Specifies any resource associated with the client that you want to destroy or
+.ZN AllTemporary .
+.SH DESCRIPTION
+The
+.ZN XSetCloseDownMode
+defines what will happen to the client's resources at connection close.
+A connection starts in
+.ZN DestroyAll
+mode.
+For information on what happens to the client's resources when the
+close_mode argument is
+.ZN RetainPermanent
+or
+.ZN RetainTemporary ,
+see section 2.6.
+.LP
+.ZN XSetCloseDownMode
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XKillClient
+function
+forces a close down of the client
+that created the resource
+if a valid resource is specified.
+If the client has already terminated in
+either
+.ZN RetainPermanent
+or
+.ZN RetainTemporary
+mode, all of the client's
+resources are destroyed.
+If
+.ZN AllTemporary
+is specified, the resources of all clients that have terminated in
+.ZN RetainTemporary
+are destroyed (see section 2.5).
+This permits implementation of window manager facilities that aid debugging.
+A client can set its close-down mode to
+.ZN RetainTemporary .
+If the client then crashes,
+its windows would not be destroyed.
+The programmer can then inspect the application's window tree
+and use the window manager to destroy the zombie windows.
+.LP
+.ZN XKillClient
+can generate a
+.ZN BadValue
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSetCommand.man b/man/XSetCommand.man
new file mode 100644
index 00000000..fc877be4
--- /dev/null
+++ b/man/XSetCommand.man
@@ -0,0 +1,237 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetCommand 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetCommand, XGetCommand \- set or read a window's WM_COMMAND property
+.SH SYNTAX
+XSetCommand\^(\^\fIdisplay\fP, \fIw\fP, \fIargv\fP, \fIargc\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char **\fIargv\fP\^;
+.br
+ int \fIargc\fP\^;
+.LP
+Status XGetCommand\^(\^\fIdisplay\fP, \fIw\fP, \fIargv_return\fP, \
+\fIargc_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char ***\fIargv_return\fP\^;
+.br
+ int *\fIargc_return\fP\^;
+.SH ARGUMENTS
+.IP \fIargc\fP 1i
+Specifies the number of arguments.
+.IP \fIargc_return\fP 1i
+Returns the number of arguments returned.
+.IP \fIargv\fP 1i
+Specifies the application's argument list.
+.IP \fIargv_return\fP 1i
+Returns the application's argument list.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XSetCommand
+function sets the command and arguments used to invoke the
+application.
+(Typically, argv is the argv array of your main program.)
+If the strings are not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+.LP
+.ZN XSetCommand
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetCommand
+function reads the WM_COMMAND property from the specified window
+and returns a string list.
+If the WM_COMMAND property exists,
+it is of type STRING and format 8.
+If sufficient memory can be allocated to contain the string list,
+.ZN XGetCommand
+fills in the argv_return and argc_return arguments
+and returns a nonzero status.
+Otherwise, it returns a zero status.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned strings are in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+To free the memory allocated to the string list, use
+.ZN XFreeStringList .
+.SH PROPERTIES
+.TP 1i
+\s-1WM_COMMAND\s+1
+The command and arguments, null-separated, used to invoke the
+application.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetErrorHandler.man b/man/XSetErrorHandler.man
new file mode 100644
index 00000000..5bc98e6e
--- /dev/null
+++ b/man/XSetErrorHandler.man
@@ -0,0 +1,292 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetErrorHandler 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetErrorHandler, XGetErrorText, XDisplayName, XSetIOErrorHandler, XGetErrorDatabaseText \- default error handlers
+.SH SYNTAX
+int (*XSetErrorHandler\^(\^\fIhandler\fP\^)\^)\^(\^)
+.br
+ int (\^*\^\fIhandler\fP\^)\^(Display *, XErrorEvent *)
+.LP
+XGetErrorText\^(\^\fIdisplay\fP, \fIcode\fP, \fIbuffer_return\fP, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIcode\fP\^;
+.br
+ char *\fIbuffer_return\fP\^;
+.br
+ int \fIlength\fP\^;
+.LP
+char *XDisplayName\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.LP
+int (*XSetIOErrorHandler\^(\^\fIhandler\fP\^)\^)\^(\^)
+.br
+ int (\^*\^\fIhandler\fP\^)(Display *);
+.LP
+XGetErrorDatabaseText\^(\^\fIdisplay\fP, \fIname\fP, \fImessage\fP, \fIdefault_string\fP, \fIbuffer_return\fP, \fIlength\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIname\fP, *\fImessage\fP\^;
+.br
+ char *\fIdefault_string\fP\^;
+.br
+ char *\fIbuffer_return\fP\^;
+.br
+ int \fIlength\fP\^;
+.SH ARGUMENTS
+.IP \fIbuffer_return\fP 1i
+Returns the error description.
+.IP \fIcode\fP 1i
+Specifies the error code for which you want to obtain a description.
+.IP \fIdefault_string\fP 1i
+Specifies the default error message if none is found in the database.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIhandler\fP 1i
+Specifies the program's supplied error handler.
+.IP \fIlength\fP 1i
+Specifies the size of the buffer.
+.IP \fImessage\fP 1i
+Specifies the type of the error message.
+.IP \fIname\fP 1i
+Specifies the name of the application.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.SH DESCRIPTION
+Xlib generally calls the program's
+supplied error handler whenever an error is received.
+It is not called on
+.ZN BadName
+errors from
+.ZN OpenFont ,
+.ZN LookupColor ,
+or
+.ZN AllocNamedColor
+protocol requests or on
+.ZN BadFont
+errors from a
+.ZN QueryFont
+protocol request.
+These errors generally are reflected back to the program through the
+procedural interface.
+Because this condition is not assumed to be fatal,
+it is acceptable for your error handler to return;
+the returned value is ignored.
+However, the error handler should not
+call any functions (directly or indirectly) on the display
+that will generate protocol requests or that will look for input events.
+The previous error handler is returned.
+.LP
+The
+.ZN XGetErrorText
+function copies a null-terminated string describing the specified error code
+into the specified buffer.
+The returned text is in the encoding of the current locale.
+It is recommended that you use this function to obtain an error description
+because extensions to Xlib may define their own error codes
+and error strings.
+.LP
+The
+.ZN XDisplayName
+function returns the name of the display that
+.ZN XOpenDisplay
+would attempt to use.
+If a NULL string is specified,
+.ZN XDisplayName
+looks in the environment for the display and returns the display name that
+.ZN XOpenDisplay
+would attempt to use.
+This makes it easier to report to the user precisely which display the
+program attempted to open when the initial connection attempt failed.
+.LP
+The
+.ZN XSetIOErrorHandler
+sets the fatal I/O error handler.
+Xlib calls the program's supplied error handler if any sort of system call
+error occurs (for example, the connection to the server was lost).
+This is assumed to be a fatal condition,
+and the called routine should not return.
+If the I/O error handler does return,
+the client process exits.
+.LP
+Note that the previous error handler is returned.
+.LP
+The
+.ZN XGetErrorDatabaseText
+function returns a null-terminated message
+(or the default message) from the error message
+database.
+Xlib uses this function internally to look up its error messages.
+The text in the default_string argument is assumed
+to be in the encoding of the current locale,
+and the text stored in the buffer_return argument
+is in the encoding of the current locale.
+.LP
+The name argument should generally be the name of your application.
+The message argument should indicate which type of error message you want.
+If the name and message are not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Xlib uses three predefined ``application names'' to report errors.
+In these names,
+uppercase and lowercase matter.
+.IP XProtoError 1i
+The protocol error number is used as a string for the message argument.
+.IP XlibMessage 1i
+These are the message strings that are used internally by the library.
+.IP XRequest 1i
+For a core protocol request,
+the major request protocol number is used for the message argument.
+For an extension request,
+the extension name (as given by
+.ZN InitExtension )
+followed by a period (\.) and the minor request protocol number
+is used for the message argument.
+If no string is found in the error database,
+the default_string is returned to the buffer argument.
+.SH "SEE ALSO"
+XOpenDisplay(3X11),
+XSynchronize(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetFillStyle.man b/man/XSetFillStyle.man
new file mode 100644
index 00000000..b2604862
--- /dev/null
+++ b/man/XSetFillStyle.man
@@ -0,0 +1,226 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetFillStyle 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetFillStyle, XSetFillRule \- GC convenience routines
+.SH SYNTAX
+XSetFillStyle\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIfill_style\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIfill_style\fP\^;
+.LP
+XSetFillRule\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIfill_rule\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIfill_rule\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfill_rule\fP 1i
+Specifies the fill-rule you want to set for the specified GC.
+You can pass
+.ZN EvenOddRule
+or
+.ZN WindingRule .
+.IP \fIfill_style\fP 1i
+Specifies the fill-style you want to set for the specified GC.
+You can pass
+.ZN FillSolid ,
+.ZN FillTiled ,
+.ZN FillStippled ,
+or
+.ZN FillOpaqueStippled .
+.IP \fIgc\fP 1i
+Specifies the GC.
+.SH DESCRIPTION
+The
+.ZN XSetFillStyle
+function sets the fill-style in the specified GC.
+.LP
+.ZN XSetFillStyle
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetFillRule
+function sets the fill-rule in the specified GC.
+.LP
+.ZN XSetFillRule
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetFont.man b/man/XSetFont.man
new file mode 100644
index 00000000..f2a9eff4
--- /dev/null
+++ b/man/XSetFont.man
@@ -0,0 +1,191 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetFont 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetFont \- GC convenience routines
+.SH SYNTAX
+XSetFont\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIfont\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Font \fIfont\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfont\fP 1i
+Specifies the font.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.SH DESCRIPTION
+The
+.ZN XSetFont
+function sets the current font in the specified GC.
+.LP
+.ZN XSetFont
+can generate
+.ZN BadAlloc ,
+.ZN BadFont ,
+and
+.ZN BadGC
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetFontPath.man b/man/XSetFontPath.man
new file mode 100644
index 00000000..4aa0a7e1
--- /dev/null
+++ b/man/XSetFontPath.man
@@ -0,0 +1,225 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetFontPath 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetFontPath, XGetFontPath, XFreeFontPath \- set, get, or free the font search path
+.SH SYNTAX
+XSetFontPath\^(\^\fIdisplay\fP, \fIdirectories\fP\^, \fIndirs\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char **\fIdirectories\fP\^;
+.br
+ int \fIndirs\fP\^;
+.LP
+char **XGetFontPath\^(\^\fIdisplay\fP, \fInpaths_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fInpaths_return\fP\^;
+
+.LP
+XFreeFontPath\^(\^\fIlist\fP\^)
+.br
+ char **\fIlist\fP\^;
+
+.SH ARGUMENTS
+.IP \fIdirectories\fP 1i
+Specifies the directory path used to look for a font.
+Setting the path to the empty list restores the default path defined
+for the X server.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIlist\fP 1i
+Specifies the array of strings you want to free.
+.IP \fIndirs\fP 1i
+Specifies the number of directories in the path.
+.IP \fInpaths_return\fP 1i
+Returns the number of strings in the font path array.
+.SH DESCRIPTION
+The
+.ZN XSetFontPath
+function defines the directory search path for font lookup.
+There is only one search path per X server, not one per client.
+The encoding and interpretation of the strings are implementation-dependent,
+but typically they specify directories or font servers to be searched
+in the order listed.
+An X server is permitted to cache font information internally;
+for example, it might cache an entire font from a file and not
+check on subsequent opens of that font to see if the underlying
+font file has changed.
+However,
+when the font path is changed,
+the X server is guaranteed to flush all cached information about fonts
+for which there currently are no explicit resource IDs allocated.
+The meaning of an error from this request is implementation-dependent.
+.LP
+.ZN XSetFontPath
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XGetFontPath
+function allocates and returns an array of strings containing the search path.
+The contents of these strings are implementation-dependent
+and are not intended to be interpreted by client applications.
+When it is no longer needed,
+the data in the font path should be freed by using
+.ZN XFreeFontPath .
+.LP
+The
+.ZN XFreeFontPath
+function
+frees the data allocated by
+.ZN XGetFontPath .
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XListFont(3X11),
+XLoadFonts(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetICFocus.man b/man/XSetICFocus.man
new file mode 100644
index 00000000..ccc38e1a
--- /dev/null
+++ b/man/XSetICFocus.man
@@ -0,0 +1,186 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetICFocus 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetICFocus, XUnsetICFocus \- set and unset input context focus
+.SH SYNTAX
+void XSetICFocus\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.LP
+void XUnsetICFocus\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.SH ARGUMENTS
+.IP \fIic\fP 1i
+Specifies the input context.
+.SH DESCRIPTION
+The
+.ZN XSetICFocus
+function allows a client to notify an input method that the focus window
+attached to the specified input context has received keyboard focus.
+The input method should take action to provide appropriate feedback.
+Complete feedback specification is a matter of user interface policy.
+.LP
+Calling
+.ZN XSetICFocus
+does not affect the focus window value.
+.LP
+The
+.ZN XUnsetICFocus
+function allows a client to notify an input method that the specified input context
+has lost the keyboard focus and that no more input is expected on the focus window
+attached to that input context.
+The input method should take action to provide appropriate feedback.
+Complete feedback specification is a matter of user interface policy.
+.LP
+Calling
+.ZN XUnsetICFocus
+does not affect the focus window value;
+the client may still receive
+events from the input method that are directed to the focus window.
+.SH "SEE ALSO"
+XCreateIC(3X11),
+XOpenIM(3X11),
+XSetICValues(3X11),
+XmbResetIC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetICValues.man b/man/XSetICValues.man
new file mode 100644
index 00000000..1b7b2d50
--- /dev/null
+++ b/man/XSetICValues.man
@@ -0,0 +1,237 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetICValues 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetICValues, XGetICValues \- set and obtain XIC values
+.SH SYNTAX
+char * XSetICValues\^(\^\fIic\fP\^, ...)
+.br
+ XIC \fIic\fP\^;
+.LP
+char * XGetICValues\^(\^\fIic\fP\^, ...)
+.br
+ XIC \fIic\fP\^;
+.SH ARGUMENTS
+.IP \fIic\fP 1i
+Specifies the input context.
+.ds Al \ to set or get XIC values
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XSetICValues
+function returns NULL if no error occurred;
+otherwise,
+it returns the name of the first argument that could not be set.
+An argument might not be set for any of the following reasons:
+.IP \(bu 5
+The argument is read-only (for example,
+.ZN XNFilterEvents ).
+.IP \(bu 5
+The argument name is not recognized.
+.IP \(bu 5
+An implementation-dependent error occurs.
+.LP
+Each value to be set must be an appropriate datum,
+matching the data type imposed by the semantics of the argument.
+.LP
+The
+.ZN XSetICValues
+can generate
+.ZN BadAtom ,
+.ZN BadColor ,
+.ZN BadCursor ,
+.ZN BadPixmap ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetICValues
+function returns NULL if no error occurred; otherwise,
+it returns the name of the first argument that could not be obtained.
+An argument could not be obtained for any of the following reasons:
+.IP \(bu 5
+The argument name is not recognized.
+.IP \(bu 5
+The input method encountered an implementation-dependent error.
+.LP
+Each IC attribute value argument (following a name) must point to
+a location where the IC value is to be stored.
+That is, if the IC value is of type T,
+the argument must be of type T*.
+If T itself is a pointer type,
+then
+.ZN XGetICValues
+allocates memory to store the actual data,
+and the client is responsible for freeing this data by calling
+.ZN XFree
+with the returned pointer.
+The exception to this rule is for an IC value of type
+.ZN XNVaNestedList
+(for preedit and status attributes).
+In this case, the argument must also be of type
+.ZN XVaNestedList .
+Then, the rule of changing type T to T* and freeing the allocated data
+applies to each element of the nested list.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadCursor
+A value for a Cursor argument does not name a defined Cursor.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XCreateIC(3X11),
+XOpenIM(3X11),
+XSetICFocus(3X11),
+XmbResetIC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetInputFocus.man b/man/XSetInputFocus.man
new file mode 100644
index 00000000..eef487fb
--- /dev/null
+++ b/man/XSetInputFocus.man
@@ -0,0 +1,285 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetInputFocus 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetInputFocus, XGetInputFocus \- control input focus
+.SH SYNTAX
+XSetInputFocus\^(\^\fIdisplay\fP, \fIfocus\fP\^, \fIrevert_to\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIfocus\fP\^;
+.br
+ int \fIrevert_to\fP\^;
+.br
+ Time \fItime\fP\^;
+.LP
+XGetInputFocus\^(\^\fIdisplay\fP, \fIfocus_return\fP\^, \fIrevert_to_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window *\fIfocus_return\fP\^;
+.br
+ int *\fIrevert_to_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfocus\fP 1i
+Specifies the window,
+.ZN PointerRoot ,
+or
+.ZN None .
+.IP \fIfocus_return\fP 1i
+Returns the focus window,
+.ZN PointerRoot ,
+or
+.ZN None .
+.IP \fIrevert_to\fP 1i
+Specifies where the input focus reverts to if the window becomes not
+viewable.
+You can pass
+.ZN RevertToParent ,
+.ZN RevertToPointerRoot ,
+or
+.ZN RevertToNone .
+.IP \fIrevert_to_return\fP 1i
+Returns the current focus state
+.Pn ( RevertToParent ,
+.ZN RevertToPointerRoot ,
+or
+.ZN RevertToNone ).
+.IP \fItime\fP 1i
+Specifies the time.
+You can pass either a timestamp or
+.ZN CurrentTime .
+.SH DESCRIPTION
+The
+.ZN XSetInputFocus
+function changes the input focus and the last-focus-change time.
+It has no effect if the specified time is earlier than the current
+last-focus-change time or is later than the current X server time.
+Otherwise, the last-focus-change time is set to the specified time
+.Pn ( CurrentTime
+is replaced by the current X server time).
+.ZN XSetInputFocus
+causes the X server to generate
+.ZN FocusIn
+and
+.ZN FocusOut
+events.
+.LP
+Depending on the focus argument,
+the following occurs:
+.IP \(bu 5
+If focus is
+.ZN None ,
+all keyboard events are discarded until a new focus window is set,
+and the revert_to argument is ignored.
+.IP \(bu 5
+If focus is a window,
+it becomes the keyboard's focus window.
+If a generated keyboard event would normally be reported to this window
+or one of its inferiors, the event is reported as usual.
+Otherwise, the event is reported relative to the focus window.
+.IP \(bu 5
+If focus is
+.ZN PointerRoot ,
+the focus window is dynamically taken to be the root window of whatever screen
+the pointer is on at each keyboard event.
+In this case, the revert_to argument is ignored.
+.LP
+The specified focus window must be viewable at the time
+.ZN XSetInputFocus
+is called,
+or a
+.ZN BadMatch
+error results.
+If the focus window later becomes not viewable,
+the X server
+evaluates the revert_to argument to determine the new focus window as follows:
+.IP \(bu 5
+If revert_to is
+.ZN RevertToParent ,
+the focus reverts to the parent (or the closest viewable ancestor),
+and the new revert_to value is taken to be
+.ZN RevertToNone .
+.IP \(bu 5
+If revert_to is
+.ZN RevertToPointerRoot
+or
+.ZN RevertToNone ,
+the focus reverts to
+.ZN PointerRoot
+or
+.ZN None ,
+respectively.
+When the focus reverts,
+the X server generates
+.ZN FocusIn
+and
+.ZN FocusOut
+events, but the last-focus-change time is not affected.
+.LP
+.ZN XSetInputFocus
+can generate
+.ZN BadMatch ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetInputFocus
+function returns the focus window and the current focus state.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XWarpPointer(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetLineAttributes.man b/man/XSetLineAttributes.man
new file mode 100644
index 00000000..b7c33aa2
--- /dev/null
+++ b/man/XSetLineAttributes.man
@@ -0,0 +1,284 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetLineAttributes 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetLineAttributes, XSetDashes \- GC convenience routines
+.SH SYNTAX
+XSetLineAttributes\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIline_width\fP\^, \fIline_style\fP\^, \fIcap_style\fP\^, \fIjoin_style\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned int \fIline_width\fP\^;
+.br
+ int \fIline_style\fP\^;
+.br
+ int \fIcap_style\fP\^;
+.br
+ int \fIjoin_style\fP\^;
+.LP
+XSetDashes\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIdash_offset\fP\^, \fIdash_list\fP\^, \fIn\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIdash_offset\fP\^;
+.br
+ char \fIdash_list\fP[]\^;
+.br
+ int \fIn\fP\^;
+.SH ARGUMENTS
+.IP \fIcap_style\fP 1i
+Specifies the line-style and cap-style you want to set for the specified GC.
+You can pass
+.ZN CapNotLast ,
+.ZN CapButt ,
+.ZN CapRound ,
+or
+.ZN CapProjecting .
+.IP \fIdash_list\fP 1i
+Specifies the dash-list for the dashed line-style
+you want to set for the specified GC.
+.IP \fIdash_offset\fP 1i
+Specifies the phase of the pattern for the dashed line-style you want to set
+for the specified GC.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIjoin_style\fP 1i
+Specifies the line join-style you want to set for the specified GC.
+You can pass
+.ZN JoinMiter ,
+.ZN JoinRound ,
+or
+.ZN JoinBevel .
+.IP \fIline_style\fP 1i
+Specifies the line-style you want to set for the specified GC.
+You can pass
+.ZN LineSolid ,
+.ZN LineOnOffDash ,
+or
+.ZN LineDoubleDash .
+.IP \fIline_width\fP 1i
+Specifies the line-width you want to set for the specified GC.
+.IP \fIn\fP 1i
+Specifies the number of elements in dash_list.
+.SH DESCRIPTION
+The
+.ZN XSetLineAttributes
+function sets the line drawing components in the specified GC.
+.LP
+.ZN XSetLineAttributes
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetDashes
+function sets the dash-offset and dash-list attributes for dashed line styles
+in the specified GC.
+There must be at least one element in the specified dash_list,
+or a
+.ZN BadValue
+error results.
+The initial and alternating elements (second, fourth, and so on)
+of the dash_list are the even dashes, and
+the others are the odd dashes.
+Each element specifies a dash length in pixels.
+All of the elements must be nonzero,
+or a
+.ZN BadValue
+error results.
+Specifying an odd-length list is equivalent to specifying the same list
+concatenated with itself to produce an even-length list.
+.LP
+The dash-offset defines the phase of the pattern,
+specifying how many pixels into the dash-list the pattern
+should actually begin in any single graphics request.
+Dashing is continuous through path elements combined with a join-style
+but is reset to the dash-offset between each sequence of joined lines.
+.LP
+The unit of measure for dashes is the same for the ordinary coordinate system.
+Ideally, a dash length is measured along the slope of the line, but implementations
+are only required to match this ideal for horizontal and vertical lines.
+Failing the ideal semantics, it is suggested that the length be measured along the
+major axis of the line.
+The major axis is defined as the x axis for lines drawn at an angle of between
+\-45 and +45 degrees or between 135 and 225 degrees from the x axis.
+For all other lines, the major axis is the y axis.
+.LP
+.ZN XSetDashes
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetState(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetPointerMapping.man b/man/XSetPointerMapping.man
new file mode 100644
index 00000000..265809ae
--- /dev/null
+++ b/man/XSetPointerMapping.man
@@ -0,0 +1,225 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetPointerMapping 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetPointerMapping, XGetPointerMapping \- manipulate pointer settings
+.SH SYNTAX
+int XSetPointerMapping\^(\^\fIdisplay\fP, \fImap\fP, \fInmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned char \fImap\fP\^[]\^;
+.br
+ int \fInmap\fP\^;
+.LP
+int XGetPointerMapping\^(\^\fIdisplay\fP, \fImap_return\fP, \fInmap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ unsigned char \fImap_return\fP\^[]\^;
+.br
+ int \fInmap\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fImap\fP 1i
+Specifies the mapping list.
+.IP \fImap_return\fP 1i
+Returns the mapping list.
+.IP \fInmap\fP 1i
+Specifies the number of items in the mapping list.
+.SH DESCRIPTION
+The
+.ZN XSetPointerMapping
+function sets the mapping of the pointer.
+If it succeeds, the X server generates a
+.ZN MappingNotify
+event, and
+.ZN XSetPointerMapping
+returns
+.ZN MappingSuccess .
+Element map[i] defines the logical button number for the physical button
+i+1.
+The length of the list must be the same as
+.ZN XGetPointerMapping
+would return,
+or a
+.ZN BadValue
+error results.
+A zero element disables a button, and elements are not restricted in
+value by the number of physical buttons.
+However, no two elements can have the same nonzero value,
+or a
+.ZN BadValue
+error results.
+If any of the buttons to be altered are logically in the down state,
+.ZN XSetPointerMapping
+returns
+.ZN MappingBusy ,
+and the mapping is not changed.
+.LP
+.ZN XSetPointerMapping
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XGetPointerMapping
+function returns the current mapping of the pointer.
+Pointer buttons are numbered starting from one.
+.ZN XGetPointerMapping
+returns the number of physical buttons actually on the pointer.
+The nominal mapping for a pointer is map[i]=i+1.
+The nmap argument specifies the length of the array where the pointer
+mapping is returned, and only the first nmap elements are returned
+in map_return.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XChangeKeyboardControl(3X11),
+XChangeKeyboardMapping(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetScreenSaver.man b/man/XSetScreenSaver.man
new file mode 100644
index 00000000..e4a33141
--- /dev/null
+++ b/man/XSetScreenSaver.man
@@ -0,0 +1,308 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetScreenSaver 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetScreenSaver, XForceScreenSaver, XActivateScreenSaver, XResetScreenSaver, XGetScreenSaver \- manipulate the screen saver
+.SH SYNTAX
+XSetScreenSaver\^(\^\fIdisplay\fP, \fItimeout\fP\^, \fIinterval\fP\^, \fIprefer_blanking\fP\^, \fIallow_exposures\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fItimeout\fP\^, \fIinterval\fP\^;
+.br
+ int \fIprefer_blanking\fP\^;
+.br
+ int \fIallow_exposures\fP\^;
+.LP
+XForceScreenSaver\^(\^\fIdisplay\fP\^, \fImode\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fImode\fP\^;
+.LP
+XActivateScreenSaver\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XResetScreenSaver\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+XGetScreenSaver\^(\^\fIdisplay\fP, \fItimeout_return\fP\^, \fIinterval_return\fP\^, \fIprefer_blanking_return\fP\^,
+.br
+ \fIallow_exposures_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fItimeout_return\fP\^, *\fIinterval_return\fP\^;
+.br
+ int *\fIprefer_blanking_return\fP\^;
+.br
+ int *\fIallow_exposures_return\fP\^;
+.SH ARGUMENTS
+.IP \fIallow_exposures\fP 1i
+Specifies the screen save control values.
+You can pass
+.ZN DontAllowExposures ,
+.ZN AllowExposures ,
+or
+.ZN DefaultExposures .
+.IP \fIallow_exposures_return\fP 1i
+Returns the current screen save control value
+.Pn ( DontAllowExposures ,
+.ZN AllowExposures ,
+or
+.ZN DefaultExposures ).
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIinterval\fP 1i
+Specifies the interval, in seconds, between screen saver alterations.
+.IP \fIinterval_return\fP 1i
+Returns the interval between screen saver invocations.
+.IP \fImode\fP 1i
+Specifies the mode that is to be applied.
+You can pass
+.ZN ScreenSaverActive
+or
+.ZN ScreenSaverReset .
+.IP \fIprefer_blanking\fP 1i
+Specifies how to enable screen blanking.
+You can pass
+.ZN DontPreferBlanking ,
+.ZN PreferBlanking ,
+or
+.ZN DefaultBlanking .
+.IP \fIprefer_blanking_return\fP 1i
+Returns the current screen blanking preference
+.Pn ( DontPreferBlanking ,
+.ZN PreferBlanking ,
+or
+.ZN DefaultBlanking ).
+.IP \fItimeout\fP 1i
+Specifies the timeout, in seconds, until the screen saver turns on.
+.IP \fItimeout_return\fP 1i
+Returns the timeout, in seconds, until the screen saver turns on.
+.SH DESCRIPTION
+Timeout and interval are specified in seconds.
+A timeout of 0 disables the screen saver
+(but an activated screen saver is not deactivated),
+and a timeout of \-1 restores the default.
+Other negative values generate a
+.ZN BadValue
+error.
+If the timeout value is nonzero,
+.ZN XSetScreenSaver
+enables the screen saver.
+An interval of 0 disables the random-pattern motion.
+If no input from devices (keyboard, mouse, and so on) is generated
+for the specified number of timeout seconds once the screen saver is enabled,
+the screen saver is activated.
+.LP
+For each screen,
+if blanking is preferred and the hardware supports video blanking,
+the screen simply goes blank.
+Otherwise, if either exposures are allowed or the screen can be regenerated
+without sending
+.ZN Expose
+events to clients,
+the screen is tiled with the root window background tile randomly
+re-origined each interval seconds.
+Otherwise, the screens' state do not change,
+and the screen saver is not activated.
+The screen saver is deactivated,
+and all screen states are restored at the next
+keyboard or pointer input or at the next call to
+.ZN XForceScreenSaver
+with mode
+.ZN ScreenSaverReset .
+.LP
+If the server-dependent screen saver method supports periodic change,
+the interval argument serves as a hint about how long the change period
+should be, and zero hints that no periodic change should be made.
+Examples of ways to change the screen include scrambling the colormap
+periodically, moving an icon image around the screen periodically, or tiling
+the screen with the root window background tile, randomly re-origined
+periodically.
+.LP
+.ZN XSetScreenSaver
+can generate a
+.ZN BadValue
+error.
+.LP
+If the specified mode is
+.ZN ScreenSaverActive
+and the screen saver currently is deactivated,
+.ZN XForceScreenSaver
+activates the screen saver even if the screen saver had been disabled
+with a timeout of zero.
+If the specified mode is
+.ZN ScreenSaverReset
+and the screen saver currently is enabled,
+.ZN XForceScreenSaver
+deactivates the screen saver if it was activated,
+and the activation timer is reset to its initial state
+(as if device input had been received).
+.LP
+.ZN XForceScreenSaver
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XActivateScreenSaver
+function activates the screen saver.
+.LP
+The
+.ZN XResetScreenSaver
+function resets the screen saver.
+.LP
+The
+.ZN XGetScreenSaver
+function gets the current screen saver values.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSetSelectionOwner.man b/man/XSetSelectionOwner.man
new file mode 100644
index 00000000..2adf20b2
--- /dev/null
+++ b/man/XSetSelectionOwner.man
@@ -0,0 +1,294 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetSelectionOwner 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetSelectionOwner, XGetSelectionOwner, XConvertSelection \- manipulate window selection
+.SH SYNTAX
+XSetSelectionOwner\^(\^\fIdisplay\fP, \fIselection\fP\^, \fIowner\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Atom \fIselection\fP\^;
+.br
+ Window \fIowner\fP\^;
+.br
+ Time \fItime\fP\^;
+.LP
+Window XGetSelectionOwner\^(\^\fIdisplay\fP, \fIselection\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Atom \fIselection\fP\^;
+.LP
+XConvertSelection\^(\^\fIdisplay\fP, \fIselection\fP\^, \fItarget\fP\^, \fIproperty\fP\^, \fIrequestor\fP\^, \fItime\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Atom \fIselection\fP\^, \fItarget\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.br
+ Window \fIrequestor\fP\^;
+.br
+ Time \fItime\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIowner\fP 1i
+Specifies the owner of the specified selection atom.
+You can pass a window or
+.ZN None .
+.IP \fIproperty\fP 1i
+Specifies the property name.
+You also can pass
+.ZN None .
+.IP \fIrequestor\fP 1i
+Specifies the requestor.
+.IP \fIselection\fP 1i
+Specifies the selection atom.
+.IP \fItarget\fP 1i
+Specifies the target atom.
+.IP \fItime\fP 1i
+Specifies the time.
+You can pass either a timestamp or
+.ZN CurrentTime .
+.SH DESCRIPTION
+The
+.ZN XSetSelectionOwner
+function changes the owner and last-change time for the specified selection
+and has no effect if the specified time is earlier than the current
+last-change time of the specified selection
+or is later than the current X server time.
+Otherwise, the last-change time is set to the specified time,
+with
+.ZN CurrentTime
+replaced by the current server time.
+If the owner window is specified as
+.ZN None ,
+then the owner of the selection becomes
+.ZN None
+(that is, no owner).
+Otherwise, the owner of the selection becomes the client executing
+the request.
+.LP
+If the new owner (whether a client or
+.ZN None )
+is not
+the same as the current owner of the selection and the current
+owner is not
+.ZN None ,
+the current owner is sent a
+.ZN SelectionClear
+event.
+If the client that is the owner of a selection is later
+terminated (that is, its connection is closed)
+or if the owner window it has specified in the request is later
+destroyed,
+the owner of the selection automatically
+reverts to
+.ZN None ,
+but the last-change time is not affected.
+The selection atom is uninterpreted by the X server.
+.ZN XGetSelectionOwner
+returns the owner window, which is reported in
+.ZN SelectionRequest
+and
+.ZN SelectionClear
+events.
+Selections are global to the X server.
+.LP
+.ZN XSetSelectionOwner
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetSelectionOwner
+function
+returns the window ID associated with the window that currently owns the
+specified selection.
+If no selection was specified, the function returns the constant
+.ZN None .
+If
+.ZN None
+is returned,
+there is no owner for the selection.
+.LP
+.ZN XGetSelectionOwner
+can generate a
+.ZN BadAtom
+error.
+.LP
+.ZN XConvertSelection
+requests that the specified selection be converted to the specified target
+type:
+.IP \(bu 5
+If the specified selection has an owner, the X server sends a
+.ZN SelectionRequest
+event to that owner.
+.IP \(bu 5
+If no owner for the specified
+selection exists, the X server generates a
+.ZN SelectionNotify
+event to the
+requestor with property
+.ZN None .
+.LP
+The arguments are passed on unchanged in either of the events.
+There are two predefined selection atoms: PRIMARY and SECONDARY.
+.LP
+.ZN XConvertSelection
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSetState.man b/man/XSetState.man
new file mode 100644
index 00000000..83457fd8
--- /dev/null
+++ b/man/XSetState.man
@@ -0,0 +1,282 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetState 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetState, XSetFunction, XSetPlanemask, XSetForeground, XSetBackground \- GC convenience routines
+.SH SYNTAX
+XSetState\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIforeground\fP\^, \fIbackground\fP\^, \fIfunction\fP\^, \fIplane_mask\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIforeground\fP\^, \fIbackground\fP\^;
+.br
+ int \fIfunction\fP\^;
+.br
+ unsigned long \fIplane_mask\fP\^;
+.LP
+XSetFunction\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIfunction\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIfunction\fP\^;
+.LP
+XSetPlaneMask\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIplane_mask\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIplane_mask\fP\^;
+.LP
+XSetForeground\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIforeground\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIforeground\fP\^;
+.LP
+XSetBackground\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIbackground\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ unsigned long \fIbackground\fP\^;
+.SH ARGUMENTS
+.IP \fIbackground\fP 1i
+Specifies the background you want to set for the specified GC.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIforeground\fP 1i
+Specifies the foreground you want to set for the specified GC.
+.IP \fIfunction\fP 1i
+Specifies the function you want to set for the specified GC.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIplane_mask\fP 1i
+Specifies the plane mask.
+.\" *** JIM: NEED MORE INFO FOR THIS. ***
+.SH DESCRIPTION
+The
+.ZN XSetState
+function sets the foreground, background, plane mask, and function components
+for the specified GC.
+.LP
+.ZN XSetState
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+.ZN XSetFunction
+sets a specified value in the specified GC.
+.LP
+.ZN XSetFunction
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XSetPlaneMask
+function sets the plane mask in the specified GC.
+.LP
+.ZN XSetPlaneMask
+can generate
+.ZN BadAlloc
+and
+.ZN BadGC
+errors.
+.LP
+The
+.ZN XSetForeground
+function sets the foreground in the specified GC.
+.LP
+.ZN XSetForeground
+can generate
+.ZN BadAlloc
+and
+.ZN BadGC
+errors.
+.LP
+The
+.ZN XSetBackground
+function sets the background in the specified GC.
+.LP
+.ZN XSetBackground
+can generate
+.ZN BadAlloc
+and
+.ZN BadGC
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetTile(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetTextProperty.man b/man/XSetTextProperty.man
new file mode 100644
index 00000000..45a0fe3f
--- /dev/null
+++ b/man/XSetTextProperty.man
@@ -0,0 +1,281 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetTextProperty 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetTextProperty, XGetTextProperty \- set and read text properties
+.SH SYNTAX
+void XSetTextProperty\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop\fP, \
+\fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.LP
+Status XGetTextProperty\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop_return\fP, \
+\fIproperty\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.br
+ Atom \fIproperty\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIproperty\fP 1i
+Specifies the property name.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.SH DESCRIPTION
+The
+.ZN XSetTextProperty
+function replaces the existing specified property for the named window
+with the data, type, format, and number of items determined
+by the value field, the encoding field, the format field,
+and the nitems field, respectively, of the specified
+.ZN XTextProperty
+structure.
+If the property does not already exist,
+.ZN XSetTextProperty
+sets it for the specified window.
+.LP
+.ZN XSetTextProperty
+can generate
+.ZN BadAlloc ,
+.ZN BadAtom ,
+.ZN BadValue ,
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetTextProperty
+function reads the specified property from the window
+and stores the data in the returned
+.ZN XTextProperty
+structure.
+It stores the data in the value field,
+the type of the data in the encoding field,
+the format of the data in the format field,
+and the number of items of data in the nitems field.
+An extra byte containing null (which is not included in the nitems member)
+is stored at the end of the value field of text_prop_return.
+The particular interpretation of the property's encoding
+and data as text is left to the calling application.
+If the specified property does not exist on the window,
+.ZN XGetTextProperty
+sets the value field to NULL,
+the encoding field to
+.ZN None ,
+the format field to zero,
+and the nitems field to zero.
+.LP
+If it was able to read and store the data in the
+.ZN XTextProperty
+structure,
+.ZN XGetTextProperty
+returns a nonzero status;
+otherwise, it returns a zero status.
+.LP
+.ZN XGetTextProperty
+can generate
+.ZN BadAtom
+and
+.ZN BadWindow
+errors.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_CLIENT_MACHINE\s+1
+The string name of the machine on which the client application is running.
+.TP 1i
+\s-1WM_COMMAND\s+1
+The command and arguments, null-separated, used to invoke the
+application.
+.TP 1i
+\s-1WM_ICON_NAME\s+1
+The name to be used in an icon.
+.TP 1i
+\s-1WM_NAME\s+1
+The name of the application.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetTile.man b/man/XSetTile.man
new file mode 100644
index 00000000..cce3789d
--- /dev/null
+++ b/man/XSetTile.man
@@ -0,0 +1,254 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetTile 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetTile, XSetStipple, XSetTSOrigin \- GC convenience routines
+.SH SYNTAX
+XSetTile\^(\^\fIdisplay\fP, \fIgc\fP\^, \fItile\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Pixmap \fItile\fP\^;
+.LP
+XSetStipple\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIstipple\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ Pixmap \fIstipple\fP\^;
+.LP
+XSetTSOrigin\^(\^\fIdisplay\fP, \fIgc\fP\^, \fIts_x_origin\fP\^, \fIts_y_origin\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIts_x_origin\fP\^, \fIts_y_origin\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIstipple\fP 1i
+Specifies the stipple you want to set for the specified GC.
+.IP \fItile\fP 1i
+Specifies the fill tile you want to set for the specified GC.
+.IP \fIts_x_origin\fP 1i
+.br
+.ns
+.IP \fIts_y_origin\fP 1i
+Specify the x and y coordinates of the tile and stipple origin.
+.SH DESCRIPTION
+The
+.ZN XSetTile
+function sets the fill tile in the specified GC.
+The tile and GC must have the same depth,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetTile
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadPixmap
+errors.
+.LP
+The
+.ZN XSetStipple
+function sets the stipple in the specified GC.
+The stipple must have a depth of one,
+or a
+.ZN BadMatch
+error results.
+.LP
+.ZN XSetStipple
+can generate
+.ZN BadAlloc ,
+.ZN BadGC ,
+.ZN BadMatch ,
+and
+.ZN BadPixmap
+errors.
+.LP
+The
+.ZN XSetTSOrigin
+function sets the tile/stipple origin in the specified GC.
+When graphics requests call for tiling or stippling,
+the parent's origin will be interpreted relative to whatever destination
+drawable is specified in the graphics request.
+.LP
+.ZN XSetTSOrigin
+can generate
+.ZN BadAlloc
+and
+.ZN BadGC
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadPixmap
+A value for a Pixmap argument does not name a defined Pixmap.
+.SH "SEE ALSO"
+XCreateGC(3X11),
+XQueryBestSize(3X11),
+XSetArcMode(3X11),
+XSetClipOrigin(3X11),
+XSetFillStyle(3X11),
+XSetFont(3X11),
+XSetLineAttributes(3X11),
+XSetState(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetTransientForHint.man b/man/XSetTransientForHint.man
new file mode 100644
index 00000000..2c229e4f
--- /dev/null
+++ b/man/XSetTransientForHint.man
@@ -0,0 +1,219 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetTransientForHint 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetTransientForHint, XGetTransientForHint \- set or read a window's WM_TRANSIENT_FOR property
+.SH SYNTAX
+XSetTransientForHint\^(\^\fIdisplay\fP, \fIw\fP, \fIprop_window\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window \fIprop_window\fP\^;
+.LP
+Status XGetTransientForHint\^(\^\fIdisplay\fP, \fIw\fP, \fIprop_window_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window *\fIprop_window_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIprop_window\fP 1i
+Specifies the window that the WM_TRANSIENT_FOR property is to be set to.
+.IP \fIprop_window_return\fP 1i
+Returns the WM_TRANSIENT_FOR property of the specified window.
+.SH DESCRIPTION
+The
+.ZN XSetTransientForHint
+function sets the WM_TRANSIENT_FOR property of the specified window to the
+specified prop_window.
+.LP
+.ZN XSetTransientForHint
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetTransientForHint
+function returns the WM_TRANSIENT_FOR property for the specified window.
+It returns a nonzero status on success;
+otherwise, it returns a zero status.
+.LP
+.ZN XGetTransientForHint
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_TRANSIENT_FOR\s+1
+Set by application programs to indicate to the window manager that a transient
+top-level window, such as a dialog box.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XSetCommand(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMClientMachine.man b/man/XSetWMClientMachine.man
new file mode 100644
index 00000000..7851abbc
--- /dev/null
+++ b/man/XSetWMClientMachine.man
@@ -0,0 +1,206 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMClientMachine 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMClientMachine, XGetWMClientMachine \- set or read a window's WM_CLIENT_MACHINE property
+.SH SYNTAX
+void XSetWMClientMachine\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.LP
+Status XGetWMClientMachine\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XSetWMClientMachine
+convenience function calls
+.ZN XSetTextProperty
+to set the WM_CLIENT_MACHINE property.
+.LP
+The
+.ZN XGetWMClientMachine
+convenience function performs an
+.ZN XGetTextProperty
+on the WM_CLIENT_MACHINE property.
+It returns a nonzero status on success;
+otherwise, it returns a zero status.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_CLIENT_MACHINE\s+1
+The string name of the machine on which the client application is running.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMColormapWindows.man b/man/XSetWMColormapWindows.man
new file mode 100644
index 00000000..5dd1b5e2
--- /dev/null
+++ b/man/XSetWMColormapWindows.man
@@ -0,0 +1,252 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMColormapWindows 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMColormapWindows, XGetWMColormapWindows \- set or read a window's WM_COLORMAP_WINDOWS property
+.SH SYNTAX
+Status XSetWMColormapWindows\^(\^\fIdisplay\fP, \fIw\fP, \
+\fIcolormap_windows\fP, \fIcount\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window *\fIcolormap_windows\fP\^;
+.br
+ int \fIcount\fP\^;
+.LP
+Status XGetWMColormapWindows\^(\^\fIdisplay\fP, \fIw\fP, \
+\fIcolormap_windows_return\fP, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Window **\fIcolormap_windows_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIcolormap_windows\fP 1i
+Specifies the list of windows.
+.IP \fIcolormap_windows_return\fP 1i
+Returns the list of windows.
+.ds Cn windows in the list
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.ds Cn windows in the list
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XSetWMColormapWindows
+function replaces the WM_COLORMAP_WINDOWS property on the specified
+window with the list of windows specified by the colormap_windows argument.
+It the property does not already exist,
+.ZN XSetWMColormapWindows
+sets the WM_COLORMAP_WINDOWS property on the specified
+window to the list of windows specified by the colormap_windows argument.
+The property is stored with a type of WINDOW and a format of 32.
+If it cannot intern the WM_COLORMAP_WINDOWS atom,
+.ZN XSetWMColormapWindows
+returns a zero status.
+Otherwise, it returns a nonzero status.
+.LP
+.ZN XSetWMColormapWindows
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetWMColormapWindows
+function returns the list of window identifiers stored
+in the WM_COLORMAP_WINDOWS property on the specified window.
+These identifiers indicate the colormaps that the window manager
+may need to install for this window.
+If the property exists, is of type WINDOW, is of format 32,
+and the atom WM_COLORMAP_WINDOWS can be interned,
+.ZN XGetWMColormapWindows
+sets the windows_return argument to a list of window identifiers,
+sets the count_return argument to the number of elements in the list,
+and returns a nonzero status.
+Otherwise, it sets neither of the return arguments
+and returns a zero status.
+To release the list of window identifiers, use
+.ZN XFree .
+.LP
+.ZN XGetWMColormapWindows
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_COLORMAP_WINDOWS\s+1
+The list of window IDs that may need a different colormap
+from that of their top-level window.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMIconName.man b/man/XSetWMIconName.man
new file mode 100644
index 00000000..22a5276f
--- /dev/null
+++ b/man/XSetWMIconName.man
@@ -0,0 +1,268 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMIconName 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMIconName, XGetWMIconName, XSetIconName, XGetIconName \- set or read a window's WM_ICON_NAME property
+.SH SYNTAX
+void XSetWMIconName\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.LP
+Status XGetWMIconName\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.LP
+XSetIconName\^(\^\fIdisplay\fP, \fIw\fP\^, \fIicon_name\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char *\fIicon_name\fP\^;
+.LP
+Status XGetIconName\^(\^\fIdisplay\fP, \fIw\fP\^, \fIicon_name_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char **\fIicon_name_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIicon_name\fP 1i
+Specifies the icon name,
+which should be a null-terminated string.
+.IP \fIicon_name_return\fP 1i
+Returns the window's icon name,
+which is a null-terminated string.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XSetWMIconName
+convenience function calls
+.ZN XSetTextProperty
+to set the WM_ICON_NAME property.
+.LP
+The
+.ZN XGetWMIconName
+convenience function calls
+.ZN XGetTextProperty
+to obtain the WM_ICON_NAME property.
+It returns a nonzero status on success;
+otherwise, it returns a zero status.
+.LP
+The
+.ZN XSetIconName
+function sets the name to be displayed in a window's icon.
+.LP
+.ZN XSetIconName
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetIconName
+function returns the name to be displayed in the specified window's icon.
+If it succeeds, it returns a nonzero status; otherwise,
+if no icon name has been set for the window,
+it returns zero.
+If you never assigned a name to the window,
+.ZN XGetIconName
+sets icon_name_return to NULL.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned string is in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+When finished with it, a client must free
+the icon name string using
+.ZN XFree .
+.LP
+.ZN XGetIconName
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_ICON_NAME\s+1
+The name to be used in an icon.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMName.man b/man/XSetWMName.man
new file mode 100644
index 00000000..e076d520
--- /dev/null
+++ b/man/XSetWMName.man
@@ -0,0 +1,275 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMName 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMName, XGetWMName, XStoreName, XFetchName \- set or read a window's WM_NAME property
+.SH SYNTAX
+void XSetWMName\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.LP
+Status XGetWMName\^(\^\fIdisplay\fP, \fIw\fP, \fItext_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.LP
+XStoreName\^(\^\fIdisplay\fP, \fIw\fP\^, \fIwindow_name\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char *\fIwindow_name\fP\^;
+.LP
+Status XFetchName\^(\^\fIdisplay\fP, \fIw\fP\^, \fIwindow_name_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char **\fIwindow_name_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIwindow_name\fP 1i
+Specifies the window name,
+which should be a null-terminated string.
+.IP \fIwindow_name_return\fP 1i
+Returns the window name, which is a null-terminated string.
+.SH DESCRIPTION
+The
+.ZN XSetWMName
+convenience function calls
+.ZN XSetTextProperty
+to set the WM_NAME property.
+.LP
+The
+.ZN XGetWMName
+convenience function calls
+.ZN XGetTextProperty
+to obtain the WM_NAME property.
+It returns a nonzero status on success;
+otherwise, it returns a zero status.
+.LP
+The
+.ZN XStoreName
+function assigns the name passed to window_name to the specified window.
+A window manager can display the window name in some prominent
+place, such as the title bar, to allow users to identify windows easily.
+Some window managers may display a window's name in the window's icon,
+although they are encouraged to use the window's icon name
+if one is provided by the application.
+If the string is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+.LP
+.ZN XStoreName
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XFetchName
+function returns the name of the specified window.
+If it succeeds,
+it returns a nonzero status;
+otherwise, no name has been set for the window,
+and it returns zero.
+If the WM_NAME property has not been set for this window,
+.ZN XFetchName
+sets window_name_return to NULL.
+If the data returned by the server is in the Latin Portable Character Encoding,
+then the returned string is in the Host Portable Character Encoding.
+Otherwise, the result is implementation-dependent.
+When finished with it, a client must free
+the window name string using
+.ZN XFree .
+.LP
+.ZN XFetchName
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_NAME\s+1
+The name of the application.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMProperties.man b/man/XSetWMProperties.man
new file mode 100644
index 00000000..84b109ff
--- /dev/null
+++ b/man/XSetWMProperties.man
@@ -0,0 +1,395 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMProperties 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMProperties, XmbSetWMProperties \- set standard window properties
+.SH SYNTAX
+void XSetWMProperties\^(\^\fIdisplay\fP, \fIw\fP, \fIwindow_name\fP, \
+\fIicon_name\fP, \fIargv\fP, \fIargc\fP, \fInormal_hints\fP, \fIwm_hints\fP, \
+\fIclass_hints\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ XTextProperty *\fIwindow_name\fP\^;
+.br
+ XTextProperty *\fIicon_name\fP\^;
+.br
+ char **\fIargv\fP\^;
+.br
+ int \fIargc\fP\^;
+.br
+ XSizeHints *\fInormal_hints\fP\^;
+.br
+ XWMHints *\fIwm_hints\fP\^;
+.br
+ XClassHint *\fIclass_hints\fP\^;
+.LP
+void XmbSetWMProperties\^(\^\fIdisplay\fP\^, \fIw\fP\^, \fIwindow_name\fP\^, \fIicon_name\fP\^, \fIargv\fP\^, \fIargc\fP\^,
+.br
+ \fInormal_hints\fP\^, \fIwm_hints\fP\^, \fIclass_hints\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ char *\fIwindow_name\fP\^;
+.br
+ char *\fIicon_name\fP\^;
+.br
+ char *\fIargv\fP\^[];
+.br
+ int \fIargc\fP\^;
+.br
+ XSizeHints *\fInormal_hints\fP\^;
+.br
+ XWMHints *\fIwm_hints\fP\^;
+.br
+ XClassHint *\fIclass_hints\fP\^;
+.SH ARGUMENTS
+.IP \fIargc\fP 1i
+Specifies the number of arguments.
+.IP \fIargv\fP 1i
+Specifies the application's argument list.
+.IP \fIclass_hints\fP 1i
+Specifies the
+.ZN XClassHint
+structure to be used.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIicon_name\fP 1i
+Specifies the icon name,
+which should be a null-terminated string.
+.IP \fInormal_hints\fP 1i
+Specifies the size hints for the window in its normal state.
+.IP \fIw\fP 1i
+Specifies the window.
+.IP \fIwindow_name\fP 1i
+Specifies the window name,
+which should be a null-terminated string.
+.IP \fIwm_hints\fP 1i
+Specifies the
+.ZN XWMHints
+structure to be used.
+.SH DESCRIPTION
+The
+.ZN XSetWMProperties
+convenience function provides a single programming interface
+for setting those essential window properties that are used
+for communicating with other clients (particularly window and session
+managers).
+.LP
+If the window_name argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetWMName ,
+which in turn, sets the WM_NAME property (see section 14.1.4).
+If the icon_name argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetWMIconName ,
+which sets the WM_ICON_NAME property (see section 14.1.5).
+If the argv argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetCommand ,
+which sets the WM_COMMAND property (see section 14.2.1).
+Note that an argc of zero is allowed to indicate a zero-length command.
+Note also that the hostname of this machine is stored using
+.ZN XSetWMClientMachine
+(see section 14.2.2).
+.LP
+If the normal_hints argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetWMNormalHints ,
+which sets the WM_NORMAL_HINTS property (see section 14.1.7).
+If the wm_hints argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetWMHints ,
+which sets the WM_HINTS property (see section 14.1.6).
+.LP
+If the class_hints argument is non-NULL,
+.ZN XSetWMProperties
+calls
+.ZN XSetClassHint ,
+which sets the WM_CLASS property (see section 14.1.8).
+If the res_name member in the
+.ZN XClassHint
+structure is set to the NULL pointer and the RESOURCE_NAME environment
+variable is set,
+then the value of the environment variable is substituted for res_name.
+If the res_name member is NULL,
+the environment variable is not set,
+and argv and argv[0] are set,
+then the value of argv[0], stripped of
+any directory prefixes, is substituted for res_name.
+.LP
+The
+.ZN XmbSetWMProperties
+convenience function provides a simple programming interface
+for setting those essential window properties that are used
+for communicating with other clients
+(particularly window and session managers).
+.LP
+If the window_name argument is non-NULL,
+.ZN XmbSetWMProperties
+sets the WM_NAME property.
+If the icon_name argument is non-NULL,
+.ZN XmbSetWMProperties
+sets the WM_ICON_NAME property.
+The window_name and icon_name arguments are null-terminated strings
+in the encoding of the current locale.
+If the arguments can be fully converted to the STRING encoding,
+the properties are created with type ``STRING'';
+otherwise, the arguments are converted to Compound Text,
+and the properties are created with type ``COMPOUND_TEXT''.
+.LP
+If the normal_hints argument is non-NULL,
+.ZN XmbSetWMProperties
+calls
+.ZN XSetWMNormalHints ,
+which sets the WM_NORMAL_HINTS property (see section 14.1.7).
+If the wm_hints argument is non-NULL,
+.ZN XmbSetWMProperties
+calls
+.ZN XSetWMHints ,
+which sets the WM_HINTS property (see section 14.1.6).
+.LP
+If the argv argument is non-NULL,
+.ZN XmbSetWMProperties
+sets the WM_COMMAND property from argv and argc.
+An argc of zero indicates a zero-length command.
+.LP
+The hostname of the machine is stored using
+.ZN XSetWMClientMachine
+(see section 14.2.2).
+.LP
+If the class_hints argument is non-NULL,
+.ZN XmbSetWMProperties
+sets the WM_CLASS property.
+If the res_name member in the
+.ZN XClassHint
+structure is set to the NULL pointer and the RESOURCE_NAME
+environment variable is set,
+the value of the environment variable is substituted for res_name.
+If the res_name member is NULL,
+the environment variable is not set, and argv and argv[0] are set,
+then the value of argv[0], stripped of any directory prefixes,
+is substituted for res_name.
+.LP
+It is assumed that the supplied class_hints.res_name and argv,
+the RESOURCE_NAME environment variable, and the hostname of the machine
+are in the encoding of the locale announced for the LC_CTYPE category
+(on POSIX-compliant systems, the LC_CTYPE, else LANG environment variable).
+The corresponding WM_CLASS, WM_COMMAND, and WM_CLIENT_MACHINE properties
+are typed according to the local host locale announcer.
+No encoding conversion is performed prior to storage in the properties.
+.LP
+For clients that need to process the property text in a locale,
+.ZN XmbSetWMProperties
+sets the WM_LOCALE_NAME property to be the name of the current locale.
+The name is assumed to be in the Host Portable Character Encoding
+and is converted to STRING for storage in the property.
+.LP
+.ZN XSetWMProperties
+and
+.ZN XmbSetWMProperties
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_CLASS\s+1
+Set by application programs to allow window and session
+managers to obtain the application's resources from the resource database.
+.TP 1i
+\s-1WM_CLIENT_MACHINE\s+1
+The string name of the machine on which the client application is running.
+.TP 1i
+\s-1WM_COMMAND\s+1
+The command and arguments, null-separated, used to invoke the
+application.
+.TP 1i
+\s-1WM_HINTS\s+1
+Additional hints set by the client for use by the window manager.
+The C type of this property is
+.ZN XWMHints .
+.TP 1i
+\s-1WM_ICON_NAME\s+1
+The name to be used in an icon.
+.TP 1i
+\s-1WM_NAME\s+1
+The name of the application.
+.TP 1i
+\s-1WM_NORMAL_HINTS\s+1
+Size hints for a window in its normal state.
+The C type of this property is
+.ZN XSizeHints .
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XParseGeometry(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProtocols(3X11),
+XStringListToTextProperty(3X11),
+XTextListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSetWMProtocols.man b/man/XSetWMProtocols.man
new file mode 100644
index 00000000..24821304
--- /dev/null
+++ b/man/XSetWMProtocols.man
@@ -0,0 +1,250 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSetWMProtocols 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSetWMProtocols, XGetWMProtocols \- set or read a window's WM__PROTOCOLS property
+.SH SYNTAX
+Status XSetWMProtocols\^(\^\fIdisplay\fP, \fIw\fP, \fIprotocols\fP, \
+\fIcount\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom *\fIprotocols\fP\^;
+.br
+ int \fIcount\fP\^;
+.LP
+Status XGetWMProtocols\^(\^\fIdisplay\fP, \fIw\fP, \fIprotocols_return\fP, \
+\fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.br
+ Atom **\fIprotocols_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.ds Cn protocols in the list
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.ds Cn protocols in the list
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIprotocols\fP 1i
+Specifies the list of protocols.
+.IP \fIprotocols_return\fP 1i
+Returns the list of protocols.
+.SH DESCRIPTION
+The
+.ZN XSetWMProtocols
+function replaces the WM_PROTOCOLS property on the specified window
+with the list of atoms specified by the protocols argument.
+If the property does not already exist,
+.ZN XSetWMProtocols
+sets the WM_PROTOCOLS property on the specified window
+to the list of atoms specified by the protocols argument.
+The property is stored with a type of ATOM and a format of 32.
+If it cannot intern the WM_PROTOCOLS atom,
+.ZN XSetWMProtocols
+returns a zero status.
+Otherwise, it returns a nonzero status.
+.LP
+.ZN XSetWMProtocols
+can generate
+.ZN BadAlloc
+and
+.ZN BadWindow
+errors.
+.LP
+The
+.ZN XGetWMProtocols
+function returns the list of atoms stored in the WM_PROTOCOLS property
+on the specified window.
+These atoms describe window manager protocols in which the owner
+of this window is willing to participate.
+If the property exists, is of type ATOM, is of format 32,
+and the atom WM_PROTOCOLS can be interned,
+.ZN XGetWMProtocols
+sets the protocols_return argument to a list of atoms,
+sets the count_return argument to the number of elements in the list,
+and returns a nonzero status.
+Otherwise, it sets neither of the return arguments
+and returns a zero status.
+To release the list of atoms, use
+.ZN XFree .
+.LP
+.ZN XGetWMProtocols
+can generate a
+.ZN BadWindow
+error.
+.SH PROPERTIES
+.TP 1i
+\s-1WM_PROTOCOLS\s+1
+List of atoms that identify the communications protocols between the
+client and window manager in which the client is willing to participate.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XStoreBytes.man b/man/XStoreBytes.man
new file mode 100644
index 00000000..d2ca223c
--- /dev/null
+++ b/man/XStoreBytes.man
@@ -0,0 +1,277 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XStoreBytes 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XStoreBytes, XStoreBuffer, XFetchBytes, XFetchBuffer, XRotateBuffers \- manipulate cut and paste buffers
+.SH SYNTAX
+XStoreBytes\^(\^\fIdisplay\fP, \fIbytes\fP\^, \fInbytes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIbytes\fP\^;
+.br
+ int \^\fInbytes\fP\^;
+.br
+.LP
+XStoreBuffer\^(\^\fIdisplay\fP, \fIbytes\fP\^, \fInbytes\fP\^, \fIbuffer\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char *\fIbytes\fP\^;
+.br
+ int \^\fInbytes\fP\^;
+.br
+ int \fIbuffer\fP\^;
+.LP
+char *XFetchBytes\^(\^\fIdisplay\fP, \fInbytes_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fInbytes_return\fP\^;
+.LP
+char *XFetchBuffer\^(\^\fIdisplay\fP, \fInbytes_return\fP\^, \fIbuffer\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int *\fInbytes_return\fP\^;
+.br
+ int \fIbuffer\fP\^;
+.LP
+XRotateBuffers\^(\^\fIdisplay\fP, \fIrotate\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIrotate\fP\^;
+.SH ARGUMENTS
+.ds Fn in which you want to store the bytes \
+or from which you want the stored data returned
+.IP \fIbuffer\fP 1i
+Specifies the buffer \*(Fn.
+.IP \fIbytes\fP 1i
+Specifies the bytes, which are not necessarily ASCII or null-terminated.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fInbytes\fP 1i
+Specifies the number of bytes to be stored.
+.IP \fInbytes_return\fP 1i
+Returns the number of bytes in the buffer.
+.IP \fIrotate\fP 1i
+Specifies how much to rotate the cut buffers.
+.SH DESCRIPTION
+The data can have embedded null characters
+and need not be null-terminated.
+The cut buffer's contents can be retrieved later by
+any client calling
+.ZN XFetchBytes .
+.LP
+.ZN XStoreBytes
+can generate a
+.ZN BadAlloc
+error.
+.LP
+If an invalid buffer is specified, the call has no effect.
+The data can have embedded null characters
+and need not be null-terminated.
+.LP
+.ZN XStoreBuffer
+can generate a
+.ZN BadAlloc
+error.
+.LP
+The
+.ZN XFetchBytes
+function
+returns the number of bytes in the nbytes_return argument,
+if the buffer contains data.
+Otherwise, the function
+returns NULL and sets nbytes to 0.
+The appropriate amount of storage is allocated and the pointer returned.
+The client must free this storage when finished with it by calling
+.ZN XFree .
+.LP
+The
+.ZN XFetchBuffer
+function returns zero to the nbytes_return argument
+if there is no data in the buffer or if an invalid
+buffer is specified.
+.LP
+.ZN XFetchBuffer
+can generate a
+.ZN BadValue
+error.
+.LP
+The
+.ZN XRotateBuffers
+function rotates the cut
+buffers, such that buffer 0 becomes buffer n,
+buffer 1 becomes n + 1 mod 8, and so on.
+This cut buffer numbering is global to the display.
+Note that
+.ZN XRotateBuffers
+generates
+.ZN BadMatch
+errors if any of the eight buffers have not been created.
+.LP
+.ZN XRotateBuffers
+can generate a
+.ZN BadMatch
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAlloc
+The server failed to allocate the requested resource or server memory.
+.TP 1i
+.ZN BadAtom
+A value for an Atom argument does not name a defined Atom.
+.TP 1i
+.ZN BadMatch
+Some argument or pair of arguments has the correct type and range but fails
+to match in some other way required by the request.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XFree(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XStoreColors.man b/man/XStoreColors.man
new file mode 100644
index 00000000..c849a5ff
--- /dev/null
+++ b/man/XStoreColors.man
@@ -0,0 +1,323 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XStoreColors 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XStoreColors, XStoreColor, XStoreNamedColor \- set colors
+.SH SYNTAX
+XStoreColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor\fP\^, \fIncolors\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XColor \fIcolor\fP\^[\^]\^;
+.br
+ int \fIncolors\fP\^;
+.LP
+XStoreColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XColor *\fIcolor\fP\^;
+.LP
+XStoreNamedColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor\fP\^, \fIpixel\fP\^, \fIflags\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\^\fIcolor\fP\^;
+.br
+ unsigned long \fIpixel\fP\^;
+.br
+ int \fIflags\fP\^;
+.SH ARGUMENTS
+.ds Co pixel and RGB values or the color name string (for example, red)
+.IP \fIcolor\fP 1i
+Specifies the \*(Co.
+.IP \fIcolor\fP 1i
+Specifies an array of color definition structures to be stored.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIflags\fP 1i
+Specifies which red, green, and blue components are set.
+.IP \fIncolors\fP 1i
+.\"Specifies the number of color definition structures.
+Specifies the number of
+.ZN XColor
+structures in the color definition array.
+.IP \fIpixel\fP 1i
+Specifies the entry in the colormap.
+.SH DESCRIPTION
+The
+.ZN XStoreColors
+function changes the colormap entries of the pixel values
+specified in the pixel members of the
+.ZN XColor
+structures.
+You specify which color components are to be changed by setting
+.ZN DoRed ,
+.ZN DoGreen ,
+and/or
+.ZN DoBlue
+in the flags member of the
+.ZN XColor
+structures.
+If the colormap is an installed map for its screen, the
+changes are visible immediately.
+.ZN XStoreColors
+changes the specified pixels if they are allocated writable in the colormap
+by any client, even if one or more pixels generates an error.
+If a specified pixel is not a valid index into the colormap, a
+.ZN BadValue
+error results.
+If a specified pixel either is unallocated or is allocated read-only, a
+.ZN BadAccess
+error results.
+If more than one pixel is in error,
+the one that gets reported is arbitrary.
+.LP
+.ZN XStoreColors
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XStoreColor
+function changes the colormap entry of the pixel value specified in the
+pixel member of the
+.ZN XColor
+structure.
+You specified this value in the
+pixel member of the
+.ZN XColor
+structure.
+This pixel value must be a read/write cell and a valid index into the colormap.
+If a specified pixel is not a valid index into the colormap,
+a
+.ZN BadValue
+error results.
+.ZN XStoreColor
+also changes the red, green, and/or blue color components.
+You specify which color components are to be changed by setting
+.ZN DoRed ,
+.ZN DoGreen ,
+and/or
+.ZN DoBlue
+in the flags member of the
+.ZN XColor
+structure.
+If the colormap is an installed map for its screen,
+the changes are visible immediately.
+.LP
+.ZN XStoreColor
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XStoreNamedColor
+function looks up the named color with respect to the screen associated with
+the colormap and stores the result in the specified colormap.
+The pixel argument determines the entry in the colormap.
+The flags argument determines which of the red, green, and blue components
+are set.
+You can set this member to the
+bitwise inclusive OR of the bits
+.ZN DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue .
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+If the specified pixel is not a valid index into the colormap, a
+.ZN BadValue
+error results.
+If the specified pixel either is unallocated or is allocated read-only, a
+.ZN BadAccess
+error results.
+.LP
+.ZN XStoreNamedColor
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+.ZN BadName ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to free a color map entry that it did not already allocate.
+.TP 1i
+.ZN BadAccess
+A client attempted
+to store into a read-only color map entry.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadName
+A font or color of the specified name does not exist.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XAllocColor(3X11),
+XCreateColormap(3X11),
+XQueryColor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XStringListToTextProperty.man b/man/XStringListToTextProperty.man
new file mode 100644
index 00000000..7a0021c0
--- /dev/null
+++ b/man/XStringListToTextProperty.man
@@ -0,0 +1,263 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XStringListToTextProperty 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XStringListToTextProperty, XTextPropertyToStringList, XFreeStringList, XTextProperty \- convert string lists and text property structure
+.SH SYNTAX
+Status XStringListToTextProperty\^(\^\fIlist\fP, \fIcount\fP, \
+\fItext_prop_return\fP\^)
+.br
+ char **\fIlist\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.LP
+Status XTextPropertyToStringList\^(\^\fItext_prop\fP, \fIlist_return\fP, \
+\fIcount_return\fP\^)
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.br
+ char ***\fIlist_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.LP
+void XFreeStringList\^(\^\fIlist\fP\^)
+.br
+ char **\fIlist\fP\^;
+.SH ARGUMENTS
+.ds Cn strings
+.IP \fIcount\fP 1i
+Specifies the number of \*(Cn.
+.ds Cn strings
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIlist\fP 1i
+Specifies the list of strings to be freed.
+.IP \fIlist\fP 1i
+Specifies a list of null-terminated character strings.
+.IP \fIlist_return\fP 1i
+Returns a list of null-terminated character strings.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.SH DESCRIPTION
+The
+.ZN XStringListToTextProperty
+function sets the specified
+.ZN XTextProperty
+to be of type STRING (format 8) with a value representing the
+concatenation of the specified list of null-separated character strings.
+An extra null byte (which is not included in the nitems member)
+is stored at the end of the value field of text_prop_return.
+The strings are assumed (without verification) to be in the STRING encoding.
+If insufficient memory is available for the new value string,
+.ZN XStringListToTextProperty
+does not set any fields in the
+.ZN XTextProperty
+structure and returns a zero status.
+Otherwise, it returns a nonzero status.
+To free the storage for the value field, use
+.ZN XFree .
+.LP
+The
+.ZN XTextPropertyToStringList
+function returns a list of strings representing the null-separated elements
+of the specified
+.ZN XTextProperty
+structure.
+The data in text_prop must be of type STRING and format 8.
+Multiple elements of the property
+(for example, the strings in a disjoint text selection)
+are separated by NULL (encoding 0).
+The contents of the property are not null-terminated.
+If insufficient memory is available for the list and its elements,
+.ZN XTextPropertyToStringList
+sets no return values and returns a zero status.
+Otherwise, it returns a nonzero status.
+To free the storage for the list and its contents, use
+.ZN XFreeStringList .
+.LP
+The
+.ZN XFreeStringList
+function releases memory allocated by
+.ZN XmbTextPropertyToTextList
+and
+.ZN XTextPropertyToStringList
+and the missing charset list allocated by
+.ZN XCreateFontSet .
+.SH STRUCTURES
+The
+.ZN XTextProperty
+structure contains:
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ unsigned char *value; /* property data */
+ Atom encoding; /* type of property */
+ int format; /* 8, 16, or 32 */
+ unsigned long nitems; /* number of items in value */
+} XTextProperty;
+.De
+.SH "SEE ALSO"
+XAllocClassHint(3X11),
+XAllocIconSize(3X11),
+XAllocSizeHints(3X11),
+XAllocWMHints(3X11),
+XFree(3X11),
+XSetCommand(3X11),
+XSetTransientForHint(3X11),
+XSetTextProperty(3X11),
+XSetWMClientMachine(3X11),
+XSetWMColormapWindows(3X11),
+XSetWMIconName(3X11),
+XSetWMName(3X11),
+XSetWMProperties(3X11),
+XSetWMProtocols(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XStringToKeysym.man b/man/XStringToKeysym.man
new file mode 100644
index 00000000..10615df3
--- /dev/null
+++ b/man/XStringToKeysym.man
@@ -0,0 +1,237 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XStringToKeysym 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XStringToKeysym, XKeysymToString, XKeycodeToKeysym, XKeysymToKeycode, XConvertCase \- convert keysyms
+.SH SYNTAX
+KeySym XStringToKeysym\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.LP
+char *XKeysymToString\^(\^\fIkeysym\fP\^)
+.br
+ KeySym \fIkeysym\fP\^;
+.LP
+KeySym XKeycodeToKeysym\^(\^\fIdisplay\fP, \fIkeycode\fP, \fIindex\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ KeyCode \fIkeycode\fP\^;
+.br
+ int \fIindex\fP\^;
+.LP
+KeyCode XKeysymToKeycode\^(\^\fIdisplay\fP, \fIkeysym\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ KeySym \fIkeysym\fP\^;
+.LP
+void XConvertCase(\^\fIkeysym\fP, \fIlower_return\fP, \fIupper_return\fP\^)
+.br
+ KeySym \fIkeysym\fP\^;
+.br
+ KeySym *\fIlower_return\fP\^;
+.br
+ KeySym *\fIupper_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIindex\fP 1i
+Specifies the element of KeyCode vector.
+.IP \fIkeycode\fP 1i
+Specifies the KeyCode.
+.ds Fn searched for or converted
+.IP \fIkeysym\fP 1i
+Specifies the KeySym that is to be \*(Fn.
+.IP \fIlower_return\fP 1i
+Returns the lowercase form of keysym, or keysym.
+.IP \fIstring\fP 1i
+Specifies the name of the KeySym that is to be converted.
+.IP \fIupper_return\fP 1i
+Returns the uppercase form of keysym, or keysym.
+.SH DESCRIPTION
+Standard KeySym names are obtained from
+.hN X11/keysymdef.h
+by removing the XK_ prefix from each name.
+KeySyms that are not part of the Xlib standard also may be obtained
+with this function.
+The set of KeySyms that are available in this manner
+and the mechanisms by which Xlib obtains them is implementation-dependent.
+.LP
+If the KeySym name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+If the specified string does not match a valid KeySym,
+.ZN XStringToKeysym
+returns
+.ZN NoSymbol .
+.LP
+The returned string is in a static area and must not be modified.
+The returned string is in the Host Portable Character Encoding.
+If the specified KeySym is not defined,
+.ZN XKeysymToString
+returns a NULL.
+.LP
+The
+.ZN XKeycodeToKeysym
+function uses internal Xlib tables
+and returns the KeySym defined for the specified KeyCode and
+the element of the KeyCode vector.
+If no symbol is defined,
+.ZN XKeycodeToKeysym
+returns
+.ZN NoSymbol .
+.LP
+If the specified KeySym is not defined for any KeyCode,
+.ZN XKeysymToKeycode
+returns zero.
+.LP
+The
+.ZN XConvertCase
+function returns the uppercase and lowercase forms of the specified Keysym,
+if the KeySym is subject to case conversion;
+otherwise, the specified KeySym is returned to both lower_return and
+upper_return.
+Support for conversion of other than Latin and Cyrillic KeySyms is
+implementation-dependent.
+.SH "SEE ALSO"
+XLookupKeysym(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XSupportsLocale.man b/man/XSupportsLocale.man
new file mode 100644
index 00000000..fa6874fb
--- /dev/null
+++ b/man/XSupportsLocale.man
@@ -0,0 +1,226 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSupportsLocal 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSupportsLocale, XSetLocaleModifiers \- determine locale support and configure locale modifiers
+.SH SYNTAX
+Bool XSupportsLocale\^(\|)
+.LP
+char *XSetLocaleModifiers\^(\^\fImodifier_list\fP\^)
+.br
+ char *\fImodifier_list\fP\^;
+.SH ARGUMENTS
+.IP \fImodifier_list\fP 1i
+Specifies the modifiers.
+.SH DESCRIPTION
+The
+.ZN XSupportsLocale
+function returns
+.ZN True
+if Xlib functions are capable of operating under the current locale.
+If it returns
+.ZN False ,
+Xlib locale-dependent functions for which the
+.ZN XLocaleNotSupported
+return status is defined will return
+.ZN XLocaleNotSupported .
+Other Xlib locale-dependent routines will operate in the ``C'' locale.
+.LP
+The
+.ZN XSetLocaleModifiers
+function sets the X modifiers for the current locale setting.
+The modifier_list argument is a null-terminated string of the form
+``{@\^\fIcategory\fP\^=\^\fIvalue\fP\^}'', that is,
+having zero or more concatenated ``@\^\fIcategory\fP\^=\^\fIvalue\fP\^''
+entries, where \fIcategory\fP is a category name
+and \fIvalue\fP is the (possibly empty) setting for that category.
+The values are encoded in the current locale.
+Category names are restricted to the POSIX Portable Filename Character Set.
+.LP
+The local host X locale modifiers announcer (on POSIX-compliant systems,
+the XMODIFIERS environment variable) is appended to the modifier_list to
+provide default values on the local host.
+If a given category appears more than once in the list,
+the first setting in the list is used.
+If a given category is not included in the full modifier list,
+the category is set to an implementation-dependent default
+for the current locale.
+An empty value for a category explicitly specifies the
+implementation-dependent default.
+.LP
+If the function is successful, it returns a pointer to a string.
+The contents of the string are such that a subsequent call with that string
+(in the same locale) will restore the modifiers to the same settings.
+If modifier_list is a NULL pointer,
+.ZN XSetLocaleModifiers
+also returns a pointer to such a string,
+and the current locale modifiers are not changed.
+.LP
+If invalid values are given for one or more modifier categories supported by
+the locale, a NULL pointer is returned, and none of the
+current modifiers are changed.
+.LP
+At program startup,
+the modifiers that are in effect are unspecified until
+the first successful call to set them. Whenever the locale is changed, the
+modifiers that are in effect become unspecified until the next successful call
+to set them.
+Clients should always call
+.ZN XSetLocaleModifiers
+with a non-NULL modifier_list after setting the locale
+before they call any locale-dependent Xlib routine.
+.LP
+The only standard modifier category currently defined is ``im'',
+which identifies the desired input method.
+The values for input method are not standardized.
+A single locale may use multiple input methods,
+switching input method under user control.
+The modifier may specify the initial input method in effect
+or an ordered list of input methods.
+Multiple input methods may be specified in a single im value string
+in an implementation-dependent manner.
+.LP
+The returned modifiers string is owned by Xlib and should not be modified or
+freed by the client.
+It may be freed by Xlib after the current locale or modifiers are changed.
+Until freed, it will not be modified by Xlib.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XSynchronize.man b/man/XSynchronize.man
new file mode 100644
index 00000000..d37c8f92
--- /dev/null
+++ b/man/XSynchronize.man
@@ -0,0 +1,184 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XSynchronize 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XSynchronize, XSetAfterFunction \- enable or disable synchronization
+.SH SYNTAX
+int (*XSynchronize\^(\^\fIdisplay\fP, \fIonoff\fP\^)\^)()
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Bool \fIonoff\fP\^;
+.LP
+int (*XSetAfterFunction\^(\^\fIdisplay\fP, \fIprocedure\fP\^))()
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int (\^*\^\fIprocedure\fP\^)\^();
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIprocedure\fP 1i
+Specifies the procedure to be called.
+.IP \fIonoff\fP 1i
+Specifies a Boolean value that indicates whether to enable
+or disable synchronization.
+.SH DESCRIPTION
+The
+.ZN XSynchronize
+function returns
+the previous after function.
+If onoff is
+.ZN True ,
+.ZN XSynchronize
+turns on synchronous behavior.
+If onoff is
+.ZN False ,
+.ZN XSynchronize
+turns off synchronous behavior.
+.LP
+The specified procedure is called with only a display pointer.
+.ZN XSetAfterFunction
+returns the previous after function.
+.SH "SEE ALSO"
+XSetErrorHandler(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XTextExtents.man b/man/XTextExtents.man
new file mode 100644
index 00000000..c897a7c5
--- /dev/null
+++ b/man/XTextExtents.man
@@ -0,0 +1,342 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XTextExtents 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XTextExtents, XTextExtents16, XQueryTextExtents, XQueryTextExtents16 \- compute or query text extents
+.SH SYNTAX
+XTextExtents\^(\^\fIfont_struct\fP\^, \fIstring\fP\^, \fInchars\fP\^, \
+\fIdirection_return\fP, \fIfont_ascent_return\fP,
+.br
+ \fIfont_descent_return\fP, \fIoverall_return\fP\^)
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInchars\fP\^;
+.br
+ int *\fIdirection_return\fP\^;
+.br
+ int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
+.br
+ XCharStruct *\fIoverall_return\fP\^;
+
+.LP
+XTextExtents16\^(\^\fIfont_struct\fP\^, \fIstring\fP\^, \fInchars\fP\^, \
+\fIdirection_return\fP, \fIfont_ascent_return\fP,
+.br
+ \fIfont_descent_return\fP, \fIoverall_return\fP\^)
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.br
+ XChar2b *\fIstring\fP\^;
+.br
+ int \fInchars\fP\^;
+.br
+ int *\fIdirection_return\fP\^;
+.br
+ int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
+.br
+ XCharStruct *\fIoverall_return\fP\^;
+
+.LP
+XQueryTextExtents\^(\^\fIdisplay\fP, \fIfont_ID\fP, \fIstring\fP, \
+\fInchars\fP, \fIdirection_return\fP, \fIfont_ascent_return\fP,
+.br
+ \fIfont_descent_return\fP, \fIoverall_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIfont_ID\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInchars\fP\^;
+.br
+ int *\fIdirection_return\fP\^;
+.br
+ int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
+.br
+ XCharStruct *\fIoverall_return\fP\^;
+.LP
+XQueryTextExtents16\^(\^\fIdisplay\fP, \fIfont_ID\fP, \fIstring\fP, \
+\fInchars\fP, \fIdirection_return\fP, \fIfont_ascent_return\fP,
+.br
+ \fIfont_descent_return\fP, \fIoverall_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XID \fIfont_ID\fP\^;
+.br
+ XChar2b *\fIstring\fP\^;
+.br
+ int \fInchars\fP\^;
+.br
+ int *\fIdirection_return\fP\^;
+.br
+ int *\fIfont_ascent_return\fP, *\fIfont_descent_return\fP\^;
+.br
+ XCharStruct *\fIoverall_return\fP\^;
+.SH ARGUMENTS
+.IP \fIdirection_return\fP 1i
+Returns the value of the direction hint
+.Pn ( FontLeftToRight
+or
+.ZN FontRightToLeft ).
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfont_ID\fP 1i
+Specifies either the font ID or the
+.ZN GContext
+ID that contains the font.
+.IP \fIfont_ascent_return\fP 1i
+Returns the font ascent.
+.IP \fIfont_descent_return\fP 1i
+Returns the font descent.
+.IP \fIfont_struct\fP 1i
+Specifies the
+.ZN XFontStruct
+structure.
+.IP \fInchars\fP 1i
+Specifies the number of characters in the character string.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.IP \fIoverall_return\fP 1i
+Returns the overall size in the specified
+.ZN XCharStruct
+structure.
+.SH DESCRIPTION
+The
+.ZN XTextExtents
+and
+.ZN XTextExtents16
+functions
+perform the size computation locally and, thereby,
+avoid the round-trip overhead of
+.ZN XQueryTextExtents
+and
+.ZN XQueryTextExtents16 .
+Both functions return an
+.ZN XCharStruct
+structure, whose members are set to the values as follows.
+.LP
+The ascent member is set to the maximum of the ascent metrics of all
+characters in the string.
+The descent member is set to the maximum of the descent metrics.
+The width member is set to the sum of the character-width metrics of all
+characters in the string.
+For each character in the string,
+let W be the sum of the character-width metrics of all characters preceding
+it in the string.
+Let L be the left-side-bearing metric of the character plus W.
+Let R be the right-side-bearing metric of the character plus W.
+The lbearing member is set to the minimum L of all characters in the string.
+The rbearing member is set to the maximum R.
+.LP
+For fonts defined with linear indexing rather than 2-byte matrix indexing,
+each
+.ZN XChar2b
+structure is interpreted as a 16-bit number with byte1 as the
+most significant byte.
+If the font has no defined default character,
+undefined characters in the string are taken to have all zero metrics.
+.LP
+The
+.ZN XQueryTextExtents
+and
+.ZN XQueryTextExtents16
+functions return the bounding box of the specified 8-bit and 16-bit
+character string in the specified font or the font contained in the
+specified GC.
+These functions query the X server and, therefore, suffer the round-trip
+overhead that is avoided by
+.ZN XTextExtents
+and
+.ZN XTextExtents16 .
+Both functions return a
+.ZN XCharStruct
+structure, whose members are set to the values as follows.
+.LP
+The ascent member is set to the maximum of the ascent metrics
+of all characters in the string.
+The descent member is set to the maximum of the descent metrics.
+The width member is set to the sum of the character-width metrics
+of all characters in the string.
+For each character in the string,
+let W be the sum of the character-width metrics of all characters preceding
+it in the string.
+Let L be the left-side-bearing metric of the character plus W.
+Let R be the right-side-bearing metric of the character plus W.
+The lbearing member is set to the minimum L of all characters in the string.
+The rbearing member is set to the maximum R.
+.LP
+For fonts defined with linear indexing rather than 2-byte matrix indexing,
+each
+.ZN XChar2b
+structure is interpreted as a 16-bit number with byte1 as the
+most significant byte.
+If the font has no defined default character,
+undefined characters in the string are taken to have all zero metrics.
+.LP
+Characters with all zero metrics are ignored.
+If the font has no defined default_char,
+the undefined characters in the string are also ignored.
+.LP
+.ZN XQueryTextExtents
+and
+.ZN XQueryTextExtents16
+can generate
+.ZN BadFont
+and
+.ZN BadGC
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadFont
+A value for a Font or GContext argument does not name a defined Font.
+.TP 1i
+.ZN BadGC
+A value for a GContext argument does not name a defined GContext.
+.SH "SEE ALSO"
+XLoadFont(3X11),
+XTextWidth(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XTextWidth.man b/man/XTextWidth.man
new file mode 100644
index 00000000..a5d70143
--- /dev/null
+++ b/man/XTextWidth.man
@@ -0,0 +1,177 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XTextWidth 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XTextWidth, XTextWidth16 \- compute text width
+.SH SYNTAX
+int XTextWidth\^(\^\fIfont_struct\fP\^, \fIstring\fP, \fIcount\fP\^)
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fIcount\fP\^;
+.LP
+int XTextWidth16\^(\^\fIfont_struct\fP\^, \fIstring\fP, \fIcount\fP\^)
+.br
+ XFontStruct *\fIfont_struct\fP\^;
+.br
+ XChar2b *\fIstring\fP\^;
+.br
+ int \fIcount\fP\^;
+.SH ARGUMENTS
+.IP \fIcount\fP 1i
+Specifies the character count in the specified string.
+.IP \fIfont_struct\fP 1i
+Specifies the font used for the width computation.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.SH DESCRIPTION
+The
+.ZN XTextWidth
+and
+.ZN XTextWidth16
+functions return the width of the specified 8-bit or 2-byte character strings.
+.SH "SEE ALSO"
+XLoadFont(3X11),
+XTextExtents(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XTranslateCoordinates.man b/man/XTranslateCoordinates.man
new file mode 100644
index 00000000..2037665a
--- /dev/null
+++ b/man/XTranslateCoordinates.man
@@ -0,0 +1,207 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XTranslateCoordinates 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XTranslateCoordinates \- translate window coordinates
+.SH SYNTAX
+Bool XTranslateCoordinates\^(\^\fIdisplay\fP, \fIsrc_w\fP\^, \fIdest_w\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIdest_x_return\fP\^,
+.br
+ \fIdest_y_return\fP\^, \fIchild_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIsrc_w\fP\^, \fIdest_w\fP\^;
+.br
+ int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
+.br
+ int *\fIdest_x_return\fP\^, *\fIdest_y_return\fP\^;
+.br
+ Window *\fIchild_return\fP\^;
+.SH ARGUMENTS
+.IP \fIchild_return\fP 1i
+Returns the child if the coordinates are contained in a mapped child of the
+destination window.
+.IP \fIdest_w\fP 1i
+Specifies the destination window.
+.IP \fIdest_x_return\fP 1i
+.br
+.ns
+.IP \fIdest_y_return\fP 1i
+Return the x and y coordinates within the destination window.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIsrc_w\fP 1i
+Specifies the source window.
+.IP \fIsrc_x\fP 1i
+.br
+.ns
+.IP \fIsrc_y\fP 1i
+Specify the x and y coordinates within the source window.
+.SH DESCRIPTION
+If
+.ZN XTranslateCoordinates
+returns
+.ZN True ,
+it takes the src_x and src_y coordinates relative
+to the source window's origin and returns these coordinates to
+dest_x_return and dest_y_return
+relative to the destination window's origin.
+If
+.ZN XTranslateCoordinates
+returns
+.ZN False ,
+src_w and dest_w are on different screens,
+and dest_x_return and dest_y_return are zero.
+If the coordinates are contained in a mapped child of dest_w,
+that child is returned to child_return.
+Otherwise, child_return is set to
+.ZN None .
+.LP
+.ZN XTranslateCoordinates
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XUnmapEvent.man b/man/XUnmapEvent.man
new file mode 100644
index 00000000..a94bc331
--- /dev/null
+++ b/man/XUnmapEvent.man
@@ -0,0 +1,225 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XUnmapEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XUnmapEvent \- UnmapNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN UnmapNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* UnmapNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window event;
+ Window window;
+ Bool from_configure;
+} XUnmapEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The event member is set either to the unmapped window or to its parent,
+depending on whether
+.ZN StructureNotify
+or
+.ZN SubstructureNotify
+was selected.
+This is the window used by the X server to report the event.
+The window member is set to the window that was unmapped.
+The from_configure member is set to
+.ZN True
+if the event was generated as a result of a resizing of the window's parent when
+the window itself had a win_gravity of
+.ZN UnmapGravity .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XVisibilityEvent(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XUnmapWindow.man b/man/XUnmapWindow.man
new file mode 100644
index 00000000..98e5519d
--- /dev/null
+++ b/man/XUnmapWindow.man
@@ -0,0 +1,216 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XUnmapWindow 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XUnmapWindow, XUnmapSubwindows \- unmap windows
+.SH SYNTAX
+XUnmapWindow\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.LP
+XUnmapSubwindows\^(\^\fIdisplay\fP, \fIw\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIw\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIw\fP 1i
+Specifies the window.
+.SH DESCRIPTION
+The
+.ZN XUnmapWindow
+function unmaps the specified window and causes the X server to generate an
+.ZN UnmapNotify
+.IN "UnmapNotify Event"
+.IN "XUnmapWindow"
+event.
+If the specified window is already unmapped,
+.ZN XUnmapWindow
+has no effect.
+Normal exposure processing on formerly obscured windows is performed.
+Any child window will no longer be visible until another map call is
+made on the parent.
+In other words, the subwindows are still mapped but are not visible
+until the parent is mapped.
+Unmapping a window will generate
+.ZN Expose
+events on windows that were formerly obscured by it.
+.LP
+.ZN XUnmapWindow
+can generate a
+.ZN BadWindow
+error.
+.LP
+The
+.ZN XUnmapSubwindows
+function unmaps all subwindows for the specified window in bottom-to-top
+stacking order.
+It causes the X server to generate an
+.ZN UnmapNotify
+event on each subwindow and
+.ZN Expose
+events on formerly obscured windows.
+.IN "UnmapNotify Event"
+Using this function is much more efficient than unmapping multiple windows
+one at a time because the server needs to perform much of the work
+only once, for all of the windows, rather than for each window.
+.LP
+.ZN XUnmapSubwindows
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XChangeWindowAttributes(3X11),
+XConfigureWindow(3X11),
+XCreateWindow(3X11),
+XDestroyWindow(3X11),
+XMapWindow(3X11)
+XRaiseWindow(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XVaCreateNestedList.man b/man/XVaCreateNestedList.man
new file mode 100644
index 00000000..56be7f32
--- /dev/null
+++ b/man/XVaCreateNestedList.man
@@ -0,0 +1,170 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XVaCreateNestedList 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XVaCreateNestedList \- allocate a nested variable argument list
+.SH SYNTAX
+typedef void * XVaNestedList;
+
+XVaNestedList XVaCreateNestedList\^(\^\fIdummy\fP\^, ...)
+.br
+ int \fIdummy\fP\^;
+.SH ARGUMENTS
+.IP \fIdummy\fP 1i
+Specifies an unused argument (required by ANSI C).
+.ds Al
+.IP ... 1i
+Specifies the variable length argument list\*(Al.
+.SH DESCRIPTION
+The
+.ZN XVaCreateNestedList
+function allocates memory and copies its arguments into
+a single list pointer,
+which may be used as a value for arguments requiring a list value.
+Any entries are copied as specified.
+Data passed by reference is not copied;
+the caller must ensure data remains valid for the lifetime
+of the nested list.
+The list should be freed using
+.ZN XFree
+when it is no longer needed.
+.SH "SEE ALSO"
+\fI\*(xL\fP
diff --git a/man/XVisibilityEvent.man b/man/XVisibilityEvent.man
new file mode 100644
index 00000000..218e4005
--- /dev/null
+++ b/man/XVisibilityEvent.man
@@ -0,0 +1,243 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XVisibilityEvent 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XVisibilityNotifyEvent \- VisibilityNotify event structure
+.SH STRUCTURES
+The structure for
+.ZN VisibilityNotify
+events contains:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ int type; /* VisibiltyNotify */
+ unsigned long serial; /* # of last request processed by server */
+ Bool send_event; /* true if this came from a SendEvent request */
+ Display *display; /* Display the event was read from */
+ Window window;
+ int state;
+} XVisibilityEvent;
+.De
+.LP
+When you receive this event,
+the structure members are set as follows.
+.LP
+The type member is set to the event type constant name that uniquely identifies
+it.
+For example, when the X server reports a
+.ZN GraphicsExpose
+event to a client application, it sends an
+.ZN XGraphicsExposeEvent
+structure with the type member set to
+.ZN GraphicsExpose .
+The display member is set to a pointer to the display the event was read on.
+The send_event member is set to
+.ZN True
+if the event came from a
+.ZN SendEvent
+protocol request.
+The serial member is set from the serial number reported in the protocol
+but expanded from the 16-bit least-significant bits to a full 32-bit value.
+The window member is set to the window that is most useful to toolkit
+dispatchers.
+.LP
+The window member is set to the window whose visibility state changes.
+The state member is set to the state of the window's visibility and can be
+.ZN VisibilityUnobscured ,
+.ZN VisibilityPartiallyObscured ,
+or
+.ZN VisibilityFullyObscured .
+The X server ignores all of a window's subwindows
+when determining the visibility state of the window and processes
+.ZN VisibilityNotify
+events according to the following:
+.IP \(bu 5
+When the window changes state from partially obscured, fully obscured,
+or not viewable to viewable and completely unobscured,
+the X server generates the event with the state member of the
+.ZN XVisibilityEvent
+structure set to
+.ZN VisibilityUnobscured .
+.IP \(bu 5
+When the window changes state from viewable and completely unobscured or
+not viewable to viewable and partially obscured,
+the X server generates the event with the state member of the
+.ZN XVisibilityEvent
+structure set to
+.ZN VisibilityPartiallyObscured .
+.IP \(bu 5
+When the window changes state from viewable and completely unobscured,
+viewable and partially obscured, or not viewable to viewable and
+fully obscured,
+the X server generates the event with the state member of the
+.ZN XVisibilityEvent
+structure set to
+.ZN VisibilityFullyObscured .
+.SH "SEE ALSO"
+XAnyEvent(3X11),
+XButtonEvent(3X11),
+XCreateWindowEvent(3X11),
+XCirculateEvent(3X11),
+XCirculateRequestEvent(3X11),
+XColormapEvent(3X11),
+XConfigureEvent(3X11),
+XConfigureRequestEvent(3X11),
+XCrossingEvent(3X11),
+XDestroyWindowEvent(3X11),
+XErrorEvent(3X11),
+XExposeEvent(3X11),
+XFocusChangeEvent(3X11),
+XGraphicsExposeEvent(3X11),
+XGravityEvent(3X11),
+XKeymapEvent(3X11),
+XMapEvent(3X11),
+XMapRequestEvent(3X11),
+XPropertyEvent(3X11),
+XReparentEvent(3X11),
+XResizeRequestEvent(3X11),
+XSelectionClearEvent(3X11),
+XSelectionEvent(3X11),
+XSelectionRequestEvent(3X11),
+XUnmapEvent(3X11),
+.br
+\fI\*(xL\fP
diff --git a/man/XWarpPointer.man b/man/XWarpPointer.man
new file mode 100644
index 00000000..0db9dce3
--- /dev/null
+++ b/man/XWarpPointer.man
@@ -0,0 +1,224 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XWarpPointer 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XWarpPointer \- move pointer
+.SH SYNTAX
+XWarpPointer\^(\^\fIdisplay\fP, \fIsrc_w\fP\^, \fIdest_w\fP\^, \fIsrc_x\fP\^, \fIsrc_y\fP\^, \fIsrc_width\fP\^, \fIsrc_height\fP\^, \fIdest_x\fP\^,
+.br
+ \fIdest_y\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Window \fIsrc_w\fP\^, \fIdest_w\fP\^;
+.br
+ int \fIsrc_x\fP\^, \fIsrc_y\fP\^;
+.br
+ unsigned int \fIsrc_width\fP\^, \fIsrc_height\fP\^;
+.br
+ int \fIdest_x\fP\^, \fIdest_y\fP\^;
+.SH ARGUMENTS
+.IP \fIdest_w\fP 1i
+Specifies the destination window or
+.ZN None .
+.IP \fIdest_x\fP 1i
+.br
+.ns
+.IP \fIdest_y\fP 1i
+Specify the x and y coordinates within the destination window.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIsrc_x\fP 1i
+.br
+.ns
+.IP \fIsrc_y\fP 1i
+.br
+.ns
+.IP \fIsrc_width\fP 1i
+.br
+.ns
+.IP \fIsrc_height\fP 1i
+Specify a rectangle in the source window.
+.IP \fIsrc_w\fP 1i
+Specifies the source window or
+.ZN None .
+.SH DESCRIPTION
+If dest_w is
+.ZN None ,
+.ZN XWarpPointer
+moves the pointer by the offsets (dest_x, dest_y) relative to the current
+position of the pointer.
+If dest_w is a window,
+.ZN XWarpPointer
+moves the pointer to the offsets (dest_x, dest_y) relative to the origin of
+dest_w.
+However, if src_w is a window,
+the move only takes place if the window src_w contains the pointer
+and if the specified rectangle of src_w contains the pointer.
+.LP
+The src_x and src_y coordinates are relative to the origin of src_w.
+If src_height is zero,
+it is replaced with the current height of src_w minus src_y.
+If src_width is zero,
+it is replaced with the current width of src_w minus src_x.
+.LP
+There is seldom any reason for calling this function.
+The pointer should normally be left to the user.
+If you do use this function, however, it generates events just as if the user
+had instantaneously moved the pointer from one position to another.
+Note that you cannot use
+.ZN XWarpPointer
+to move the pointer outside the confine_to window of an active pointer grab.
+An attempt to do so will only move the pointer as far as the closest edge of the
+confine_to window.
+.LP
+.ZN XWarpPointer
+can generate a
+.ZN BadWindow
+error.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadWindow
+A value for a Window argument does not name a defined Window.
+.SH "SEE ALSO"
+XSetInputFocus(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsAllocColor.man b/man/XcmsAllocColor.man
new file mode 100644
index 00000000..685b3409
--- /dev/null
+++ b/man/XcmsAllocColor.man
@@ -0,0 +1,277 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsAllocColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsAllocColor, XcmsAllocNamedColor \- allocate colors
+.SH SYNTAX
+Status XcmsAllocColor\^(\^\fIdisplay\fP\^, \fIcolormap\fP\^, \fIcolor_in_out\fP\^, \fIresult_format\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsColor *\fIcolor_in_out\fP\^;
+.br
+ XcmsColorFormat \fIresult_format\fP\^;
+.LP
+Status XcmsAllocNamedColor\^(\^\fIdisplay\fP\^, \fIcolormap\fP\^, \fIcolor_string\fP\^, \fIcolor_screen_return\fP\^, \fIcolor_exact_return\fP\^,
+.br
+ \fIresult_format\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\fIcolor_string\fP\^;
+.br
+ XcmsColor *\fIcolor_screen_return\fP\^;
+.br
+ XcmsColor *\fIcolor_exact_return\fP\^;
+.br
+ XcmsColorFormat \fIresult_format\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsAClr.man,v 1.3 2001/03/16 17:47:48 pookie Exp $
+.IP \fIcolor_exact_return\fP 1i
+Returns the color specification parsed from the color string
+or parsed from the corresponding string found in a color-name database.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsAClr.man,v 1.3 2001/03/16 17:47:48 pookie Exp $
+.IP \fIcolor_in_out\fP 1i
+Specifies the color to allocate and returns the pixel and color
+that is actually used in the colormap.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsAClr.man,v 1.3 2001/03/16 17:47:48 pookie Exp $
+.IP \fIcolor_screen_return\fP 1i
+Returns the pixel value of the color cell and color specification
+that actually is stored for that cell.
+.ds St \ whose color definition structure is to be returned
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsAClr.man,v 1.3 2001/03/16 17:47:48 pookie Exp $
+.IP \fIcolor_string\fP 1i
+Specifies the color string\*(St.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsAClr.man,v 1.3 2001/03/16 17:47:48 pookie Exp $
+.IP \fIresult_format\fP 1i
+Specifies the color format for the returned color specification.
+.SH DESCRIPTION
+The
+.ZN XcmsAllocColor
+function is similar to
+.ZN XAllocColor
+except the color can be specified in any format.
+The
+.ZN XcmsAllocColor
+function ultimately calls
+.ZN XAllocColor
+to allocate a read-only color cell (colormap entry) with the specified color.
+.ZN XcmsAllocColor
+first converts the color specified
+to an RGB value and then passes this to
+.ZN XAllocColor .
+.ZN XcmsAllocColor
+returns the pixel value of the color cell and the color specification
+actually allocated.
+This returned color specification is the result of converting the RGB value
+returned by
+.ZN XAllocColor
+into the format specified with the result_format argument.
+If there is no interest in a returned color specification,
+unnecessary computation can be bypassed if result_format is set to
+.ZN XcmsRGBFormat .
+The corresponding colormap cell is read-only.
+If this routine returns
+.ZN XcmsFailure ,
+the color_in_out color specification is left unchanged.
+.LP
+.ZN XcmsAllocColor
+can generate a
+.ZN BadColor
+errors.
+.LP
+The
+.ZN XcmsAllocNamedColor
+function is similar to
+.ZN XAllocNamedColor
+except that the color returned can be in any format specified.
+This function
+ultimately calls
+.ZN XAllocColor
+to allocate a read-only color cell with
+the color specified by a color string.
+The color string is parsed into an
+.ZN XcmsColor
+structure (see
+.ZN XcmsLookupColor ),
+converted
+to an RGB value, and finally passed to
+.ZN XAllocColor .
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+.LP
+This function returns both the color specification as a result
+of parsing (exact specification) and the actual color specification
+stored (screen specification).
+This screen specification is the result of converting the RGB value
+returned by
+.ZN XAllocColor
+into the format specified in result_format.
+If there is no interest in a returned color specification,
+unnecessary computation can be bypassed if result_format is set to
+.ZN XcmsRGBFormat .
+If color_screen_return and color_exact_return
+point to the same structure, the pixel field will be set correctly,
+but the color values are undefined.
+.LP
+.LP
+.ZN XcmsAllocNamedColor
+can generate a
+.ZN BadColor
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.SH "SEE ALSO"
+XcmsQueryColor(3X11),
+XcmsStoreColor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsCCCOfColormap.man b/man/XcmsCCCOfColormap.man
new file mode 100644
index 00000000..36d7377f
--- /dev/null
+++ b/man/XcmsCCCOfColormap.man
@@ -0,0 +1,193 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsCCCOfColormap 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsCCCOfColormap, XcmsSetCCCOfColormap \- query and modify CCC of a colormap
+.SH SYNTAX
+XcmsCCC XcmsCCCOfColormap\^(\^\fIdisplay\fP, \fIcolormap\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.LP
+XcmsCCC XcmsSetCCCOfColormap\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIccc\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsCCC \fIccc\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIccc\fP 1i
+Specifies the CCC.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.SH DESCRIPTION
+The
+.ZN XcmsCCCOfColormap
+function returns the CCC associated with the specified colormap.
+Once obtained,
+the CCC attributes can be queried or modified.
+Unless the CCC associated with the specified colormap is changed with
+.ZN XcmsSetCCCOfColormap ,
+this CCC is used when the specified colormap is used as an argument
+to color functions.
+.LP
+The
+.ZN XcmsSetCCCOfColormap
+function changes the CCC associated with the specified colormap.
+It returns the CCC previously associated with the colormap.
+If they are not used again in the application,
+CCCs should be freed by calling
+.ZN XcmsFreeCCC .
+Several colormaps may share the same CCC without restriction; this
+includes the CCCs generated by Xlib with each colormap. Xlib, however,
+creates a new CCC with each new colormap.
+.SH "SEE ALSO"
+DisplayOfCCC(3X11),
+XcmsConvertColors(3X11),
+XcmsCreateCCC(3X11),
+XcmsDefaultCCC(3X11),
+XcmsSetWhitePoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsCIELabQueryMaxC.man b/man/XcmsCIELabQueryMaxC.man
new file mode 100644
index 00000000..3e785d16
--- /dev/null
+++ b/man/XcmsCIELabQueryMaxC.man
@@ -0,0 +1,245 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsCIELabQueryMax 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsCIELabQueryMaxC, XcmsCIELabQueryMaxL, XcmsCIELabQueryMaxLC, XcmsCIELabQueryMinL \- obtain the CIE L*a*b* coordinates
+.SH SYNTAX
+Status XcmsCIELabQueryMaxC\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIL_star\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIL_star\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELabQueryMaxL\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELabQueryMaxLC\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELabQueryMinL\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+Note that the CCC's Client White Point and White Point Adjustment procedures
+are ignored.
+.ds Ch maximum lightness (MaxL) or minimum lightness (MinL)
+.IP \fIchroma\fP 1i
+Specifies the chroma at which to find \*(Ch.
+.ds Lc maximum chroma (MaxC and MaxLC), maximum lightnes (MaxL), \
+or minimum lightness (MinL)
+.ds lC hue angle and lightness (MaxC), hue angle and chroma (MaxL and MinL), \
+or hue angle (MaxLC)
+.IP \fIcolor_return\fP 1i
+Returns the CIE L*a*b* coordinates of \*(Lc
+displayable by the screen for the given \*(lC.
+The white point associated with the returned
+color specification is the Screen White Point.
+The value returned in the pixel member is undefined.
+.ds Ha maximum chroma (MaxC and MaxLC), maximum lightness (MaxL), \
+or minimum lightness (MinL)
+.IP \fIhue_angle\fP 1i
+Specifies the hue angle (in degrees) at which to find \*(Ha.
+.ds Ls maximum chroma (MaxC)
+.IP \fIL_star\fP 1i
+Specifies the lightness (L*) at which to find \*(Ls.
+.SH DESCRIPTION
+The
+.ZN XcmsCIELabQueryMaxC
+function, given a hue angle and lightness,
+finds the point of maximum chroma displayable by the screen.
+It returns this point in CIE L*a*b* coordinates.
+.LP
+The
+.ZN XcmsCIELabQueryMaxL
+function, given a hue angle and chroma,
+finds the point in CIE L*a*b* color space of maximum
+lightness (L*) displayable by the screen.
+It returns this point in CIE L*a*b* coordinates.
+An
+.ZN XcmsFailure
+return value usually indicates that the given chroma
+is beyond maximum for the given hue angle.
+.LP
+The
+.ZN XcmsCIELabQueryMaxLC
+function, given a hue angle,
+finds the point of maximum chroma displayable by the screen.
+It returns this point in CIE L*a*b* coordinates.
+.LP
+The
+.ZN XcmsCIELabQueryMinL
+function, given a hue angle and chroma,
+finds the point of minimum lightness (L*) displayable by the screen.
+It returns this point in CIE L*a*b* coordinates.
+An
+.ZN XcmsFailure
+return value usually indicates that the given chroma
+is beyond maximum for the given hue angle.
+.SH "SEE ALSO"
+XcmsCIELuvQueryMaxC(3X11),
+XcmsTekHVCQueryMaxC(3X11),
+XcmsQueryBlack(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsCIELuvQueryMaxC.man b/man/XcmsCIELuvQueryMaxC.man
new file mode 100644
index 00000000..60fe8e16
--- /dev/null
+++ b/man/XcmsCIELuvQueryMaxC.man
@@ -0,0 +1,245 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsCIELuvQueryMaxC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsCIELuvQueryMaxC, XcmsCIELuvQueryMaxL, XcmsCIELuvQueryMaxLC, XcmsCIELuvQueryMinL \- obtain the CIE L*u*v* coordinates
+.SH SYNTAX
+Status XcmsCIELuvQueryMaxC\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIL_star\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIL_star\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELuvQueryMaxL\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELuvQueryMaxLC\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsCIELuvQueryMinL\^(\^\fIccc\fP\^, \fIhue_angle\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue_angle\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+Note that the CCC's Client White Point and White Point Adjustment procedures
+are ignored.
+.ds Ch maximum lightness (MaxL) or minimum lightness (MinL)
+.IP \fIchroma\fP 1i
+Specifies the chroma at which to find \*(Ch.
+.ds Lc maximum chroma (MaxC and MaxLC), maximum lightnes (MaxL), \
+or minimum lightness (MinL)
+.ds lC hue angle and lightness (MaxC), hue angle and chroma (MaxL and MinL), \
+or hue angle (MaxLC)
+.IP \fIcolor_return\fP 1i
+Returns the CIE L*u*v* coordinates of \*(Lc
+displayable by the screen for the given \*(lC.
+The white point associated with the returned
+color specification is the Screen White Point.
+The value returned in the pixel member is undefined.
+.ds Ha maximum chroma (MaxC and MaxLC), maximum lightness (MaxL), \
+or minimum lightness (MinL)
+.IP \fIhue_angle\fP 1i
+Specifies the hue angle (in degrees) at which to find \*(Ha.
+.ds Ls maximum chroma (MaxC) or maximum lightness (MaxL)
+.IP \fIL_star\fP 1i
+Specifies the lightness (L*) at which to find \*(Ls.
+.SH DESCRIPTION
+The
+.ZN XcmsCIELuvQueryMaxC
+function, given a hue angle and lightness,
+finds the point of maximum chroma displayable by the screen.
+It returns this point in CIE L*u*v* coordinates.
+.LP
+The
+.ZN XcmsCIELuvQueryMaxL
+function, given a hue angle and chroma,
+finds the point in CIE L*u*v* color space of maximum
+lightness (L*) displayable by the screen.
+It returns this point in CIE L*u*v* coordinates.
+An
+.ZN XcmsFailure
+return value usually indicates that the given chroma
+is beyond maximum for the given hue angle.
+.LP
+The
+.ZN XcmsCIELuvQueryMaxLC
+function, given a hue angle,
+finds the point of maximum chroma displayable by the screen.
+It returns this point in CIE L*u*v* coordinates.
+.LP
+The
+.ZN XcmsCIELuvQueryMinL
+function, given a hue angle and chroma,
+finds the point of minimum lightness (L*) displayable by the screen.
+It returns this point in CIE L*u*v* coordinates.
+An
+.ZN XcmsFailure
+return value usually indicates that the given chroma
+is beyond maximum for the given hue angle.
+.SH "SEE ALSO"
+XcmsCIELabQueryMaxC(3X11),
+XcmsTekHVCQueryMaxC(3X11),
+XcmsQueryBlack(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsColor.man b/man/XcmsColor.man
new file mode 100644
index 00000000..a19630f6
--- /dev/null
+++ b/man/XcmsColor.man
@@ -0,0 +1,273 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsColor, XcmsRGB, XcmsRGBi, XcmsCIEXYZ, XcmsCIEuvY, XcmsCIExyY, XcmsCIELab, XcmsCIELuv, XcmsTekHVC, XcmsPad \- Xcms color struture
+.SH STRUCTURES
+The structure for
+.ZN XcmsColor
+contains:
+.LP
+.Ds 0
+.TA .5i 1i 2.5i
+.ta .5i 1i 2.5i
+typedef unsigned long XcmsColorFormat; /* Color Specification Format */
+
+typedef struct {
+ union {
+ XcmsRGB RGB;
+ XcmsRGBi RGBi;
+ XcmsCIEXYZ CIEXYZ;
+ XcmsCIEuvY CIEuvY;
+ XcmsCIExyY CIExyY;
+ XcmsCIELab CIELab;
+ XcmsCIELuv CIELuv;
+ XcmsTekHVC TekHVC;
+ XcmsPad Pad;
+ } spec;
+ unsigned long pixel;
+ XcmsColorFormat format;
+} XcmsColor; /* Xcms Color Structure */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef double XcmsFloat;
+
+typedef struct {
+ unsigned short red; /* 0x0000 to 0xffff */
+ unsigned short green; /* 0x0000 to 0xffff */
+ unsigned short blue; /* 0x0000 to 0xffff */
+} XcmsRGB; /* RGB Device */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat red; /* 0.0 to 1.0 */
+ XcmsFloat green; /* 0.0 to 1.0 */
+ XcmsFloat blue; /* 0.0 to 1.0 */
+} XcmsRGBi; /* RGB Intensity */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat X;
+ XcmsFloat Y; /* 0.0 to 1.0 */
+ XcmsFloat Z;
+} XcmsCIEXYZ; /* CIE XYZ */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat u_prime; /* 0.0 to ~0.6 */
+ XcmsFloat v_prime; /* 0.0 to ~0.6 */
+ XcmsFloat Y; /* 0.0 to 1.0 */
+} XcmsCIEuvY; /* CIE u'v'Y */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat x; /* 0.0 to ~.75 */
+ XcmsFloat y; /* 0.0 to ~.85 */
+ XcmsFloat Y; /* 0.0 to 1.0 */
+} XcmsCIExyY; /* CIE xyY */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat L_star; /* 0.0 to 100.0 */
+ XcmsFloat a_star;
+ XcmsFloat b_star;
+} XcmsCIELab; /* CIE L*a*b* */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat L_star; /* 0.0 to 100.0 */
+ XcmsFloat u_star;
+ XcmsFloat v_star;
+} XcmsCIELuv; /* CIE L*u*v* */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat H; /* 0.0 to 360.0 */
+ XcmsFloat V; /* 0.0 to 100.0 */
+ XcmsFloat C; /* 0.0 to 100.0 */
+} XcmsTekHVC; /* TekHVC */
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ XcmsFloat pad0;
+ XcmsFloat pad1;
+ XcmsFloat pad2;
+ XcmsFloat pad3;
+} XcmsPad; /* four doubles */
+.De
+.SH DESCRIPTION
+The
+.ZN XcmsColor
+structure contains a union of substructures,
+each supporting color specification encoding for a particular color space.
+.SH "SEE ALSO"
+XcmsAllocColor(3X11),
+XcmsStoreColor(3X11),
+XcmsConvertColors(3X11),
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsConvertColors.man b/man/XcmsConvertColors.man
new file mode 100644
index 00000000..1a7c55ad
--- /dev/null
+++ b/man/XcmsConvertColors.man
@@ -0,0 +1,207 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsConvertColors 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsConvertColors \- convert CCC color specifications
+.SH SYNTAX
+Status XcmsConvertColors\^(\^\fIccc\fP\^, \fIcolors_in_out\fP\^, \fIncolors\fP\^, \fItarget_format\fP\^, \fIcompression_flags_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColor \fIcolors_in_out\fP\^[\^]\^;
+.br
+ unsigned int \fIncolors\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ Bool \fIcompression_flags_return\fP\^[\^]\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+If Conversion is between device-independent color spaces only
+(for example, TekHVC to CIELuv),
+the CCC is necessary only to specify the Client White Point.
+.IP \fIcolors_in_out\fP 1i
+Specifies an array of color specifications.
+Pixel members are ignored and remain unchanged upon return.
+.IP \fIcompression_flags_return\fP 1i
+Returns an array of Boolean values indicating compression status.
+If a non-NULL pointer is supplied,
+each element of the array is set to
+.ZN True
+if the corresponding color was compressed and
+.ZN False
+otherwise.
+Pass NULL if the compression status is not useful.
+.IP \fIncolors\fP 1i
+Specifies the number of
+.ZN XcmsColor
+structures in the color-specification array.
+.IP \fItarget_format\fP 1i
+Specifies the target color specification format.
+.SH DESCRIPTION
+The
+.ZN XcmsConvertColors
+function converts the color specifications in the specified array of
+.ZN XcmsColor
+structures from their current format to a single target format,
+using the specified CCC.
+When the return value is
+.ZN XcmsFailure ,
+the contents of the color specification array are left unchanged.
+.LP
+The array may contain a mixture of color specification formats
+(for example, 3 CIE XYZ, 2 CIE Luv, and so on).
+When the array contains both device-independent and
+device-dependent color specifications and the target_format argument specifies
+a device-dependent format (for example,
+.ZN XcmsRGBiFormat ,
+.ZN XcmsRGBFormat ),
+all specifications are converted to CIE XYZ format and then to the target
+device-dependent format.
+.SH "SEE ALSO"
+DisplayOfCCC(3X11),
+XcmsCCCOfColormap(3X11),
+XcmsCreateCCC(3X11),
+XcmsDefaultCCC(3X11),
+XcmsSetWhitePoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsCreateCCC.man b/man/XcmsCreateCCC.man
new file mode 100644
index 00000000..8fc15459
--- /dev/null
+++ b/man/XcmsCreateCCC.man
@@ -0,0 +1,216 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsCreateCCC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsCreateCCC, XcmsFreeCCC \- creating and destroying CCCs
+.SH SYNTAX
+XcmsCCC XcmsCreateCCC\^(\^\fIdisplay\fP, \fIscreen_number\fP\^, \fIvisual\fP\^, \fIclient_white_point\fP\^, \fIcompression_proc\fP\^,
+.br
+ \fIcompression_client_data\fP\^, \fIwhite_adjust_proc\fP\^, \fIwhite_adjust_client_data\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIscreen_number\fP\^;
+.br
+ Visual *\fIvisual\fP\^;
+.br
+ XcmsColor *\fIclient_white_point\fP\^;
+.br
+ XcmsCompressionProc \fIcompression_proc\fP\^;
+.br
+ XPointer \fIcompression_client_data\fP\^;
+.br
+ XcmsWhiteAdjustProc \fIwhite_adjust_proc\fP\^;
+.br
+ XPointer \fIwhite_adjust_client_data\fP\^;
+.LP
+void XcmsFreeCCC\^(\^\fIccc\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIccc\fP 1i
+Specifies the CCC.
+.IP \fIclient_white_point\fP 1i
+Specifies the Client White Point.
+If NULL is specified,
+the Client White Point is to be assumed to be the same as the
+Screen White Point.
+Note that the pixel member is ignored.
+.IP \fIcompression_client_data\fP 1i
+Specifies client data for use by the gamut compression procedure or NULL.
+.IP \fIcompression_proc\fP 1i
+Specifies the gamut compression procedure that is to be applied
+when a color lies outside the screen's color gamut.
+If NULL is specified and a function using this CCC must convert
+a color specification to a device-dependent format and encounters a color
+that lies outside the screen's color gamut,
+that function will return
+.ZN XcmsFailure .
+.IP \fIscreen_number\fP 1i
+Specifies the appropriate screen number on the host server.
+.IP \fIvisual\fP 1i
+Specifies the visual type.
+.IP \fIwhite_adjust_client_data\fP 1i
+Specifies client data for use with the white point adjustment procedure or NULL.
+.IP \fIwhite_adjust_proc\fP 1i
+Specifies the white adjustment procedure that is to be applied
+when the Client White Point differs from the Screen White Point.
+NULL indicates that no white point adjustment is desired.
+.SH DESCRIPTION
+The
+.ZN XcmsCreateCCC
+function creates a CCC for the specified display, screen, and visual.
+.LP
+The
+.ZN XcmsFreeCCC
+function frees the memory used for the specified CCC.
+Note that default CCCs and those currently associated with colormaps
+are ignored.
+.SH "SEE ALSO"
+DisplayOfCCC(3X11),
+XcmsCCCOfColormap(3X11),
+XcmsConvertColors(3X11),
+XcmsDefaultCCC(3X11),
+XcmsSetWhitePoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsDefaultCCC.man b/man/XcmsDefaultCCC.man
new file mode 100644
index 00000000..9a9996dc
--- /dev/null
+++ b/man/XcmsDefaultCCC.man
@@ -0,0 +1,170 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsDefaultCCC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsDefaultCCC \- obtain the default CCC for a screen
+.SH SYNTAX
+XcmsCCC XcmsDefaultCCC\^(\^\fIdisplay\fP, \fIscreen_number\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ int \fIscreen_number\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIscreen_number\fP 1i
+Specifies the appropriate screen number on the host server.
+.SH DESCRIPTION
+The
+.ZN XcmsDefaultCCC
+function returns the default CCC for the specified screen.
+Its visual is the default visual of the screen.
+Its initial gamut compression and white point
+adjustment procedures as well as the associated client data are implementation
+specific.
+.SH "SEE ALSO"
+DisplayOfCCC(3X11),
+XcmsCCCOfColormap(3X11),
+XcmsConvertColors(3X11),
+XcmsCreateCCC(3X11),
+XcmsSetWhitePoint(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsQueryBlack.man b/man/XcmsQueryBlack.man
new file mode 100644
index 00000000..3598b769
--- /dev/null
+++ b/man/XcmsQueryBlack.man
@@ -0,0 +1,228 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsQueryBlack 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsQueryBlack, XcmsQueryBlue, XcmsQueryGreen, XcmsQueryRed, XcmsQueryWhite \- obtain black, blue, green, red, and white CCC color specifications
+.SH SYNTAX
+Status XcmsQueryBlack\^(\^\fIccc\fP\^, \fItarget_format\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsQueryBlue\^(\^\fIccc\fP\^, \fItarget_format\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsQueryGreen\^(\^\fIccc\fP\^, \fItarget_format\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsQueryRed\^(\^\fIccc\fP\^, \fItarget_format\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsQueryWhite\^(\^\fIccc\fP\^, \fItarget_format\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColorFormat \fItarget_format\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+Note that the CCC's Client White Point and White Point Adjustment procedures
+are ignored.
+.ds Cs
+.IP \fIcolor_return\fP 1i
+Returns the color specification in the specified target format
+for \*(Cs.
+The white point associated with the returned
+color specification is the Screen White Point.
+The value returned in the pixel member is undefined.
+.IP \fItarget_format\fP 1i
+Specifies the target color specification format.
+.SH DESCRIPTION
+The
+.ZN XcmsQueryBlack
+function returns the color specification in the specified target format
+for zero-intensity red, green, and blue.
+.LP
+The
+.ZN XcmsQueryBlue
+function returns the color specification in the specified target format
+for full-intensity blue while red and green are zero.
+.LP
+The
+.ZN XcmsQueryGreen
+function returns the color specification in the specified target format
+for full-intensity green while red and blue are zero.
+.LP
+The
+.ZN XcmsQueryRed
+function returns the color specification in the specified target format
+for full-intensity red while green and blue are zero.
+.LP
+The
+.ZN XcmsQueryWhite
+function returns the color specification in the specified target format
+for full-intensity red, green, and blue.
+.SH "SEE ALSO"
+XcmsCIELabQueryMaxC(3X11),
+XcmsCIELuvQueryMaxC(3X11),
+XcmsTekHVCQueryMaxC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsQueryColor.man b/man/XcmsQueryColor.man
new file mode 100644
index 00000000..ea91e167
--- /dev/null
+++ b/man/XcmsQueryColor.man
@@ -0,0 +1,291 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsQueryColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsQueryColor, XcmsQueryColors, XcmsLookupColor \- obtain color values
+.SH SYNTAX
+Status XcmsQueryColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor_in_out\fP\^, \fIresult_format\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsColor *\fIcolor_in_out\fP\^;
+.br
+ XcmsColorFormat \fIresult_format\fP\^;
+.LP
+Status XcmsQueryColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolors_in_out\fP\^, \fIncolors\fP\^, \fIresult_format\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsColor \fIcolors_in_out\fP\^[\^]\^;
+.br
+ unsigned int \fIncolors\fP\^;
+.br
+ XcmsColorFormat \fIresult_format\fP\^;
+.LP
+Status XcmsLookupColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor_string\fP\^, \fIcolor_exact_return\fP\^, \fIcolor_screen_return\fP\^,
+.br
+ \fIresult_format\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ char *\fIcolor_string\fP\^;
+.br
+ XcmsColor *\fIcolor_exact_return\fP\^, *\fIcolor_screen_return\fP\^;
+.br
+ XcmsColorFormat \fIresult_format\fP\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsQClr.man,v 1.3 2001/03/16 17:47:49 pookie Exp $
+.IP \fIcolor_exact_return\fP 1i
+Returns the color specification parsed from the color string
+or parsed from the corresponding string found in a color-name database.
+.IP \fIcolor_in_out\fP 1i
+Specifies the pixel member that indicates the color cell to query.
+The color specification stored for the color cell is returned in this
+.ZN XcmsColor
+structure.
+.IP \fIcolor_screen_return\fP 1i
+Returns the color that can be reproduced on the screen.
+.ds St
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsQClr.man,v 1.3 2001/03/16 17:47:49 pookie Exp $
+.IP \fIcolor_string\fP 1i
+Specifies the color string\*(St.
+.\" $Header: /X.org/CVS/xc/doc/man/X11/XcmsQClr.man,v 1.3 2001/03/16 17:47:49 pookie Exp $
+.IP \fIresult_format\fP 1i
+Specifies the color format for the returned color
+specifications (color_screen_return and color_exact_return arguments).
+If the format is
+.ZN XcmsUndefinedFormat
+and the color string contains a
+numerical color specification,
+the specification is returned in the format used in that numerical
+color specification.
+If the format is
+.ZN XcmsUndefinedFormat
+and the color string contains a color name,
+the specification is returned in the format used
+to store the color in the database.
+.IP \fIncolors\fP 1i
+Specifies the number of
+.ZN XcmsColor
+structures in the color-specification array.
+.SH DESCRIPTION
+The
+.ZN XcmsQueryColor
+function obtains the RGB value
+for the pixel value in the pixel member of the specified
+.ZN XcmsColor
+structure and then
+converts the value to the target format as
+specified by the result_format argument.
+If the pixel is not a valid index in the specified colormap, a
+.ZN BadValue
+error results.
+The
+.ZN XcmsQueryColors
+function obtains the RGB values
+for pixel values in the pixel members of
+.ZN XcmsColor
+structures and then
+converts the values to the target format as
+specified by the result_format argument.
+If a pixel is not a valid index into the specified colormap, a
+.ZN BadValue
+error results.
+If more than one pixel is in error,
+the one that gets reported is arbitrary.
+.LP
+.ZN XcmsQueryColor
+and
+.ZN XcmsQueryColors
+can generate
+.ZN BadColor
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XcmsLookupColor
+function looks up the string name of a color with respect to the screen
+associated with the specified colormap.
+It returns both the exact color values and
+the closest values provided by the screen
+with respect to the visual type of the specified colormap.
+The values are returned in the format specified by result_format.
+If the color name is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Use of uppercase or lowercase does not matter.
+.ZN XcmsLookupColor
+returns
+.ZN XcmsSuccess
+or
+.ZN XcmsSuccessWithCompression
+if the name is resolved; otherwise, it returns
+.ZN XcmsFailure .
+If
+.ZN XcmsSuccessWithCompression
+is returned, the color specification returned in
+color_screen_return is the result of gamut compression.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XcmsAllocColor(3X11),
+XcmsStoreColor(3X11),
+XQueryColor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsSetWhitePoint.man b/man/XcmsSetWhitePoint.man
new file mode 100644
index 00000000..760ce854
--- /dev/null
+++ b/man/XcmsSetWhitePoint.man
@@ -0,0 +1,204 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsSetWhitePoint 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsSetWhitePoint, XcmsSetWhiteAdjustProc \- modifying CCC attributes
+.SH SYNTAX
+Status XcmsSetWhitePoint\^(\^\fIccc\fP\^, \fIcolor\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsColor *\fIcolor\fP\^;
+.LP
+XcmsWhiteAdjustProc XcmsSetWhiteAdjustProc\^(\^\fIccc\fP\^, \fIwhite_adjust_proc\fP\^, \fIclient_data\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsWhiteAdjustProc \fIwhite_adjust_proc\fP\^;
+.br
+ XPointer \fIclient_data\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+.ds Cd the white point adjustment procedure
+.IP \fIclient_data\fP 1i
+Specifies client data for \*(Cd or NULL.
+.ds Co new Client White Point
+.IP \fIcolor\fP 1i
+Specifies the \*(Co.
+.IP \fIwhite_adjust_proc\fP 1i
+Specifies the white point adjustment procedure.
+.SH DESCRIPTION
+The
+.ZN XcmsSetWhitePoint
+function changes the Client White Point in the specified CCC.
+Note that the pixel member is ignored
+and that the color specification is left unchanged upon return.
+The format for the new white point must be
+.ZN XcmsCIEXYZFormat ,
+.ZN XcmsCIEuvYFormat ,
+.ZN XcmsCIExyYFormat ,
+or
+.ZN XcmsUndefinedFormat .
+If the color argument is NULL, this function sets the format component of the
+Client White Point specification to
+.ZN XcmsUndefinedFormat ,
+indicating that the Client White Point is assumed to be the same as the
+Screen White Point.
+.LP
+This function returns nonzero status
+if the format for the new white point is valid;
+otherwise, it returns zero.
+
+.LP
+The
+.ZN XcmsSetWhiteAdjustProc
+function first sets the white point adjustment procedure and client data
+in the specified CCC with the newly specified procedure and client data
+and then returns the old procedure.
+.SH "SEE ALSO"
+DisplayOfCCC(3X11),
+XcmsCCCOfColormap(3X11),
+XcmsConvertColors(3X11),
+XcmsCreateCCC(3X11),
+XcmsDefaultCCC(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsStoreColor.man b/man/XcmsStoreColor.man
new file mode 100644
index 00000000..65d0e3a4
--- /dev/null
+++ b/man/XcmsStoreColor.man
@@ -0,0 +1,317 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsStoreColor 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsStoreColor, XcmsStoreColors \- set colors
+.SH SYNTAX
+Status XcmsStoreColor\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolor\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsColor *\fIcolor\fP\^;
+.LP
+Status XcmsStoreColors\^(\^\fIdisplay\fP, \fIcolormap\fP\^, \fIcolors\fP\^, \fIncolors\fP\^, \fIcompression_flags_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Colormap \fIcolormap\fP\^;
+.br
+ XcmsColor \fIcolors\fP\^[\^]\^;
+.br
+ int \fIncolors\fP\^;
+.br
+ Bool \fIcompression_flags_return\fP\^[\^]\^;
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIcolor\fP 1i
+Specifies the color cell and the color to store.
+Values specified in this
+.ZN XcmsColor
+structure remain unchanged on return.
+.IP \fIcolors\fP 1i
+Specifies the color specification array of
+.ZN XcmsColor
+structures, each specifying a color cell and the color to store in that
+cell.
+Values specified in the array remain unchanged upon return.
+.IP \fIcolormap\fP 1i
+Specifies the colormap.
+.IP \fIcompression_flags_return\fP 1i
+Returns an array of Boolean values indicating compression status.
+If a non-NULL pointer is supplied,
+each element of the array is set to
+.ZN True
+if the corresponding color was compressed and
+.ZN False
+otherwise.
+Pass NULL if the compression status is not useful.
+.IP \fIncolors\fP 1i
+Specifies the number of
+.ZN XcmsColor
+structures in the color-specification array.
+.SH DESCRIPTION
+The
+.ZN XcmsStoreColor
+function converts the color specified in the
+.ZN XcmsColor
+structure into RGB values.
+It then uses this RGB specification in an
+.ZN XColor
+structure, whose three flags
+.Pn ( DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue )
+are set, in a call to
+.ZN XStoreColor
+to change the color cell specified by the pixel member of the
+.ZN XcmsColor
+structure.
+This pixel value must be a valid index for the specified colormap,
+and the color cell specified by the pixel value must be a read/write cell.
+If the pixel value is not a valid index, a
+.ZN BadValue
+error results.
+If the color cell is unallocated or is allocated read-only, a
+.ZN BadAccess
+error results.
+If the colormap is an installed map for its screen,
+the changes are visible immediately.
+.LP
+Note that
+.ZN XStoreColor
+has no return value; therefore, an
+.ZN XcmsSuccess
+return value from this function indicates that the conversion
+to RGB succeeded and the call to
+.ZN XStoreColor
+was made.
+To obtain the actual color stored, use
+.ZN XcmsQueryColor .
+Because of the screen's hardware limitations or gamut compression,
+the color stored in the colormap may not be identical
+to the color specified.
+.LP
+.ZN XcmsStoreColor
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+and
+.ZN BadValue
+errors.
+.LP
+The
+.ZN XcmsStoreColors
+function converts the colors specified in the array of
+.ZN XcmsColor
+structures into RGB values and then uses these RGB specifications in
+.ZN XColor
+structures, whose three flags
+.Pn ( DoRed ,
+.ZN DoGreen ,
+and
+.ZN DoBlue )
+are set, in a call to
+.ZN XStoreColors
+to change the color cells specified by the pixel member of the corresponding
+.ZN XcmsColor
+structure.
+Each pixel value must be a valid index for the specified colormap,
+and the color cell specified by each pixel value must be a read/write cell.
+If a pixel value is not a valid index, a
+.ZN BadValue
+error results.
+If a color cell is unallocated or is allocated read-only, a
+.ZN BadAccess
+error results.
+If more than one pixel is in error,
+the one that gets reported is arbitrary.
+If the colormap is an installed map for its screen,
+the changes are visible immediately.
+.LP
+Note that
+.ZN XStoreColors
+has no return value; therefore, an
+.ZN XcmsSuccess
+return value from this function indicates that conversions
+to RGB succeeded and the call to
+.ZN XStoreColors
+was made.
+To obtain the actual colors stored, use
+.ZN XcmsQueryColors .
+Because of the screen's hardware limitations or gamut compression,
+the colors stored in the colormap may not be identical
+to the colors specified.
+.LP
+.LP
+.ZN XcmsStoreColors
+can generate
+.ZN BadAccess ,
+.ZN BadColor ,
+and
+.ZN BadValue
+errors.
+.SH DIAGNOSTICS
+.TP 1i
+.ZN BadAccess
+A client attempted
+to free a color map entry that it did not already allocate.
+.TP 1i
+.ZN BadAccess
+A client attempted
+to store into a read-only color map entry.
+.TP 1i
+.ZN BadColor
+A value for a Colormap argument does not name a defined Colormap.
+.TP 1i
+.ZN BadValue
+Some numeric value falls outside the range of values accepted by the request.
+Unless a specific range is specified for an argument, the full range defined
+by the argument's type is accepted. Any argument defined as a set of
+alternatives can generate this error.
+.SH "SEE ALSO"
+XcmsAllocColor(3X11),
+XcmsQueryColor(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XcmsTekHVCQueryMaxC.man b/man/XcmsTekHVCQueryMaxC.man
new file mode 100644
index 00000000..fe399866
--- /dev/null
+++ b/man/XcmsTekHVCQueryMaxC.man
@@ -0,0 +1,273 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XcmsTekHVCQueryMaxC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XcmsTekHVCQueryMaxC, XcmsTekHVCQueryMaxV, XcmsTekHVCQueryMaxVC, XcmsTekHVCQueryMaxVSamples, XcmsTekHVCQueryMinV \- obtain the TekHVC coordinates
+.SH SYNTAX
+Status XcmsTekHVCQueryMaxC\^(\^\fIccc\fP\^, \fIhue\fP\^, \fIvalue\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue\fP\^;
+.br
+ XcmsFloat \fIvalue\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsTekHVCQueryMaxV\^(\^\fIccc\fP\^, \fIhue\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsTekHVCQueryMaxVC\^(\^\fIccc\fP\^, \fIhue\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.LP
+Status XcmsTekHVCQueryMaxVSamples\^(\^\fIccc\fP\^, \fIhue\fP\^, \fIcolors_return\fP\^, \fInsamples\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue\fP\^;
+.br
+ XcmsColor \fIcolors_return[]\fP\^;
+.br
+ unsigned int \fInsamples\fP\^;
+.LP
+Status XcmsTekHVCQueryMinV\^(\^\fIccc\fP\^, \fIhue\fP\^, \fIchroma\fP\^, \fIcolor_return\fP\^)
+.br
+ XcmsCCC \fIccc\fP\^;
+.br
+ XcmsFloat \fIhue\fP\^;
+.br
+ XcmsFloat \fIchroma\fP\^;
+.br
+ XcmsColor *\fIcolor_return\fP\^;
+.SH ARGUMENTS
+.IP \fIccc\fP 1i
+Specifies the CCC.
+Note that the CCC's Client White Point and White Point Adjustment procedures
+are ignored.
+.ds Ch maximum Value (MaxV)
+.IP \fIchroma\fP 1i
+Specifies the chroma at which to find \*(Ch.
+.IP \fIcolors_return\fP 1i
+Returns nsamples of color specifications in XcmsTekHVC
+such that the Chroma is the maximum attainable for the Value and Hue.
+The white point associated with the returned
+color specification is the Screen White Point.
+The value returned in the pixel member is undefined.
+.ds Lc maximum Chroma along with the actual Hue and Value (MaxC), \
+maximum Value along with the Hue and Chroma (MaxV), \
+color specification in XcmsTekHVC for the maximum Chroma, \
+the Value at which that maximum Chroma is reached and actual Hue (MaxVC) \
+or minimum Value and the actual Hue and Chroma (MinL)
+.ds lC maximum Chroma (MaxC and MaxVC), maximum Value (MaxV), or \
+minimum Value (MinL)
+.IP \fIcolor_return\fP 1i
+Returns the \*(Lc at which the \*(lC was found.
+The white point associated with the returned
+color specification is the Screen White Point.
+The value returned in the pixel member is undefined.
+.ds Hu in which to find the maximum Chroma (MaxC and MaxVC), \
+maximum Value (MaxV), the maximum Chroma/Value samples (MaxVSamples), \
+or the minimum Value (MinL)
+.IP \fIhue\fP 1i
+Specifies the Hue \*(Hu.
+.IP \fInsamples\fP 1i
+Specifies the number of samples.
+.ds Va maximum Chroma (MaxC) or minimum Value (MinL)
+.IP \fIvalue\fP 1i
+Specifies the Value in which to find the \*(Va.
+.SH DESCRIPTION
+The
+.ZN XcmsTekHVCQueryMaxC
+function, given a Hue and Value,
+determines the maximum Chroma in TekHVC color space
+displayable by the screen.
+It returns the maximum Chroma along with the actual Hue
+and Value at which the maximum Chroma was found.
+.LP
+The
+.ZN XcmsTekHVCQueryMaxV
+function, given a Hue and Chroma,
+determines the maximum Value in TekHVC color space
+displayable by the screen.
+It returns the maximum Value and the actual Hue and Chroma
+at which the maximum Value was found.
+.LP
+The
+.ZN XcmsTekHVCQueryMaxVC
+function, given a Hue,
+determines the maximum Chroma in TekHVC color space displayable by the screen
+and the Value at which that maximum Chroma is reached.
+It returns the maximum Chroma,
+the Value at which that maximum Chroma is reached,
+and the actual Hue for which the maximum Chroma was found.
+.LP
+The
+.ZN XcmsTekHVCQueryMaxVSamples
+returns nsamples of maximum Value, the Chroma at which that maximum Value
+is reached, and the actual Hue for which the maximum Chroma was found.
+These sample points may then be used to plot the maximum Value/Chroma
+boundary of the screen's color gamut for the specified Hue in TekHVC color
+space.
+.LP
+The
+.ZN XcmsTekHVCQueryMinV
+function, given a Hue and Chroma,
+determines the minimum Value in TekHVC color space displayable by the screen.
+It returns the minimum Value and the actual Hue and Chroma at which
+the minimum Value was found.
+.SH "SEE ALSO"
+XcmsCIELabQueryMaxC(3X11),
+XcmsCIELuvQueryMaxC(3X11),
+XcmsQueryBlack(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbDrawImageString.man b/man/XmbDrawImageString.man
new file mode 100644
index 00000000..5889cb70
--- /dev/null
+++ b/man/XmbDrawImageString.man
@@ -0,0 +1,224 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbDrawImageString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbDrawImageString, XwcDrawImageString \- draw image text using a single font set
+.SH SYNTAX
+void XmbDrawImageString\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIfont_set\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fInum_bytes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.LP
+void XwcDrawImageString\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIfont_set\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fInum_wchars\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ wchar_t *\fIstring\fP\^;
+.br
+ int \fInum_wchars\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fInum_wchars\fP 1i
+Specifies the number of characters in the string argument.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.ds Xy
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XmbDrawImageString
+and
+.ZN XwcDrawImageString
+functions fill a destination rectangle with the background pixel defined
+in the GC and then paint the text with the foreground pixel.
+The filled rectangle is the rectangle returned to overall_logical_return by
+.ZN XmbTextExtents
+or
+.ZN XwcTextExtents
+for the same text and
+.ZN XFontSet .
+.LP
+When the
+.ZN XFontSet
+has missing charsets, each unavailable character is drawn
+with the default string returned by
+.ZN XCreateFontSet .
+The behavior for an invalid codepoint is undefined.
+.SH "SEE ALSO"
+XDrawImageString(3X11),
+XDrawString(3X11),
+XDrawText(3X11),
+XmbDrawString(3X11),
+XmbDrawText(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbDrawString.man b/man/XmbDrawString.man
new file mode 100644
index 00000000..9d1fe1e4
--- /dev/null
+++ b/man/XmbDrawString.man
@@ -0,0 +1,216 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbDrawString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbDrawString, XwcDrawString \- draw text using a single font set
+.SH SYNTAX
+void XmbDrawString\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIfont_set\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fInum_bytes\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.LP
+void XwcDrawString\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIfont_set\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIstring\fP\^, \fInum_wchars\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ wchar_t *\fIstring\fP\^;
+.br
+ int \fInum_wchars\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fInum_wchars\fP 1i
+Specifies the number of characters in the string argument.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.ds Xy
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XmbDrawString
+and
+.ZN XwcDrawString
+functions draw the specified text with the foreground pixel.
+When the
+.ZN XFontSet
+has missing charsets, each unavailable character is drawn
+with the default string returned by
+.ZN XCreateFontSet .
+The behavior for an invalid codepoint is undefined.
+.SH "SEE ALSO"
+XXDrawImageString(3X11),
+XDrawString(3X11),
+XDrawText(3X11),
+XmbDrawImageString(3X11),
+XmbDrawText(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbDrawText.man b/man/XmbDrawText.man
new file mode 100644
index 00000000..959a770c
--- /dev/null
+++ b/man/XmbDrawText.man
@@ -0,0 +1,260 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbDrawText 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbDrawText, XwcDrawText \- draw text using multiple font sets
+.SH SYNTAX
+void XmbDrawText\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XmbTextItem *\fIitems\fP\^;
+.br
+ int \fInitems\fP\^;
+.LP
+void XwcDrawText\^(\^\fIdisplay\fP\^, \fId\fP\^, \fIgc\fP\^, \fIx\fP\^, \fIy\fP\^, \fIitems\fP\^, \fInitems\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ Drawable \fId\fP\^;
+.br
+ GC \fIgc\fP\^;
+.br
+ int \fIx\fP\^, \fIy\fP\^;
+.br
+ XwcTextItem *\fIitems\fP\^;
+.br
+ int \fInitems\fP\^;
+.SH ARGUMENTS
+.IP \fId\fP 1i
+Specifies the drawable.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIgc\fP 1i
+Specifies the GC.
+.IP \fIitems\fP 1i
+Specifies an array of text items.
+.IP \fInitems\fP 1i
+Specifies the number of text items in the array.
+.ds Xy
+.IP \fIx\fP 1i
+.br
+.ns
+.IP \fIy\fP 1i
+Specify the x and y coordinates\*(Xy.
+.SH DESCRIPTION
+The
+.ZN XmbDrawText
+and
+.ZN XwcDrawText
+functions allow complex spacing and font set shifts between text strings.
+Each text item is processed in turn, with the origin of a text
+element advanced in the primary draw direction by the escapement of the
+previous text item.
+A text item delta specifies an additional escapement of the text item
+drawing origin in the primary draw direction.
+A font_set member other than
+.ZN None
+in an item causes the font set to be used for this and subsequent text items
+in the text_items list.
+Leading text items with a font_set member set to
+.ZN None
+will not be drawn.
+.LP
+.ZN XmbDrawText
+and
+.ZN XwcDrawText
+do not perform any context-dependent rendering between text segments.
+Clients may compute the drawing metrics by passing each text segment to
+.ZN XmbTextExtents
+and
+.ZN XwcTextExtents
+or
+.ZN XmbTextPerCharExtents
+and
+.ZN XwcTextPerCharExtents .
+When the
+.ZN XFontSet
+has missing charsets, each unavailable character is drawn
+with the default string returned by
+.ZN XCreateFontSet .
+The behavior for an invalid codepoint is undefined.
+.SH STRUCTURES
+The
+.ZN XmbTextItem
+structure contains:
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ char *chars; /* pointer to string */
+ int nchars; /* number of bytes */
+ int delta; /* pixel delta between strings */
+ XFontSet font_set; /* fonts, None means don't change */
+} XmbTextItem;
+.De
+The
+.ZN XwcTextItem
+structure contains:
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ wchar_t *chars; /* pointer to wide char string */
+ int nchars; /* number of wide characters */
+ int delta; /* pixel delta between strings */
+ XFontSet font_set; /* fonts, None means don't change */
+} XwcTextItem;
+.De
+.SH "SEE ALSO"
+XDrawImageString(3X11),
+XDrawString(3X11),
+XDrawText(3X11),
+XmbDrawImageString(3X11),
+XmbDrawString(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbLookupString.man b/man/XmbLookupString.man
new file mode 100644
index 00000000..48085d08
--- /dev/null
+++ b/man/XmbLookupString.man
@@ -0,0 +1,307 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XmbLookupString 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbLookupString, XwcLookupString \- obtain composed input from an input method
+.SH SYNTAX
+int XmbLookupString\^(\^\fIic\fP\^, \fIevent\fP\^, \fIbuffer_return\fP\^, \fIbytes_buffer\fP\^, \fIkeysym_return\fP\^, \fIstatus_return\fP\^)
+.br
+ XIC \fIic\fP\^;
+.br
+ XKeyPressedEvent *\fIevent\fP;
+.br
+ char *\fIbuffer_return\fP\^;
+.br
+ int \fIbytes_buffer\fP\^;
+.br
+ KeySym *\fIkeysym_return\fP\^;
+.br
+ Status *\fIstatus_return\fP\^;
+.LP
+int XwcLookupString\^(\^\fIic\fP\^, \fIevent\fP\^, \fIbuffer_return\fP\^, \fIbytes_buffer\fP\^, \fIkeysym_return\fP\^, \fIstatus_return\fP\^)
+.br
+ XIC \fIic\fP\^;
+.br
+ XKeyPressedEvent *\fIevent\fP\^;
+.br
+ wchar_t *\fIbuffer_return\fP\^;
+.br
+ int \fIwchars_buffer\fP\^;
+.br
+ KeySym *\fIkeysym_return\fP\^;
+.br
+ Status *\fIstatus_return\fP\^;
+.SH ARGUMENTS
+.IP \fIbuffer_return\fP 1i
+Returns a multibyte string or wide character string (if any)
+from the input method.
+.IP \fIbytes_buffer\fP 1i
+.br
+.ns
+.IP \fIwchars_buffer\fP 1i
+Specifies space available in the return buffer.
+.ds Ev key event to be used
+.IP \fIevent\fP 1i
+Specifies the \*(Ev.
+.IP \fIic\fP 1i
+Specifies the input context.
+.IP \fIkeysym_return\fP 1i
+Returns the KeySym computed from the event if this argument is not NULL.
+.IP \fIstatus_return\fP 1i
+Returns a value indicating what kind of data is returned.
+.SH DESCRIPTION
+The
+.ZN XmbLookupString
+and
+.ZN XwcLookupString
+functions return the string from the input method specified
+in the buffer_return argument.
+If no string is returned,
+the buffer_return argument is unchanged.
+.LP
+The KeySym into which the KeyCode from the event was mapped is returned
+in the keysym_return argument if it is non-NULL and the status_return
+argument indicates that a KeySym was returned.
+If both a string and a KeySym are returned,
+the KeySym value does not necessarily correspond to the string returned.
+.LP
+.ZN XmbLookupString
+returns the length of the string in bytes, and
+.ZN XwcLookupString
+returns the length of the string in characters.
+Both
+.ZN XmbLookupString
+and
+.ZN XwcLookupString
+return text in the encoding of the locale bound to the input method
+of the specified input context.
+.LP
+Each string returned by
+.ZN XmbLookupString
+and
+.ZN XwcLookupString
+begins in the initial state of the encoding of the locale
+(if the encoding of the locale is state-dependent).
+.NT
+To insure proper input processing,
+it is essential that the client pass only
+.ZN KeyPress
+events to
+.ZN XmbLookupString
+and
+.ZN XwcLookupString .
+Their behavior when a client passes a
+.ZN KeyRelease
+event is undefined.
+.NE
+.LP
+Clients should check the status_return argument before
+using the other returned values.
+These two functions both return a value to status_return
+that indicates what has been returned in the other arguments.
+The possible values returned are:
+.TS
+lw(1.5i) lw(4.3i).
+T{
+.ZN XBufferOverflow
+T} T{
+The input string to be returned is too large for the supplied buffer_return.
+The required size
+.Pn ( XmbLookupString
+in bytes;
+.ZN XwcLookupString
+in characters) is returned as the value of the function,
+and the contents of buffer_return and keysym_return are not modified.
+The client should recall the function with the same event
+and a buffer of adequate size to obtain the string.
+T}
+T{
+.ZN XLookupNone
+T} T{
+No consistent input has been composed so far.
+The contents of buffer_return and keysym_return are not modified,
+and the function returns zero.
+T}
+T{
+.ZN XLookupChars
+T} T{
+Some input characters have been composed.
+They are placed in the buffer_return argument,
+and the string length is returned as the value of the function.
+The string is encoded in the locale bound to the input context.
+The content of the keysym_return argument is not modified.
+T}
+T{
+.ZN XLookupKeySym
+T} T{
+A KeySym has been returned instead of a string
+and is returned in keysym_return.
+The content of the buffer_return argument is not modified,
+and the function returns zero.
+T}
+T{
+.ZN XLookupBoth
+T} T{
+Both a KeySym and a string are returned;
+.ZN XLookupChars
+and
+.ZN XLookupKeySym
+occur simultaneously.
+T}
+.TE
+.LP
+It does not make any difference if the input context passed as an argument to
+.ZN XmbLookupString
+and
+.ZN XwcLookupString
+is the one currently in possession of the focus or not.
+Input may have been composed within an input context before it lost the focus,
+and that input may be returned on subsequent calls to
+.ZN XmbLookupString
+or
+.ZN XwcLookupString
+even though it does not have any more keyboard focus.
+.SH "SEE ALSO"
+XLookupKeysym(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbResetIC.man b/man/XmbResetIC.man
new file mode 100644
index 00000000..a1b07747
--- /dev/null
+++ b/man/XmbResetIC.man
@@ -0,0 +1,195 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbResetIC 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbResetIC, XwcResetIC \- reset the state of an input context
+.SH SYNTAX
+char * XmbResetIC\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.LP
+wchar_t * XwcResetIC\^(\^\fIic\fP\^)
+.br
+ XIC \fIic\fP\^;
+.SH ARGUMENTS
+.IP \fIic\fP 1i
+Specifies the input context.
+.SH DESCRIPTION
+When
+.ZN XNResetState
+is set to
+.ZN XIMInitialState ,
+.ZN XmbResetIC
+and
+.ZN XwcResetIC
+reset an input context to its initial state;
+when
+.ZN XNResetState
+is set to
+.ZN XIMPreserveState ,
+the current input context state is preserved.
+In both cases, any input pending on that context is deleted.
+The input method is required to clear the preedit area, if any,
+and update the status accordingly.
+Calling
+.ZN XmbResetIC
+or
+.ZN XwcResetIC
+does not change the focus.
+.LP
+The return value of
+.ZN XmbResetIC
+is its current preedit string as a multibyte string.
+If there is any preedit text drawn or visible to the user,
+then these procedures must return a non-NULL string.
+If there is no visible preedit text,
+then it is input method implementation-dependent
+whether these procedures return a non-NULL string or NULL.
+.LP
+The client should free the returned string by calling
+.ZN XFree .
+.SH "SEE ALSO"
+XCreateIC(3X11),
+XOpenIM(3X11),
+XSetICFocus(3X11),
+XSetICValues(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbTextEscapement.man b/man/XmbTextEscapement.man
new file mode 100644
index 00000000..6eb89877
--- /dev/null
+++ b/man/XmbTextEscapement.man
@@ -0,0 +1,186 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbTextEscapement 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbTextEscapement, XwcTextEscapement \- obtain the escapement of text
+.SH SYNTAX
+int XmbTextEscapement\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_bytes\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.LP
+int XwcTextEscapement\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_wchars\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ wchar_t *\fIstring\fP\^;
+.br
+ int \fInum_wchars\fP\^;
+.SH ARGUMENTS
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fInum_wchars\fP 1i
+Specifies the number of characters in the string argument.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.SH DESCRIPTION
+The
+.ZN XmbTextEscapement
+and
+.ZN XwcTextEscapement
+functions return the escapement in pixels of the specified string as a value,
+using the fonts loaded for the specified font set.
+The escapement is the distance in pixels in the primary draw
+direction from the drawing origin to the origin of the next character to
+be drawn, assuming that the rendering of the next character is not
+dependent on the supplied string.
+.LP
+Regardless of the character rendering order,
+the escapement is always positive.
+.SH "SEE ALSO"
+XmbTextExtents(3X11),
+XmbTextPerCharExtents(3X11)
+\fI\*(xL\fP
diff --git a/man/XmbTextExtents.man b/man/XmbTextExtents.man
new file mode 100644
index 00000000..fe43c225
--- /dev/null
+++ b/man/XmbTextExtents.man
@@ -0,0 +1,226 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbTextExtents 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbTextExtents, XwcTextExtents \- compute text extents
+.SH SYNTAX
+int XmbTextExtents\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_bytes\fP\^, \fIoverall_ink_return\fP\^, \fIoverall_logical_return\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.br
+ XRectangle *\fIoverall_ink_return\fP\^;
+.br
+ XRectangle *\fIoverall_logical_return\fP\^;
+.LP
+int XwcTextExtents\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_wchars\fP\^, \fIoverall_ink_return\fP\^, \fIoverall_logical_return\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ wchar_t *\fIstring\fP\^;
+.br
+ int \fInum_wchars\fP\^;
+.br
+ XRectangle *\fIoverall_ink_return\fP\^;
+.br
+ XRectangle *\fIoverall_logical_return\fP\^;
+.SH ARGUMENTS
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fInum_wchars\fP 1i
+Specifies the number of characters in the string argument.
+.ds Ov dimensions
+.IP \fIoverall_ink_return\fP 1i
+Returns the overall ink \*(Ov.
+.IP \fIoverall_logical_return\fP 1i
+Returns the overall logical \*(Ov.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.SH DESCRIPTION
+The
+.ZN XmbTextExtents
+and
+.ZN XwcTextExtents
+functions set the components of the specified overall_ink_return and
+overall_logical_return
+arguments to the overall bounding box of the string's image
+and a logical bounding box for spacing purposes, respectively.
+They return the value returned by
+.ZN XmbTextEscapement
+or
+.ZN XwcTextEscapement .
+These metrics are relative to the drawing origin of the string,
+using the fonts loaded for the specified font set.
+.LP
+If the overall_ink_return argument is non-NULL,
+it is set to the bounding box of the string's character ink.
+The overall_ink_return for a nondescending, horizontally drawn
+Latin character is conventionally entirely above the baseline;
+that is, overall_ink_return.height <= \-overall_ink_return.y.
+The overall_ink_return for a nonkerned character
+is entirely at, and to the right of, the origin;
+that is, overall_ink_return.x >= 0.
+A character consisting of a single pixel at the origin would set
+overall_ink_return fields y = 0, x = 0, width = 1, and height = 1.
+.LP
+If the overall_logical_return argument is non-NULL,
+it is set to the bounding box that provides minimum spacing
+to other graphical features for the string.
+Other graphical features, for example, a border surrounding the text,
+should not intersect this rectangle.
+.LP
+When the
+.ZN XFontSet
+has missing charsets,
+metrics for each unavailable character are taken
+from the default string returned by
+.ZN XCreateFontSet
+so that the metrics represent the text as it will actually be drawn.
+The behavior for an invalid codepoint is undefined.
+.SH "SEE ALSO"
+XmbTextEscapement(3X11),
+XmbTextPerCharExtents(3X11)
+\fI\*(xL\fP
diff --git a/man/XmbTextListToTextProperty.man b/man/XmbTextListToTextProperty.man
new file mode 100644
index 00000000..94dffb36
--- /dev/null
+++ b/man/XmbTextListToTextProperty.man
@@ -0,0 +1,444 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XmbTextListToTextProperty 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbTextListToTextProperty, XwcTextListToTextProperty, XmbTextPropertyToTextList, XwcTextPropertyToTextList, XwcFreeStringList, XDefaultString \- convert text lists and text property structures
+.SH SYNTAX
+int XmbTextListToTextProperty\^(\^\fIdisplay\fP\^, \fIlist\fP\^, \fIcount\fP\^, \fIstyle\fP\^, \fItext_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ char **\fIlist\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ XICCEncodingStyle \fIstyle\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.LP
+int XwcTextListToTextProperty\^(\^\fIdisplay\fP\^, \fIlist\fP\^, \fIcount\fP\^, \fIstyle\fP\^, \fItext_prop_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ wchar_t **\fIlist\fP\^;
+.br
+ int \fIcount\fP\^;
+.br
+ XICCEncodingStyle \fIstyle\fP\^;
+.br
+ XTextProperty *\fItext_prop_return\fP\^;
+.LP
+int XmbTextPropertyToTextList\^(\^\fIdisplay\fP\^, \fItext_prop\fP\^, \fIlist_return\fP\^, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.br
+ char ***\fIlist_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.LP
+int XwcTextPropertyToTextList\^(\^\fIdisplay\fP\^, \fItext_prop\fP\^, \fIlist_return\fP\^, \fIcount_return\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XTextProperty *\fItext_prop\fP\^;
+.br
+ wchar_t ***\fIlist_return\fP\^;
+.br
+ int *\fIcount_return\fP\^;
+.LP
+void XwcFreeStringList\^(\^\fIlist\fP\^)
+.br
+ wchar_t **\fIlist\fP\^;
+.LP
+char *XDefaultString\^(\|)
+.SH ARGUMENTS
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.IP \fIlist\fP 1i
+Specifies a list of null-terminated character strings.
+.IP \fIcount\fP 1i
+Specifies the number of strings specified.
+.IP \fIstyle\fP 1i
+Specifies the manner in which the property is encoded.
+.IP \fItext_prop_return\fP 1i
+Returns the
+.ZN XTextProperty
+structure.
+.IP \fItext_prop\fP 1i
+Specifies the
+.ZN XTextProperty
+structure to be used.
+.IP \fIlist_return\fP 1i
+Returns a list of null-terminated character strings.
+.ds Cn strings
+.IP \fIcount_return\fP 1i
+Returns the number of \*(Cn.
+.IP \fIlist\fP 1i
+Specifies the list of strings to be freed.
+.SH DESCRIPTION
+The
+.ZN XmbTextListToTextProperty
+and
+.ZN XwcTextListToTextProperty
+functions set the specified
+.ZN XTextProperty
+value to a set of null-separated elements representing the concatenation
+of the specified list of null-terminated text strings.
+A final terminating null is stored at the end of the value field
+of text_prop_return but is not included in the nitems member.
+.LP
+The functions set the encoding field of text_prop_return to an
+.ZN Atom
+for the specified display
+naming the encoding determined by the specified style
+and convert the specified text list to this encoding for storage in
+the text_prop_return value field.
+If the style
+.ZN XStringStyle
+or
+.ZN XCompoundTextStyle
+is specified,
+this encoding is ``STRING'' or ``COMPOUND_TEXT'', respectively.
+If the style
+.ZN XTextStyle
+is specified,
+this encoding is the encoding of the current locale.
+If the style
+.ZN XStdICCTextStyle
+is specified,
+this encoding is ``STRING'' if the text is fully convertible to STRING,
+else ``COMPOUND_TEXT''.
+.LP
+If insufficient memory is available for the new value string,
+the functions return
+.ZN XNoMemory .
+If the current locale is not supported,
+the functions return
+.ZN XLocaleNotSupported .
+In both of these error cases,
+the functions do not set text_prop_return.
+.LP
+To determine if the functions are guaranteed not to return
+.ZN XLocaleNotSupported ,
+use
+.ZN XSupportsLocale .
+.LP
+If the supplied text is not fully convertible to the specified encoding,
+the functions return the number of unconvertible characters.
+Each unconvertible character is converted to an implementation-defined and
+encoding-specific default string.
+Otherwise, the functions return
+.ZN Success .
+Note that full convertibility to all styles except
+.ZN XStringStyle
+is guaranteed.
+.LP
+To free the storage for the value field, use
+.ZN XFree .
+.LP
+The
+.ZN XmbTextPropertyToTextList
+and
+.ZN XwcTextPropertyToTextList
+functions return a list of text strings in the current locale representing the
+null-separated elements of the specified
+.ZN XTextProperty
+structure.
+The data in text_prop must be format 8.
+.LP
+Multiple elements of the property (for example, the strings in a disjoint
+text selection) are separated by a null byte.
+The contents of the property are not required to be null-terminated;
+any terminating null should not be included in text_prop.nitems.
+.LP
+If insufficient memory is available for the list and its elements,
+.ZN XmbTextPropertyToTextList
+and
+.ZN XwcTextPropertyToTextList
+return
+.ZN XNoMemory .
+If the current locale is not supported,
+the functions return
+.ZN XLocaleNotSupported .
+Otherwise, if the encoding field of text_prop is not convertible
+to the encoding of the current locale,
+the functions return
+.ZN XConverterNotFound .
+For supported locales,
+existence of a converter from COMPOUND_TEXT, STRING
+or the encoding of the current locale is guaranteed if
+.ZN XSupportsLocale
+returns
+.ZN True
+for the current locale (but the actual text
+may contain unconvertible characters).
+Conversion of other encodings is implementation-dependent.
+In all of these error cases,
+the functions do not set any return values.
+.LP
+Otherwise,
+.ZN XmbTextPropertyToTextList
+and
+.ZN XwcTextPropertyToTextList
+return the list of null-terminated text strings to list_return
+and the number of text strings to count_return.
+.LP
+If the value field of text_prop is not fully convertible to the encoding of
+the current locale,
+the functions return the number of unconvertible characters.
+Each unconvertible character is converted to a string in the
+current locale that is specific to the current locale.
+To obtain the value of this string,
+use
+.ZN XDefaultString .
+Otherwise,
+.ZN XmbTextPropertyToTextList
+and
+.ZN XwcTextPropertyToTextList
+return
+.ZN Success .
+.LP
+To free the storage for the list and its contents returned by
+.ZN XmbTextPropertyToTextList ,
+use
+.ZN XFreeStringList .
+To free the storage for the list and its contents returned by
+.ZN XwcTextPropertyToTextList ,
+use
+.ZN XwcFreeStringList .
+.LP
+The
+.ZN XwcFreeStringList
+function frees memory allocated by
+.ZN XwcTextPropertyToTextList .
+.LP
+The
+.ZN XDefaultString
+function returns the default string used by Xlib for text conversion
+(for example, in
+.ZN XmbTextPropertyToTextList ).
+The default string is the string in the current locale that is output
+when an unconvertible character is found during text conversion.
+If the string returned by
+.ZN XDefaultString
+is the empty string ("\^"),
+no character is output in the converted text.
+.ZN XDefaultString
+does not return NULL.
+.LP
+The string returned by
+.ZN XDefaultString
+is independent of the default string for text drawing;
+see
+.ZN XCreateFontSet
+to obtain the default string for an
+.ZN XFontSet .
+.LP
+The behavior when an invalid codepoint is supplied to any Xlib function is
+undefined.
+.LP
+The returned string is null-terminated.
+It is owned by Xlib and should not be modified or freed by the client.
+It may be freed after the current locale is changed.
+Until freed, it will not be modified by Xlib.
+.SH STRUCTURES
+The
+.ZN XTextProperty
+structure contains:
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ unsigned char *value; /* property data */
+ Atom encoding; /* type of property */
+ int format; /* 8, 16, or 32 */
+ unsigned long nitems; /* number of items in value */
+} XTextProperty;
+.De
+.LP
+The
+.ZN XICCEncodingStyle
+structure contains:
+.LP
+.TS
+lw(.5i) lw(2i) lw(2.5i).
+T{
+#define
+T} T{
+.ZN XNoMemory
+T} T{
+\-1
+T}
+T{
+#define
+T} T{
+.ZN XLocaleNotSupported
+T} T{
+\-2
+T}
+T{
+#define
+T} T{
+.ZN XConverterNotFound
+T} T{
+\-3
+T}
+.TE
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef enum {
+ XStringStyle, /* STRING */
+ XCompoundTextStyle, /* COMPOUND_TEXT */
+ XTextStyle, /* text in owner's encoding (current locale) */
+ XStdICCTextStyle /* STRING, else COMPOUND_TEXT */
+} XICCEncodingStyle;
+.De
+.SH "SEE ALSO"
+XSetTextProperty(3X11),
+XStringListToTextProperty(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XmbTextPerCharExtents.man b/man/XmbTextPerCharExtents.man
new file mode 100644
index 00000000..1173a8a1
--- /dev/null
+++ b/man/XmbTextPerCharExtents.man
@@ -0,0 +1,269 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XmbTextPerCharExtents 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XmbTextPerCharExtents, XwcTextPerCharExtents \- obtain per-character information for a text string
+.SH SYNTAX
+Status XmbTextPerCharExtents\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_bytes\fP\^, \fIink_array_return\fP\^,
+.br
+ \fIlogical_array_return\fP\^, \fIarray_size\fP\^, \fInum_chars_return\fP\^, \fIoverall_ink_return\fP\^, \fIoverall_logical_return\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ char *\fIstring\fP\^;
+.br
+ int \fInum_bytes\fP\^;
+.br
+ XRectangle *\fIink_array_return\fP\^;
+.br
+ XRectangle *\fIlogical_array_return\fP\^;
+.br
+ int \fIarray_size\fP\^;
+.br
+ int *\fInum_chars_return\fP\^;
+.br
+ XRectangle *\fIoverall_ink_return\fP\^;
+.br
+ XRectangle *\fIoverall_logical_return\fP\^;
+.LP
+Status XwcTextPerCharExtents\^(\^\fIfont_set\fP\^, \fIstring\fP\^, \fInum_wchars\fP\^, \fIink_array_return\fP\^,
+.br
+ \fIlogical_array_return\fP\^, \fIarray_size\fP\^, \fInum_chars_return\fP\^, \fIoverall_ink_return\fP\^, \fIoverall_logical_return\fP\^)
+.br
+ XFontSet \fIfont_set\fP\^;
+.br
+ wchar_t *\fIstring\fP\^;
+.br
+ int \fInum_wchars\fP\^;
+.br
+ XRectangle *\fIink_array_return\fP\^;
+.br
+ XRectangle *\fIlogical_array_return\fP;
+.br
+ int \fIarray_size\fP\^;
+.br
+ int *\fInum_chars_return\fP\^;
+.br
+ XRectangle *\fIoverall_ink_return\fP\^;
+.br
+ XRectangle *\fIoverall_logical_return\fP\^;
+.SH ARGUMENTS
+.IP \fIarray_size\fP 1i
+Specifies the size of ink_array_return and logical_array_return.
+The caller must pass in arrays of this size.
+.IP \fIfont_set\fP 1i
+Specifies the font set.
+.IP \fIink_array_return\fP 1i
+Returns the ink dimensions for each character.
+.IP \fIlogical_array_return\fP 1i
+Returns the logical dimensions for each character.
+.IP \fInum_bytes\fP 1i
+Specifies the number of bytes in the string argument.
+.IP \fInum_chars_return\fP 1i
+Returns the number of characters in the string argument.
+.IP \fInum_wchars\fP 1i
+Specifies the number of characters in the string argument.
+.ds Ov extents of the entire string
+.IP \fIoverall_ink_return\fP 1i
+Returns the overall ink \*(Ov.
+.IP \fIoverall_logical_return\fP 1i
+Returns the overall logical \*(Ov.
+.IP \fIstring\fP 1i
+Specifies the character string.
+.SH DESCRIPTION
+The
+.ZN XmbTextPerCharExtents
+and
+.ZN XwcTextPerCharExtents
+functions return the text dimensions of each character of the specified text,
+using the fonts loaded for the specified font set.
+Each successive element of ink_array_return and logical_array_return
+is set to the successive character's drawn metrics,
+relative to the drawing origin of the string and one
+rectangle
+for each character in the supplied text string.
+The number of elements of ink_array_return and logical_array_return
+that have been set is returned to num_chars_return.
+.LP
+Each element of ink_array_return is set to the bounding box
+of the corresponding character's drawn foreground color.
+Each element of logical_array_return is set to the bounding box
+that provides minimum spacing to other graphical features
+for the corresponding character.
+Other graphical features should not intersect any of the
+logical_array_return rectangles.
+.LP
+Note that an
+.ZN XRectangle
+represents the effective drawing dimensions of the character,
+regardless of the number of font glyphs that are used to draw
+the character or the direction in which the character is drawn.
+If multiple characters map to a single character glyph,
+the dimensions of all the
+.ZN XRectangles
+of those characters are the same.
+.LP
+When the
+.ZN XFontSet
+has missing charsets, metrics for each unavailable
+character are taken from the default string returned by
+.ZN XCreateFontSet
+so that the metrics represent the text as it will actually be drawn.
+The behavior for an invalid codepoint is undefined.
+.LP
+If the array_size is too small for the number of characters in the
+supplied text, the functions return zero
+and num_chars_return is set to the number of rectangles required.
+Otherwise, the functions return a nonzero value.
+.LP
+If the overall_ink_return or overall_logical_return argument is non-NULL,
+.ZN XmbTextPerCharExtents
+and
+.ZN XwcTextPerCharExtents
+return the maximum extent of the string's metrics to overall_ink_return
+or overall_logical_return, as returned by
+.ZN XmbTextExtents
+or
+.ZN XwcTextExtents .
+.SH "SEE ALSO"
+XmbTextEscapement(3X11),
+XmbTextExtents(3X11)
+\fI\*(xL\fP
diff --git a/man/XrmEnumerateDatabase.man b/man/XrmEnumerateDatabase.man
new file mode 100644
index 00000000..d91081de
--- /dev/null
+++ b/man/XrmEnumerateDatabase.man
@@ -0,0 +1,243 @@
+'\" t
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" t
+.TH XrmEnumerateDatabase 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmEnumerateDatabase \- enumerate resource database entries
+.SH SYNTAX
+.TS
+lw(.5i) lw(2i) lw(2.5i).
+T{
+#define
+T} T{
+.ZN XrmEnumAllLevels
+T} T{
+0
+T}
+T{
+#define
+T} T{
+.ZN XrmEnumOneLevel
+T} T{
+1
+T}
+.TE
+.FD 0
+Bool XrmEnumerateDatabase\^(\^\fIdatabase\fP, \fIname_prefix\fP, \fIclass_prefix\fP, \fImode\fP, \fIproc\fP, \fIarg\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.br
+ XrmNameList \fIname_prefix\fP\^;
+.br
+ XrmClassList \fIclass_prefix\fP\^;
+.br
+ int \fImode\fP\^;
+.br
+ Bool (\^*\fIproc\fP\^)\^(\^)\^;
+.br
+ XPointer \fIarg\fP\^;
+.SH ARGUMENTS
+.IP \fIdatabase\fP 1i
+Specifies the resource database.
+.IP \fIname_prefix\fP 1i
+Specifies the resource name prefix.
+.IP \fIclass_prefix\fP 1i
+Specifies the resource class prefix.
+.IP \fImode\fP 1i
+Specifies the number of levels to enumerate.
+.IP \fIproc\fP 1i
+Specifies the procedure that is to be called for each matching entry.
+.IP \fIarg\fP 1i
+Specifies the user-supplied argument that will be passed to the procedure.
+.SH DESCRIPTION
+The
+.ZN XrmEnumerateDatabase
+function calls the specified procedure for each resource in the database
+that would match some completion of the given name/class resource prefix.
+The order in which resources are found is implementation-dependent.
+If mode is
+.ZN XrmEnumOneLevel ,
+a resource must match the given name/class prefix with
+just a single name and class appended. If mode is
+.ZN XrmEnumAllLevels ,
+the resource must match the given name/class prefix with one or more names and
+classes appended.
+If the procedure returns
+.ZN True ,
+the enumeration terminates and the function returns
+.ZN True .
+If the procedure always returns
+.ZN False ,
+all matching resources are enumerated and the function returns
+.ZN False .
+.LP
+The procedure is called with the following arguments:
+.LP
+.\" Start marker code here
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+(*\fIproc\fP\^)(\^\fIdatabase\fP, \fIbindings\fP, \fIquarks\fP, \fItype\fP, \fIvalue\fP, \fIarg\fP\^)
+ XrmDatabase *\fIdatabase\fP\^;
+ XrmBindingList \fIbindings\fP\^;
+ XrmQuarkList \fIquarks\fP\^;
+ XrmRepresentation *\fItype\fP\^;
+ XrmValue *\fIvalue\fP\^;
+ XPointer \fIarg\fP\^;
+.De
+.\" End marker code here
+.LP
+The bindings and quarks lists are terminated by
+.ZN NULLQUARK .
+Note that pointers
+to the database and type are passed, but these values should not be modified.
+.LP
+The procedure must not modifiy the database.
+If Xlib has been initialized for threads, the procedure is called with
+the database locked and the result of a call by the procedure to any
+Xlib function using the same database is not defined.
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmInitialize(3X11),
+XrmPutResource(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmGetFileDatabase.man b/man/XrmGetFileDatabase.man
new file mode 100644
index 00000000..62a9b55c
--- /dev/null
+++ b/man/XrmGetFileDatabase.man
@@ -0,0 +1,330 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XrmGetFileDatabase 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmGetFileDatabase, XrmPutFileDatabase, XrmGetStringDatabase, XrmLocaleOfDatabase, XrmGetDatabase, XrmSetDatabase, XrmDestroyDatabase \- retrieve and store resource databases
+.SH SYNTAX
+XrmDatabase XrmGetFileDatabase\^(\^\fIfilename\fP\^)
+.br
+ char *\fIfilename\fP\^;
+.LP
+void XrmPutFileDatabase\^(\^\fIdatabase\fP, \fIstored_db\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.br
+ char *\fIstored_db\fP\^;
+.LP
+XrmDatabase XrmGetStringDatabase\^(\^\fIdata\fP\^)
+.br
+ char *\fIdata\fP\^;
+.LP
+char *XrmLocaleOfDatabase\^(\^\fIdatabase\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.LP
+XrmDatabase XrmGetDatabase\^(\^\fIdisplay\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.LP
+void XrmSetDatabase\^(\^\fIdisplay\fP\^, \fIdatabase\fP\^)
+.br
+ Display *\fIdisplay\fP\^;
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.LP
+void XrmDestroyDatabase\^(\^\fIdatabase\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.SH ARGUMENTS
+.IP \fIfilename\fP 1i
+Specifies the resource database file name.
+.IP \fIdatabase\fP 1i
+Specifies the database that is to be used.
+.IP \fIstored_db\fP 1i
+Specifies the file name for the stored database.
+.IP \fIdata\fP 1i
+Specifies the database contents using a string.
+.IP \fIdatabase\fP 1i
+Specifies the resource database.
+.IP \fIdisplay\fP 1i
+Specifies the connection to the X server.
+.SH DESCRIPTION
+The
+.ZN XrmGetFileDatabase
+function opens the specified file,
+creates a new resource database, and loads it with the specifications
+read in from the specified file.
+The specified file should contain a sequence of entries in valid ResourceLine
+format (see section 15.1); the database that results from reading a file
+with incorrect syntax is implementation-dependent.
+The file is parsed in the current locale,
+and the database is created in the current locale.
+If it cannot open the specified file,
+.ZN XrmGetFileDatabase
+returns NULL.
+.LP
+The
+.ZN XrmPutFileDatabase
+function stores a copy of the specified database in the specified file.
+Text is written to the file as a sequence of entries in valid
+ResourceLine format (see section 15.1).
+The file is written in the locale of the database.
+Entries containing resource names that are not in the Host Portable Character
+Encoding or containing values that are not in the encoding of the database
+locale, are written in an implementation-dependent manner.
+The order in which entries are written is implementation-dependent.
+Entries with representation types other than ``String'' are ignored.
+.LP
+The
+.ZN XrmGetStringDatabase
+function creates a new database and stores the resources specified
+in the specified null-terminated string.
+.ZN XrmGetStringDatabase
+is similar to
+.ZN XrmGetFileDatabase
+except that it reads the information out of a string instead of out of a file.
+The string should contain a sequence of entries in valid ResourceLine
+format (see section 15.1) terminated by a null character;
+the database that results from using a string
+with incorrect syntax is implementation-dependent.
+The string is parsed in the current locale,
+and the database is created in the current locale.
+.LP
+If database is NULL,
+.ZN XrmDestroyDatabase
+returns immediately.
+.LP
+The
+.ZN XrmLocaleOfDatabase
+function returns the name of the locale bound to the specified
+database, as a null-terminated string.
+The returned locale name string is owned by Xlib and should not be
+modified or freed by the client.
+Xlib is not permitted to free the string until the database is destroyed.
+Until the string is freed,
+it will not be modified by Xlib.
+.LP
+The
+.ZN XrmGetDatabase
+function returns the database associated with the specified display.
+It returns NULL if a database has not yet been set.
+.LP
+The
+.ZN XrmSetDatabase
+function associates the specified resource database (or NULL)
+with the specified display.
+The database previously associated with the display (if any) is not destroyed.
+A client or toolkit may find this function convenient for retaining a database
+once it is constructed.
+.SH "FILE SYNTAX"
+The syntax of a resource file is a sequence of resource lines
+terminated by newline characters or the end of the file.
+The syntax of an individual resource line is:
+.LP
+.\" Start marker code here
+.Ds 0
+.TA 1.5i 1.75i
+.ta 1.5i 1.75i
+ResourceLine = Comment | IncludeFile | ResourceSpec | <empty line>
+Comment = "!" {<any character except null or newline>}
+IncludeFile = "#" WhiteSpace "include" WhiteSpace FileName WhiteSpace
+FileName = <valid filename for operating system>
+ResourceSpec = WhiteSpace ResourceName WhiteSpace ":" WhiteSpace Value
+ResourceName = [Binding] {Component Binding} ComponentName
+Binding = "\&." | "*"
+WhiteSpace = {<space> | <horizontal tab>}
+Component = "?" | ComponentName
+ComponentName = NameChar {NameChar}
+NameChar = "a"\-"z" | "A"\-"Z" | "0"\-"9" | "_" | "-"
+Value = {<any character except null or unescaped newline>}
+.De
+.\" End marker code here
+.LP
+Elements separated by vertical bar (|) are alternatives.
+Curly braces ({\&.\&.\&.}) indicate zero or more repetitions
+of the enclosed elements.
+Square brackets ([\&.\&.\&.]) indicate that the enclosed element is optional.
+Quotes ("\&.\&.\&.") are used around literal characters.
+.LP
+IncludeFile lines are interpreted by replacing the line with the
+contents of the specified file.
+The word ``include'' must be in lowercase.
+The file name is interpreted relative to the directory of the file in
+which the line occurs (for example, if the file name contains no
+directory or contains a relative directory specification).
+.LP
+If a ResourceName contains a contiguous sequence of two or more Binding
+characters, the sequence will be replaced with single ``\&.'' character
+if the sequence contains only ``\&.'' characters;
+otherwise, the sequence will be replaced with a single ``*'' character.
+.LP
+A resource database never contains more than one entry for a given
+ResourceName. If a resource file contains multiple lines with the
+same ResourceName, the last line in the file is used.
+.LP
+Any white space characters before or after the name or colon in a ResourceSpec
+are ignored.
+To allow a Value to begin with white space,
+the two-character sequence ``\^\\\^\fIspace\fP'' (backslash followed by space)
+is recognized and replaced by a space character,
+and the two-character sequence ``\^\\\^\fItab\fP''
+(backslash followed by horizontal tab)
+is recognized and replaced by a horizontal tab character.
+To allow a Value to contain embedded newline characters,
+the two-character sequence ``\^\\\^n'' is recognized and replaced by a
+newline character.
+To allow a Value to be broken across multiple lines in a text file,
+the two-character sequence ``\^\\\^\fInewline\fP''
+(backslash followed by newline) is
+recognized and removed from the value.
+To allow a Value to contain arbitrary character codes,
+the four-character sequence ``\^\\\^\fInnn\fP'',
+where each \fIn\fP is a digit character in the range of ``0''\^\-``7'',
+is recognized and replaced with a single byte that contains
+the octal value specified by the sequence.
+Finally, the two-character sequence ``\^\\\\'' is recognized
+and replaced with a single backslash.
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmInitialize(3X11),
+XrmPutResource(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmGetResource.man b/man/XrmGetResource.man
new file mode 100644
index 00000000..65dad31d
--- /dev/null
+++ b/man/XrmGetResource.man
@@ -0,0 +1,359 @@
+'\" e
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+'\" e
+.TH XrmGetResource 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmGetResource, XrmQGetResource, XrmQGetSearchList, XrmQGetSearchResource \- retrieve database resources and search lists
+.SH SYNTAX
+Bool XrmGetResource\^(\^\fIdatabase\fP, \fIstr_name\fP, \fIstr_class\fP, \
+\fIstr_type_return\fP, \fIvalue_return\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.br
+ char *\fIstr_name\fP\^;
+.br
+ char *\fIstr_class\fP\^;
+.br
+ char **\fIstr_type_return\fP\^;
+.br
+ XrmValue *\fIvalue_return\fP\^;
+.LP
+Bool XrmQGetResource\^(\^\fIdatabase\fP, \fIquark_name\fP, \fIquark_class\fP, \
+\fIquark_type_return\fP, \fIvalue_return\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.br
+ XrmNameList \fIquark_name\fP\^;
+.br
+ XrmClassList \fIquark_class\fP\^;
+.br
+ XrmRepresentation *\fIquark_type_return\fP\^;
+.br
+ XrmValue *\fIvalue_return\fP\^;
+.LP
+typedef XrmHashTable *XrmSearchList;
+.sp
+Bool XrmQGetSearchList\^(\^\fIdatabase\fP, \fInames\fP, \fIclasses\fP, \
+\fIlist_return\fP, \fIlist_length\fP\^)
+.br
+ XrmDatabase \fIdatabase\fP\^;
+.br
+ XrmNameList \fInames\fP\^;
+.br
+ XrmClassList \fIclasses\fP\^;
+.br
+ XrmSearchList \fIlist_return\fP\^;
+.br
+ int \fIlist_length\fP\^;
+.LP
+Bool XrmQGetSearchResource\^(\^\fIlist\fP, \fIname\fP, \fIclass\fP, \
+\fItype_return\fP, \fIvalue_return\fP\^)
+.br
+ XrmSearchList \fIlist\fP\^;
+.br
+ XrmName \fIname\fP\^;
+.br
+ XrmClass \fIclass\fP\^;
+.br
+ XrmRepresentation *\fItype_return\fP\^;
+.br
+ XrmValue *\fIvalue_return\fP\^;
+.SH ARGUMENTS
+.IP \fIclass\fP 1i
+Specifies the resource class.
+.IP \fIclasses\fP 1i
+Specifies a list of resource classes.
+.IP \fIdatabase\fP 1i
+Specifies the database that is to be used.
+.IP \fIlist\fP 1i
+Specifies the search list returned by
+.ZN XrmQGetSearchList .
+.IP \fIlist_length\fP 1i
+Specifies the number of entries (not the byte size) allocated for list_return.
+.IP \fIlist_return\fP 1i
+Returns a search list for further use.
+.IP \fIname\fP 1i
+Specifies the resource name.
+.IP \fInames\fP 1i
+Specifies a list of resource names.
+.IP \fIquark_class\fP 1i
+Specifies the fully qualified class of the value being retrieved (as a quark).
+.IP \fIquark_name\fP 1i
+Specifies the fully qualified name of the value being retrieved (as a quark).
+.IP \fIquark_type_return\fP 1i
+Returns the representation type of the destination (as a quark).
+.IP \fIstr_class\fP 1i
+Specifies the fully qualified class of the value being retrieved (as a string).
+.IP \fIstr_name\fP 1i
+Specifies the fully qualified name of the value being retrieved (as a string).
+.IP \fIstr_type_return\fP 1i
+Returns the representation type of the destination (as a string).
+.IP \fItype_return\fP 1i
+Returns data representation type.
+.IP \fIvalue_return\fP 1i
+Returns the value in the database.
+.SH DESCRIPTION
+The
+.ZN XrmGetResource
+and
+.ZN XrmQGetResource
+functions retrieve a resource from the specified database.
+Both take a fully qualified name/class pair, a destination
+resource representation, and the address of a value
+(size/address pair).
+The value and returned type point into database memory;
+therefore, you must not modify the data.
+.LP
+The database only frees or overwrites entries on
+.ZN XrmPutResource ,
+.ZN XrmQPutResource ,
+or
+.ZN XrmMergeDatabases .
+A client that is not storing new values into the database or
+is not merging the database should be safe using the address passed
+back at any time until it exits.
+If a resource was found, both
+.ZN XrmGetResource
+and
+.ZN XrmQGetResource
+return
+.ZN True ;
+otherwise, they return
+.ZN False .
+.LP
+The
+.ZN XrmQGetSearchList
+function takes a list of names and classes
+and returns a list of database levels where a match might occur.
+The returned list is in best-to-worst order and
+uses the same algorithm as
+.ZN XrmGetResource
+for determining precedence.
+If list_return was large enough for the search list,
+.ZN XrmQGetSearchList
+returns
+.ZN True ;
+otherwise, it returns
+.ZN False .
+.LP
+The size of the search list that the caller must allocate is
+dependent upon the number of levels and wildcards in the resource specifiers
+that are stored in the database.
+The worst case length is %3 sup n%,
+where \fIn\fP is the number of name or class components in names or classes.
+.LP
+When using
+.ZN XrmQGetSearchList
+followed by multiple probes for resources with a common name and class prefix,
+only the common prefix should be specified in the name and class list to
+.ZN XrmQGetSearchList .
+.LP
+The
+.ZN XrmQGetSearchResource
+function searches the specified database levels for the resource
+that is fully identified by the specified name and class.
+The search stops with the first match.
+.ZN XrmQGetSearchResource
+returns
+.ZN True
+if the resource was found;
+otherwise, it returns
+.ZN False .
+.LP
+A call to
+.ZN XrmQGetSearchList
+with a name and class list containing all but the last component
+of a resource name followed by a call to
+.ZN XrmQGetSearchResource
+with the last component name and class returns the same database entry as
+.ZN XrmGetResource
+and
+.ZN XrmQGetResource
+with the fully qualified name and class.
+.SH "MATCHING RULES"
+The algorithm for determining which resource database entry
+matches a given query is the heart of the resource manager.
+All queries must fully specify the name and class of the desired resource
+(use of the characters ``*'' and ``?'' are not permitted).
+The library supports up to 100 components in a full name or class.
+Resources are stored in the database with only partially specified
+names and classes, using pattern matching constructs.
+An asterisk (*) is a loose binding and is used to represent any number
+of intervening components, including none.
+A period (.) is a tight binding and is used to separate immediately
+adjacent components.
+A question mark (?) is used to match any single component name or class.
+A database entry cannot end in a loose binding;
+the final component (which cannot be the character ``?'') must be specified.
+The lookup algorithm searches the database for the entry that most
+closely matches (is most specific for) the full name and class being queried.
+When more than one database entry matches the full name and class,
+precedence rules are used to select just one.
+.LP
+The full name and class are scanned from left to right (from highest
+level in the hierarchy to lowest), one component at a time.
+At each level, the corresponding component and/or binding of each
+matching entry is determined, and these matching components and
+bindings are compared according to precedence rules.
+Each of the rules is applied at each level before moving to the next level,
+until a rule selects a single entry over all others.
+The rules, in order of precedence, are:
+.IP 1. 5
+An entry that contains a matching component (whether name, class,
+or the character ``?'')
+takes precedence over entries that elide the level (that is, entries
+that match the level in a loose binding).
+.IP 2. 5
+An entry with a matching name takes precedence over both
+entries with a matching class and entries that match using the character ``?''.
+An entry with a matching class takes precedence over
+entries that match using the character ``?''.
+.IP 3. 5
+An entry preceded by a tight binding takes precedence over entries
+preceded by a loose binding.
+.SH "SEE ALSO"
+XrmInitialize(3X11),
+XrmMergeDatabases(3X11),
+XrmPutResource(3X11),
+XrmUniqueQuark(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmInitialize.man b/man/XrmInitialize.man
new file mode 100644
index 00000000..9aed6182
--- /dev/null
+++ b/man/XrmInitialize.man
@@ -0,0 +1,272 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XrmInitialize 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmInitialize, XrmParseCommand, XrmValue, XrmOptionKind, XrmOptionDescRec \- initialize the Resource Manager, Resource Manager structures, and parse the command line
+.SH SYNTAX
+void XrmInitialize\^(\|);
+.LP
+void XrmParseCommand\^(\^\fIdatabase\fP\^, \^\fItable\fP\^, \^\fItable_count\fP\^, \
+\^\fIname\fP\^, \^\fIargc_in_out\fP\^, \^\fIargv_in_out\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ XrmOptionDescList \fItable\fP\^;
+.br
+ int \fItable_count\fP\^;
+.br
+ char *\fIname\fP\^;
+.br
+ int *\fIargc_in_out\fP\^;
+.br
+ char **\fIargv_in_out\fP\^;
+.SH ARGUMENTS
+.IP \fIargc_in_out\fP 1i
+Specifies the number of arguments and returns the number of remaining arguments.
+.IP \fIargv_in_out\fP 1i
+Specifies the command line arguments
+and returns the remaining arguments.
+.IP \fIdatabase\fP 1i
+Specifies the resource database.
+.IP \fIname\fP 1i
+Specifies the application name.
+.IP \fItable\fP 1i
+Specifies the table of command line arguments to be parsed.
+.IP \fItable_count\fP 1i
+Specifies the number of entries in the table.
+.SH DESCRIPTION
+The
+.ZN XrmInitialize
+function initialize the resource manager.
+It must be called before any other Xrm functions are used.
+.LP
+The
+.ZN XrmParseCommand
+function parses an (argc, argv) pair according to the specified option table,
+loads recognized options into the specified database with type ``String,''
+and modifies the (argc, argv) pair to remove all recognized options.
+If database contains NULL,
+.ZN XrmParseCommand
+creates a new database and returns a pointer to it.
+Otherwise, entries are added to the database specified.
+If a database is created, it is created in the current locale.
+.LP
+The specified table is used to parse the command line.
+Recognized options in the table are removed from argv,
+and entries are added to the specified resource database
+in the order they occur in argv.
+The table entries contain information on the option string,
+the option name, the style of option,
+and a value to provide if the option kind is
+.ZN XrmoptionNoArg .
+The option names are compared byte-for-byte to arguments in argv,
+independent of any locale.
+The resource values given in the table are stored in the resource database
+without modification.
+All resource database entries are created
+using a ``String'' representation type.
+The argc argument specifies the number of arguments in argv
+and is set on return to the remaining number of arguments that were not parsed.
+The name argument should be the name of your application
+for use in building the database entry.
+The name argument is prefixed to the resourceName in the option table
+before storing a database entry.
+The name argument is treated as a single component, even if it
+has embedded periods.
+No separating (binding) character is inserted,
+so the table must contain either a period (.) or an asterisk (*)
+as the first character in each resourceName entry.
+To specify a more completely qualified resource name,
+the resourceName entry can contain multiple components.
+If the name argument and the resourceNames are not in the
+Host Portable Character Encoding,
+the result is implementation-dependent.
+.SH STRUCTURES
+The
+.ZN XrmValue ,
+.ZN XrmOptionKind ,
+and
+.ZN XrmOptionDescRec
+structures contain:
+.LP
+.Ds 0
+.TA .5i 3i
+.ta .5i 3i
+typedef struct {
+ unsigned int size;
+ XPointer addr;
+} XrmValue, *XrmValuePtr;
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef enum {
+ XrmoptionNoArg, /* Value is specified in XrmOptionDescRec.value */
+ XrmoptionIsArg, /* Value is the option string itself */
+ XrmoptionStickyArg, /* Value is characters immediately following option */
+ XrmoptionSepArg, /* Value is next argument in argv */
+ XrmoptionResArg, /* Resource and value in next argument in argv */
+ XrmoptionSkipArg, /* Ignore this option and the next argument in argv */
+ XrmoptionSkipLine, /* Ignore this option and the rest of argv */
+ XrmoptionSkipNArgs /* Ignore this option and the next
+ \ \ \ XrmOptionDescRec.value arguments in argv */
+} XrmOptionKind;
+.De
+.LP
+.Ds 0
+.TA .5i 2.5i
+.ta .5i 2.5i
+typedef struct {
+ char *option; /* Option specification string in argv */
+ char *specifier; /* Binding and resource name (sans application name) */
+ XrmOptionKind argKind; /* Which style of option it is */
+ XPointer value; /* Value to provide if XrmoptionNoArg or
+ \ \ \ XrmoptionSkipNArgs */
+} XrmOptionDescRec, *XrmOptionDescList;
+.De
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmMergeDatabases(3X11),
+XrmPutResource(3X11),
+XrmUniqueQuark(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmMergeDatabases.man b/man/XrmMergeDatabases.man
new file mode 100644
index 00000000..3cd1f3fc
--- /dev/null
+++ b/man/XrmMergeDatabases.man
@@ -0,0 +1,222 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XrmMergeDatabases 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmMergeDatabases, XrmCombineDatabase, XrmCombineFileDatabase \- merge resource databases
+.SH SYNTAX
+void XrmMergeDatabases(\^\fIsource_db\fP, \fItarget_db\fP\^)
+.br
+ XrmDatabase \fIsource_db\fP, *\fItarget_db\fP\^;
+.LP
+void XrmCombineDatabase(\^\fIsource_db\fP, \fItarget_db\fP, \fIoverride\fP\^)
+.br
+ XrmDatabase \fIsource_db\fP, *\fItarget_db\fP\^;
+.br
+ Bool \fIoverride\fP;
+.LP
+Status XrmCombineFileDatabase(\^\fIfilename\fP, \fItarget_db\fP, \fIoverride\fP\^)
+.br
+ char *\fIfilename\fP;
+.br
+ XrmDatabase *\fItarget_db\fP\^;
+.br
+ Bool \fIoverride\fP;
+.SH ARGUMENTS
+.IP \fIsource_db\fP 1i
+Specifies the resource database that is to be merged into the target database.
+.IP \fItarget_db\fP 1i
+Specifies the resource database into which the source
+database is to be merged.
+.IP \fIfilename\fP 1i
+Specifies the resource database file name.
+.IP \fIoverride\fP 1i
+Specifies whether source entries override target ones.
+.SH DESCRIPTION
+Calling the
+.ZN XrmMergeDatabases
+function is equivalent to calling the
+.ZN XrmCombineDatabase
+function with an override argument of
+.ZN True .
+.LP
+The
+.ZN XrmCombineDatabase
+function merges the contents of one database into another.
+If the same specifier is used for an entry in both databases,
+the entry in the source_db will replace the entry in the target_db
+if override is
+.ZN True ;
+otherwise, the entry in source_db is discarded.
+If target_db contains NULL,
+.ZN XrmCombineDatabase
+simply stores source_db in it.
+Otherwise, source_db is destroyed by the merge, but the database pointed
+to by target_db is not destroyed.
+The database entries are merged without changing values or types,
+regardless of the locales of the databases.
+The locale of the target database is not modified.
+.LP
+The
+.ZN XrmCombineFileDatabase
+function merges the contents of a resource file into a database.
+If the same specifier is used for an entry in both the file and
+the database,
+the entry in the file will replace the entry in the database
+if override is
+.ZN True ;
+otherwise, the entry in the file is discarded.
+The file is parsed in the current locale.
+If the file cannot be read,
+a zero status is returned;
+otherwise, a nonzero status is returned.
+If target_db contains NULL,
+.ZN XrmCombineFileDatabase
+creates and returns a new database to it.
+Otherwise, the database pointed to by target_db is not destroyed by the merge.
+The database entries are merged without changing values or types,
+regardless of the locale of the database.
+The locale of the target database is not modified.
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmInitialize(3X11),
+XrmPutResource(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmPutResource.man b/man/XrmPutResource.man
new file mode 100644
index 00000000..acbc6d7c
--- /dev/null
+++ b/man/XrmPutResource.man
@@ -0,0 +1,281 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XrmPutResource 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmPutResource, XrmQPutResource, XrmPutStringResource, XrmQPutStringResource, XrmPutLineResource \- store database resources
+.SH SYNTAX
+void XrmPutResource\^(\^\fIdatabase\fP, \fIspecifier\fP, \fItype\fP, \fIvalue\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ char *\fIspecifier\fP\^;
+.br
+ char *\fItype\fP\^;
+.br
+ XrmValue *\fIvalue\fP\^;
+.LP
+void XrmQPutResource\^(\^\fIdatabase\fP, \fIbindings\fP, \fIquarks\fP, \
+\fItype\fP, \fIvalue\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ XrmBindingList \fIbindings\fP\^;
+.br
+ XrmQuarkList \fIquarks\fP\^;
+.br
+ XrmRepresentation \fItype\fP\^;
+.br
+ XrmValue *\fIvalue\fP\^;
+.LP
+void XrmPutStringResource\^(\^\fIdatabase\fP, \fIspecifier\fP, \fIvalue\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ char *\fIspecifier\fP\^;
+.br
+ char *\fIvalue\fP\^;
+.LP
+void XrmQPutStringResource\^(\^\fIdatabase\fP, \fIbindings\fP, \fIquarks\fP, \
+\fIvalue\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ XrmBindingList \fIbindings\fP\^;
+.br
+ XrmQuarkList \fIquarks\fP\^;
+.br
+ char *\fIvalue\fP\^;
+.LP
+void XrmPutLineResource\^(\^\fIdatabase\fP, \fIline\fP\^)
+.br
+ XrmDatabase *\fIdatabase\fP\^;
+.br
+ char *\fIline\fP\^;
+.SH ARGUMENTS
+.IP \fIbindings\fP 1i
+Specifies a list of bindings.
+.IP \fIdatabase\fP 1i
+Specifies the resource database.
+.IP \fIline\fP 1i
+Specifies the resource name and value pair as a single string.
+.IP \fIquarks\fP 1i
+Specifies the complete or partial name or the class list of the resource.
+.IP \fIspecifier\fP 1i
+Specifies a complete or partial specification of the resource.
+.IP \fItype\fP 1i
+Specifies the type of the resource.
+.IP \fIvalue\fP 1i
+Specifies the value of the resource, which is specified as a string.
+.SH DESCRIPTION
+If database contains NULL,
+.ZN XrmPutResource
+creates a new database and returns a pointer to it.
+.ZN XrmPutResource
+is a convenience function that calls
+.ZN XrmStringToBindingQuarkList
+followed by:
+.LP
+.Ds
+XrmQPutResource(database, bindings, quarks, XrmStringToQuark(type), value)
+.De
+If the specifier and type are not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+The value is stored in the database without modification.
+.LP
+If database contains NULL,
+.ZN XrmQPutResource
+creates a new database and returns a pointer to it.
+If a resource entry with the identical bindings and quarks already
+exists in the database, the previous type and value are replaced by the new
+specified type and value.
+The value is stored in the database without modification.
+.LP
+If database contains NULL,
+.ZN XrmPutStringResource
+creates a new database and returns a pointer to it.
+.ZN XrmPutStringResource
+adds a resource with the specified value to the specified database.
+.ZN XrmPutStringResource
+is a convenience function that first calls
+.ZN XrmStringToBindingQuarkList
+on the specifier and then calls
+.ZN XrmQPutResource ,
+using a ``String'' representation type.
+If the specifier is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+The value is stored in the database without modification.
+.LP
+If database contains NULL,
+.ZN XrmQPutStringResource
+creates a new database and returns a pointer to it.
+.ZN XrmQPutStringResource
+is a convenience routine that constructs an
+.ZN XrmValue
+for the value string (by calling
+.ZN strlen
+to compute the size) and
+then calls
+.ZN XrmQPutResource ,
+using a ``String'' representation type.
+The value is stored in the database without modification.
+.LP
+If database contains NULL,
+.ZN XrmPutLineResource
+creates a new database and returns a pointer to it.
+.ZN XrmPutLineResource
+adds a single resource entry to the specified database.
+The line should be in valid ResourceLine format (see section 15.1)
+terminated by a newline or null character;
+the database that results from using a string
+with incorrect syntax is implementation-dependent.
+The string is parsed in the locale of the database.
+If the
+.ZN ResourceName
+is not in the Host Portable Character Encoding,
+the result is implementation-dependent.
+Note that comment lines are not stored.
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmInitialize(3X11),
+XrmMergeDatabases(3X11),
+XrmUniqueQuark(3X11)
+.br
+\fI\*(xL\fP
diff --git a/man/XrmUniqueQuark.man b/man/XrmUniqueQuark.man
new file mode 100644
index 00000000..54aa3cb7
--- /dev/null
+++ b/man/XrmUniqueQuark.man
@@ -0,0 +1,314 @@
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991, 1994, 1996 X Consortium
+.\"
+.\" Permission is hereby granted, free of charge, to any person obtaining
+.\" a copy of this software and associated documentation files (the
+.\" "Software"), to deal in the Software without restriction, including
+.\" without limitation the rights to use, copy, modify, merge, publish,
+.\" distribute, sublicense, and/or sell copies of the Software, and to
+.\" permit persons to whom the Software is furnished to do so, subject to
+.\" the following conditions:
+.\"
+.\" The above copyright notice and this permission notice shall be included
+.\" in all copies or substantial portions of the Software.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+.\" OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+.\" MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+.\" IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR
+.\" OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+.\" ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+.\" OTHER DEALINGS IN THE SOFTWARE.
+.\"
+.\" Except as contained in this notice, the name of the X Consortium shall
+.\" not be used in advertising or otherwise to promote the sale, use or
+.\" other dealings in this Software without prior written authorization
+.\" from the X Consortium.
+.\"
+.\" Copyright \(co 1985, 1986, 1987, 1988, 1989, 1990, 1991 by
+.\" Digital Equipment Corporation
+.\"
+.\" Portions Copyright \(co 1990, 1991 by
+.\" Tektronix, Inc.
+.\"
+.\" Permission to use, copy, modify and distribute this documentation for
+.\" any purpose and without fee is hereby granted, provided that the above
+.\" copyright notice appears in all copies and that both that copyright notice
+.\" and this permission notice appear in all copies, and that the names of
+.\" Digital and Tektronix not be used in in advertising or publicity pertaining
+.\" to this documentation without specific, written prior permission.
+.\" Digital and Tektronix makes no representations about the suitability
+.\" of this documentation for any purpose.
+.\" It is provided ``as is'' without express or implied warranty.
+.\"
+.ds xT X Toolkit Intrinsics \- C Language Interface
+.ds xW Athena X Widgets \- C Language X Toolkit Interface
+.ds xL Xlib \- C Language X Interface
+.ds xC Inter-Client Communication Conventions Manual
+.na
+.de Ds
+.nf
+.\\$1D \\$2 \\$1
+.ft 1
+.\".ps \\n(PS
+.\".if \\n(VS>=40 .vs \\n(VSu
+.\".if \\n(VS<=39 .vs \\n(VSp
+..
+.de De
+.ce 0
+.if \\n(BD .DF
+.nr BD 0
+.in \\n(OIu
+.if \\n(TM .ls 2
+.sp \\n(DDu
+.fi
+..
+.de FD
+.LP
+.KS
+.TA .5i 3i
+.ta .5i 3i
+.nf
+..
+.de FN
+.fi
+.KE
+.LP
+..
+.de IN \" send an index entry to the stderr
+..
+.de C{
+.KS
+.nf
+.D
+.\"
+.\" choose appropriate monospace font
+.\" the imagen conditional, 480,
+.\" may be changed to L if LB is too
+.\" heavy for your eyes...
+.\"
+.ie "\\*(.T"480" .ft L
+.el .ie "\\*(.T"300" .ft L
+.el .ie "\\*(.T"202" .ft PO
+.el .ie "\\*(.T"aps" .ft CW
+.el .ft R
+.ps \\n(PS
+.ie \\n(VS>40 .vs \\n(VSu
+.el .vs \\n(VSp
+..
+.de C}
+.DE
+.R
+..
+.de Pn
+.ie t \\$1\fB\^\\$2\^\fR\\$3
+.el \\$1\fI\^\\$2\^\fP\\$3
+..
+.de ZN
+.ie t \fB\^\\$1\^\fR\\$2
+.el \fI\^\\$1\^\fP\\$2
+..
+.de hN
+.ie t <\fB\\$1\fR>\\$2
+.el <\fI\\$1\fP>\\$2
+..
+.de NT
+.ne 7
+.ds NO Note
+.if \\n(.$>$1 .if !'\\$2'C' .ds NO \\$2
+.if \\n(.$ .if !'\\$1'C' .ds NO \\$1
+.ie n .sp
+.el .sp 10p
+.TB
+.ce
+\\*(NO
+.ie n .sp
+.el .sp 5p
+.if '\\$1'C' .ce 99
+.if '\\$2'C' .ce 99
+.in +5n
+.ll -5n
+.R
+..
+. \" Note End -- doug kraft 3/85
+.de NE
+.ce 0
+.in -5n
+.ll +5n
+.ie n .sp
+.el .sp 10p
+..
+.ny0
+.TH XrmUniqueQuark 3X11 "Release 6.6" "X Version 11" "XLIB FUNCTIONS"
+.SH NAME
+XrmUniqueQuark, XrmStringToQuark, XrmPermStringToQuark, XrmQuarkToString, XrmStringToQuarkList, XrmStringToBindingQuarkList \- manipulate resource quarks
+.SH SYNTAX
+XrmQuark XrmUniqueQuark\^(\|)
+.LP
+#define XrmStringToName(string) XrmStringToQuark(string)
+#define XrmStringToClass(string) XrmStringToQuark(string)
+#define XrmStringToRepresentation(string) XrmStringToQuark(string)
+.sp
+XrmQuark XrmStringToQuark\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.sp
+XrmQuark XrmPermStringToQuark\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.LP
+#define XrmStringToName(string) XrmStringToQuark(string)
+#define XrmStringToClass(string) XrmStringToQuark(string)
+#define XrmStringToRepresentation(string) XrmStringToQuark(string)
+.sp
+XrmQuark XrmStringToQuark\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.sp
+XrmQuark XrmPermStringToQuark\^(\^\fIstring\fP\^)
+.br
+ char *\fIstring\fP\^;
+.LP
+#define XrmNameToString(name) XrmQuarkToString(name)
+#define XrmClassToString(class) XrmQuarkToString(class)
+#define XrmRepresentationToString(type) XrmQuarkToString(type)
+.sp
+char *XrmQuarkToString\^(\^\fIquark\fP\^)
+.br
+ XrmQuark \fIquark\fP\^;
+.LP
+#define XrmStringToNameList(str, name) XrmStringToQuarkList((str), (name))
+#define XrmStringToClassList(str,class) XrmStringToQuarkList((str), (class))
+.sp
+void XrmStringToQuarkList\^(\^\fIstring\fP, \fIquarks_return\fP\^)
+.br
+ char *\fIstring\fP\^;
+.br
+ XrmQuarkList \fIquarks_return\fP\^;
+.LP
+XrmStringToBindingQuarkList\^(\^\fIstring\fP, \fIbindings_return\fP, \
+\fIquarks_return\fP\^)
+.br
+ char *\fIstring\fP\^;
+.br
+ XrmBindingList \fIbindings_return\fP\^;
+.br
+ XrmQuarkList \fIquarks_return\fP\^;
+.SH ARGUMENTS
+.IP \fIbindings_return\fP 1i
+Returns the binding list.
+.IP \fIquark\fP 1i
+Specifies the quark for which the equivalent string is desired.
+.IP \fIquarks_return\fP 1i
+Returns the list of quarks.
+.ds Ql \ or quark list
+.IP \fIstring\fP 1i
+Specifies the string for which a quark\*(Ql is to be allocated.
+.SH DESCRIPTION
+The
+.ZN XrmUniqueQuark
+function allocates a quark that is guaranteed not to represent any string that
+is known to the resource manager.
+.LP
+These functions can be used to convert from string to quark representation.
+If the string is not in the Host Portable Character Encoding,
+the conversion is implementation-dependent.
+The string argument to
+.ZN XrmStringToQuark
+need not be permanently allocated storage.
+.ZN XrmPermStringToQuark
+is just like
+.ZN XrmStringToQuark ,
+except that Xlib is permitted to assume the string argument is permanently
+allocated,
+and, hence, that it can be used as the value to be returned by
+.ZN XrmQuarkToString .
+.LP
+For any given quark, if
+.ZN XrmStringToQuark
+returns a non-NULL value,
+all future calls will return the same value (identical address).
+.LP
+These functions can be used to convert from quark representation to string.
+The string pointed to by the return value must not be modified or freed.
+The returned string is byte-for-byte equal to the original
+string passed to one of the string-to-quark routines.
+If no string exists for that quark,
+.ZN XrmQuarkToString
+returns NULL.
+For any given quark, if
+.ZN XrmQuarkToString
+returns a non-NULL value,
+all future calls will return the same value (identical address).
+.LP
+These functions can be used to convert from string to quark representation.
+If the string is not in the Host Portable Character Encoding,
+the conversion is implementation-dependent.
+The string argument to
+.ZN XrmStringToQuark
+need not be permanently allocated storage.
+.ZN XrmPermStringToQuark
+is just like
+.ZN XrmStringToQuark ,
+except that Xlib is permitted to assume the string argument is permanently
+allocated,
+and, hence, that it can be used as the value to be returned by
+.ZN XrmQuarkToString .
+.LP
+For any given quark, if
+.ZN XrmStringToQuark
+returns a non-NULL value,
+all future calls will return the same value (identical address).
+.LP
+The
+.ZN XrmStringToQuarkList
+function converts the null-terminated string (generally a fully qualified name)
+to a list of quarks.
+The caller must allocate sufficient space for the quarks list before calling
+.ZN XrmStringToQuarkList .
+Note that the string must be in the valid ResourceName format
+(see section 15.1).
+If the string is not in the Host Portable Character Encoding,
+the conversion is implementation-dependent.
+.LP
+A binding list is a list of type
+.ZN XrmBindingList
+and indicates if components of name or class lists are bound tightly or loosely
+(that is, if wildcarding of intermediate components is specified).
+.LP
+.Ds 0
+typedef enum {XrmBindTightly, XrmBindLoosely} XrmBinding, *XrmBindingList;
+.De
+.LP
+.ZN XrmBindTightly
+indicates that a period separates the components, and
+.ZN XrmBindLoosely
+indicates that an asterisk separates the components.
+.LP
+The
+.ZN XrmStringToBindingQuarkList
+function converts the specified string to a binding list and a quark list.
+The caller must allocate sufficient space for the quarks list and the
+binding list before calling
+.ZN XrmStringToBindingQuarkList .
+If the string is not in the Host Portable Character Encoding
+the conversion is implementation-dependent.
+Component names in the list are separated by a period or
+an asterisk character.
+If the string does not start with period or asterisk,
+a period is assumed.
+For example, ``*a.b*c'' becomes:
+.LP
+.Ds 0
+.TA .75i 1.5i 2.25i
+.ta .75i 1.5i 2.25i
+quarks a b c
+.br
+bindings loose tight loose
+.De
+.SH "SEE ALSO"
+XrmGetResource(3X11),
+XrmInitialize(3X11),
+XrmMergeDatabases(3X11),
+XrmPutResource(3X11)
+.br
+\fI\*(xL\fP
diff --git a/modules/im/ximcp/imCallbk.c b/modules/im/ximcp/imCallbk.c
new file mode 100644
index 00000000..158b1021
--- /dev/null
+++ b/modules/im/ximcp/imCallbk.c
@@ -0,0 +1,890 @@
+/* $Xorg: imCallbk.c,v 1.4 2000/08/17 19:45:10 cpqbld Exp $ */
+/***********************************************************************
+Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+Copyright 1994 by FUJITSU LIMITED
+Copyright 1994 by Sony Corporation
+
+ All Rights Reserved
+
+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 names of Digital, FUJITSU
+LIMITED and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+
+DIGITAL, FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL DIGITAL, FUJITSU LIMITED
+AND SONY CORPORATION 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.
+
+ Author: Hiroyuki Miyamoto Digital Equipment Corporation
+ miyamoto@jrd.dec.com
+ Modifier: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+***********************************************************************/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XlcPubI.h"
+
+#define sz_CARD8 1
+#define sz_INT8 1
+#define sz_CARD16 2
+#define sz_INT16 2
+#define sz_BITMASK16 sz_CARD16
+#define sz_CARD32 4
+#define sz_INT32 4
+#define sz_BITMASK32 sz_CARD32
+#define sz_XIMID sizeof(XIMID)
+#define sz_XICID sizeof(XICID)
+#define sz_XIMATTRID sizeof(XIMATTRID)
+#define sz_XICATTRID sizeof(XICATTRID)
+#define sz_ximPacketHeader (XIM_HEADER_SIZE + sz_XIMID + sz_XICID)
+#define sz_ximGeometry 0
+#define sz_ximStrConversion (sz_CARD32 + sz_CARD32 + sz_CARD32 + sz_CARD32)
+#define sz_ximPreeditStart 0
+#define sz_ximPreeditStartReply sz_INT32
+#define sz_ximPreeditCaret (sz_INT32 + sz_CARD32 + sz_CARD32)
+#define sz_ximPreeditCaretReply sz_CARD32
+#define sz_ximPreeditDone 0
+#define sz_ximStatusStart 0
+#define sz_ximStatusDone 0
+
+typedef enum {
+ XimCbSuccess,
+ XimCbNoCallback,
+ XimCbError,
+ XimCbQueued,
+ XimCbBadContextID,
+ XimCbBadOpcode
+} XimCbStatus;
+
+typedef XimCbStatus (*XimCb)(
+#if NeedFunctionPrototypes
+ Xim, Xic, char*, int
+#endif
+ );
+
+#define PACKET_TO_MAJOROPCODE(p) (*(CARD8*)((CARD8*)(p)))
+#define PACKET_TO_MINOROPCODE(p) (*(CARD8*)((CARD8*)(p) + sz_CARD8))
+#define PACKET_TO_LENGTH(p) (*(CARD16*)((CARD8*)(p) + sz_CARD8 + sz_CARD8))
+#define PACKET_TO_IMID(p) (*(XIMID*)((CARD8*)(p) + XIM_HEADER_SIZE))
+#define PACKET_TO_ICID(p) (*(XICID*)((CARD8*)(p) + XIM_HEADER_SIZE + sz_XIMID))
+
+#define _XimWriteData(im,len,data) \
+ (im->private.proto.write((im),(len),(XPointer)(data)))
+#define _XimReadData(im,buf,buf_len,len) \
+ (im->private.proto.read((im),(XPointer)(buf),(buf_len),&(len)))
+#define _XimFlushData(im) im->private.proto.flush((im))
+
+#if NeedFunctionPrototypes
+Public Bool _XimCbDispatch(Xim xim, INT16 len, XPointer data, XPointer call_data);
+Private XimCbStatus _XimGeometryCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStrConversionCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditStartCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditDoneCallback(Xim, Xic, char*, int);
+Private void _free_memory_for_text(XIMText*);
+Private XimCbStatus _XimPreeditDrawCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditCaretCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusStartCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusDoneCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimStatusDrawCallback(Xim, Xic, char*, int);
+Private XimCbStatus _XimPreeditStateNotifyCallback(Xim, Xic, char *, int);
+#else
+Public Bool _XimCbDispatch();
+Private XimCbStatus _XimGeometryCallback();
+Private XimCbStatus _XimStrConversionCallback();
+Private XimCbStatus _XimPreeditStartCallback();
+Private XimCbStatus _XimPreeditDoneCallback();
+Private void _free_memory_for_text();
+Private XimCbStatus _XimPreeditDrawCallback();
+Private XimCbStatus _XimPreeditCaretCallback();
+Private XimCbStatus _XimStatusStartCallback();
+Private XimCbStatus _XimStatusDoneCallback();
+Private XimCbStatus _XimStatusDrawCallback();
+Private XimCbStatus _XimPreeditStateNotifyCallback();
+#endif /* NeedFunctionPrototypes */
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
+#define RConst /**/
+#else
+#define RConst Const
+#endif
+
+/* NOTE:
+ * the table below depends on the protocol number
+ * defined in the IM Protocol document.
+ */
+static RConst XimCb callback_table[] = {
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #000-009 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #010-019 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #020-029 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #030-039 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #040-049 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #050-059 */
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, /* #060-069 */
+ _XimGeometryCallback, /* #070 */
+ _XimStrConversionCallback, /* #071 */
+ NULL, /* #072 */
+ _XimPreeditStartCallback, /* #073 */
+ NULL, /* #074 */
+ _XimPreeditDrawCallback, /* #075 */
+ _XimPreeditCaretCallback, /* #076 */
+ NULL, /* #077 */
+ _XimPreeditDoneCallback, /* #078 */
+ _XimStatusStartCallback, /* #079 */
+ _XimStatusDrawCallback, /* #080 */
+ _XimStatusDoneCallback, /* #081 */
+ _XimPreeditStateNotifyCallback /* #082 */
+ };
+
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimIsReadyForProcess(Xic ic)
+#else
+_XimIsReadyForProcess(ic)
+ Xic ic;
+#endif
+{
+ return(!ic->private.proto.waitCallback); /* check HM */
+}
+
+Private void
+#if NeedFunctionPrototypes
+_XimProcessPendingCallbacks(Xic ic)
+#else
+_XimProcessPendingCallbacks(ic)
+ Xic ic;
+#endif
+{
+ XimPendingCallback pcbq;
+
+ while (((pcbq = ic->private.proto.pend_cb_que) != (XimPendingCallback)NULL)
+ && _XimIsReadyForProcess(ic)) {
+ (void) (*callback_table[pcbq->major_opcode])(pcbq->im,
+ pcbq->ic,
+ pcbq->proto,
+ pcbq->proto_len);
+ ic->private.proto.pend_cb_que = pcbq->next;
+ Xfree(pcbq->proto); /* free memory of XimPendingCallback */
+ Xfree(pcbq);
+ }
+}
+
+Private void
+#if NeedFunctionPrototypes
+_XimPutCbIntoQueue(Xic ic, XimPendingCallback call_data)
+#else
+_XimPutCbIntoQueue(ic, call_data)
+ Xic ic;
+ XimPendingCallback call_data;
+#endif
+{
+ XimPendingCallback pcbq = ic->private.proto.pend_cb_que;
+
+ /* Queuing is FIFO
+ */
+ while (pcbq != (XimPendingCallback)NULL) {
+ if (pcbq->next == (XimPendingCallback)NULL) {
+ break;
+ }
+ pcbq = pcbq->next;
+ }
+ if (pcbq == (XimPendingCallback)NULL) {
+ ic->private.proto.pend_cb_que = call_data;
+ }
+ else {
+ pcbq->next = call_data;
+ }
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimCbDispatch(Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimCbDispatch(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif
+{
+ /* `data' points to the beginning of the packet defined in IM Protocol doc.
+ */
+ int major_opcode = PACKET_TO_MAJOROPCODE(data);
+ XIMID imid = PACKET_TO_IMID(data);
+ XICID icid = PACKET_TO_ICID(data);
+ Xim im = (Xim)call_data; /* check HM */
+ Xic ic = _XimICOfXICID(im, icid);
+ char* proto;
+ int proto_len;
+
+ /* check validity of im/ic
+ */
+ if ((imid != im->private.proto.imid) || !ic) {
+ return False; /* status = XimCbBadContextID; */
+ }
+
+ /* process pending callbacks
+ */
+ _XimProcessPendingCallbacks(ic);
+
+ /* check if the protocol should be processed here
+ */
+ if (major_opcode > 82) {
+ return False; /* status = XimCbBadOpcode; */
+ }
+ if (!callback_table[major_opcode]) {
+ return False; /* status = XimCbBadOpcode; */
+ }
+
+ /* move the pointer ahead by the IM Protocol packet header size
+ */
+ proto = (char*)data + sz_ximPacketHeader;
+ proto_len = (int)len - sz_ximPacketHeader;
+
+ /* check if it can be processed right away
+ * and if no, queue the protocol, otherwise invoke a callback
+ */
+ if (!_XimIsReadyForProcess(ic)) {
+
+ /* queue the protocol
+ */
+ XimPendingCallback pcb;
+ char *proto_buf = (proto_len > 0) ? (char*)Xmalloc(proto_len) : NULL;
+
+ pcb = (XimPendingCallback)Xmalloc(sizeof(XimPendingCallbackRec));
+ if (pcb && (proto_len <= 0 || proto_buf)) {
+ if (proto_len > 0)
+ memcpy(proto_buf, proto, proto_len);
+
+ pcb->major_opcode = major_opcode;
+ pcb->im = im;
+ pcb->ic = ic;
+ pcb->proto = proto_buf;
+ pcb->proto_len = proto_len;
+ pcb->next = (XimPendingCallback)NULL; /* queue is FIFO */
+ _XimPutCbIntoQueue(ic, pcb);
+ /* status = XimCbQueued; */
+ } else {
+ /* status = XimCbError; */
+ }
+ }
+ else {
+ /* invoke each callback according to the major opcode.
+ * `proto' points to the next address of IM-ID and IC-ID.
+ * `proto_len' specifies the packet length.
+ */
+ (void) (*callback_table[major_opcode])(im, ic, proto, proto_len);
+ }
+ return True;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimGeometryCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimGeometryCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.geometry_callback;
+
+ /* invoke the callack
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimStrConversionCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimStrConversionCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.string_conversion_callback; /* check HM */
+ XIMStringConversionCallbackStruct cbrec;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ int p = XIM_HEADER_SIZE;
+ cbrec.position = (XIMStringConversionPosition)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.direction = (XIMCaretDirection)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.operation = (XIMStringConversionOperation)
+ *(CARD32*)&proto[p]; p += sz_CARD32;
+ cbrec.factor = (unsigned short)
+ *(CARD32*)&proto[p];
+
+ (*cb->callback)((XIC)ic, cb->client_data, &cbrec);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_STR_CONVERSION,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* send a reply
+ */
+ {
+ CARD8 *buf;
+ INT16 buf_len;
+ int p, length_in_bytes, i;
+
+ /* Assumption:
+ * `cbrec.text->length' means the string length in characters
+ */
+ {
+ length_in_bytes = (cbrec.text->encoding_is_wchar)?
+ sizeof(wchar_t) * cbrec.text->length: /* wchar */
+ strlen(cbrec.text->string.mbs); /* mb */
+ buf_len = XIM_HEADER_SIZE +
+ sz_CARD16 +
+ 2 + length_in_bytes +
+ XIM_PAD(2 + length_in_bytes) +
+ 2 + 2 + sz_CARD32 * cbrec.text->length;
+ buf = (CARD8*)Xmalloc(buf_len);
+ }
+ _XimSetHeader((XPointer)buf, XIM_STR_CONVERSION_REPLY, 0, &buf_len);
+ buf_len -= XIM_HEADER_SIZE; /* added by _XimSetHeader (HACK) */
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)cbrec.text->length; p += sz_CARD16;
+ memcpy(&buf[p],&cbrec.text->string.mbs,length_in_bytes);
+ p += length_in_bytes;
+ *(CARD16*)&buf[p] = (CARD16)(sz_CARD32*cbrec.text->length);
+ p += XIM_PAD(2);
+ for (i = 0; i < (int)cbrec.text->length; i++) {
+ *(CARD32*)&buf[p] = (CARD32)cbrec.text->feedback[i];
+ p += sz_CARD32;
+ }
+
+ if (!(_XimWriteData(im, buf_len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+
+ Xfree(buf);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimPreeditStartCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimPreeditStartCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.preedit_attr.start_callback;
+ int ret;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback){
+ ret = (*(int (*)(
+#if NeedNestedPrototypes
+ XIC, XPointer, XPointer
+#endif
+ ))(cb->callback))((XIC)ic,
+ cb->client_data,
+ (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_PREEDIT_START,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* send a reply
+ */
+ {
+ CARD32 buf32[(sz_ximPacketHeader + sz_ximPreeditStartReply) / 4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 buf_len = sz_XIMID + sz_XICID + sz_ximPreeditStartReply;
+ int p;
+
+ _XimSetHeader((XPointer)buf, XIM_PREEDIT_START_REPLY, 0, &buf_len);
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(INT32*)&buf[p] = (INT32)ret;
+
+ if (!(_XimWriteData(im, buf_len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimPreeditDoneCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimPreeditDoneCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.preedit_attr.done_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private void
+#if NeedFunctionPrototypes
+_read_text_from_packet(Xim im,
+ char* buf,
+ XIMText** text_ptr)
+#else
+_read_text_from_packet(im, buf, text_ptr)
+ Xim im;
+ char* buf;
+ XIMText** text_ptr;
+#endif
+{
+ int status;
+ XIMText* text;
+ int tmp_len;
+ char* tmp_buf;
+ Status s = 0;
+
+ status = (int)*(BITMASK32*)buf; buf += sz_BITMASK32;
+
+ /* string part
+ */
+ if (status & 0x00000001) /* "no string" bit on */ {
+ buf += sz_CARD16; /* skip "length of preedit string" */
+ buf += 2; /* pad */
+ *text_ptr = (XIMText*)NULL;
+ return;
+ }
+
+ *text_ptr = text = (XIMText*)Xmalloc(sizeof(XIMText));
+ if (text == (XIMText*)NULL) return;
+
+ tmp_len = (int)*(CARD16*)buf;
+ buf += sz_CARD16;
+ if ((tmp_buf = (char*)Xmalloc(tmp_len + 1))) {
+ memcpy(tmp_buf, buf, tmp_len);
+ tmp_buf[tmp_len] = '\0';
+
+ text->encoding_is_wchar = False;
+ text->length = im->methods->ctstombs((XIM)im,
+ tmp_buf, tmp_len,
+ NULL, 0, &s); /* CT? HM */
+ if (s != XLookupNone) {
+#ifndef NO_DEC_I18N_FIX
+ /* Allow for NULL-terminated */
+ if ((text->string.multi_byte =
+ (char*)Xmalloc(text->length *
+ XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1))) {
+#else
+ if (text->string.multi_byte = (char*)Xmalloc(text->length+1)) {
+#endif
+ int tmp;
+#ifndef NO_DEC_I18N_FIX
+ char *char_tmp;
+ int char_len;
+#endif
+ tmp = im->methods->ctstombs((XIM)im,
+ tmp_buf, tmp_len,
+#ifndef NO_DEC_I18N_FIX
+ text->string.multi_byte,
+ text->length * XLC_PUBLIC(im->core.lcd,mb_cur_max) + 1,
+#else
+ text->string.multi_byte, text->length,
+#endif
+ &s);
+ text->string.multi_byte[tmp] = '\0';
+#ifndef NO_DEC_I18N_FIX
+ text->length = 0;
+ char_tmp = text->string.multi_byte;
+ while (*char_tmp != '\0') {
+ char_len = mblen(char_tmp, strlen(char_tmp));
+ char_tmp = char_tmp + char_len;
+ (text->length)++;
+ }
+#endif
+ }
+ }
+ else {
+ text->length = 0;
+ text->string.multi_byte = NULL;
+ }
+
+ Xfree(tmp_buf);
+ }
+ buf += tmp_len;
+
+ buf += XIM_PAD(sz_CARD16 + tmp_len); /* pad */
+
+ /* feedback part
+ */
+ if (status & 0x00000002) /* "no feedback" bit on */ {
+ text->feedback = (XIMFeedback*)NULL;
+ }
+ else {
+ int i, j;
+
+ i = (int)*(CARD16*)buf; buf += sz_CARD16;
+ buf += sz_CARD16; /* skip `unused' */
+ text->feedback = (XIMFeedback*)Xmalloc(i*(sizeof(XIMFeedback)/sizeof(CARD32)));
+ j = 0;
+ while (i > 0) {
+ text->feedback[j] = (XIMFeedback)*(CARD32*)buf;
+ buf += sz_CARD32;
+ i -= sz_CARD32;
+ j++;
+ }
+ /*
+ * text->length tells how long both the status string and
+ * the feedback array are. If there's "no string" the
+ * text->length was set to zero previously. See above.
+ * But if there is feedback (i.e. not "no feedback") then
+ * we need to convey the length of the feedback array.
+ * It might have been better if the protocol sent two
+ * different values, one for the length of the status
+ * string and one for the length of the feedback array.
+ */
+ if (status & 0x00000001) /* "no string" bit on */ {
+ text->length = j;
+ }
+ }
+}
+
+Private void
+#if NeedFunctionPrototypes
+_free_memory_for_text(XIMText* text)
+#else
+_free_memory_for_text(text)
+ XIMText* text;
+#endif
+{
+ if (text) {
+ if (text->string.multi_byte)
+ Xfree(text->string.multi_byte);
+ if (text->feedback)
+ Xfree(text->feedback);
+ Xfree(text);
+ }
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimPreeditDrawCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimPreeditDrawCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.preedit_attr.draw_callback;
+ XIMPreeditDrawCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.caret = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.chg_first = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.chg_length = (int)*(INT32*)proto; proto += sz_INT32;
+ _read_text_from_packet(im, proto, &cbs.text);
+
+ (*cb->callback)((XIC)ic, cb->client_data, &cbs);
+
+ _free_memory_for_text((XIMText*)cbs.text);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimPreeditCaretCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimPreeditCaretCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.preedit_attr.caret_callback;
+ XIMPreeditCaretCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.position = (int)*(INT32*)proto; proto += sz_INT32;
+ cbs.direction = (XIMCaretDirection)*(CARD32*)proto; proto += sz_CARD32;
+ cbs.style = (XIMCaretStyle)*(CARD32*)proto; proto += sz_CARD32;
+
+ (*cb->callback)((XIC)ic, cb->client_data, &cbs);
+ }
+ else {
+
+ /* no callback registered
+ */
+ _XimError(im, ic,
+ (CARD16)XIM_BadSomething,
+ (INT16)len,
+ (CARD16)XIM_PREEDIT_CARET,
+ (char*)proto); /* send XIM_ERROR */
+ return XimCbNoCallback;
+ }
+
+ /* Send a reply
+ */
+ {
+ CARD8 buf[sz_ximPacketHeader + sz_ximPreeditCaretReply];
+ INT16 len = sz_XIMID + sz_XICID + sz_ximPreeditCaretReply;
+ int p;
+
+ _XimSetHeader((XPointer)buf, XIM_PREEDIT_CARET_REPLY, 0, &len);
+ p = XIM_HEADER_SIZE;
+ *(CARD16*)&buf[p] = (CARD16)im->private.proto.imid; p += sz_CARD16;
+ *(CARD16*)&buf[p] = (CARD16)ic->private.proto.icid; p += sz_CARD16;
+ *(CARD32*)&buf[p] = (CARD32)cbs.position;
+
+ if (!(_XimWriteData(im, len, buf))) {
+ return XimCbError;
+ }
+ _XimFlushData(im);
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimStatusStartCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimStatusStartCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.status_attr.start_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimStatusDoneCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimStatusDoneCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.status_attr.done_callback;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)NULL);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimStatusDrawCallback(Xim im,
+ Xic ic,
+ char* proto,
+ int len)
+#else
+_XimStatusDrawCallback(im, ic, proto, len)
+ Xim im;
+ Xic ic;
+ char* proto;
+ int len;
+#endif
+{
+ XIMCallback* cb = &ic->core.status_attr.draw_callback;
+ XIMStatusDrawCallbackStruct cbs;
+
+ /* invoke the callback
+ */
+ if (cb && cb->callback) {
+ cbs.type = (XIMStatusDataType)*(CARD32*)proto; proto += sz_CARD32;
+ if (cbs.type == XIMTextType) {
+ _read_text_from_packet(im, proto, &cbs.data.text);
+ }
+ else if (cbs.type == XIMBitmapType) {
+ cbs.data.bitmap = (Pixmap)*(CARD32*)proto;
+ }
+
+ (*cb->callback)((XIC)ic, cb->client_data, (XPointer)&cbs);
+
+ _free_memory_for_text((XIMText *)cbs.data.text);
+ }
+ else {
+
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
+Private XimCbStatus
+#if NeedFunctionPrototypes
+_XimPreeditStateNotifyCallback( Xim im, Xic ic, char* proto, int len )
+#else
+_XimPreeditStateNotifyCallback( im, ic, proto, len )
+ Xim im;
+ Xic ic;
+ char *proto;
+ int len;
+#endif
+{
+ XIMCallback *cb = &ic->core.preedit_attr.state_notify_callback;
+
+ /* invoke the callack
+ */
+ if( cb && cb->callback ) {
+ XIMPreeditStateNotifyCallbackStruct cbrec;
+
+ cbrec.state = *(BITMASK32 *)proto;
+ (*cb->callback)( (XIC)ic, cb->client_data, &cbrec );
+ }
+ else {
+ /* no callback registered
+ */
+ return XimCbNoCallback;
+ }
+
+ return XimCbSuccess;
+}
+
diff --git a/modules/im/ximcp/imDefFlt.c b/modules/im/ximcp/imDefFlt.c
new file mode 100644
index 00000000..6f32b446
--- /dev/null
+++ b/modules/im/ximcp/imDefFlt.c
@@ -0,0 +1,416 @@
+/* $Xorg: imDefFlt.c,v 1.4 2000/08/17 19:45:11 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private long
+_XimTriggerCheck(im, ev, len, keylist)
+ Xim im;
+ XKeyEvent *ev;
+ INT32 len;
+ CARD32 *keylist;
+{
+ register long i;
+ KeySym keysym;
+ CARD32 buf32[BUFSIZE/4];
+ char *buf = (char *)buf32;
+ int modifier;
+ int modifier_mask;
+ CARD32 min_len = sizeof(CARD32) /* sizeof keysym */
+ + sizeof(CARD32) /* sizeof modifier */
+ + sizeof(CARD32); /* sizeof modifier mask */
+
+ XLookupString(ev, buf, BUFSIZE, &keysym, NULL);
+ if (!keysym)
+ return -1;
+
+ for (i = 0; len >= min_len; i += 3, len -= min_len) {
+ modifier = keylist[i + 1];
+ modifier_mask = keylist[i + 2];
+ if (((KeySym)keylist[i] == keysym)
+ && ((ev->state & modifier_mask) == modifier))
+ return i;
+ }
+ return -1;
+}
+
+Private long
+_XimTriggerOnCheck(im, ev)
+ Xim im;
+ XKeyEvent *ev;
+{
+ return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_onkeylist[0],
+ &im->private.proto.im_onkeylist[1]);
+}
+
+Private long
+_XimTriggerOffCheck(im, ev)
+ Xim im;
+ XKeyEvent *ev;
+{
+ return _XimTriggerCheck(im, ev, (INT32)im->private.proto.im_offkeylist[0],
+ &im->private.proto.im_offkeylist[1]);
+}
+
+Private Bool
+_XimOnKeysCheck(ic, ev)
+ Xic ic;
+ XKeyEvent *ev;
+{
+ Xim im = (Xim)ic->core.im;
+ long idx;
+
+ if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
+ im->private.proto.im_onkeylist &&
+ im->private.proto.im_onkeylist[0]) {
+ if ((idx = _XimTriggerOnCheck(im, ev)) >= 0) {
+ (void)_XimTriggerNotify(im, ic, 0, (CARD32)idx); /* Trigger on */
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimOffKeysCheck(ic, ev)
+ Xic ic;
+ XKeyEvent *ev;
+{
+ Xim im = (Xim)ic->core.im;
+ long idx;
+
+ if (IS_DYNAMIC_EVENT_FLOW(ic->core.im) &&
+ im->private.proto.im_offkeylist &&
+ im->private.proto.im_offkeylist[0]) {
+ if ((idx = _XimTriggerOffCheck(im, ev)) >= 0) {
+ _XimTriggerNotify(im, ic, 1, (CARD32)idx); /* Trigger off */
+ return True;
+ }
+ }
+ return False;
+}
+
+Private void
+_XimPendingFilter(ic)
+ Xic ic;
+{
+ Xim im = (Xim)ic->core.im;
+
+ if (IS_NEED_SYNC_REPLY(ic)) {
+ (void)_XimProcSyncReply(im, ic);
+ UNMARK_NEED_SYNC_REPLY(ic);
+ }
+ return;
+}
+
+Private Bool
+_XimProtoKeypressFilter(ic, ev)
+ Xic ic;
+ XKeyEvent *ev;
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (IS_FABLICATED(ic)) {
+ _XimPendingFilter(ic);
+ UNMARK_FABLICATED(ic);
+ return NOTFILTERD;
+ }
+
+ if (IS_NEGLECT_EVENT(ic, KeyPressMask))
+ return FILTERD;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ }
+#else
+ if (!IS_IC_CONNECTED(ic))
+ return NOTFILTERD;
+#endif /* XIM_CONNECTABLE */
+
+ if (!IS_FORWARD_EVENT(ic, KeyPressMask)) {
+ if (_XimOnKeysCheck(ic, ev))
+ return FILTERD;
+ return NOTFILTERD;
+ }
+ if (_XimOffKeysCheck(ic, ev))
+ return FILTERD;
+
+ if (_XimForwardEvent(ic, (XEvent *)ev,
+ IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
+ return FILTERD;
+
+ return NOTFILTERD;
+}
+
+Private Bool
+_XimFilterKeypress (d, w, ev, client_data)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer client_data;
+{
+ return _XimProtoKeypressFilter((Xic)client_data, (XKeyEvent *)ev );
+}
+
+Private Bool
+_XimProtoKeyreleaseFilter( ic, ev )
+ Xic ic;
+ XKeyEvent *ev;
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (IS_FABLICATED(ic)) {
+ _XimPendingFilter(ic);
+ UNMARK_FABLICATED(ic);
+ return NOTFILTERD;
+ }
+
+ if (IS_NEGLECT_EVENT(ic, KeyReleaseMask))
+ return FILTERD;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ } else {
+ return NOTFILTERD;
+ }
+ }
+#else
+ if (!IS_IC_CONNECTED(ic))
+ return NOTFILTERD;
+#endif /* XIM_CONNECTABLE */
+
+ if (!IS_FORWARD_EVENT(ic, KeyReleaseMask)) {
+ if (_XimOnKeysCheck(ic, ev))
+ return FILTERD;
+ return NOTFILTERD;
+ }
+ if (_XimOffKeysCheck(ic, ev))
+ return FILTERD;
+
+ if (_XimForwardEvent(ic, (XEvent *)ev,
+ IS_SYNCHRONOUS_EVENT(ic, KeyPressMask)))
+ return FILTERD;
+
+ return NOTFILTERD;
+}
+
+Private Bool
+_XimFilterKeyrelease (d, w, ev, client_data)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer client_data;
+{
+ return _XimProtoKeyreleaseFilter((Xic)client_data, (XKeyEvent *)ev);
+}
+
+Private void
+_XimRegisterKeyPressFilter(ic)
+ Xic ic ;
+{
+ if (ic->core.focus_window) {
+ if (!(ic->private.proto.registed_filter_event & KEYPRESS_MASK)) {
+ _XRegisterFilterByType (ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyPress, KeyPress,
+ _XimFilterKeypress,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event |= KEYPRESS_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimRegisterKeyReleaseFilter(ic)
+ Xic ic ;
+{
+ if (ic->core.focus_window) {
+ if (!(ic->private.proto.registed_filter_event & KEYRELEASE_MASK)) {
+ _XRegisterFilterByType (ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyRelease, KeyRelease,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event |= KEYRELEASE_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimUnregisterKeyPressFilter(ic)
+ Xic ic ;
+{
+ if (ic->core.focus_window) {
+ if (ic->private.proto.registed_filter_event & KEYPRESS_MASK) {
+ _XUnregisterFilter (ic->core.im->core.display,
+ ic->core.focus_window,
+ _XimFilterKeypress,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event &= ~KEYPRESS_MASK;
+ }
+ }
+ return;
+}
+
+Private void
+_XimUnregisterKeyReleaseFilter(ic)
+ Xic ic ;
+{
+ if (ic->core.focus_window) {
+ if (ic->private.proto.registed_filter_event & KEYRELEASE_MASK) {
+ _XUnregisterFilter (ic->core.im->core.display,
+ ic->core.focus_window,
+ _XimFilterKeyrelease,
+ (XPointer)ic);
+ ic->private.proto.registed_filter_event &= ~KEYRELEASE_MASK;
+ }
+ }
+ return;
+}
+
+Public void
+_XimRegisterFilter(ic)
+ Xic ic;
+{
+ _XimRegisterKeyPressFilter(ic);
+ if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
+ _XimRegisterKeyReleaseFilter(ic);
+ return;
+}
+
+Public void
+_XimUnregisterFilter(ic)
+ Xic ic;
+{
+ _XimUnregisterKeyPressFilter(ic);
+ _XimUnregisterKeyReleaseFilter(ic);
+ return;
+}
+
+Public void
+_XimReregisterFilter(ic)
+ Xic ic;
+{
+ if (IS_FORWARD_EVENT(ic, KeyReleaseMask))
+ _XimRegisterKeyReleaseFilter(ic);
+ else
+ _XimUnregisterKeyReleaseFilter(ic);
+
+ return;
+}
+
+Private Bool
+_XimFilterServerDestroy (d, w, ev, client_data)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer client_data;
+{
+ Xim im = (Xim)client_data;
+
+ if (ev->type == DestroyNotify) {
+ UNMARK_SERVER_CONNECTED(im);
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ _XimServerReconectableDestroy();
+ return True;
+ }
+#endif /* XIM_CONNECTABLE */
+ _XimServerDestroy(im);
+ }
+ return True;
+}
+
+Public void
+_XimRegisterServerFilter(im)
+ Xim im ;
+{
+ if (im->private.proto.im_window) {
+ if (!(im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK)) {
+ _XRegisterFilterByMask(im->core.display,
+ im->private.proto.im_window,
+ StructureNotifyMask,
+ _XimFilterServerDestroy,
+ (XPointer)im);
+ XSelectInput(im->core.display, im->private.proto.im_window,
+ StructureNotifyMask);
+ im->private.proto.registed_filter_event |= DESTROYNOTIFY_MASK;
+ }
+ }
+ return;
+}
+
+Public void
+_XimUnregisterServerFilter(im)
+ Xim im ;
+{
+ if (im->private.proto.im_window) {
+ if (im->private.proto.registed_filter_event & DESTROYNOTIFY_MASK) {
+ _XUnregisterFilter(im->core.display,
+ im->private.proto.im_window,
+ _XimFilterServerDestroy,
+ (XPointer)im);
+ im->private.proto.registed_filter_event &= ~DESTROYNOTIFY_MASK;
+ }
+ }
+ return;
+}
+
diff --git a/modules/im/ximcp/imDefIc.c b/modules/im/ximcp/imDefIc.c
new file mode 100644
index 00000000..37726654
--- /dev/null
+++ b/modules/im/ximcp/imDefIc.c
@@ -0,0 +1,1588 @@
+/* $Xorg: imDefIc.c,v 1.5 2000/08/17 19:45:11 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimCreateICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimCreateICCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_CREATE_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+#ifdef XIM_CONNECTABLE
+Public Bool
+_XimReCreateIC(ic)
+ Xic ic;
+{
+ Xim im = (Xim)ic->core.im;
+ Xic save_ic;
+ XIMResourceList res;
+ unsigned int num;
+ XIMStyle input_style = ic->core.input_style;
+ XimDefICValues ic_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ int idx;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+ if (!(save_ic = (Xic)Xmalloc(sizeof(XicRec))))
+ return False;
+ memcpy((char *)save_ic, (char *)ic, sizeof(XicRec));
+
+ ic->core.filter_events = im->private.proto.forward_event_mask;
+ ic->private.proto.forward_event_mask =
+ im->private.proto.forward_event_mask;
+ ic->private.proto.synchronous_event_mask =
+ im->private.proto.synchronous_event_mask;
+
+ num = im->core.ic_num_resources;
+ buf_size = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ goto ErrorOnReCreateIC;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, buf_size);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+ num = im->private.proto.ic_num_inner_resources;
+ buf_size = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(buf_size)))
+ goto ErrorOnReCreateIC;
+ (void)memcpy((char *)res,
+ (char *)im->private.proto.ic_inner_resources, buf_size);
+ ic->private.proto.ic_inner_resources = res;
+ ic->private.proto.ic_num_inner_resources = num;
+
+ _XimSetICMode(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, input_style);
+
+ _XimSetICMode(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, input_style);
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ idx = 0;
+ for (;;) {
+ data = &buf[buf_size];
+ if (!_XimEncodeSavedICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, &idx, data, data_len,
+ &ret_len, (XPointer)&ic_values, XIM_CREATEIC)) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+
+ total += ret_len;
+ if (idx == -1) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ goto ErrorOnReCreateIC;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+ buf = tmp;
+ }
+ }
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_CREATE_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnReCreateIC;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCreateICCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimCreateICCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnReCreateIC;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnReCreateIC;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ goto ErrorOnReCreateIC;
+ }
+
+ ic->private.proto.icid = buf_s[1]; /* icid */
+ if(reply != preply)
+ Xfree(preply);
+
+ _XimRegisterFilter(ic);
+ MARK_IC_CONNECTED(ic);
+ if (save_ic->private.proto.ic_resources)
+ Xfree(save_ic->private.proto.ic_resources);
+ if (save_ic->private.proto.ic_inner_resources)
+ Xfree(save_ic->private.proto.ic_inner_resources);
+ Xfree(save_ic);
+ return True;
+
+ErrorOnReCreateIC:
+ memcpy((char *)ic, (char *)save_ic, sizeof(XicRec));
+ Xfree(save_ic);
+ return False;
+}
+
+Private char *
+_XimDelayModeGetICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ XimDefICValues ic_values;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ return _XimGetICValueData(ic, (XPointer)&ic_values,
+ ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources,
+ arg, XIM_GETICVALUES);
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimGetICValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimGetICValuesCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_GET_IC_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoGetICValues(xic, arg)
+ XIC xic ;
+ XIMArg *arg ;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ register XIMArg *p;
+ register XIMArg *pp;
+ register int n;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply = NULL;
+ int buf_size;
+ int ret_code;
+ char *makeid_name;
+ char *decode_name;
+ CARD16 *data = NULL;
+ INT16 data_len = 0;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return arg->name;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return _XimDelayModeGetICValues(ic, arg);
+ }
+ } else {
+ return _XimDelayModeGetICValues(ic, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ for (n = 0, p = arg; p && p->name; p++) {
+ n++;
+ if ((strcmp(p->name, XNPreeditAttributes) == 0)
+ || (strcmp(p->name, XNStatusAttributes) == 0)) {
+ n++;
+ for (pp = (XIMArg *)p->value; pp && pp->name; pp++)
+ n++;
+ }
+ }
+
+ if (!n)
+ return (char *)NULL;
+
+ buf_size = sizeof(CARD16) * n;
+ buf_size += XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + XIM_PAD(2 + buf_size);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ return arg->name;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ makeid_name = _XimMakeICAttrIDList(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg,
+ &buf_s[3], &len, XIM_GETICVALUES);
+
+ if (len > 0) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = len; /* length of ic-attr-id */
+ len += sizeof(INT16); /* sizeof length of attr */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_GET_IC_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimGetICValuesCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimGetICValuesCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ if (preply != reply)
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else {
+ return arg->name;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ data = &buf_s[4];
+ data_len = buf_s[2];
+ }
+ else if (len < 0) {
+ return arg->name;
+ }
+
+ decode_name = _XimDecodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, data, data_len,
+ arg, XIM_GETICVALUES);
+ if (reply != preply)
+ Xfree(preply);
+
+ if (decode_name)
+ return decode_name;
+ else
+ return makeid_name;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckNestQuarkList(quark_list, num_quark, quark, separator)
+ XrmQuark *quark_list;
+ int num_quark;
+ XrmQuark quark;
+ XrmQuark separator;
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == separator) {
+ break;
+ }
+ if (quark_list[i] == quark) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimCheckNestedQuarkList(quark_list, idx, num_quark, arg, separator)
+ XrmQuark **quark_list;
+ int idx;
+ int *num_quark;
+ XIMArg *arg;
+ XrmQuark separator;
+{
+ XrmQuark *q_list = *quark_list;
+ int n_quark = *num_quark;
+ register XIMArg *p;
+ XrmQuark quark;
+ XrmQuark *tmp;
+ register int i;
+
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if (_XimCheckNestQuarkList(&q_list[idx], n_quark - idx,
+ quark, separator)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xmalloc((sizeof(XrmQuark) * (n_quark + 1))))) {
+ *quark_list = q_list;
+ *num_quark = n_quark;
+ return False;
+ }
+ n_quark++;
+ for (i = 0; i < idx; i++) {
+ tmp[i] = q_list[i];
+ }
+ tmp[i] = quark;
+ for (i = idx + 1; i < n_quark; i++) {
+ tmp[i] = q_list[i - 1];
+ }
+ q_list = tmp;
+ }
+ *quark_list = q_list;
+ *num_quark = n_quark;
+ return True;
+}
+
+Private Bool
+_XimCheckICQuarkList(quark_list, num_quark, quark, idx)
+ XrmQuark *quark_list;
+ int num_quark;
+ XrmQuark quark;
+ int *idx;
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == quark) {
+ *idx = i;
+ return True;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimSaveICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ register XIMArg *p;
+ register int n;
+ XrmQuark *quark_list;
+ XrmQuark *tmp;
+ XrmQuark quark;
+ int num_quark;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ XrmQuark separator;
+ int idx;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+ separator = XrmStringToQuark(XNSeparatorofNestedList);
+
+ if (quark_list = ic->private.proto.saved_icvalues) {
+ num_quark = ic->private.proto.num_saved_icvalues;
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if ((quark == pre_quark) || (quark == sts_quark)) {
+ if (!_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
+ register XIMArg *pp;
+ int nn;
+ XrmQuark *q_list;
+
+ for (pp = (XIMArg *)p->value, nn = 0;
+ pp && pp->name; pp++, nn++);
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + nn + 2))))) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ quark_list = tmp;
+ q_list = &quark_list[num_quark];
+ num_quark += nn + 2;
+ *q_list++ = quark;
+ for (pp = (XIMArg *)p->value;
+ pp && pp->name; pp++, quark_list++) {
+ *q_list = XrmStringToQuark(pp->name);
+ }
+ *q_list = separator;
+ } else {
+ if (!_XimCheckNestedQuarkList(&quark_list, idx + 1,
+ &num_quark, (XIMArg *)p->value, separator)) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ }
+ } else {
+ if (_XimCheckICQuarkList(quark_list, num_quark, quark, &idx)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + 1))))) {
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return False;
+ }
+ quark_list = tmp;
+ quark_list[num_quark] = quark;
+ num_quark++;
+ }
+ }
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = num_quark;
+ return True;
+ }
+
+ for (p = arg, n = 0; p && p->name; p++, n++) {
+ if ((!strcmp(p->name, XNPreeditAttributes))
+ || (!strcmp(p->name, XNStatusAttributes))) {
+ register XIMArg *pp;
+ int nn;
+
+ for (pp = (XIMArg *)p->value, nn = 0; pp && pp->name; pp++, nn++);
+ n += nn + 1;
+ }
+ }
+
+ if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ return False;
+ }
+
+ ic->private.proto.saved_icvalues = quark_list;
+ ic->private.proto.num_saved_icvalues = n;
+ for (p = arg; p && p->name; p++, quark_list++) {
+ *quark_list = XrmStringToQuark(p->name);
+ if ((*quark_list == pre_quark) || (*quark_list == sts_quark)) {
+ register XIMArg *pp;
+
+ quark_list++;
+ for (pp = (XIMArg *)p->value; pp && pp->name; pp++, quark_list++) {
+ *quark_list = XrmStringToQuark(pp->name);
+ }
+ *quark_list = separator;
+ }
+ }
+ return True;
+}
+
+Private char *
+_XimDelayModeSetICValues(ic, arg)
+ Xic ic;
+ XIMArg *arg;
+{
+ XimDefICValues ic_values;
+ char *name;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ name = _XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources,
+ arg, XIM_SETICVALUES, False);
+ _XimSetCurrentICValues(ic, &ic_values);
+ return name;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimSetICValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimSetICValuesCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SET_IC_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoSetICValues(xic, arg)
+ XIC xic;
+ XIMArg *arg;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ XimDefICValues ic_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply = NULL;
+ int ret_code;
+ BITMASK32 flag = 0L;
+ char *name;
+ char *tmp_name = (arg) ? arg->name : NULL;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return tmp_name;
+#else
+ if (!_XimSaveICValues(ic, arg))
+ return NULL;
+
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return _XimDelayModeSetICValues(ic, arg);
+ }
+ } else {
+ return _XimDelayModeSetICValues(ic, arg);
+ }
+ } else {
+ return tmp_name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE
+ + sizeof(CARD16) + sizeof(CARD16) + sizeof(INT16) + sizeof(CARD16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if ((name = _XimEncodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg, &arg_ret,
+ data, data_len, &ret_len, (XPointer)&ic_values,
+ &flag, XIM_SETICVALUES))) {
+ break;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return tmp_name;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return tmp_name;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ if (!total) {
+ return tmp_name;
+ }
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+#ifdef EXT_MOVE
+ if (_XimExtenMove(im, ic, flag, &buf_s[4], (INT16)total))
+ return name;
+#endif
+
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = ic->private.proto.icid;
+ buf_s[2] = (INT16)total;
+ buf_s[3] = 0;
+ len = (INT16)(sizeof(CARD16) + sizeof(CARD16)
+ + sizeof(INT16) + sizeof(CARD16) + total);
+
+ _XimSetHeader((XPointer)buf, XIM_SET_IC_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return tmp_name;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetICValuesCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSetICValuesCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ return tmp_name;
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ return tmp_name;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return tmp_name;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ return name;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimDestroyICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimDestroyICCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Bool ret = False;
+
+ if ((major_opcode == XIM_DESTROY_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ ret = True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ ret = False;
+ return ret;
+}
+
+Private void
+_XimProtoICFree(ic)
+ Xic ic;
+{
+#ifdef XIM_CONNECTABLE
+ Xim im = (Xim)ic->core.im;
+#endif
+
+ if (ic->private.proto.preedit_font) {
+ Xfree(ic->private.proto.preedit_font);
+ ic->private.proto.preedit_font = NULL;
+ }
+ if (ic->private.proto.status_font) {
+ Xfree(ic->private.proto.status_font);
+ ic->private.proto.status_font = NULL;
+ }
+ if (ic->private.proto.commit_info) {
+ _XimFreeCommitInfo(ic);
+ ic->private.proto.commit_info = NULL;
+ }
+ if (ic->private.proto.ic_inner_resources) {
+ Xfree(ic->private.proto.ic_inner_resources);
+ ic->private.proto.ic_inner_resources = NULL;
+ }
+
+#ifdef XIM_CONNECTABLE
+ if (IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ return;
+ }
+#endif /* XIM_CONNECTABLE */
+
+ if (ic->private.proto.saved_icvalues) {
+ Xfree(ic->private.proto.saved_icvalues);
+ ic->private.proto.saved_icvalues = NULL;
+ }
+ if (ic->private.proto.ic_resources) {
+ Xfree(ic->private.proto.ic_resources);
+ ic->private.proto.ic_resources = NULL;
+ }
+ if (ic->core.hotkey) {
+ Xfree(ic->core.hotkey);
+ ic->core.hotkey = NULL;
+ }
+
+ return;
+}
+
+Private void
+_XimProtoDestroyIC(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (IS_SERVER_CONNECTED(im)) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_DESTROY_IC, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimDestroyICCheck, (XPointer)ic);
+ if(ret_code == XIM_OVERFLOW) {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ (void)_XimRead(im, &len, preply, buf_size,
+ _XimDestroyICCheck, (XPointer)ic);
+ Xfree(preply);
+ }
+ }
+ UNMARK_IC_CONNECTED(ic);
+ _XimUnregisterFilter(ic);
+ _XimProtoICFree(ic);
+ return;
+}
+
+Private void
+_XimProtoSetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return;
+ }
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SET_IC_FOCUS, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+
+ _XimRegisterFilter(ic);
+ return;
+}
+
+Private void
+_XimProtoUnsetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_IC_CONNECTED(ic))
+ return;
+#else
+ if (!IS_IC_CONNECTED(ic)) {
+ if (IS_CONNECTABLE(im)) {
+ if (_XimConnectServer(im)) {
+ if (!_XimReCreateIC(ic)) {
+ _XimDelayModeSetAttr(im);
+ return;
+ }
+ } else {
+ return;
+ }
+ } else {
+ return;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_UNSET_IC_FOCUS, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+
+ _XimUnregisterFilter(ic);
+ return;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimResetICCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimResetICCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_RESET_IC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimCommitedMbString(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ XimCommitInfo info;
+ int len;
+ int new_len;
+ char *commit;
+ char *new_commit = NULL;
+ char *str;
+ Status status;
+
+ len = 0;
+ for (info = ic->private.proto.commit_info; info; info = info->next)
+ len += info->string_len;
+ len += buf_s[0];
+ if( len == 0 )
+ return( NULL );
+
+ if (!(commit = (char *)Xmalloc(len + 1)))
+ goto Error_On_Reset;
+
+ str = commit;
+ for (info = ic->private.proto.commit_info; info; info = info->next) {
+ (void)memcpy(str, info->string, info->string_len);
+ str += info->string_len;
+ }
+ (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+ commit[len] = '\0';
+
+ new_len = im->methods->ctstombs((XIM)im, commit, len, NULL, 0, &status);
+ if (status != XLookupNone) {
+ if (!(new_commit = Xmalloc(new_len + 1))) {
+ Xfree(commit);
+ goto Error_On_Reset;
+ }
+ (void)im->methods->ctstombs((XIM)im, commit, len,
+ new_commit, new_len, NULL);
+ new_commit[new_len] = '\0';
+ }
+ Xfree(commit);
+
+Error_On_Reset:
+ _XimFreeCommitInfo( ic );
+ return new_commit;
+}
+
+Private char *
+_XimProtoMbReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ char *commit;
+
+ if (!IS_IC_CONNECTED(ic))
+ return (char *)NULL;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_RESET_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return NULL;
+ _XimFlush(im);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len < 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ free(preply);
+ return NULL;
+ }
+
+ commit = _XimCommitedMbString(im, ic, (XPointer)&buf_s[2]);
+
+ if(reply != preply)
+ Xfree(preply);
+ return commit;
+}
+
+Private wchar_t *
+_XimCommitedWcString(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ XimCommitInfo info;
+ int len;
+ int new_len;
+ char *commit;
+ wchar_t *new_commit = (wchar_t *)NULL;
+ char *str;
+ Status status;
+
+ len = 0;
+ for (info = ic->private.proto.commit_info; info; info = info->next)
+ len += info->string_len;
+ len += buf_s[0];
+ if( len == 0 )
+ return( (wchar_t *)NULL );
+
+ if (!(commit = (char *)Xmalloc(len + 1)))
+ goto Error_On_Reset;
+
+ str = commit;
+ for (info = ic->private.proto.commit_info; info; info = info->next) {
+ (void)memcpy(str, info->string, info->string_len);
+ str += info->string_len;
+ }
+ (void)memcpy(str, (char *)&buf_s[1], buf_s[0]);
+ commit[len] = '\0';
+
+ new_len = im->methods->ctstowcs((XIM)im, commit, len, NULL, 0, &status);
+ if (status != XLookupNone) {
+ if (!(new_commit =
+ (wchar_t *)Xmalloc(sizeof(wchar_t) * (new_len + 1)))) {
+ Xfree(commit);
+ goto Error_On_Reset;
+ }
+ (void)im->methods->ctstowcs((XIM)im, commit, len,
+ new_commit, new_len, NULL);
+ new_commit[new_len] = (wchar_t)'\0';
+ }
+ Xfree(commit);
+
+Error_On_Reset:
+ _XimFreeCommitInfo( ic );
+ return new_commit;
+}
+
+Private wchar_t *
+_XimProtoWcReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ wchar_t *commit;
+
+ if (!IS_IC_CONNECTED(ic))
+ return (wchar_t *)NULL;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_RESET_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return NULL;
+ _XimFlush(im);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimResetICCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ return NULL;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ free(preply);
+ return NULL;
+ }
+
+ commit = _XimCommitedWcString(im, ic, (XPointer)&buf_s[2]);
+
+ Xfree(preply);
+ return commit;
+}
+
+Private XICMethodsRec ic_methods = {
+ _XimProtoDestroyIC, /* destroy */
+ _XimProtoSetFocus, /* set_focus */
+ _XimProtoUnsetFocus, /* unset_focus */
+ _XimProtoSetICValues, /* set_values */
+ _XimProtoGetICValues, /* get_values */
+ _XimProtoMbReset, /* mb_reset */
+ _XimProtoWcReset, /* wc_reset */
+ _XimProtoMbLookupString, /* mb_lookup_string */
+ _XimProtoWcLookupString, /* wc_lookup_string */
+};
+
+Private Bool
+_XimGetInputStyle(arg, input_style)
+ XIMArg *arg;
+ XIMStyle *input_style;
+{
+ register XIMArg *p;
+
+ for (p = arg; p && p->name; p++) {
+ if (!(strcmp(p->name, XNInputStyle))) {
+ *input_style = (XIMStyle)p->value;
+ return True;
+ }
+ }
+ return False;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimDelayModeCreateIC(ic, values, res, num)
+ Xic ic;
+ XIMArg *values;
+ XIMResourceList res;
+ unsigned int num;
+{
+ Xim im = (Xim)ic->core.im;
+ XimDefICValues ic_values;
+ int len;
+ XIMStyle input_style;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ _XimGetCurrentICValues(ic, &ic_values);
+ if (!(_XimGetInputStyle(values, &input_style)))
+ return False;
+
+ _XimSetICMode(res, num, input_style);
+
+ if(_XimSetICValueData(ic, (XPointer)&ic_values, res, num,
+ values, XIM_CREATEIC, False)) {
+ return False;
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+ if(!_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num)) {
+ return False;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+ _XimRegisterFilter(ic);
+
+ return True;
+}
+
+Public Bool
+_XimReconnectModeCreateIC(ic)
+ Xic ic;
+{
+ Xim im = (Xim)ic->core.im;
+ int len;
+ XIMStyle input_style = ic->core.input_style;
+ XIMResourceList res;
+ unsigned int num;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return False;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+ _XimSetICMode(res, num, input_style);
+
+ ic->core.filter_events = KeyPressMask;
+
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Public XIC
+_XimProtoCreateIC(xim, arg)
+ XIM xim;
+ XIMArg *arg;
+{
+ Xim im = (Xim)xim;
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ XIMStyle input_style;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && !IS_CONNECTABLE(im))
+ return (XIC)NULL;
+#else
+ if (!IS_SERVER_CONNECTED(im))
+ return (XIC)NULL;
+#endif /* XIM_CONNECTABLE */
+
+ if (!(_XimGetInputStyle(arg, &input_style)))
+ return (XIC)NULL;
+
+ if ((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL)
+ return (XIC)NULL;
+
+ bzero((char *)ic, sizeof(XicRec));
+ ic->methods = &ic_methods;
+ ic->core.im = (XIM)im;
+ ic->core.input_style = input_style;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return (XIC)NULL;
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.proto.ic_resources = res;
+ ic->private.proto.ic_num_resources = num;
+
+#ifdef XIM_CONNECTABLE
+ if (!_XimSaveICValues(ic, arg))
+ return False;
+
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (!_XimConnectServer(im)) {
+ if (_XimDelayModeCreateIC(ic, arg, res, num)) {
+ return (XIC)ic;
+ }
+ goto ErrorOnCreatingIC;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ ic->core.filter_events = im->private.proto.forward_event_mask;
+ ic->private.proto.forward_event_mask =
+ im->private.proto.forward_event_mask;
+ ic->private.proto.synchronous_event_mask =
+ im->private.proto.synchronous_event_mask;
+
+ num = im->private.proto.ic_num_inner_resources;
+ len = sizeof(XIMResource) * num;
+ if (!(res = (XIMResourceList)Xmalloc(len)))
+ return (XIC)NULL;
+ (void)memcpy((char *)res,
+ (char *)im->private.proto.ic_inner_resources, len);
+ ic->private.proto.ic_inner_resources = res;
+ ic->private.proto.ic_num_inner_resources = num;
+
+ _XimSetICMode(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, input_style);
+
+ _XimSetICMode(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, input_style);
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if (_XimEncodeICATTRIBUTE(ic, ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources, arg, &arg_ret, data,
+ data_len, &ret_len, (XPointer)&ic_values, 0, XIM_CREATEIC)) {
+ goto ErrorOnCreatingIC;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ goto ErrorOnCreatingIC;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ goto ErrorOnCreatingIC;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ if (!(_XimCheckCreateICValues(ic->private.proto.ic_resources,
+ ic->private.proto.ic_num_resources)))
+ goto ErrorOnCreatingIC;
+
+ _XimRegisterFilter(ic);
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_CREATE_IC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ goto ErrorOnCreatingIC;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ ic->private.proto.waitCallback = True;
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCreateICCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimCreateICCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnCreatingIC;
+ }
+ }
+ } else {
+ ic->private.proto.waitCallback = False;
+ goto ErrorOnCreatingIC;
+ }
+ ic->private.proto.waitCallback = False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ goto ErrorOnCreatingIC;
+ }
+
+ ic->private.proto.icid = buf_s[1]; /* icid */
+ if(reply != preply)
+ Xfree(preply);
+ MARK_IC_CONNECTED(ic);
+ return (XIC)ic;
+
+ErrorOnCreatingIC:
+ if (ic->private.proto.ic_resources)
+ Xfree(ic->private.proto.ic_resources);
+ if (ic->private.proto.ic_inner_resources)
+ Xfree(ic->private.proto.ic_inner_resources);
+ Xfree(ic);
+ return (XIC)NULL;
+}
diff --git a/modules/im/ximcp/imDefIm.c b/modules/im/ximcp/imDefIm.c
new file mode 100644
index 00000000..2fca3f9e
--- /dev/null
+++ b/modules/im/ximcp/imDefIm.c
@@ -0,0 +1,2021 @@
+/* $Xorg: imDefIm.c,v 1.5 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+ Copyright 1990, 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, 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 Sun Microsystems, Inc., FUJITSU LIMITED and Sony
+Corporation not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc., FUJITSU LIMITED and Sony Corporation makes no
+representations about the suitability of this software for any purpose. It
+is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc., FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc.,
+FUJITSU LIMITED AND SONY CORPORATION 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "XimTrInt.h"
+#include "Ximint.h"
+
+Public int
+_XimCheckDataSize(buf, len)
+ XPointer buf;
+ int len;
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if(len < XIM_HEADER_SIZE)
+ return -1;
+ return buf_s[1];
+}
+
+Public void
+#if NeedFunctionPrototypes
+_XimSetHeader(
+ XPointer buf,
+ CARD8 major_opcode,
+ CARD8 minor_opcode,
+ INT16 *len
+)
+#else
+_XimSetHeader(buf, major_opcode, minor_opcode, len)
+ XPointer buf;
+ CARD8 major_opcode;
+ CARD8 minor_opcode;
+ INT16 *len;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD8 *buf_b = (CARD8 *)buf;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ buf_b[0] = major_opcode;
+ buf_b[1] = minor_opcode;
+ buf_s[1] = ((*len) / 4);
+ *len += XIM_HEADER_SIZE;
+ return;
+}
+
+Private char
+_XimGetMyEndian()
+{
+ CARD16 test_card = 1;
+
+ if(*((char *)&test_card))
+ return LITTLEENDIAN;
+ else
+ return BIGENDIAN;
+}
+
+Private Bool
+_XimCheckServerName(im, str)
+ Xim im;
+ char *str;
+{
+ char *server_name = im->core.im_name;
+ int len;
+ int str_len;
+ int category_len = strlen(XIM_SERVER_CATEGORY);
+ char *pp;
+ register char *p;
+
+ if(server_name && *server_name)
+ len = strlen(server_name);
+ else
+ return True;
+
+ if((int)strlen(str) < category_len)
+ return False;
+
+ if(strncmp(str, XIM_SERVER_CATEGORY, category_len))
+ return False;
+
+ pp = &str[category_len];
+
+ for(;;) {
+ for(p = pp; (*p != ',') && (*p); p++);
+ str_len = (int)(p - pp);
+
+ if((len == str_len) && (!strncmp(pp, server_name, len)))
+ break;
+ if(!(*p))
+ return False;
+ pp = p + 1;
+ }
+ return True;
+}
+
+Private char *
+_XimCheckLocaleName(im, address, address_len, locale_name, len)
+ Xim im;
+ char *address;
+ int address_len;
+ char *locale_name[];
+ int len;
+{
+ int category_len;
+ char *pp;
+ register char *p;
+ register int n;
+ Bool finish = False;
+
+ category_len = strlen(XIM_LOCAL_CATEGORY);
+ if(address_len < category_len)
+ return (char*)NULL;
+
+ if(strncmp(address, XIM_LOCAL_CATEGORY, category_len))
+ return (char*)NULL;
+
+ pp = &address[category_len];
+
+ for(;;) {
+ for( p = pp; *p && *p != ','; p++);
+ if (!*p)
+ finish = True;
+ address_len = (int)(p - pp);
+ *p = '\0';
+
+ for( n = 0; n < len; n++ )
+ if( locale_name[n] && !strcmp( pp, locale_name[n] ) )
+ return locale_name[n];
+ if (finish)
+ break;
+ pp = p + 1;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimCheckTransport(address, address_len, transport, len, trans_addr)
+ char *address;
+ int address_len;
+ char *transport;
+ int len;
+ char **trans_addr;
+{
+ int category_len = strlen(XIM_TRANSPORT_CATEGORY);
+ char *pp;
+ register char *p;
+
+ if(address_len < category_len)
+ return False;
+
+ if(strncmp(address, XIM_TRANSPORT_CATEGORY, category_len))
+ return False;
+
+ pp = &address[category_len];
+
+ for(;;) {
+ *trans_addr = pp;
+
+ for(p = pp; (*p != '/') && (*p != ',') && (*p); p++);
+ if(*p == ',') {
+ pp = p + 1;
+ continue;
+ }
+ if(!(*p))
+ return False;
+
+ address_len = (int)(p - pp);
+
+ if((len == address_len) && (!strncmp(pp, transport, len)))
+ break;
+ pp = p + 1;
+ }
+ pp = p + 1;
+ for(p = pp; (*p != ',') && (*p); p++);
+ if (*p)
+ *p = '\0';
+ return True;
+}
+
+Private Bool
+_CheckSNEvent(display, xevent, arg)
+ Display *display;
+ XEvent *xevent;
+ XPointer arg;
+{
+ XSelectionEvent *event = (XSelectionEvent *)xevent;
+ Window window = *(Window*)arg;
+
+ if((event->type == SelectionNotify) && (window == event->requestor))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimGetSelectionNotify(display, window, target, ret_address)
+ Display *display;
+ Window window;
+ Atom target;
+ char **ret_address;
+{
+ XEvent event;
+ XSelectionEvent *ev = (XSelectionEvent *)&event;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+
+ for(;;) {
+ XIfEvent(display, &event, _CheckSNEvent, (XPointer)&window);
+ if((ev->type == SelectionNotify) && (window == ev->requestor))
+ break;
+ }
+
+ if(ev->property == (Atom)None)
+ return False;
+ if( XGetWindowProperty( display, window, target, 0L, 1000000L,
+ True, target, &actual_type, &actual_format,
+ &nitems, &bytes_after,
+ (unsigned char **)&*ret_address ) != Success )
+ return False;
+ return True;
+}
+
+Private Bool
+_XimPreConnectionIM(im, selection)
+ Xim im;
+ Atom selection;
+{
+ Display *display = im->core.display;
+ Atom locales, transport;
+ char *address;
+ XLCd lcd;
+ char *language;
+ char *territory;
+ char *codeset;
+ char *trans_addr;
+ char *locale_name[4], *locale;
+ int llen, tlen, clen;
+ register int i;
+ Window window;
+ char *str;
+
+ if(!(lcd = im->core.lcd))
+ return False;
+
+ for( i = 0; i < 4; i++ )
+ locale_name[i] = NULL;
+ /* requestor window */
+ if(!(window = XCreateSimpleWindow(display, DefaultRootWindow(display),
+ 0, 0, 1, 1, 1, 0, 0)))
+ return False;
+
+ /* server name check */
+ if( !(str = XGetAtomName( display, selection )) )
+ return False;
+ if(!_XimCheckServerName(im, str)) {
+ XFree( (XPointer)str );
+ goto Error;
+ }
+ XFree( (XPointer)str );
+
+ /* locale name check */
+ _XGetLCValues(lcd, XlcNLanguage, &language, XlcNTerritory, &territory,
+ XlcNCodeset, &codeset, NULL);
+ llen = strlen( language );
+ tlen = territory ? strlen( territory ): 0;
+ clen = codeset ? strlen( codeset ): 0;
+
+ if( tlen != 0 && clen != 0 ) {
+ if( (locale_name[0] = Xmalloc(llen+tlen+clen+3)) != NULL )
+ sprintf( locale_name[0], "%s_%s.%s", language, territory, codeset );
+ }
+ if( clen != 0 ) {
+ if( (locale_name[1] = Xmalloc(llen+clen+2)) != NULL )
+ sprintf( locale_name[1], "%s.%s", language, codeset );
+ else
+ goto Error;
+ }
+ if( tlen != 0 ) {
+ if( (locale_name[2] = Xmalloc(llen+tlen+2)) != NULL )
+ sprintf( locale_name[2], "%s_%s", language, territory );
+ else
+ goto Error;
+ }
+ if( (locale_name[3] = Xmalloc(llen+1)) != NULL )
+ strcpy( locale_name[3], language );
+ else
+ goto Error;
+ if((locales = XInternAtom(display, XIM_LOCALES, True)) == (Atom)None)
+ goto Error;
+
+ XConvertSelection(display, selection, locales, locales, window,
+ CurrentTime);
+ if(!(_XimGetSelectionNotify(display, window, locales, &address)))
+ goto Error;
+
+ if((locale = _XimCheckLocaleName(im, address, strlen(address), locale_name,
+ 4)) == NULL) {
+ XFree((XPointer)address);
+ goto Error;
+ }
+ im->private.proto.locale_name = locale;
+ for( i = 0; i < 4; i++ ) {
+ if( locale_name[i] != NULL && locale_name[i] != locale ) {
+ XFree( locale_name[i] );
+ locale_name[i] = NULL;
+ }
+ }
+ XFree((XPointer)address);
+
+ /* transport check */
+ if((transport = XInternAtom(display, XIM_TRANSPORT, True)) == (Atom)None)
+ goto Error;
+
+ XConvertSelection(display, selection, transport, transport, window,
+ CurrentTime);
+ if(!_XimGetSelectionNotify(display, window, transport, &address))
+ goto Error;
+
+ for(i = 0; _XimTransportRec[i].transportname ; i++) {
+ if( _XimCheckTransport(address, strlen(address),
+ _XimTransportRec[i].transportname,
+ strlen(_XimTransportRec[i].transportname),
+ &trans_addr)) {
+ if( _XimTransportRec[i].config(im, trans_addr) ) {
+ XFree((XPointer)address);
+ XDestroyWindow(display, window);
+ return True;
+ }
+ }
+ }
+
+ XFree((XPointer)address);
+Error:
+ for( i = 0; i < 4; i++ )
+ if( locale_name[i] != NULL )
+ XFree( locale_name[i] );
+ XDestroyWindow(display, window);
+ return False;
+}
+
+Private Bool
+_XimPreConnect(im)
+ Xim im;
+{
+ Display *display = im->core.display;
+ Atom imserver;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long bytes_after;
+ unsigned char *prop_return;
+ Atom *atoms;
+ Window im_window;
+ register int i;
+
+ if((imserver = XInternAtom(display, XIM_SERVERS, True)) == (Atom)None)
+ return False;
+
+ if(XGetWindowProperty(display, RootWindow(display, 0),
+ imserver, 0L, 1000000L, False, XA_ATOM, &actual_type,
+ &actual_format, &nitems, &bytes_after,
+ &prop_return) != Success)
+ return False;
+
+ if( (actual_type != XA_ATOM) || (actual_format != 32) ) {
+ if( nitems )
+ XFree((XPointer)prop_return);
+ return False;
+ }
+
+ atoms = (Atom *)prop_return;
+ for(i = 0; i < nitems; i++) {
+ if((im_window = XGetSelectionOwner(display, atoms[i])) == (Window)None)
+ continue;
+
+ if(_XimPreConnectionIM(im, atoms[i]))
+ break;
+ }
+
+ XFree((XPointer)prop_return);
+ if(i >= nitems)
+ return False;
+
+ im->private.proto.im_window = im_window;
+ return True;
+}
+
+Private Bool
+_XimGetAuthProtocolNames(im, buf, num, len)
+ Xim im;
+ CARD16 *buf;
+ CARD8 *num;
+ INT16 *len;
+{
+ if (!IS_USE_AUTHORIZATION_FUNC(im)) {
+ *num = 0;
+ *len = 0;
+ return True;
+ }
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimSetAuthReplyData(im, buf, len)
+ Xim im;
+ XPointer buf;
+ INT16 *len;
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimSetAuthNextData(im, buf, len)
+ Xim im;
+ XPointer buf;
+ INT16 *len;
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimSetAuthRequiredData(im, buf, len)
+ Xim im;
+ XPointer buf;
+ INT16 *len;
+{
+ /*
+ * Not yet
+ */
+ *len = 0;
+ return True;
+}
+
+Private Bool
+_XimCheckAuthSetupData(im, buf)
+ Xim im;
+ XPointer buf;
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimCheckAuthNextData(im, buf)
+ Xim im;
+ XPointer buf;
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+#define NO_MORE_AUTH 2
+#define GOOD_AUTH 1
+#define BAD_AUTH 0
+
+Private int
+_XimClientAuthCheck(im, buf)
+ Xim im;
+ XPointer buf;
+{
+ /*
+ * Not yet
+ */
+ return NO_MORE_AUTH;
+}
+
+Private void
+_XimAuthNG(im)
+ Xim im;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 len = 0;
+
+ _XimSetHeader((XPointer)buf, XIM_AUTH_NG, 0, &len);
+ (void)_XimWrite(im, len, (XPointer)buf);
+ _XimFlush(im);
+ return;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimAllRecv(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimAllRecv(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ return True;
+}
+
+#define CLIENT_WAIT1 1
+#define CLIENT_WAIT2 2
+
+Private Bool
+_XimConnection(im)
+ Xim im;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s = (CARD16 *)((XPointer)buf_b);
+ INT16 len;
+ CARD8 num;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ CARD8 major_opcode;
+ int wait_mode;
+ int ret;
+
+ if(!(_XimConnect(im))) /* Transport Connect */
+ return False;
+
+ if(!_XimDispatchInit(im))
+ return False;
+
+ _XimRegProtoIntrCallback(im, XIM_ERROR, 0, _XimErrorCallback, (XPointer)im);
+
+ if(!_XimGetAuthProtocolNames(im, &buf_s[4], &num, &len))
+ return False;
+
+ im->private.proto.protocol_major_version = PROTOCOLMAJORVERSION;
+ im->private.proto.protocol_minor_version = PROTOCOLMINORVERSION;
+
+ buf_b[0] = _XimGetMyEndian();
+ buf_b[1] = 0;
+ buf_s[1] = PROTOCOLMAJORVERSION;
+ buf_s[2] = PROTOCOLMINORVERSION;
+ buf_s[3] = num;
+ len += sizeof(CARD8)
+ + sizeof(CARD8)
+ + sizeof(CARD16)
+ + sizeof(CARD16)
+ + sizeof(CARD16);
+
+ major_opcode = XIM_CONNECT;
+ wait_mode = (IS_USE_AUTHORIZATION_FUNC(im)) ? CLIENT_WAIT1 : CLIENT_WAIT2;
+
+ for(;;) {
+ _XimSetHeader((XPointer)buf, major_opcode, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, reply, buf_size, _XimAllRecv, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size, _XimAllRecv, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+
+ major_opcode = *((CARD8 *)preply);
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+
+ if (wait_mode == CLIENT_WAIT1) {
+ if (major_opcode == XIM_AUTH_REQUIRED) {
+ ret = _XimClientAuthCheck(im, (XPointer)buf_s);
+ if(reply != preply)
+ Xfree(preply);
+ if (ret == NO_MORE_AUTH) {
+ if (!(_XimSetAuthReplyData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REPLY;
+ wait_mode = CLIENT_WAIT2;
+ } else if (ret == GOOD_AUTH) {
+ if (!(_XimSetAuthNextData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_NEXT;
+ } else { /* BAD_AUTH */
+ _XimAuthNG(im);
+ return False;
+ }
+ } else {
+ if(reply != preply)
+ Xfree(preply);
+ _XimAuthNG(im);
+ return False;
+ }
+ } else { /* CLIENT_WAIT2 */
+ if (major_opcode == XIM_CONNECT_REPLY) {
+ break;
+ } else if (major_opcode == XIM_AUTH_SETUP) {
+ if (!(_XimCheckAuthSetupData(im, (XPointer)buf_s))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ if (!(_XimSetAuthRequiredData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REQUIRED;
+ } else if (major_opcode == XIM_AUTH_NEXT) {
+ if (!(_XimCheckAuthNextData(im, (XPointer)buf_s))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ if (!(_XimSetAuthRequiredData(im,
+ (XPointer)&buf[XIM_HEADER_SIZE], &len))) {
+ _XimAuthNG(im);
+ return False;
+ }
+ major_opcode = XIM_AUTH_REQUIRED;
+ } else if (major_opcode == XIM_AUTH_NG) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ } else {
+ _XimAuthNG(im);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ }
+ }
+
+ if (!( buf_s[0] == im->private.proto.protocol_major_version
+ && buf_s[1] == im->private.proto.protocol_minor_version)) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ MARK_SERVER_CONNECTED(im);
+
+ _XimRegProtoIntrCallback(im, XIM_REGISTER_TRIGGERKEYS, 0,
+ _XimRegisterTriggerKeysCallback, (XPointer)im);
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimDisconnectCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimDisconnectCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ if ((major_opcode == XIM_DISCONNECT_REPLY)
+ && (minor_opcode == 0))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimDisconnect(im)
+ Xim im;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ INT16 len = 0;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (IS_SERVER_CONNECTED(im)) {
+ _XimSetHeader((XPointer)buf, XIM_DISCONNECT, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimDisconnectCheck, 0);
+ if(ret_code == XIM_OVERFLOW) {
+ if(len > 0) {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimDisconnectCheck, 0);
+ Xfree(preply);
+ if(ret_code != XIM_TRUE)
+ return False;
+ }
+ } else if(ret_code == XIM_FALSE)
+ return False;
+
+ }
+ if (!(_XimShutdown(im))) /* Transport shutdown */
+ return False;
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimOpenCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimOpenCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ if ((major_opcode == XIM_OPEN_REPLY)
+ && (minor_opcode == 0))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimOpen(im)
+ Xim im;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ char *locale_name;
+
+ locale_name = im->private.proto.locale_name;
+ len = strlen(locale_name);
+ buf_b[0] = (BYTE)len; /* length of locale name */
+ (void)strcpy((char *)&buf_b[1], locale_name); /* locale name */
+ len += sizeof(BYTE); /* sizeof length */
+ XIM_SET_PAD(buf_b, len); /* pad */
+
+ _XimSetHeader((XPointer)buf, XIM_OPEN, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimOpenCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimOpenCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ im->private.proto.imid = buf_s[0]; /* imid */
+
+ if (!(_XimGetAttributeID(im, &buf_s[1]))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ if (!(_XimSetInnerIMResourceList(&(im->private.proto.im_inner_resources),
+ &(im->private.proto.im_num_inner_resources))))
+ return False;
+
+ if (!(_XimSetInnerICResourceList(&(im->private.proto.ic_inner_resources),
+ &(im->private.proto.ic_num_inner_resources))))
+ return False;
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+ _XimSetIMMode(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources);
+
+ /* Transport Callbak */
+ _XimRegProtoIntrCallback(im, XIM_SET_EVENT_MASK, 0,
+ _XimSetEventMaskCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_FORWARD_EVENT, 0,
+ _XimForwardEventCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_COMMIT, 0,
+ _XimCommitCallback, (XPointer)im);
+ _XimRegProtoIntrCallback(im, XIM_SYNC, 0,
+ _XimSyncCallback, (XPointer)im);
+
+ if(!_XimExtension(im))
+ return False;
+
+ /* register a hook for callback protocols */
+ _XimRegisterDispatcher(im, _XimCbDispatch, (XPointer)im);
+
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimCloseCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimCloseCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_CLOSE_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimClose(im)
+ Xim im;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return True;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = 0; /* unused */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof unused */
+
+ _XimSetHeader((XPointer)buf, XIM_CLOSE, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimCloseCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size, _XimCloseCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Public void
+_XimProtoIMFree(im)
+ Xim im;
+{
+ /* XIMPrivateRec */
+ if (im->private.proto.im_onkeylist) {
+ Xfree(im->private.proto.im_onkeylist);
+ im->private.proto.im_onkeylist = NULL;
+ }
+ if (im->private.proto.im_offkeylist) {
+ Xfree(im->private.proto.im_offkeylist);
+ im->private.proto.im_offkeylist = NULL;
+ }
+ if (im->private.proto.intrproto) {
+ _XimFreeProtoIntrCallback(im);
+ im->private.proto.intrproto = NULL;
+ }
+ if (im->private.proto.im_inner_resources) {
+ Xfree(im->private.proto.im_inner_resources);
+ im->private.proto.im_inner_resources = NULL;
+ }
+ if (im->private.proto.ic_inner_resources) {
+ Xfree(im->private.proto.ic_inner_resources);
+ im->private.proto.ic_inner_resources = NULL;
+ }
+ if (im->private.proto.hold_data) {
+ Xfree(im->private.proto.hold_data);
+ im->private.proto.hold_data = NULL;
+ }
+ if (im->private.proto.locale_name) {
+ Xfree(im->private.proto.locale_name);
+ im->private.proto.locale_name = NULL;
+ }
+ if (im->private.proto.ctom_conv) {
+ _XlcCloseConverter(im->private.proto.ctom_conv);
+ im->private.proto.ctom_conv = NULL;
+ }
+ if (im->private.proto.ctow_conv) {
+ _XlcCloseConverter(im->private.proto.ctow_conv);
+ im->private.proto.ctow_conv = NULL;
+ }
+
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ return;
+ }
+#endif /* XIM_CONNECTABLE */
+
+ if (im->private.proto.saved_imvalues) {
+ Xfree(im->private.proto.saved_imvalues);
+ im->private.proto.saved_imvalues = NULL;
+ }
+ if (im->private.proto.default_styles) {
+ Xfree(im->private.proto.default_styles);
+ im->private.proto.default_styles = NULL;
+ }
+
+ /* core */
+ if (im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if (im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if (im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ if (im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+
+ return;
+}
+
+Private Status
+_XimProtoCloseIM(xim)
+ XIM xim;
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+ Status status;
+
+ ic = im->core.ic_chain;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+#ifdef XIM_CONNECTABLE
+ if (!(!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im))) {
+ Xfree ((char *) ic);
+ }
+#else
+ Xfree ((char *) ic);
+#endif /* XIM_CONNECTABLE */
+ ic = next;
+ }
+ _XimUnregisterServerFilter(im);
+ _XimResetIMInstantiateCallback(im);
+ status = (Status)_XimClose(im);
+ status = (Status)_XimDisconnect(im) && status;
+ _XimProtoIMFree(im);
+#ifdef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im) && IS_RECONNECTABLE(im)) {
+ _XimReconnectModeSetAttr(im);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ _XimReconnectModeCreateIC(ic);
+ }
+ return 0;
+ }
+#endif /* XIM_CONNECTABLE */
+ _XimDestroyIMStructureList(im);
+ return status;
+}
+
+Private Bool
+_XimCheckIMQuarkList(quark_list, num_quark, quark)
+ XrmQuark *quark_list;
+ int num_quark;
+ XrmQuark quark;
+{
+ register int i;
+
+ for (i = 0; i < num_quark; i++) {
+ if (quark_list[i] == quark) {
+ return True;
+ }
+ }
+ return False;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimSaveIMValues(im, arg)
+ Xim im;
+ XIMArg *arg;
+{
+ register XIMArg *p;
+ register int n;
+ XrmQuark *quark_list;
+ XrmQuark *tmp;
+ XrmQuark quark;
+ int num_quark;
+
+ if (quark_list = im->private.proto.saved_imvalues) {
+ num_quark = im->private.proto.num_saved_imvalues;
+ for (p = arg; p && p->name; p++) {
+ quark = XrmStringToQuark(p->name);
+ if (_XimCheckIMQuarkList(quark_list, num_quark, quark)) {
+ continue;
+ }
+ if (!(tmp = (XrmQuark *)Xrealloc(quark_list,
+ (sizeof(XrmQuark) * (num_quark + 1))))) {
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = num_quark;
+ return False;
+ }
+ num_quark++;
+ quark_list = tmp;
+ quark_list[num_quark] = quark;
+ }
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = num_quark;
+ return True;
+ }
+
+ for (p = arg, n = 0; p && p->name; p++, n++);
+
+ if (!(quark_list = (XrmQuark *)Xmalloc(sizeof(XrmQuark) * n))) {
+ return False;
+ }
+
+ im->private.proto.saved_imvalues = quark_list;
+ im->private.proto.num_saved_imvalues = n;
+ for (p = arg; p && p->name; p++, quark_list++) {
+ *quark_list = XrmStringToQuark(p->name);
+ }
+
+ return True;
+}
+
+Private char *
+_XimDelayModeSetIMValues(im, arg)
+ Xim im;
+ XIMArg *arg;
+{
+ XimDefIMValues im_values;
+ char *name;
+ XIMArg *values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ name = _XimSetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources);
+ _XimSetCurrentIMValues(im, &im_values);
+
+ return name;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimSetIMValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimSetIMValuesCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_SET_IM_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoSetIMValues(xim, arg)
+ XIM xim;
+ XIMArg *arg;
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ XIMArg *arg_ret;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+ char *name;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im))
+ return arg->name;
+#else
+ if (!_XimSaveIMValues(im, arg))
+ return arg->name;
+
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (IS_CONNECTABLE(im)) {
+ if (!_XimConnectServer(im)) {
+ return _XimDelayModeSetIMValues(im, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ _XimGetCurrentIMValues(im, &im_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ arg_ret = arg;
+ for (;;) {
+ data = &buf[buf_size];
+ if ((name = _XimEncodeIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, arg, &arg_ret, data, data_len,
+ &ret_len, (XPointer)&im_values, XIM_SETIMVALUES))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ break;
+ }
+
+ total += ret_len;
+ if (!(arg = arg_ret)) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return arg->name;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ buf = tmp;
+ }
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!total)
+ return (char *)NULL;
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_SET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else
+ return arg->name;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ return name;
+}
+
+#ifdef XIM_CONNECTABLE
+Private char *
+_XimDelayModeGetIMValues(im, arg)
+ Xim im;
+ XIMArg *arg;
+{
+ XimDefIMValues im_values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return(_XimGetIMValueData(im, (XPointer)&im_values, arg,
+ im->core.im_resources, im->core.im_num_resources));
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimGetIMValuesCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimGetIMValuesCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_GET_IM_VALUES_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private char *
+_XimProtoGetIMValues(xim, arg)
+ XIM xim;
+ XIMArg *arg;
+{
+ Xim im = (Xim)xim;
+ register XIMArg *p;
+ register int n;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ char *makeid_name;
+ char *decode_name;
+ CARD16 *data = NULL;
+ INT16 data_len = 0;
+
+#ifndef XIM_CONNECTABLE
+ if (!IS_SERVER_CONNECTED(im))
+ return arg->name;
+#else
+ if (!IS_SERVER_CONNECTED(im)) {
+ if (IS_CONNECTABLE(im)) {
+ if (!_XimConnectServer(im)) {
+ return _XimDelayModeGetIMValues(im, arg);
+ }
+ } else {
+ return arg->name;
+ }
+ }
+#endif /* XIM_CONNECTABLE */
+
+ for (n = 0, p = arg; p->name; p++)
+ n++;
+
+ if (!n)
+ return (char *)NULL;
+
+ buf_size = sizeof(CARD16) * n;
+ buf_size += XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + XIM_PAD(buf_size);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_size)))
+ return arg->name;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ makeid_name = _XimMakeIMAttrIDList(im, im->core.im_resources,
+ im->core.im_num_resources, arg,
+ &buf_s[2], &len, XIM_GETIMVALUES);
+
+ if (len) {
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = len; /* length of im-attr-id */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(INT16); /* sizeof length of attr */
+
+ _XimSetHeader((XPointer)buf, XIM_GET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return arg->name;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimGetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimGetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return arg->name;
+ }
+ }
+ } else
+ return arg->name;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return arg->name;
+ }
+ data = &buf_s[2];
+ data_len = buf_s[1];
+ }
+ decode_name = _XimDecodeIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, data, data_len,
+ arg, XIM_GETIMVALUES);
+ if (reply != preply)
+ Xfree(preply);
+
+ if (decode_name)
+ return decode_name;
+ else
+ return makeid_name;
+}
+
+Private XIMMethodsRec im_methods = {
+ _XimProtoCloseIM, /* close */
+ _XimProtoSetIMValues, /* set_values */
+ _XimProtoGetIMValues, /* get_values */
+ _XimProtoCreateIC, /* create_ic */
+ _Ximctstombs, /* ctstombs */
+ _Ximctstowcs /* ctstowcs */
+};
+
+Private Bool
+_XimSetEncodingByName(im, buf, len)
+ Xim im;
+ char **buf;
+ int *len;
+{
+ char *encoding = (char *)NULL;
+ int encoding_len;
+ int compound_len;
+ BYTE *ret;
+
+ _XGetLCValues(im->core.lcd, XlcNCodeset, &encoding, NULL);
+ if (!encoding) {
+ *buf = (char *)NULL;
+ *len = 0;
+ return True;
+ }
+ encoding_len = strlen(encoding);
+ compound_len = strlen("COMPOUND_TEXT");
+ *len = encoding_len + sizeof(BYTE) + compound_len + sizeof(BYTE);
+ if (!(ret = (BYTE *)Xmalloc(*len))) {
+ return False;
+ }
+ *buf = (char *)ret;
+
+ ret[0] = (BYTE)encoding_len;
+ (void)strncpy((char *)&ret[1], encoding, encoding_len);
+ ret += (encoding_len + sizeof(BYTE));
+ ret[0] = (BYTE)compound_len;
+ (void)strncpy((char *)&ret[1], "COMPOUND_TEXT", compound_len);
+ return True;
+}
+
+Private Bool
+_XimSetEncodingByDetail(im, buf, len)
+ Xim im;
+ char **buf;
+ int *len;
+{
+ *len = 0;
+ *buf = NULL;
+ return True;
+}
+
+Private Bool
+_XimGetEncoding(im, buf, name, name_len, detail, detail_len)
+ Xim im;
+ CARD16 *buf;
+ char *name;
+ int name_len;
+ char *detail;
+ int detail_len;
+{
+ XLCd lcd = im->core.lcd;
+ CARD16 category = buf[0];
+ CARD16 idx = buf[1];
+ int len;
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+
+ if (idx == (CARD16)XIM_Default_Encoding_IDX) { /* XXX */
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ return False;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ return False;
+ }
+
+ if (category == XIM_Encoding_NameCategory) {
+ while (name_len > 0) {
+ len = (int)name[0];
+ if (!strncmp(&name[1], "COMPOUND_TEXT", len)) {
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ return False;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ return False;
+ break;
+ } else {
+ /*
+ * Not yet
+ */
+ }
+ len += sizeof(BYTE);
+ name_len -= len;
+ name += len;
+ }
+ } else if (category == XIM_Encoding_DetailCategory) {
+ /*
+ * Not yet
+ */
+ } else {
+ return False;
+ }
+ im->private.proto.ctom_conv = ctom_conv;
+ im->private.proto.ctow_conv = ctow_conv;
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimEncodingNegoCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimEncodingNegoCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_ENCODING_NEGOTIATION_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Private Bool
+_XimEncodingNegotiation(im)
+ Xim im;
+{
+ char *name_ptr = 0;
+ int name_len = 0;
+ char *detail_ptr = 0;
+ int detail_len = 0;
+ CARD8 *buf;
+ CARD16 *buf_s;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ if (!(_XimSetEncodingByName(im, &name_ptr, &name_len)))
+ return False;
+
+ if (!(_XimSetEncodingByDetail(im, &detail_ptr, &detail_len))) {
+ if (name_ptr)
+ Xfree(name_ptr);
+ return False;
+ }
+
+ len = sizeof(CARD16)
+ + sizeof(INT16)
+ + name_len
+ + XIM_PAD(name_len)
+ + sizeof(INT16)
+ + sizeof(CARD16)
+ + detail_len;
+
+ if (!(buf = (CARD8 *)Xmalloc(XIM_HEADER_SIZE + len))) {
+ if (name_ptr)
+ Xfree(name_ptr);
+ if (detail_ptr)
+ Xfree(detail_ptr);
+ return False;
+ }
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)name_len;
+ if (name_ptr)
+ (void)memcpy((char *)&buf_s[2], name_ptr, name_len);
+ XIM_SET_PAD(&buf_s[2], name_len);
+ buf_s = (CARD16 *)((char *)&buf_s[2] + name_len);
+ buf_s[0] = detail_len;
+ buf_s[1] = 0;
+ if (detail_ptr)
+ (void)memcpy((char *)&buf_s[2], detail_ptr, detail_len);
+
+ _XimSetHeader((XPointer)buf, XIM_ENCODING_NEGOTIATION, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ Xfree(buf);
+ return False;
+ }
+ _XimFlush(im);
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimEncodingNegoCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimEncodingNegoCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if (!(_XimGetEncoding(im, &buf_s[1], name_ptr, name_len,
+ detail_ptr, detail_len))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if (name_ptr)
+ Xfree(name_ptr);
+ if (detail_ptr)
+ Xfree(detail_ptr);
+
+ if(reply != preply)
+ Xfree(preply);
+
+ return True;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimSendSavedIMValues(im)
+ Xim im;
+{
+ XimDefIMValues im_values;
+ INT16 len;
+ CARD16 *buf_s;
+ char *tmp;
+ CARD32 tmp_buf32[BUFSIZE/4];
+ char *tmp_buf = (char *)tmp_buf32;
+ char *buf;
+ int buf_size;
+ char *data;
+ int data_len;
+ int ret_len;
+ int total;
+ int idx;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int ret_code;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ buf = tmp_buf;
+ buf_size = XIM_HEADER_SIZE + sizeof(CARD16) + sizeof(INT16);
+ data_len = BUFSIZE - buf_size;
+ total = 0;
+ idx = 0;
+ for (;;) {
+ data = &buf[buf_size];
+ if (!_XimEncodeSavedIMATTRIBUTE(im, im->core.im_resources,
+ im->core.im_num_resources, &idx, data, data_len,
+ &ret_len, (XPointer)&im_values, XIM_SETIMVALUES)) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return False;
+ }
+
+ total += ret_len;
+ if (idx == -1) {
+ break;
+ }
+
+ buf_size += ret_len;
+ if (buf == tmp_buf) {
+ if (!(tmp = (char *)Xmalloc(buf_size + data_len))) {
+ return False;
+ }
+ memcpy(tmp, buf, buf_size);
+ buf = tmp;
+ } else {
+ if (!(tmp = (char *)Xrealloc(buf, (buf_size + data_len)))) {
+ Xfree(buf);
+ return False;
+ }
+ buf = tmp;
+ }
+ }
+
+ if (!total)
+ return True;
+
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ buf_s[0] = im->private.proto.imid;
+ buf_s[1] = (INT16)total;
+
+ len = (INT16)(sizeof(CARD16) + sizeof(INT16) + total);
+ _XimSetHeader((XPointer)buf, XIM_SET_IM_VALUES, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf))) {
+ if (buf != tmp_buf)
+ Xfree(buf);
+ return False;
+ }
+ _XimFlush(im);
+ if (buf != tmp_buf)
+ Xfree(buf);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimSetIMValuesCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ return True;
+}
+
+Private void
+_XimDelayModeIMFree(im)
+ Xim im;
+{
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ return;
+}
+
+Public Bool
+_XimConnectServer(im)
+ Xim im;
+{
+ Xim save_im;
+
+ if (!(save_im = (Xim)Xmalloc(sizeof(XimRec))))
+ return False;
+ memcpy((char *)save_im, (char *)im, sizeof(XimRec));
+
+ if (_XimPreConnect(im) && _XimConnection(im)
+ && _XimOpen(im) && _XimEncodingNegotiation(im)) {
+ if (_XimSendSavedIMValues(im)) {
+ _XimDelayModeIMFree(save_im);
+ _XimRegisterServerFilter(im);
+ Xfree(save_im);
+ return True;
+ }
+ }
+ memcpy((char *)im, (char *)save_im, sizeof(XimRec));
+ Xfree(save_im);
+ return False;
+}
+
+Public Bool
+_XimDelayModeSetAttr(im)
+ Xim im;
+{
+ XimDefIMValues im_values;
+
+ if(!_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources)) {
+ return False;
+ }
+ if(!_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources)) {
+ return False;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(!_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources)) {
+ return False;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+ if (im->private.proto.default_styles) {
+ if (im->core.styles)
+ Xfree(im->core.styles);
+ im->core.styles = im->private.proto.default_styles;
+ }
+
+ return True;
+}
+
+Private Bool
+_XimReconnectModeSetAttr(im)
+ Xim im;
+{
+ XimDefIMValues im_values;
+
+ if(!_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources)) {
+ return False;
+ }
+ if(!_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources)) {
+ return False;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ if (im->private.proto.default_styles) {
+ if (im->core.styles)
+ Xfree(im->core.styles);
+ im->core.styles = im->private.proto.default_styles;
+ }
+
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Public Bool
+_XimProtoOpenIM(im)
+ Xim im;
+{
+ _XimInitialResourceInfo();
+
+ im->methods = &im_methods;
+
+#ifdef XIM_CONNECTABLE
+ _XimSetProtoResource(im);
+#endif /* XIM_CONNECTABLE */
+
+ if (_XimPreConnect(im)) {
+ if (_XimConnection(im) && _XimOpen(im) && _XimEncodingNegotiation(im)) {
+ _XimRegisterServerFilter(im);
+ return True;
+ }
+#ifdef XIM_CONNECTABLE
+ } else if (IS_DELAYBINDABLE(im)) {
+ if (_XimDelayModeSetAttr(im))
+ return True;
+#endif /* XIM_CONNECTABLE */
+ }
+ _XimProtoIMFree(im);
+ return False;
+}
diff --git a/modules/im/ximcp/imDefLkup.c b/modules/im/ximcp/imDefLkup.c
new file mode 100644
index 00000000..8653a07c
--- /dev/null
+++ b/modules/im/ximcp/imDefLkup.c
@@ -0,0 +1,1186 @@
+/* $Xorg: imDefLkup.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public Xic
+#if NeedFunctionPrototypes
+_XimICOfXICID(
+ Xim im,
+ XICID icid)
+#else
+_XimICOfXICID(im, icid)
+ Xim im;
+ XICID icid;
+#endif /* NeedFunctionPrototypes */
+{
+ Xic pic;
+
+ for (pic = (Xic)im->core.ic_chain; pic; pic = (Xic)pic->core.next) {
+ if (pic->private.proto.icid == icid)
+ return pic;
+ }
+ return (Xic)0;
+}
+
+Private void
+_XimProcIMSetEventMask(im, buf)
+ Xim im;
+ XPointer buf;
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+
+ im->private.proto.forward_event_mask = buf_l[0];
+ im->private.proto.synchronous_event_mask = buf_l[1];
+ return;
+}
+
+Private void
+_XimProcICSetEventMask(ic, buf)
+ Xic ic;
+ XPointer buf;
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+
+ ic->private.proto.forward_event_mask = buf_l[0];
+ ic->private.proto.synchronous_event_mask = buf_l[1];
+ _XimReregisterFilter(ic);
+ return;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimSetEventMaskCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimSetEventMaskCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if (imid == im->private.proto.imid) {
+ if (icid) {
+ ic = _XimICOfXICID(im, icid);
+ _XimProcICSetEventMask(ic, (XPointer)&buf_s[2]);
+ } else {
+ _XimProcIMSetEventMask(im, (XPointer)&buf_s[2]);
+ }
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimSyncCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimSyncCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SYNC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimSync(im, ic)
+ Xim im;
+ Xic ic;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SYNC, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Public Bool
+_XimProcSyncReply(im, ic)
+ Xim im;
+ Xic ic;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16); /* sizeof icid */
+
+ _XimSetHeader((XPointer)buf, XIM_SYNC_REPLY, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+Public Bool
+_XimRespSyncReply(ic, mode)
+ Xic ic;
+ BITMASK16 mode;
+{
+ if (mode & XimSYNCHRONUS) /* SYNC Request */
+ MARK_NEED_SYNC_REPLY(ic);
+ return True;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimSyncCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimSyncCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcSyncReply(im, ic);
+ return True;
+ }
+ return False;
+}
+
+Private INT16
+_XimSetEventToWire(ev, event)
+ XEvent *ev;
+ xEvent *event;
+{
+ if (!(_XimProtoEventToWire(ev, event, False)))
+ return 0;
+ event->u.u.sequenceNumber =
+ ((XAnyEvent *)ev)->serial & (unsigned long)0xffff;
+ return sz_xEvent;
+}
+
+Private Bool
+_XimForwardEventCore(ic, ev, sync)
+ Xic ic;
+ XEvent *ev;
+ Bool sync;
+{
+ Xim im = (Xim)ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+
+ if (!(len = _XimSetEventToWire(ev, (xEvent *)&buf_s[4])))
+ return False; /* X event */
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */
+ buf_s[3] =
+ (CARD16)((((XAnyEvent *)ev)->serial & ~((unsigned long)0xffff)) >> 16);
+ /* serial number */
+
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16); /* sizeof serila number */
+
+ _XimSetHeader((XPointer)buf, XIM_FORWARD_EVENT, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+
+ if (sync) {
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimSyncCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ }
+ return True;
+}
+
+Public Bool
+_XimForwardEvent(ic, ev, sync)
+ Xic ic;
+ XEvent *ev;
+ Bool sync;
+{
+#ifdef EXT_FORWARD
+ if (((ev->type == KeyPress) || (ev->type == KeyRelease)))
+ if (_XimExtForwardKeyEvent(ic, (XKeyEvent *)ev, sync))
+ return True;
+#endif
+ return _XimForwardEventCore(ic, ev, sync);
+}
+
+Private void
+_XimProcEvent(d, ic, ev, buf)
+ Display *d;
+ Xic ic;
+ XEvent *ev;
+ CARD16 *buf;
+{
+ INT16 serial = buf[0];
+ xEvent *xev = (xEvent *)&buf[1];
+
+ _XimProtoWireToEvent(ev, xev, False);
+ ev->xany.serial |= serial << 16;
+ ev->xany.send_event = False;
+ ev->xany.display = d;
+ MARK_FABLICATED(ic);
+ return;
+}
+
+Private Bool
+_XimForwardEventRecv(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ Display *d = im->core.display;
+ XEvent ev;
+
+ _XimProcEvent(d, ic, &ev, &buf_s[1]);
+
+ (void)_XimRespSyncReply(ic, buf_s[0]);
+
+ XPutBackEvent(d, &ev);
+
+ return True;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimForwardEventCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimForwardEventCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimForwardEventRecv(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimRegisterTriggerkey(im, buf)
+ Xim im;
+ XPointer buf;
+{
+ CARD32 *buf_l = (CARD32 *)buf;
+ CARD32 len;
+ CARD32 *key;
+
+ if (IS_DYNAMIC_EVENT_FLOW(im)) /* already Dynamic event flow mode */
+ return True;
+
+ /*
+ * register onkeylist
+ */
+
+ len = buf_l[0]; /* length of on-keys */
+ len += sizeof(INT32); /* sizeof length of on-keys */
+
+ if (!(key = (CARD32 *)Xmalloc(len))) {
+ _XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+ memcpy((char *)key, (char *)buf_l, len);
+ im->private.proto.im_onkeylist = key;
+
+ MARK_DYNAMIC_EVENT_FLOW(im);
+
+ /*
+ * register offkeylist
+ */
+
+ buf_l = (CARD32 *)((char *)buf + len);
+ len = buf_l[0]; /* length of off-keys */
+ len += sizeof(INT32); /* sizeof length of off-keys */
+
+ if (!(key = (CARD32 *)Xmalloc(len))) {
+ _XimError(im, 0, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ memcpy((char *)key, (char *)buf_l, len);
+ im->private.proto.im_offkeylist = key;
+
+ return True;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimRegisterTriggerKeysCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimRegisterTriggerKeysCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ Xim im = (Xim)call_data;
+
+ (void )_XimRegisterTriggerkey(im, (XPointer)&buf_s[2]);
+ return True;
+}
+
+Public EVENTMASK
+_XimGetWindowEventmask(ic)
+ Xic ic;
+{
+ Xim im = (Xim )ic->core.im;
+ XWindowAttributes atr;
+
+ if (!XGetWindowAttributes(im->core.display, ic->core.focus_window, &atr))
+ return 0;
+ return (EVENTMASK)atr.your_event_mask;
+}
+
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimTriggerNotifyCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimTriggerNotifyCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_TRIGGER_NOTIFY_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimTriggerNotify(im, ic, mode, idx)
+ Xim im;
+ Xic ic;
+ int mode;
+ CARD32 idx;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ CARD32 *buf_l = (CARD32 *)&buf[XIM_HEADER_SIZE];
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+ EVENTMASK mask = _XimGetWindowEventmask(ic);
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_l[1] = mode; /* flag */
+ buf_l[2] = idx; /* index of keys list */
+ buf_l[3] = mask; /* select-event-mask */
+
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(CARD32) /* sizeof flag */
+ + sizeof(CARD32) /* sizeof index of key list */
+ + sizeof(EVENTMASK); /* sizeof select-event-mask */
+
+ _XimSetHeader((XPointer)buf, XIM_TRIGGER_NOTIFY, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimTriggerNotifyCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(len);
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimTriggerNotifyCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
+
+Private Bool
+_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len)
+ Xic ic;
+ char *string;
+ int string_len;
+ KeySym *keysym;
+ int keysym_len;
+{
+ XimCommitInfo info;
+
+ if (!(info = (XimCommitInfo)Xmalloc(sizeof(XimCommitInfoRec))))
+ return False;
+ info->string = string;
+ info->string_len = string_len;
+ info->keysym = keysym;
+ info->keysym_len = keysym_len;
+ info->next = ic->private.proto.commit_info;
+ ic->private.proto.commit_info = info;
+ return True;
+}
+
+Private void
+_XimUnregCommitInfo(ic)
+ Xic ic;
+{
+ XimCommitInfo info;
+
+ if (!(info = ic->private.proto.commit_info))
+ return;
+
+ if (info->string)
+ Xfree(info->string);
+ if (info->keysym)
+ Xfree(info->keysym);
+ ic->private.proto.commit_info = info->next;
+ Xfree(info);
+ return;
+}
+
+Public void
+_XimFreeCommitInfo(ic)
+ Xic ic;
+{
+ while (ic->private.proto.commit_info)
+ _XimUnregCommitInfo(ic);
+ return;
+}
+
+Private Bool
+_XimProcKeySym(ic, sym, xim_keysym, xim_keysym_len)
+ Xic ic;
+ CARD32 sym;
+ KeySym **xim_keysym;
+ int *xim_keysym_len;
+{
+ Xim im = (Xim)ic->core.im;
+
+ if (!(*xim_keysym = (KeySym *)Xmalloc(sizeof(KeySym)))) {
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ **xim_keysym = (KeySym)sym;
+ *xim_keysym_len = 1;
+
+ return True;
+}
+
+Private Bool
+_XimProcCommit(ic, buf, len, xim_string, xim_string_len)
+ Xic ic;
+ BYTE *buf;
+ int len;
+ char **xim_string;
+ int *xim_string_len;
+{
+ Xim im = (Xim)ic->core.im;
+ char *string;
+
+ if (!(string = (char *)Xmalloc(len + 1))) {
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ (void)memcpy(string, (char *)buf, len);
+ string[len] = '\0';
+
+ *xim_string = string;
+ *xim_string_len = len;
+ return True;
+}
+
+Private Bool
+_XimCommitRecv(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ CARD16 *buf_s = (CARD16 *)buf;
+ BITMASK16 flag = buf_s[0];
+ XKeyEvent ev;
+ char *string = NULL;
+ int string_len = 0;
+ KeySym *keysym = NULL;
+ int keysym_len = 0;
+
+ if ((flag & XimLookupBoth) == XimLookupChars) {
+ if (!(_XimProcCommit(ic, (BYTE *)&buf_s[2],
+ (int)buf_s[1], &string, &string_len)))
+ return False;
+
+ } else if ((flag & XimLookupBoth) == XimLookupKeySym) {
+ if (!(_XimProcKeySym(ic, *(CARD32 *)&buf_s[2], &keysym, &keysym_len)))
+ return False;
+
+ } else if ((flag & XimLookupBoth) == XimLookupBoth) {
+ if (!(_XimProcKeySym(ic, *(CARD32 *)&buf_s[2], &keysym, &keysym_len)))
+ return False;
+
+ if (!(_XimProcCommit(ic, (BYTE *)&buf_s[5],
+ (int)buf_s[4], &string, &string_len)))
+ return False;
+ }
+
+ if (!(_XimRegCommitInfo(ic, string, string_len, keysym, keysym_len))) {
+ if (string)
+ Xfree(string);
+ if (keysym)
+ Xfree(keysym);
+ _XimError(im, ic, XIM_BadAlloc, (INT16)0, (CARD16)0, (char *)NULL);
+ return False;
+ }
+
+ (void)_XimRespSyncReply(ic, flag);
+
+ MARK_FABLICATED(ic);
+
+ ev.type = KeyPress;
+ ev.send_event = False;
+ ev.display = im->core.display;
+ ev.window = ic->core.focus_window;
+ ev.keycode = 0;
+ ev.state = 0;
+
+ XPutBackEvent(im->core.display, (XEvent *)&ev);
+
+ return True;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimCommitCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimCommitCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimCommitRecv(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Public void
+_XimProcError(im, ic, data)
+ Xim im;
+ Xic ic;
+ XPointer data;
+{
+ return;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimErrorCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimErrorCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ BITMASK16 flag = buf_s[2];
+ XIMID imid;
+ XICID icid;
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if (flag & XIM_IMID_VALID) {
+ imid = buf_s[0];
+ if (imid != im->private.proto.imid)
+ return False;
+ }
+ if (flag & XIM_ICID_VALID) {
+ icid = buf_s[1];
+ if (!(ic = _XimICOfXICID(im, icid)))
+ return False;
+ }
+ _XimProcError(im, ic, (XPointer)&buf_s[3]);
+
+ return True;
+}
+
+Public Bool
+_XimError(im, ic, error_code, detail_length, type, detail)
+ Xim im;
+ Xic ic;
+ CARD16 error_code;
+ INT16 detail_length;
+ CARD16 type;
+ char *detail;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len = 0;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[2] = XIM_IMID_VALID; /* flag */
+ if (ic) {
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] |= XIM_ICID_VALID; /* flag */
+ }
+ buf_s[3] = error_code; /* Error Code */
+ buf_s[4] = detail_length; /* length of error detail */
+ buf_s[5] = type; /* type of error detail */
+
+ if (detail_length && detail) {
+ len = detail_length;
+ memcpy((char *)&buf_s[6], detail, len);
+ XIM_SET_PAD(&buf_s[6], len);
+ }
+
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16) /* sizeof error_code */
+ + sizeof(INT16) /* sizeof length of detail */
+ + sizeof(CARD16); /* sizeof type */
+
+ _XimSetHeader((XPointer)buf, XIM_ERROR, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+#ifndef MAXINT
+#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
+#endif /* !MAXINT */
+
+Public int
+_Ximctstombs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ char *to;
+ int to_len;
+ Status *state;
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.proto.ctom_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ char *to_buf;
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ if (to && to_len) {
+ from_left = from_len;
+ to_left = to_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_savelen = from_left;
+ to_savelen = to_left;
+ from_buf = &from[from_cnvlen];
+ to_buf = &to[to_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0) {
+ *state = XLookupChars;
+ } else {
+ *state = XLookupNone;
+ }
+ return to_cnvlen;
+ }
+ if (to_left == 0)
+ break;
+ }
+ }
+
+ from_left = from_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ to_buf = NULL;
+ for (;;) {
+ from_savelen = from_left;
+ to_left = MAXINT;
+ from_buf = &from[from_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (MAXINT - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0)
+ *state = XBufferOverflow;
+ else
+ *state = XLookupNone;
+ break;
+ }
+ }
+ return to_cnvlen;
+}
+
+Public int
+_Ximctstowcs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ wchar_t *to;
+ int to_len;
+ Status *state;
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.proto.ctow_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ wchar_t *to_buf;
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ if (to && to_len) {
+ from_left = from_len;
+ to_left = to_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_savelen = from_left;
+ to_savelen = to_left;
+ from_buf = &from[from_cnvlen];
+ to_buf = &to[to_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0) {
+ *state = XLookupChars;
+ } else {
+ *state = XLookupNone;
+ }
+ return to_cnvlen;
+ }
+ if (to_left == 0)
+ break;
+ }
+ }
+
+ from_left = from_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ to_buf = (wchar_t *)NULL;
+ for (;;) {
+ from_savelen = from_left;
+ to_left = MAXINT;
+ from_buf = &from[from_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (MAXINT - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0)
+ *state = XBufferOverflow;
+ else
+ *state = XLookupNone;
+ break;
+ }
+ }
+ return to_cnvlen;
+}
+
+Public int
+_XimProtoMbLookupString(xic, ev, buffer, bytes, keysym, state)
+ XIC xic;
+ XKeyEvent *ev;
+ char *buffer;
+ int bytes;
+ KeySym *keysym;
+ Status *state;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ int ret;
+ Status tmp_state;
+ XimCommitInfo info;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return 0;
+
+ if (!state)
+ state = &tmp_state;
+
+ if ((ev->type == KeyPress) && (ev->keycode == 0)) { /* Filter function */
+ if (!(info = ic->private.proto.commit_info)) {
+ if (state)
+ *state = XLookupNone;
+ return 0;
+ }
+
+ ret = im->methods->ctstombs((XIM)im, info->string,
+ info->string_len, buffer, bytes, state);
+ if (*state == XBufferOverflow)
+ return 0;
+ if (keysym && (info->keysym && *(info->keysym))) {
+ *keysym = *(info->keysym);
+ if (*state == XLookupChars)
+ *state = XLookupBoth;
+ else
+ *state = XLookupKeySym;
+ }
+ _XimUnregCommitInfo(ic);
+
+ } else if (ev->type == KeyPress) {
+ ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
+ if (ret > 0) {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupBoth;
+ else
+ *state = XLookupChars;
+ } else {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupKeySym;
+ else
+ *state = XLookupNone;
+ }
+ } else {
+ *state = XLookupNone;
+ ret = 0;
+ }
+
+ return ret;
+}
+
+Public int
+_XimProtoWcLookupString(xic, ev, buffer, bytes, keysym, state)
+ XIC xic;
+ XKeyEvent *ev;
+ wchar_t *buffer;
+ int bytes;
+ KeySym *keysym;
+ Status *state;
+{
+ Xic ic = (Xic)xic;
+ Xim im = (Xim)ic->core.im;
+ int ret;
+ Status tmp_state;
+ XimCommitInfo info;
+
+ if (!IS_SERVER_CONNECTED(im))
+ return 0;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (ev->type == KeyPress && ev->keycode == 0) { /* Filter function */
+ if (!(info = ic->private.proto.commit_info)) {
+ if (state)
+ *state = XLookupNone;
+ return 0;
+ }
+
+ ret = im->methods->ctstowcs((XIM)im, info->string,
+ info->string_len, buffer, bytes, state);
+ if (*state == XBufferOverflow)
+ return 0;
+ if (keysym && (info->keysym && *(info->keysym))) {
+ *keysym = *(info->keysym);
+ if (*state == XLookupChars)
+ *state = XLookupBoth;
+ else
+ *state = XLookupKeySym;
+ }
+ _XimUnregCommitInfo(ic);
+
+ } else if (ev->type == KeyPress) {
+ ret = _XimLookupWCText(ic, ev, buffer, bytes, keysym, NULL);
+ if (ret > 0) {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupBoth;
+ else
+ *state = XLookupChars;
+ } else {
+ if (keysym && *keysym != NoSymbol)
+ *state = XLookupKeySym;
+ else
+ *state = XLookupNone;
+ }
+ } else {
+ *state = XLookupNone;
+ ret = 0;
+ }
+
+ return ret;
+}
diff --git a/modules/im/ximcp/imDispch.c b/modules/im/ximcp/imDispch.c
new file mode 100644
index 00000000..b693537f
--- /dev/null
+++ b/modules/im/ximcp/imDispch.c
@@ -0,0 +1,122 @@
+/* $Xorg: imDispch.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <X11/Xlib.h>
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimRegProtoIntrCallback(
+ Xim im,
+ CARD16 major_code,
+ CARD16 minor_code,
+ Bool (*proc)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+
+ XPointer call_data)
+#else
+_XimRegProtoIntrCallback(im, major_code, minor_code, proc, call_data)
+ Xim im;
+ CARD16 major_code;
+ CARD16 minor_code;
+ Bool (*proc)();
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ XimProtoIntrRec *rec;
+
+ if (!(rec = (XimProtoIntrRec *)Xmalloc(sizeof(XimProtoIntrRec))))
+ return False;
+ rec->func = proc;
+ rec->major_code = major_code;
+ rec->minor_code = minor_code;
+ rec->call_data = call_data;
+ rec->next = im->private.proto.intrproto;
+ im->private.proto.intrproto = rec;
+ return True;
+}
+
+Public void
+_XimFreeProtoIntrCallback(im)
+ Xim im;
+{
+ register XimProtoIntrRec *rec, *next;
+
+ for (rec = im->private.proto.intrproto; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ im->private.proto.intrproto = NULL;
+ return;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimTransportIntr(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimTransportIntr(im, len, data, call_data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif
+{
+ Xim call_im = (Xim)call_data;
+ XimProtoIntrRec *rec = call_im->private.proto.intrproto;
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+
+ for (; rec; rec = rec->next) {
+ if ((major_opcode == (CARD8)rec->major_code)
+ && (minor_opcode == (CARD8)rec->minor_code))
+ if ((*rec->func)(call_im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+Public Bool
+_XimDispatchInit(im)
+ Xim im;
+{
+ if (_XimRegisterDispatcher(im, _XimTransportIntr, (XPointer)im))
+ return True;
+ return False;
+}
diff --git a/modules/im/ximcp/imEvToWire.c b/modules/im/ximcp/imEvToWire.c
new file mode 100644
index 00000000..1bbf74e6
--- /dev/null
+++ b/modules/im/ximcp/imEvToWire.c
@@ -0,0 +1,786 @@
+/* $Xorg: imEvToWire.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/***********************************************************
+Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xlib.h>
+#undef NEED_EVENTS
+
+#define sw16(n, s) ((s) ? \
+ (((n) << 8 & 0xff00) | \
+ ((n) >> 8 & 0xff) \
+ ) : n)
+
+#define sw32(n, s) ((s) ? \
+ (((n) << 24 & 0xff000000) | \
+ ((n) << 8 & 0xff0000) | \
+ ((n) >> 8 & 0xff00) | \
+ ((n) >> 24 & 0xff) \
+ ) : n)
+
+Status
+_XimProtoEventToWire(re, event, sw)
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+Bool sw; /* swap byte? */
+{
+ switch (event->u.u.type = re->type) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ event->u.keyButtonPointer.root = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event =
+ sw32(ev->window, sw);
+ event->u.keyButtonPointer.child =
+ sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX = sw16(ev->x, sw) ;
+ event->u.keyButtonPointer.eventY = sw16(ev->y, sw) ;
+ event->u.keyButtonPointer.rootX =
+ sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY =
+ sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->keycode;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ event->u.keyButtonPointer.root = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event = sw32(ev->window, sw);
+ event->u.keyButtonPointer.child = sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX = sw16(ev->x, sw);
+ event->u.keyButtonPointer.eventY = sw16(ev->y, sw);
+ event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->button;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ event->u.keyButtonPointer.root = sw32(ev->root, sw);
+ event->u.keyButtonPointer.event = sw32(ev->window, sw);
+ event->u.keyButtonPointer.child = sw32(ev->subwindow, sw);
+ event->u.keyButtonPointer.time = sw32(ev->time, sw);
+ event->u.keyButtonPointer.eventX= sw16(ev->x, sw);
+ event->u.keyButtonPointer.eventY= sw16(ev->y, sw);
+ event->u.keyButtonPointer.rootX = sw16(ev->x_root, sw);
+ event->u.keyButtonPointer.rootY = sw16(ev->y_root, sw);
+ event->u.keyButtonPointer.state = sw16(ev->state, sw);
+ event->u.keyButtonPointer.sameScreen= ev->same_screen;
+ event->u.u.detail = ev->is_hint;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ event->u.enterLeave.root = sw32(ev->root, sw);
+ event->u.enterLeave.event = sw32(ev->window, sw);
+ event->u.enterLeave.child = sw32(ev->subwindow, sw);
+ event->u.enterLeave.time = sw32(ev->time, sw);
+ event->u.enterLeave.eventX = sw16(ev->x, sw);
+ event->u.enterLeave.eventY = sw16(ev->y, sw);
+ event->u.enterLeave.rootX = sw16(ev->x_root, sw);
+ event->u.enterLeave.rootY = sw16(ev->y_root, sw);
+ event->u.enterLeave.state = sw16(ev->state, sw);
+ event->u.enterLeave.mode = ev->mode;
+ event->u.enterLeave.flags = 0;
+ if (ev->same_screen) {
+ event->u.enterLeave.flags |= ELFlagSameScreen;
+ }
+ if (ev->focus) {
+ event->u.enterLeave.flags |= ELFlagFocus;
+ }
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ event->u.focus.window = sw32(ev->window, sw);
+ event->u.focus.mode = ev->mode;
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ memcpy((char *)(((xKeymapEvent *) event)->map),
+ &ev->key_vector[1],
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ event->u.expose.window = sw32(ev->window, sw);
+ event->u.expose.x = sw16(ev->x, sw);
+ event->u.expose.y = sw16(ev->y, sw);
+ event->u.expose.width = sw16(ev->width, sw);
+ event->u.expose.height = sw16(ev->height, sw);
+ event->u.expose.count = sw16(ev->count, sw);
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ event->u.graphicsExposure.drawable = sw32(ev->drawable, sw);
+ event->u.graphicsExposure.x = sw16(ev->x, sw);
+ event->u.graphicsExposure.y = sw16(ev->y, sw);
+ event->u.graphicsExposure.width = sw16(ev->width, sw);
+ event->u.graphicsExposure.height = sw16(ev->height, sw);
+ event->u.graphicsExposure.count = sw16(ev->count, sw);
+ event->u.graphicsExposure.majorEvent= ev->major_code;
+ event->u.graphicsExposure.minorEvent= sw16(ev->minor_code, sw);
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ event->u.noExposure.drawable = sw32(ev->drawable, sw);
+ event->u.noExposure.majorEvent = ev->major_code;
+ event->u.noExposure.minorEvent = sw16(ev->minor_code, sw);
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ event->u.visibility.window = sw32(ev->window, sw);
+ event->u.visibility.state = ev->state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ event->u.createNotify.window = sw32(ev->window, sw);
+ event->u.createNotify.parent = sw32(ev->parent, sw);
+ event->u.createNotify.x = sw16(ev->x, sw);
+ event->u.createNotify.y = sw16(ev->y, sw);
+ event->u.createNotify.width = sw16(ev->width, sw);
+ event->u.createNotify.height = sw16(ev->height, sw);
+ event->u.createNotify.borderWidth = sw16(ev->border_width, sw);
+ event->u.createNotify.override = ev->override_redirect;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ event->u.destroyNotify.window = sw32(ev->window, sw);
+ event->u.destroyNotify.event = sw32(ev->event, sw);
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ event->u.unmapNotify.window = sw32(ev->window, sw);
+ event->u.unmapNotify.event = sw32(ev->event, sw);
+ event->u.unmapNotify.fromConfigure = ev->from_configure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ event->u.mapNotify.window = sw32(ev->window, sw);
+ event->u.mapNotify.event = sw32(ev->event, sw);
+ event->u.mapNotify.override = ev->override_redirect;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ event->u.mapRequest.window = sw32(ev->window, sw);
+ event->u.mapRequest.parent = sw32(ev->parent, sw);
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ event->u.reparent.window = sw32(ev->window, sw);
+ event->u.reparent.event = sw32(ev->event, sw);
+ event->u.reparent.parent = sw32(ev->parent, sw);
+ event->u.reparent.x = sw16(ev->x, sw);
+ event->u.reparent.y = sw16(ev->y, sw);
+ event->u.reparent.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ event->u.configureNotify.window = sw32(ev->window, sw);
+ event->u.configureNotify.event = sw32(ev->event, sw);
+ event->u.configureNotify.aboveSibling = sw32(ev->above, sw);
+ event->u.configureNotify.x = sw16(ev->x, sw);
+ event->u.configureNotify.y = sw16(ev->y, sw);
+ event->u.configureNotify.width = sw16(ev->width, sw);
+ event->u.configureNotify.height = sw16(ev->height, sw);
+ event->u.configureNotify.borderWidth= sw16(ev->border_width, sw);
+ event->u.configureNotify.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ event->u.configureRequest.window = sw32(ev->window, sw);
+ event->u.configureRequest.parent = sw32(ev->parent, sw);
+ event->u.configureRequest.sibling = sw32(ev->above, sw);
+ event->u.configureRequest.x = sw16(ev->x, sw);
+ event->u.configureRequest.y = sw16(ev->y, sw);
+ event->u.configureRequest.width = sw16(ev->width, sw);
+ event->u.configureRequest.height = sw16(ev->height, sw);
+ event->u.configureRequest.borderWidth= sw16(ev->border_width, sw);
+ event->u.configureRequest.valueMask= sw16(ev->value_mask, sw);
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ event->u.gravity.window = sw32(ev->window, sw);
+ event->u.gravity.event = sw32(ev->event, sw);
+ event->u.gravity.x = sw16(ev->x, sw);
+ event->u.gravity.y = sw16(ev->y, sw);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ event->u.resizeRequest.window = sw32(ev->window, sw);
+ event->u.resizeRequest.width = sw16(ev->width, sw);
+ event->u.resizeRequest.height = sw16(ev->height, sw);
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ event->u.circulate.window = sw32(ev->window, sw);
+ event->u.circulate.event = sw32(ev->event, sw);
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ event->u.circulate.window = sw32(ev->window, sw);
+ event->u.circulate.event = sw32(ev->parent, sw);
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ event->u.property.window = sw32(ev->window, sw);
+ event->u.property.atom = sw32(ev->atom, sw);
+ event->u.property.time = sw32(ev->time, sw);
+ event->u.property.state = ev->state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ event->u.selectionClear.window = sw32(ev->window, sw);
+ event->u.selectionClear.atom = sw32(ev->selection, sw);
+ event->u.selectionClear.time = sw32(ev->time, sw);
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ event->u.selectionRequest.owner = sw32(ev->owner, sw);
+ event->u.selectionRequest.requestor = sw32(ev->requestor, sw);
+ event->u.selectionRequest.selection = sw32(ev->selection, sw);
+ event->u.selectionRequest.target = sw32(ev->target, sw);
+ event->u.selectionRequest.property = sw32(ev->property, sw);
+ event->u.selectionRequest.time = sw32(ev->time, sw);
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ event->u.selectionNotify.requestor = sw32(ev->requestor, sw);
+ event->u.selectionNotify.selection = sw32(ev->selection, sw);
+ event->u.selectionNotify.target = sw32(ev->target, sw);
+ event->u.selectionNotify.property = sw32(ev->property, sw);
+ event->u.selectionNotify.time = sw32(ev->time, sw);
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ event->u.colormap.window = sw32(ev->window, sw);
+ event->u.colormap.colormap = sw32(ev->colormap, sw);
+ event->u.colormap.new = ev->new;
+ event->u.colormap.state = ev->state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ event->u.clientMessage.window = sw32(ev->window, sw);
+ event->u.u.detail = ev->format;
+ switch (ev->format) {
+ case 8:
+ event->u.clientMessage.u.b.type = sw32(ev->message_type, sw);
+ for (i = 0; i < 20; i++)
+ event->u.clientMessage.u.b.bytes[i] = ev->data.b[i];
+ break;
+ case 16:
+ event->u.clientMessage.u.s.type = sw32(ev->message_type, sw);
+ event->u.clientMessage.u.s.shorts0 = sw16(ev->data.s[0], sw);
+ event->u.clientMessage.u.s.shorts1 = sw16(ev->data.s[1], sw);
+ event->u.clientMessage.u.s.shorts2 = sw16(ev->data.s[2], sw);
+ event->u.clientMessage.u.s.shorts3 = sw16(ev->data.s[3], sw);
+ event->u.clientMessage.u.s.shorts4 = sw16(ev->data.s[4], sw);
+ event->u.clientMessage.u.s.shorts5 = sw16(ev->data.s[5], sw);
+ event->u.clientMessage.u.s.shorts6 = sw16(ev->data.s[6], sw);
+ event->u.clientMessage.u.s.shorts7 = sw16(ev->data.s[7], sw);
+ event->u.clientMessage.u.s.shorts8 = sw16(ev->data.s[8], sw);
+ event->u.clientMessage.u.s.shorts9 = sw16(ev->data.s[9], sw);
+ break;
+ case 32:
+ event->u.clientMessage.u.l.type = sw32(ev->message_type, sw);
+ event->u.clientMessage.u.l.longs0 = sw32(ev->data.l[0], sw);
+ event->u.clientMessage.u.l.longs1 = sw32(ev->data.l[1], sw);
+ event->u.clientMessage.u.l.longs2 = sw32(ev->data.l[2], sw);
+ event->u.clientMessage.u.l.longs3 = sw32(ev->data.l[3], sw);
+ event->u.clientMessage.u.l.longs4 = sw32(ev->data.l[4], sw);
+ break;
+ default:
+ /* client passing bogus data, let server complain */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *) re;
+ event->u.mappingNotify.firstKeyCode = ev->first_keycode;
+ event->u.mappingNotify.request = ev->request;
+ event->u.mappingNotify.count = ev->count;
+ }
+ break;
+
+ default:
+ return(0);
+ }
+ /* Common process */
+ if (((XAnyEvent *)re)->send_event)
+ event->u.u.type &= 0x80;
+ event->u.u.sequenceNumber =
+ ((XAnyEvent *)re)->serial & ~((unsigned long)0xffff);
+ event->u.u.sequenceNumber = sw16(event->u.u.sequenceNumber, sw);
+ return(1);
+}
+
+
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XimProtoWireToEvent(re, event, sw)
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+Bool sw; /* swap byte? */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = sw16(event->u.u.sequenceNumber, sw);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = NULL;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = sw32(event->u.keyButtonPointer.root, sw);
+ ev->window = sw32(event->u.keyButtonPointer.event, sw);
+ ev->subwindow = sw32(event->u.keyButtonPointer.child, sw);
+ ev->time = sw32(event->u.keyButtonPointer.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.keyButtonPointer.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.keyButtonPointer.rootY, sw));
+ ev->state = sw16(event->u.keyButtonPointer.state, sw);
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = sw32(event->u.enterLeave.root, sw);
+ ev->window = sw32(event->u.enterLeave.event, sw);
+ ev->subwindow = sw32(event->u.enterLeave.child, sw);
+ ev->time = sw32(event->u.enterLeave.time, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.enterLeave.eventX, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.enterLeave.eventY, sw));
+ ev->x_root = cvtINT16toInt(sw16(event->u.enterLeave.rootX, sw));
+ ev->y_root = cvtINT16toInt(sw16(event->u.enterLeave.rootY, sw));
+ ev->state = sw16(event->u.enterLeave.state, sw);
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = sw32(event->u.focus.window, sw);
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = sw32(event->u.expose.window, sw);
+ ev->x = sw16(event->u.expose.x, sw);
+ ev->y = sw16(event->u.expose.y, sw);
+ ev->width = sw16(event->u.expose.width, sw);
+ ev->height = sw16(event->u.expose.height, sw);
+ ev->count = sw16(event->u.expose.count, sw);
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = sw32(event->u.graphicsExposure.drawable, sw);
+ ev->x = sw16(event->u.graphicsExposure.x, sw);
+ ev->y = sw16(event->u.graphicsExposure.y, sw);
+ ev->width = sw16(event->u.graphicsExposure.width, sw);
+ ev->height = sw16(event->u.graphicsExposure.height, sw);
+ ev->count = sw16(event->u.graphicsExposure.count, sw);
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = sw16(event->u.graphicsExposure.minorEvent, sw);
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = sw32(event->u.noExposure.drawable, sw);
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = sw16(event->u.noExposure.minorEvent, sw);
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = sw32(event->u.visibility.window, sw);
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = sw32(event->u.createNotify.window, sw);
+ ev->parent = sw32(event->u.createNotify.parent, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.createNotify.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.createNotify.y, sw));
+ ev->width = sw16(event->u.createNotify.width, sw);
+ ev->height = sw16(event->u.createNotify.height, sw);
+ ev->border_width = sw16(event->u.createNotify.borderWidth, sw);
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = sw32(event->u.destroyNotify.window, sw);
+ ev->event = sw32(event->u.destroyNotify.event, sw);
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = sw32(event->u.unmapNotify.window, sw);
+ ev->event = sw32(event->u.unmapNotify.event, sw);
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = sw32(event->u.mapNotify.window, sw);
+ ev->event = sw32(event->u.mapNotify.event, sw);
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = sw32(event->u.mapRequest.window, sw);
+ ev->parent = sw32(event->u.mapRequest.parent, sw);
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = sw32(event->u.reparent.event, sw);
+ ev->window = sw32(event->u.reparent.window, sw);
+ ev->parent = sw32(event->u.reparent.parent, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.reparent.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.reparent.y, sw));
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = sw32(event->u.configureNotify.event, sw);
+ ev->window = sw32(event->u.configureNotify.window, sw);
+ ev->above = sw32(event->u.configureNotify.aboveSibling, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.configureNotify.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.configureNotify.y, sw));
+ ev->width = sw16(event->u.configureNotify.width, sw);
+ ev->height = sw16(event->u.configureNotify.height, sw);
+ ev->border_width = sw16(event->u.configureNotify.borderWidth, sw);
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = sw32(event->u.configureRequest.window, sw);
+ ev->parent = sw32(event->u.configureRequest.parent, sw);
+ ev->above = sw32(event->u.configureRequest.sibling, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.configureRequest.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.configureRequest.y, sw));
+ ev->width = sw16(event->u.configureRequest.width, sw);
+ ev->height = sw16(event->u.configureRequest.height, sw);
+ ev->border_width = sw16(event->u.configureRequest.borderWidth, sw);
+ ev->value_mask = sw16(event->u.configureRequest.valueMask, sw);
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = sw32(event->u.gravity.window, sw);
+ ev->event = sw32(event->u.gravity.event, sw);
+ ev->x = cvtINT16toInt(sw16(event->u.gravity.x, sw));
+ ev->y = cvtINT16toInt(sw16(event->u.gravity.y, sw));
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = sw32(event->u.resizeRequest.window, sw);
+ ev->width = sw16(event->u.resizeRequest.width, sw);
+ ev->height = sw16(event->u.resizeRequest.height, sw);
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = sw32(event->u.circulate.window, sw);
+ ev->event = sw32(event->u.circulate.event, sw);
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = sw32(event->u.circulate.window, sw);
+ ev->parent = sw32(event->u.circulate.event, sw);
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = sw32(event->u.property.window, sw);
+ ev->atom = sw32(event->u.property.atom, sw);
+ ev->time = sw32(event->u.property.time, sw);
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = sw32(event->u.selectionClear.window, sw);
+ ev->selection = sw32(event->u.selectionClear.atom, sw);
+ ev->time = sw32(event->u.selectionClear.time, sw);
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = sw32(event->u.selectionRequest.owner, sw);
+ ev->requestor = sw32(event->u.selectionRequest.requestor, sw);
+ ev->selection = sw32(event->u.selectionRequest.selection, sw);
+ ev->target = sw32(event->u.selectionRequest.target, sw);
+ ev->property = sw32(event->u.selectionRequest.property, sw);
+ ev->time = sw32(event->u.selectionRequest.time, sw);
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = sw32(event->u.selectionNotify.requestor, sw);
+ ev->selection = sw32(event->u.selectionNotify.selection, sw);
+ ev->target = sw32(event->u.selectionNotify.target, sw);
+ ev->property = sw32(event->u.selectionNotify.property, sw);
+ ev->time = sw32(event->u.selectionNotify.time, sw);
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = sw32(event->u.colormap.window, sw);
+ ev->colormap = sw32(event->u.colormap.colormap, sw);
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = sw32(event->u.clientMessage.window, sw);
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = sw32(event->u.clientMessage.u.b.type, sw);
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = sw32(event->u.clientMessage.u.s.type, sw);
+ ev->data.s[0] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts0, sw));
+ ev->data.s[1] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts1, sw));
+ ev->data.s[2] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts2, sw));
+ ev->data.s[3] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts3, sw));
+ ev->data.s[4] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts4, sw));
+ ev->data.s[5] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts5, sw));
+ ev->data.s[6] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts6, sw));
+ ev->data.s[7] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts7, sw));
+ ev->data.s[8] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts8, sw));
+ ev->data.s[9] = cvtINT16toShort(sw16(event->u.clientMessage.u.s.shorts9, sw));
+ break;
+ case 32:
+ ev->message_type = sw32(event->u.clientMessage.u.l.type, sw);
+ ev->data.l[0] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs0, sw));
+ ev->data.l[1] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs1, sw));
+ ev->data.l[2] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs2, sw));
+ ev->data.l[3] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs3, sw));
+ ev->data.l[4] = cvtINT32toLong(sw32(event->u.clientMessage.u.l.longs4, sw));
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(False);
+ }
+ return(True);
+}
diff --git a/modules/im/ximcp/imExten.c b/modules/im/ximcp/imExten.c
new file mode 100644
index 00000000..c73bcf06
--- /dev/null
+++ b/modules/im/ximcp/imExten.c
@@ -0,0 +1,612 @@
+/* $Xorg: imExten.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+/*
+ * index of extensions
+ */
+
+#define XIM_EXT_SET_EVENT_MASK_IDX 0
+#ifdef EXT_FORWARD
+#define XIM_EXT_FORWARD_KEYEVENT_IDX 1
+#endif
+#ifdef EXT_MOVE
+#define XIM_EXT_MOVE_IDX 2
+#endif
+
+typedef struct _XIM_QueryExtRec {
+ Bool is_support;
+ char *name;
+ int name_len;
+ CARD16 major_opcode;
+ CARD16 minor_opcode;
+ int idx;
+} XIM_QueryExtRec;
+
+Private XIM_QueryExtRec extensions[] = {
+ {False, "XIM_EXT_SET_EVENT_MASK", 0, 0, 0,
+ XIM_EXT_SET_EVENT_MASK_IDX},
+#ifdef EXT_FORWARD
+ {False, "XIM_EXT_FORWARD_KEYEVENT", 0, 0, 0,
+ XIM_EXT_FORWARD_KEYEVENT_IDX},
+#endif
+#ifdef EXT_MOVE
+ {False, "XIM_EXT_MOVE", 0, 0, 0, XIM_EXT_MOVE_IDX},
+#endif
+ {False, NULL, 0, 0, 0, 0} /* dummy */
+};
+
+Private int
+_XimIsSupportExt(idx)
+ int idx;
+{
+ register int i;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ if (extensions[i].idx == idx)
+ if (extensions[i].is_support)
+ return i;
+ else
+ break;
+ }
+ return -1;
+}
+
+Private Bool
+_XimProcExtSetEventMask(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ EVENTMASK *buf_l = (EVENTMASK *)buf;
+ EVENTMASK select_mask = _XimGetWindowEventmask(ic);
+
+ ic->private.proto.filter_event_mask = buf_l[0];
+ ic->private.proto.intercept_event_mask = buf_l[1];
+ ic->private.proto.select_event_mask = buf_l[2];
+ ic->private.proto.forward_event_mask = buf_l[3];
+ ic->private.proto.synchronous_event_mask = buf_l[4];
+
+ select_mask &= ~ic->private.proto.intercept_event_mask;
+ /* deselected event mask */
+ select_mask |= ic->private.proto.select_event_mask;
+ /* selected event mask */
+ XSelectInput(im->core.display, ic->core.focus_window, select_mask);
+ _XimReregisterFilter(ic);
+
+ if (!(_XimProcSyncReply(im, ic)))
+ return False;
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimExtSetEventMaskCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimExtSetEventMaskCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcExtSetEventMask(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+#ifdef EXT_FORWARD
+Private Bool
+_XimProcExtForwardKeyEvent(im, ic, buf)
+ Xim im;
+ Xic ic;
+ XPointer buf;
+{
+ CARD8 *buf_b = (CARD8 *)buf;
+ CARD16 *buf_s = (CARD16 *)buf;
+ CARD32 *buf_l = (CARD32 *)buf;
+ XEvent ev;
+ XKeyEvent *kev = (XKeyEvent *)&ev;
+
+ bzero(&ev, sizeof(XEvent));
+ kev->send_event = False;
+ kev->display = im->core.display;
+ kev->serial = buf_s[1]; /* sequence number */
+ kev->type = buf_b[4] & 0x7f; /* xEvent.u.u.type */
+ kev->keycode = buf_b[5]; /* Keycode */
+ kev->state = buf_s[3]; /* state */
+ kev->time = buf_l[2]; /* time */
+
+ XPutBackEvent(im->core.display, &ev);
+
+ _XimRespSyncReply(ic, buf_s[0]);
+ MARK_FABLICATED(ic);
+
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimExtForwardKeyEventCallback(
+ Xim xim,
+ INT16 len,
+ XPointer data,
+ XPointer call_data)
+#else
+_XimExtForwardKeyEventCallback(xim, len, data, call_data)
+ Xim xim;
+ INT16 len;
+ XPointer data;
+ XPointer call_data;
+#endif /* NeedFunctionPrototypes */
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+ Xim im = (Xim)call_data;
+ Xic ic;
+
+ if ((imid == im->private.proto.imid)
+ && (ic = _XimICOfXICID(im, icid))) {
+ (void)_XimProcExtForwardKeyEvent(im, ic, (XPointer)&buf_s[2]);
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimExtForwardKeyEventCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimExtForwardKeyEventCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ Xic ic = (Xic)arg;
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+ XICID icid = buf_s[1];
+
+ if ((major_opcode == XIM_SYNC_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid)
+ && (icid == ic->private.proto.icid))
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid)
+ && (buf_s[2] & XIM_ICID_VALID)
+ && (icid == ic->private.proto.icid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimExtForwardKeyEvent(ic, ev, sync)
+ Xic ic;
+ XKeyEvent *ev;
+ Bool sync;
+{
+ Xim im = (Xim) ic->core.im;
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD8 *buf_b = &buf[XIM_HEADER_SIZE];
+ CARD16 *buf_s = (CARD16 *)buf_b;
+ CARD32 *buf_l = (CARD32 *)buf_b;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ INT16 len;
+ int idx;
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) < 0)
+ return False;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = sync ? XimSYNCHRONUS : 0; /* flag */
+ buf_s[3] = (CARD16)(((XAnyEvent *)ev)->serial & ((unsigned long) 0xffff));
+ /* sequence number */
+ buf_b[8] = ev->type; /* xEvent.u.u.type */
+ buf_b[9] = ev->keycode; /* keycode */
+ buf_s[5] = ev->state; /* state */
+ buf_l[3] = ev->time; /* time */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(BITMASK16) /* sizeof flag */
+ + sizeof(CARD16) /* sizeof sequence number */
+ + sizeof(BYTE) /* sizeof xEvent.u.u.type */
+ + sizeof(BYTE) /* sizeof keycode */
+ + sizeof(CARD16) /* sizeof state */
+ + sizeof(CARD32); /* sizeof time */
+
+ _XimSetHeader((XPointer)buf,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ if (sync) {
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimExtForwardKeyEventCheck, (XPointer)ic);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_sizex = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, preply, buf_size,
+ _XimExtForwardKeyEventCheck, (XPointer)ic);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+ }
+ return True;
+}
+#endif /* EXT_FORWARD */
+
+Private int
+_XimCheckExtensionListSize()
+{
+ register int i;
+ int len;
+ int total = 0;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ len = strlen(extensions[i].name);
+ extensions[i].name_len = len;
+ len += sizeof(BYTE);
+ total += len;
+ }
+ return total;
+}
+
+Private void
+_XimSetExtensionList(buf)
+ CARD8 *buf;
+{
+ register int i;
+ int len;
+ int n = XIMNumber(extensions) - 1;
+
+ for (i = 0; i < n; i++) {
+ len = extensions[i].name_len;
+ buf[0] = (BYTE)len;
+ (void)strcpy((char *)&buf[1], extensions[i].name);
+ len += sizeof(BYTE);
+ buf += len;
+ }
+ return;
+}
+
+Private unsigned int
+_XimCountNumberOfExtension(total, ext)
+ INT16 total;
+ CARD8 *ext;
+{
+ unsigned int n;
+ INT16 len;
+ INT16 min_len = sizeof(CARD8)
+ + sizeof(CARD8)
+ + sizeof(INT16);
+
+ n = 0;
+ while (total > min_len) {
+ len = *((INT16 *)(&ext[2]));
+ len += (min_len + XIM_PAD(len));
+ total -= len;
+ ext += len;
+ n++;
+ }
+ return n;
+}
+
+Private Bool
+_XimParseExtensionList(im, data)
+ Xim im;
+ CARD16 *data;
+{
+ int num = XIMNumber(extensions) - 1;
+ unsigned int n;
+ CARD8 *buf;
+ register int i;
+ register int j;
+ INT16 len;
+
+ if (!(n = _XimCountNumberOfExtension(data[0], (CARD8 *)&data[1])))
+ return True;
+
+ buf = (CARD8 *)&data[1];;
+ for (i = 0; i < n; i++) {
+ len = *((INT16 *)(&buf[2]));
+ for (j = 0; j < num; j++) {
+ if (!(strncmp(extensions[j].name, (char *)&buf[4], len))) {
+ extensions[j].major_opcode = buf[0];
+ extensions[j].minor_opcode = buf[1];
+ extensions[j].is_support = True;
+ break;
+ }
+ }
+ len += sizeof(CARD8) /* sizeof major_opcode */
+ + sizeof(CARD8) /* sizeof minor_opcode */
+ + sizeof(INT16) /* sizeof length */
+ + XIM_PAD(len); /* sizeof pad */
+ buf += len;
+ }
+
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimQueryExtensionCheck(
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer arg)
+#else
+_XimQueryExtensionCheck(im, len, data, arg)
+ Xim im;
+ INT16 len;
+ XPointer data;
+ XPointer arg;
+#endif
+{
+ CARD16 *buf_s = (CARD16 *)((CARD8 *)data + XIM_HEADER_SIZE);
+ CARD8 major_opcode = *((CARD8 *)data);
+ CARD8 minor_opcode = *((CARD8 *)data + 1);
+ XIMID imid = buf_s[0];
+
+ if ((major_opcode == XIM_QUERY_EXTENSION_REPLY)
+ && (minor_opcode == 0)
+ && (imid == im->private.proto.imid))
+ return True;
+ if ((major_opcode == XIM_ERROR)
+ && (minor_opcode == 0)
+ && (buf_s[2] & XIM_IMID_VALID)
+ && (imid == im->private.proto.imid))
+ return True;
+ return False;
+}
+
+Public Bool
+_XimExtension(im)
+ Xim im;
+{
+ CARD8 *buf;
+ CARD16 *buf_s;
+ int buf_len;
+ INT16 len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+ int idx;
+
+ if (!(len = _XimCheckExtensionListSize()))
+ return True;
+
+ buf_len = XIM_HEADER_SIZE
+ + sizeof(CARD16)
+ + sizeof(INT16)
+ + len
+ + XIM_PAD(len);
+
+ if (!(buf = (CARD8 *)Xmalloc(buf_len)))
+ return False;
+ buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = len; /* length of Extensions */
+ _XimSetExtensionList((CARD8 *)&buf_s[2]);
+ /* extensions supported */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += sizeof(CARD16) /* sizeof imid */
+ + sizeof(INT16); /* sizeof length of extensions */
+
+ _XimSetHeader((XPointer)buf, XIM_QUERY_EXTENSION, 0, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ buf_size = BUFSIZE;
+ ret_code = _XimRead(im, &len, (XPointer)reply, buf_size,
+ _XimQueryExtensionCheck, 0);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimRead(im, &len, reply, buf_size,
+ _XimQueryExtensionCheck, 0);
+ if(ret_code != XIM_TRUE) {
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else
+ return False;
+ buf_s = (CARD16 *)((char *)preply + XIM_HEADER_SIZE);
+ if (*((CARD8 *)preply) == XIM_ERROR) {
+ _XimProcError(im, 0, (XPointer)&buf_s[3]);
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+
+ if (!(_XimParseExtensionList(im, &buf_s[1]))) {
+ if(reply != preply)
+ Xfree(preply);
+ return False;
+ }
+ if(reply != preply)
+ Xfree(preply);
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_SET_EVENT_MASK_IDX)) >= 0)
+ _XimRegProtoIntrCallback(im,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode,
+ _XimExtSetEventMaskCallback, (XPointer)im);
+#ifdef EXT_FORWARD
+ if ((idx = _XimIsSupportExt(XIM_EXT_FORWARD_KEYEVENT_IDX)) >= 0)
+ _XimRegProtoIntrCallback(im,
+ extensions[idx].major_opcode,
+ extensions[idx].minor_opcode,
+ _XimExtForwardKeyEventCallback, (XPointer)im);
+#endif
+
+ return True;
+}
+
+#ifdef EXT_MOVE
+/* flag of ExtenArgCheck */
+#define EXT_XNSPOTLOCATION (1L<<0)
+
+/* macro for ExtenArgCheck */
+#define SET_EXT_XNSPOTLOCATION(flag) (flag |= EXT_XNSPOTLOCATION)
+#define IS_EXT_XNSPOTLOCATION(flag) (flag & EXT_XNSPOTLOCATION)
+
+/* length of XPoint attribute */
+#define XIM_Xpoint_length 12
+
+Private Bool
+_XimExtMove(im, ic, x, y)
+ Xim im;
+ Xic ic;
+ CARD16 x;
+ CARD16 y;
+{
+ CARD32 buf32[BUFSIZE/4];
+ CARD8 *buf = (CARD8 *)buf32;
+ CARD16 *buf_s = (CARD16 *)&buf[XIM_HEADER_SIZE];
+ INT16 len;
+ int idx;
+
+ if ((idx = _XimIsSupportExt(XIM_EXT_MOVE_IDX)) < 0)
+ return False;
+
+ buf_s[0] = im->private.proto.imid; /* imid */
+ buf_s[1] = ic->private.proto.icid; /* icid */
+ buf_s[2] = x; /* X */
+ buf_s[3] = y; /* Y */
+ len = sizeof(CARD16) /* sizeof imid */
+ + sizeof(CARD16) /* sizeof icid */
+ + sizeof(INT16) /* sizeof X */
+ + sizeof(INT16); /* sizeof Y */
+
+ _XimSetHeader((XPointer)buf, extensions[idx].major_opcode,
+ extensions[idx].minor_opcode, &len);
+ if (!(_XimWrite(im, len, (XPointer)buf)))
+ return False;
+ _XimFlush(im);
+ return True;
+}
+
+Public BITMASK32
+_XimExtenArgCheck(arg)
+ XIMArg *arg;
+{
+ CARD32 flag = 0L;
+ if (!strcmp(arg->name, XNSpotLocation))
+ SET_EXT_XNSPOTLOCATION(flag);
+ return flag;
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimExtenMove(
+ Xim im,
+ Xic ic,
+ CARD32 flag,
+ CARD16 *buf,
+ INT16 length)
+#else
+_XimExtenMove(im, ic, flag, buf, length)
+ Xim im;
+ Xic ic;
+ CARD32 flag;
+ CARD16 *buf;
+ INT16 length;
+#endif /* NeedFunctionPrototypes */
+{
+ if ((IS_EXT_XNSPOTLOCATION(flag)) && (length == XIM_Xpoint_length))
+ return _XimExtMove(im, ic, buf[4], buf[5]);
+ return False;
+}
+#endif /* EXT_MOVE */
diff --git a/modules/im/ximcp/imImSw.c b/modules/im/ximcp/imImSw.c
new file mode 100644
index 00000000..13ea2a70
--- /dev/null
+++ b/modules/im/ximcp/imImSw.c
@@ -0,0 +1,53 @@
+/* $Xorg: imImSw.c,v 1.3 2000/08/17 19:45:12 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimImSw.h"
+
+Private Bool
+_XimCheckIfDefault(im)
+ Xim im;
+{
+ return(True);
+}
+
+XimImsportSW _XimImSportRec[] = {
+ _XimCheckIfLocalProcessing, _XimLocalOpenIM, _XimLocalIMFree,
+ _XimCheckIfThaiProcessing, _XimThaiOpenIM, _XimThaiIMFree,
+ _XimCheckIfDefault, _XimProtoOpenIM, _XimProtoIMFree,
+ NULL, NULL, NULL,
+};
diff --git a/modules/im/ximcp/imInsClbk.c b/modules/im/ximcp/imInsClbk.c
new file mode 100644
index 00000000..413dd38f
--- /dev/null
+++ b/modules/im/ximcp/imInsClbk.c
@@ -0,0 +1,303 @@
+/* $Xorg: imInsClbk.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1993, 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sony Corporation
+ not be used in advertising or publicity pertaining to distribution
+ of the software without specific, written prior permission.
+Sony Corporation makes no representations about the suitability of
+ this software for any purpose. It is provided "as is" without
+ express or implied warranty.
+
+SONY CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL SONY CORPORATION 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.
+
+ Author: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "Ximint.h"
+
+
+typedef struct _XimInstCallback {
+ Bool call;
+ Bool destroy;
+ Display *display;
+ XLCd lcd;
+ char name[XIM_MAXLCNAMELEN];
+ char *modifiers;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+ void (*callback)(
+#if NeedNestedPrototype
+ Display* /* display */,
+ XPointer /* client_data */,
+ XPointer /* call_data */
+#endif
+ );
+ XPointer *client_data;
+ struct _XimInstCallback *next;
+} XimInstCallbackRec, *XimInstCallback;
+
+
+Private XimInstCallback callback_list = NULL;
+Private Bool lock = False;
+
+
+Private void
+#if NeedFunctionPrototypes
+MakeLocale( XLCd lcd, char locale[] )
+#else
+MakeLocale( lcd, locale )
+ XLCd lcd;
+ char locale[];
+#endif
+{
+ char *language, *territory, *codeset;
+
+ _XGetLCValues( lcd, XlcNLanguage, &language, XlcNTerritory, &territory,
+ XlcNCodeset, &codeset, NULL );
+
+ strcpy( locale, language );
+ if( territory && *territory ) {
+ strcat( locale, "_" );
+ strcat( locale, territory );
+ }
+ if( codeset && *codeset ) {
+ strcat( locale, "." );
+ strcat( locale, codeset );
+ }
+}
+
+
+Private Bool
+_XimFilterPropertyNotify( display, window, event, client_data )
+ Display *display;
+ Window window;
+ XEvent *event;
+ XPointer client_data;
+{
+ Atom ims, actual_type, *atoms;
+ int actual_format;
+ unsigned long nitems, bytes_after;
+ Window ims_window;
+ int ii;
+ XIM xim;
+ Bool flag = False;
+ XimInstCallback icb, picb, tmp;
+
+ if( (ims = XInternAtom( display, XIM_SERVERS, True )) == None ||
+ event->xproperty.atom != ims ||
+ event->xproperty.state == PropertyDelete )
+ return( False );
+
+ if( XGetWindowProperty( display, RootWindow(display, 0), ims, 0L, 1000000L,
+ False, XA_ATOM, &actual_type, &actual_format,
+ &nitems, &bytes_after, (unsigned char **)&atoms )
+ != Success ) {
+ return( False );
+ }
+ if( actual_type != XA_ATOM || actual_format != 32 ) {
+ XFree( atoms );
+ return( False );
+ }
+
+ lock = True;
+ for( ii = 0; ii < nitems; ii++, atoms ) {
+ if((ims_window = XGetSelectionOwner (display, atoms[ii]))) {
+ for( icb = callback_list; icb; icb = icb->next ) {
+ if( !icb->call && !icb->destroy ) {
+ xim = (*icb->lcd->methods->open_im)( icb->lcd, display,
+ icb->rdb,
+ icb->res_name,
+ icb->res_class );
+ if( xim ) {
+ xim->methods->close( (XIM)xim );
+ flag = True;
+ icb->call = True;
+ icb->callback( icb->display, icb->client_data, NULL );
+ }
+ }
+ }
+ break;
+ }
+ }
+ XFree( atoms );
+
+ for( icb = callback_list, picb = NULL; icb; ) {
+ if( icb->destroy ) {
+ if( picb )
+ picb->next = icb->next;
+ else
+ callback_list = icb->next;
+ tmp = icb;
+ icb = icb->next;
+ XFree( tmp );
+ }
+ else {
+ picb = icb;
+ icb = icb->next;
+ }
+ }
+ lock = False;
+
+ return( flag );
+}
+
+
+Public Bool
+_XimRegisterIMInstantiateCallback( lcd, display, rdb, res_name, res_class,
+ callback, client_data )
+ XLCd lcd;
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name, *res_class;
+ XIMProc callback;
+ XPointer *client_data;
+{
+ XimInstCallback icb, tmp;
+ XIM xim;
+ Window root;
+ XWindowAttributes attr;
+
+ if( lock )
+ return( False );
+
+ icb = (XimInstCallback)Xmalloc(sizeof(XimInstCallbackRec));
+ if( !icb )
+ return( False );
+ icb->call = icb->destroy = False;
+ icb->display = display;
+ icb->lcd = lcd;
+ MakeLocale( lcd, icb->name );
+ icb->modifiers = lcd->core->modifiers; /* XXXXX */
+ icb->rdb = rdb;
+ icb->res_name = res_name;
+ icb->res_class = res_class;
+ icb->callback = callback;
+ icb->client_data = client_data;
+ icb->next = NULL;
+
+ if( !callback_list )
+ callback_list = icb;
+ else {
+ for( tmp = callback_list; tmp->next; tmp = tmp->next );
+ tmp->next = icb;
+ }
+
+ xim = (*lcd->methods->open_im)( lcd, display, rdb, res_name, res_class );
+
+ if( icb == callback_list ) {
+ root = RootWindow( display, 0 );
+ XGetWindowAttributes( display, root, &attr );
+ _XRegisterFilterByType( display, root, PropertyNotify, PropertyNotify,
+ _XimFilterPropertyNotify, (XPointer)NULL );
+ XSelectInput( display, root,
+ attr.your_event_mask | PropertyChangeMask );
+ }
+
+ if( xim ) {
+ lock = True;
+ xim->methods->close( (XIM)xim );
+ lock = False;
+ icb->call = True;
+ callback( display, client_data, NULL );
+ }
+
+ return( True );
+}
+
+
+Public Bool
+_XimUnRegisterIMInstantiateCallback( lcd, display, rdb, res_name, res_class,
+ callback, client_data )
+ XLCd lcd;
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name, *res_class;
+ XIMProc callback;
+ XPointer *client_data;
+{
+ char locale[XIM_MAXLCNAMELEN];
+ XimInstCallback icb, picb;
+
+ if( !callback_list )
+ return( False );
+
+ MakeLocale( lcd, locale );
+
+ for( icb = callback_list, picb = NULL; icb; picb = icb, icb = icb->next ) {
+ if( !strcmp( locale, icb->name ) &&
+ (lcd->core->modifiers == icb->modifiers || /* XXXXX */
+ (lcd->core->modifiers && icb->modifiers &&
+ !strcmp( lcd->core->modifiers, icb->modifiers ))) &&
+ rdb == icb->rdb && /* XXXXX */
+ ((res_name == NULL && icb->res_name == NULL) ||
+ (res_name != NULL && icb->res_name != NULL &&
+ !strcmp( res_name, icb->res_name ))) &&
+ ((res_class == NULL && icb->res_class == NULL) ||
+ (res_class != NULL && icb->res_class != NULL &&
+ !strcmp( res_class, icb->res_class ))) &&
+ callback == icb->callback &&
+ client_data == icb->client_data && /* XXXXX */
+ !icb->destroy ) {
+ if( lock )
+ icb->destroy = True;
+ else {
+ if( !picb ) {
+ callback_list = icb->next;
+ _XUnregisterFilter( display, RootWindow(display, 0),
+ _XimFilterPropertyNotify,
+ (XPointer)NULL );
+ XSelectInput( display, RootWindow(display, 0),
+ NoEventMask );
+ }
+ else
+ picb->next = icb->next;
+ _XCloseLC( icb->lcd );
+ XFree( icb );
+ }
+ return( True );
+ }
+ }
+ return( False );
+}
+
+
+Public void
+_XimResetIMInstantiateCallback( xim )
+ Xim xim;
+{
+ char locale[XIM_MAXLCNAMELEN];
+ XimInstCallback icb;
+ XLCd lcd = xim->core.lcd;
+
+ if( !callback_list && lock )
+ return;
+
+ MakeLocale( lcd, locale );
+
+ for( icb = callback_list; icb; icb = icb->next )
+ if( !strcmp( locale, icb->name ) &&
+ (lcd->core->modifiers == icb->modifiers ||
+ (lcd->core->modifiers && icb->modifiers &&
+ !strcmp( lcd->core->modifiers, icb->modifiers ))) )
+ icb->call = False;
+}
diff --git a/modules/im/ximcp/imInt.c b/modules/im/ximcp/imInt.c
new file mode 100644
index 00000000..05c4b2b0
--- /dev/null
+++ b/modules/im/ximcp/imInt.c
@@ -0,0 +1,266 @@
+/* $Xorg: imInt.c,v 1.8 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimImSw.h"
+
+Private Xim *_XimCurrentIMlist = (Xim *)NULL;
+Private int _XimCurrentIMcount = 0;
+
+Private Bool
+_XimSetIMStructureList(im)
+ Xim im;
+{
+ register int i;
+ Xim *xim;
+
+ if(!(_XimCurrentIMlist)) {
+ if(!(_XimCurrentIMlist = (Xim *)Xmalloc(sizeof(Xim))))
+ return False;
+ _XimCurrentIMlist[0] = im;
+ _XimCurrentIMcount = 1;
+ }
+ else {
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!( _XimCurrentIMlist[i])) {
+ _XimCurrentIMlist[i] = im;
+ break;
+ }
+ }
+ if(i >= _XimCurrentIMcount) {
+ if(!(xim = (Xim *)Xrealloc(_XimCurrentIMlist,
+ ((i + 1) * sizeof(Xim)))))
+ return False;
+ _XimCurrentIMlist = xim;
+ _XimCurrentIMlist[_XimCurrentIMcount] = im;
+ _XimCurrentIMcount++;
+ }
+ }
+ return True;
+}
+
+Public void
+_XimDestroyIMStructureList(im)
+ Xim im;
+{
+ register int i;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(_XimCurrentIMlist[i] == im) {
+ _XimCurrentIMlist[i] = NULL;
+ break;
+ }
+ }
+ return;
+}
+
+Public void
+_XimServerDestroy(im_2_destroy)
+ Xim im_2_destroy;
+{
+ register int i;
+ Xim im;
+ XIC ic;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!(im = _XimCurrentIMlist[i]))
+ continue;
+ /*
+ * Only continue if this im is the one to be destroyed.
+ */
+ if (im != im_2_destroy)
+ continue;
+
+ if (im->core.destroy_callback.callback)
+ (*im->core.destroy_callback.callback)(im,
+ im->core.destroy_callback.client_data, NULL);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ if (ic->core.destroy_callback.callback) {
+ (*ic->core.destroy_callback.callback)(ic,
+ ic->core.destroy_callback.client_data, NULL);
+ }
+ }
+ _XimResetIMInstantiateCallback( im );
+ (void)im->methods->close((XIM)im);
+ Xfree(im);
+ _XimCurrentIMlist[i] = NULL;
+ return;
+ }
+}
+
+#ifdef XIM_CONNECTABLE
+Public void
+_XimServerReconectableDestroy()
+{
+ register int i;
+ Xim im;
+ XIC ic;
+
+ for(i = 0; i < _XimCurrentIMcount; i++) {
+ if(!(im = _XimCurrentIMlist[i]))
+ continue;
+
+ if (im->core.destroy_callback.callback)
+ (*im->core.destroy_callback.callback)(im,
+ im->core.destroy_callback.client_data, NULL);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next) {
+ if (ic->core.destroy_callback.callback) {
+ (*ic->core.destroy_callback.callback)(ic,
+ ic->core.destroy_callback.client_data, NULL);
+ }
+ }
+ _XimResetIMInstantiateCallback( im );
+ (void)im->methods->close((XIM)im);
+ }
+ return;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private char *
+_XimStrstr(src, dest)
+ register char *src, *dest;
+{
+ int len;
+
+ len = strlen(dest);
+ while((src = strchr(src, *dest))) {
+ if(!strncmp(src, dest, len))
+ return src;
+ src++;
+ }
+ return NULL;
+}
+
+Private char *
+_XimMakeImName(lcd)
+ XLCd lcd;
+{
+ char* begin = NULL;
+ char* end = NULL;
+ char* ret = NULL;
+ char* ximmodifier = XIMMODIFIER;
+
+ if(lcd->core->modifiers != NULL && *lcd->core->modifiers != '\0') {
+ begin = _XimStrstr(lcd->core->modifiers, ximmodifier);
+ if (begin != NULL) {
+ end = begin += strlen(ximmodifier);
+ while (*end && *end != '@')
+ end++;
+ }
+ }
+
+ ret = Xmalloc(end - begin + 1);
+ if (ret != NULL) {
+ if (begin != NULL) {
+ (void)strncpy(ret, begin, end - begin);
+ ret[end - begin] = '\0';
+ } else {
+ ret[0] = '\0';
+ }
+ }
+
+ return ret;
+}
+
+Public XIM
+_XimOpenIM(lcd, dpy, rdb, res_name, res_class)
+ XLCd lcd;
+ Display *dpy;
+ XrmDatabase rdb;
+ char *res_name, *res_class;
+{
+ Xim im;
+ register int i;
+
+ if (!(im = (Xim)Xmalloc(sizeof(XimRec))))
+ return (XIM)NULL;
+ bzero(im, sizeof(XimRec));
+
+ im->core.lcd = lcd;
+ im->core.ic_chain = (XIC)NULL;
+ im->core.display = dpy;
+ im->core.rdb = rdb;
+ im->core.res_name = NULL;
+ im->core.res_class = NULL;
+ if((res_name != NULL) && (*res_name != '\0')){
+ if(!(im->core.res_name = (char *)Xmalloc(strlen(res_name)+1)))
+ goto Error1;
+ strcpy(im->core.res_name,res_name);
+ }
+ if((res_class != NULL) && (*res_class != '\0')){
+ if(!(im->core.res_class = (char *)Xmalloc(strlen(res_class)+1)))
+ goto Error2;
+ strcpy(im->core.res_class,res_class);
+ }
+ if(!(im->core.im_name = _XimMakeImName(lcd)))
+ goto Error3;
+
+ for(i= 0; ; i++) {
+ if(_XimImSportRec[i].checkprocessing(im)) {
+ if(!(_XimImSportRec[i].im_open(im)))
+ goto Error4;
+ if(!_XimSetIMStructureList(im))
+ goto Error4;
+ return (XIM)im;
+ }
+ }
+
+Error4 :
+ _XimImSportRec[i].im_free(im);
+ Xfree(im);
+ return NULL;
+Error3 :
+ if(im->core.im_name)
+ Xfree(im->core.im_name);
+Error2:
+ if(im->core.res_class)
+ Xfree(im->core.res_class);
+Error1:
+ if(im->core.res_name)
+ Xfree(im->core.res_name);
+ Xfree(im);
+ return NULL;
+}
+
+Public Bool
+_XInitIM(lcd)
+ XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+ lcd->methods->open_im = _XimOpenIM;
+ lcd->methods->register_callback = _XimRegisterIMInstantiateCallback;
+ lcd->methods->unregister_callback = _XimUnRegisterIMInstantiateCallback;
+ return True;
+}
diff --git a/modules/im/ximcp/imLcFlt.c b/modules/im/ximcp/imLcFlt.c
new file mode 100644
index 00000000..85130137
--- /dev/null
+++ b/modules/im/ximcp/imLcFlt.c
@@ -0,0 +1,90 @@
+/* $Xorg: imLcFlt.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+ Copyright 1992, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Fuji Xerox,
+FUJITSU LIMITED not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission. Fuji Xerox, FUJITSU LIMITED make no representations
+about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX, FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX,
+FUJITSU LIMITED 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.
+
+ Author : Kazunori Nishihara Fuji Xerox
+ Modifier : Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/keysym.h>
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Bool
+_XimLocalFilter(d, w, ev, client_data)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer client_data;
+{
+ Xic ic = (Xic)client_data;
+ KeySym keysym;
+ static char buf[256];
+ DefTree *p;
+
+ if( (ev->type != KeyPress)
+ || (ev->xkey.keycode == 0)
+ || (((Xim)ic->core.im)->private.local.top == (DefTree *)NULL) )
+ return(False);
+
+ XLookupString((XKeyEvent *)ev, buf, sizeof(buf), &keysym, NULL);
+
+ if(IsModifierKey(keysym))
+ return (False);
+
+ for(p = ic->private.local.context; p; p = p->next) {
+ if(((ev->xkey.state & p->modifier_mask) == p->modifier) &&
+ (keysym == p->keysym)) {
+ break;
+ }
+ }
+
+ if(p) { /* Matched */
+ if(p->succession) { /* Intermediate */
+ ic->private.local.context = p->succession;
+ return(True);
+ } else { /* Terminate (reached to leaf) */
+ ic->private.local.composed = p;
+ /* return back to client KeyPressEvent keycode == 0 */
+ ev->xkey.keycode = 0;
+ XPutBackEvent(d, ev);
+ /* initialize internal state for next key sequence */
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return(True);
+ }
+ } else { /* Unmatched */
+ if(ic->private.local.context == ((Xim)ic->core.im)->private.local.top) {
+ return(False);
+ }
+ /* Error (Sequence Unmatch occured) */
+ /* initialize internal state for next key sequence */
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return(True);
+ }
+}
diff --git a/modules/im/ximcp/imLcGIc.c b/modules/im/ximcp/imLcGIc.c
new file mode 100644
index 00000000..4f37fd04
--- /dev/null
+++ b/modules/im/ximcp/imLcGIc.c
@@ -0,0 +1,48 @@
+/* $Xorg: imLcGIc.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992,1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public char *
+_XimLocalGetICValues(xic, values)
+ XIC xic;
+ XIMArg *values;
+{
+ Xic ic = (Xic)xic;
+ XimDefICValues ic_values;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ return(_XimGetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_GETICVALUES));
+}
diff --git a/modules/im/ximcp/imLcIc.c b/modules/im/ximcp/imLcIc.c
new file mode 100644
index 00000000..541d2227
--- /dev/null
+++ b/modules/im/ximcp/imLcIc.c
@@ -0,0 +1,180 @@
+/* $Xorg: imLcIc.c,v 1.3 2000/08/17 19:45:13 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992,1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private void
+_XimLocalUnSetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)NULL;
+
+ if (ic->core.focus_window)
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimLocalDestroyIC(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
+ _XimLocalUnSetFocus(xic);
+ }
+ if(ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+ return;
+}
+
+Private void
+_XimLocalSetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ XIC current_ic = ((Xim)ic->core.im)->private.local.current_ic;
+
+ if (current_ic == (XIC)ic)
+ return;
+
+ if (current_ic != (XIC)NULL) {
+ _XimLocalUnSetFocus(current_ic);
+ }
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)ic;
+
+ if (ic->core.focus_window)
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window, KeyPress, KeyPress,
+ _XimLocalFilter, (XPointer)ic);
+ return;
+}
+
+Private char *
+_XimLocalMbReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.composed = (DefTree *)NULL;
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return((char *)NULL);
+}
+
+Private wchar_t *
+_XimLocalWcReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.composed = (DefTree *)NULL;
+ ic->private.local.context = ((Xim)ic->core.im)->private.local.top;
+ return((wchar_t *)NULL);
+}
+
+Private XICMethodsRec Local_ic_methods = {
+ _XimLocalDestroyIC, /* destroy */
+ _XimLocalSetFocus, /* set_focus */
+ _XimLocalUnSetFocus, /* unset_focus */
+ _XimLocalSetICValues, /* set_values */
+ _XimLocalGetICValues, /* get_values */
+ _XimLocalMbReset, /* mb_reset */
+ _XimLocalWcReset, /* wc_reset */
+ _XimLocalMbLookupString, /* mb_lookup_string */
+ _XimLocalWcLookupString, /* wc_lookup_string */
+};
+
+Public XIC
+_XimLocalCreateIC(im, values)
+ XIM im;
+ XIMArg *values;
+{
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ int len;
+
+ if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ return ((XIC)NULL);
+ }
+ bzero((char *)ic, sizeof(XicRec));
+
+ ic->methods = &Local_ic_methods;
+ ic->core.im = im;
+ ic->private.local.context = ((Xim)im)->private.local.top;
+ ic->private.local.composed = (DefTree *)NULL;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ goto Set_Error;
+ }
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.local.ic_resources = res;
+ ic->private.local.ic_num_resources = num;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ if(_XimCheckLocalInputStyle(ic, (XPointer)&ic_values, values,
+ im->core.styles, res, num) == False) {
+ goto Set_Error;
+ }
+
+ _XimSetICMode(res, num, ic_values.input_style);
+
+ if(_XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_CREATEIC, True)) {
+ goto Set_Error;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+ if(_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num) == False) {
+ goto Set_Error;
+ }
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ return((XIC)ic);
+
+Set_Error :
+ if (ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+ Xfree(ic);
+ return((XIC)NULL);
+}
diff --git a/modules/im/ximcp/imLcIm.c b/modules/im/ximcp/imLcIm.c
new file mode 100644
index 00000000..907b0479
--- /dev/null
+++ b/modules/im/ximcp/imLcIm.c
@@ -0,0 +1,274 @@
+/* $Xorg: imLcIm.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#include <stdio.h>
+/*
+#include <X11/Xlib.h>
+*/
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "Ximint.h"
+#include <ctype.h>
+
+Public Bool
+_XimCheckIfLocalProcessing(im)
+ Xim im;
+{
+ FILE *fp;
+ char *name;
+
+ if(strcmp(im->core.im_name, "") == 0) {
+ name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (name != (char *)NULL) {
+ fp = _XFopenFile (name, "r");
+ Xfree(name);
+ if (fp != (FILE *)NULL) {
+ fclose(fp);
+ return(True);
+ }
+ }
+ return(False);
+ } else if(strcmp(im->core.im_name, "local") == 0 ||
+ strcmp(im->core.im_name, "none" ) == 0 ) {
+ return(True);
+ }
+ return(False);
+}
+
+Private void
+XimFreeDefaultTree(top)
+ DefTree *top;
+{
+ if (!top) return;
+ if (top->succession) XimFreeDefaultTree(top->succession);
+ if (top->next) XimFreeDefaultTree(top->next);
+ if (top->mb) Xfree(top->mb);
+ if (top->wc) Xfree(top->wc);
+ Xfree(top);
+}
+
+Public void
+_XimLocalIMFree(im)
+ Xim im;
+{
+ XimFreeDefaultTree(im->private.local.top);
+ if(im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if(im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if(im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if(im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if(im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if(im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if(im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if(im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ return;
+}
+
+Private Status
+_XimLocalCloseIM(xim)
+ XIM xim;
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+
+ ic = im->core.ic_chain;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+ Xfree ((char *) ic);
+ ic = next;
+ }
+ _XimLocalIMFree(im);
+ _XimDestroyIMStructureList(im);
+ return(True);
+}
+
+Public char *
+_XimLocalGetIMValues(xim, values)
+ XIM xim;
+ XIMArg *values;
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return(_XimGetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources));
+}
+
+Public char *
+_XimLocalSetIMValues(xim, values)
+ XIM xim;
+ XIMArg *values;
+{
+ Xim im = (Xim)xim;
+ XimDefIMValues im_values;
+ char *name = (char *)NULL;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ name = _XimSetIMValueData(im, (XPointer)&im_values, values,
+ im->core.im_resources, im->core.im_num_resources);
+ _XimSetCurrentIMValues(im, &im_values);
+ return(name);
+}
+
+Private void
+_XimCreateDefaultTree(im)
+ Xim im;
+{
+ FILE *fp;
+ char *name;
+
+ name = _XlcFileName(im->core.lcd, COMPOSE_FILE);
+ if (name == (char *)NULL)
+ return;
+ fp = _XFopenFile (name, "r");
+ Xfree(name);
+ if (fp == (FILE *)NULL)
+ return;
+ _XimParseStringFile(fp, &im->private.local.top);
+ fclose(fp);
+}
+
+Private XIMMethodsRec Xim_im_local_methods = {
+ _XimLocalCloseIM, /* close */
+ _XimLocalSetIMValues, /* set_values */
+ _XimLocalGetIMValues, /* get_values */
+ _XimLocalCreateIC, /* create_ic */
+ _XimLcctstombs, /* ctstombs */
+ _XimLcctstowcs /* ctstowcs */
+};
+
+Public Bool
+_XimLocalOpenIM(im)
+ Xim im;
+{
+ XLCd lcd = im->core.lcd;
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+ XimDefIMValues im_values;
+
+ _XimInitialResourceInfo();
+ if(_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ if(_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources) == False) {
+ goto Open_Error;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ _XimCreateDefaultTree(im);
+
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ goto Open_Error;
+
+ im->methods = &Xim_im_local_methods;
+ im->private.local.current_ic = (XIC)NULL;
+ im->private.local.ctom_conv = ctom_conv;
+ im->private.local.ctow_conv = ctow_conv;
+
+ return(True);
+
+Open_Error :
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if (im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if (im->private.local.ctom_conv) {
+ _XlcCloseConverter(im->private.local.ctom_conv);
+ }
+ if (im->private.local.ctow_conv) {
+ _XlcCloseConverter(im->private.local.ctow_conv);
+ }
+ return(False);
+}
diff --git a/modules/im/ximcp/imLcLkup.c b/modules/im/ximcp/imLcLkup.c
new file mode 100644
index 00000000..fa92701d
--- /dev/null
+++ b/modules/im/ximcp/imLcLkup.c
@@ -0,0 +1,330 @@
+/* $Xorg: imLcLkup.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+ Copyright 1992, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Fuji Xerox,
+FUJITSU LIMITED not be used in advertising or publicity pertaining
+to distribution of the software without specific, written prior
+permission. Fuji Xerox, FUJITSU LIMITED make no representations
+about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX, FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX,
+FUJITSU LIMITED 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.
+
+ Author: Kazunori Nishihara Fuji Xerox
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Xlib.h>
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public int
+_XimLocalMbLookupString(xic, ev, buffer, bytes, keysym, status)
+ XIC xic;
+ XKeyEvent *ev;
+ char *buffer;
+ int bytes;
+ KeySym *keysym;
+ Status *status;
+{
+ Xic ic = (Xic)xic;
+ int ret;
+
+ if(ev->type != KeyPress) {
+ if(status) *status = XLookupNone;
+ return(0);
+ }
+ if(ev->keycode == 0) { /* Composed Event */
+ ret = strlen(ic->private.local.composed->mb);
+ if(ret > bytes) {
+ if(status) *status = XBufferOverflow;
+ return(ret);
+ }
+ memcpy(buffer, ic->private.local.composed->mb, ret);
+ if(keysym) *keysym = ic->private.local.composed->ks;
+ if (ret > 0) {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ return (ret);
+ } else { /* Throughed Event */
+ ret = _XimLookupMBText(ic, ev, buffer, bytes, keysym, NULL);
+ if(ret > 0) {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ }
+ return (ret);
+}
+
+Public int
+_XimLocalWcLookupString(xic, ev, buffer, wlen, keysym, status)
+ XIC xic;
+ XKeyEvent *ev;
+ wchar_t *buffer;
+ int wlen;
+ KeySym *keysym;
+ Status *status;
+{
+ Xic ic = (Xic)xic;
+ int ret;
+
+ if(ev->type != KeyPress) {
+ if(status) *status = XLookupNone;
+ return(0);
+ }
+ if(ev->keycode == 0) { /* Composed Event */
+ ret = _Xwcslen(ic->private.local.composed->wc);
+ if(ret > wlen) {
+ if(status) *status = XBufferOverflow;
+ return (ret);
+ }
+ memcpy((char *)buffer, (char *)ic->private.local.composed->wc,
+ ret * sizeof(wchar_t));
+ if(keysym) *keysym = ic->private.local.composed->ks;
+ if (ret > 0) {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ return (ret);
+ } else { /* Throughed Event */
+ ret = _XimLookupWCText(ic, ev, buffer, wlen, keysym, NULL);
+ if(ret > 0) {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupBoth;
+ } else {
+ if(status) *status = XLookupChars;
+ }
+ } else {
+ if(keysym && *keysym != NoSymbol) {
+ if(status) *status = XLookupKeySym;
+ } else {
+ if(status) *status = XLookupNone;
+ }
+ }
+ }
+ return (ret);
+}
+
+#ifndef MAXINT
+#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
+#endif /* !MAXINT */
+
+Public int
+_XimLcctstombs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ char *to;
+ int to_len;
+ Status *state;
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.local.ctom_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ char *to_buf;
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ if (to && to_len) {
+ from_left = from_len;
+ to_left = to_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_savelen = from_left;
+ to_savelen = to_left;
+ from_buf = &from[from_cnvlen];
+ to_buf = &to[to_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0) {
+ *state = XLookupChars;
+ } else {
+ *state = XLookupNone;
+ }
+ return to_cnvlen;
+ }
+ if (to_left == 0)
+ break;
+ }
+ }
+
+ from_left = from_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ to_buf = NULL;
+ for (;;) {
+ from_savelen = from_left;
+ to_left = MAXINT;
+ from_buf = &from[from_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (MAXINT - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0)
+ *state = XBufferOverflow;
+ else
+ *state = XLookupNone;
+ break;
+ }
+ }
+ return to_cnvlen;
+}
+
+Public int
+_XimLcctstowcs(xim, from, from_len, to, to_len, state)
+ XIM xim;
+ char *from;
+ int from_len;
+ wchar_t *to;
+ int to_len;
+ Status *state;
+{
+ Xim im = (Xim)xim;
+ XlcConv conv = im->private.local.ctow_conv;
+ int from_left;
+ int to_left;
+ int from_savelen;
+ int to_savelen;
+ int from_cnvlen;
+ int to_cnvlen;
+ char *from_buf;
+ wchar_t *to_buf;
+ Status tmp_state;
+
+ if (!state)
+ state = &tmp_state;
+
+ if (!conv || !from || !from_len) {
+ *state = XLookupNone;
+ return 0;
+ }
+
+ if (to && to_len) {
+ from_left = from_len;
+ to_left = to_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ for (;;) {
+ from_savelen = from_left;
+ to_savelen = to_left;
+ from_buf = &from[from_cnvlen];
+ to_buf = &to[to_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (to_savelen - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0) {
+ *state = XLookupChars;
+ } else {
+ *state = XLookupNone;
+ }
+ return to_cnvlen;
+ }
+ if (to_left == 0)
+ break;
+ }
+ }
+
+ from_left = from_len;
+ from_cnvlen = 0;
+ to_cnvlen = 0;
+ to_buf = (wchar_t *)NULL;
+ for (;;) {
+ from_savelen = from_left;
+ to_left = MAXINT;
+ from_buf = &from[from_cnvlen];
+ if (_XlcConvert(conv, (XPointer *)&from_buf, &from_left,
+ (XPointer *)&to_buf, &to_left, NULL, 0) < 0) {
+ *state = XLookupNone;
+ return 0;
+ }
+ from_cnvlen += (from_savelen - from_left);
+ to_cnvlen += (MAXINT - to_left);
+ if (from_left == 0) {
+ if (to_cnvlen > 0)
+ *state = XBufferOverflow;
+ else
+ *state = XLookupNone;
+ break;
+ }
+ }
+ return to_cnvlen;
+}
diff --git a/modules/im/ximcp/imLcPrs.c b/modules/im/ximcp/imLcPrs.c
new file mode 100644
index 00000000..d3e5813d
--- /dev/null
+++ b/modules/im/ximcp/imLcPrs.c
@@ -0,0 +1,508 @@
+/* $Xorg: imLcPrs.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Oki Technosystems Laboratory, Inc.
+ Copyright 1992 by Fuji Xerox Co., Ltd.
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Oki Technosystems
+Laboratory and Fuji Xerox not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission.
+Oki Technosystems Laboratory and Fuji Xerox make no representations
+about the suitability of this software for any purpose. It is provided
+"as is" without express or implied warranty.
+
+OKI TECHNOSYSTEMS LABORATORY AND FUJI XEROX DISCLAIM ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OKI TECHNOSYSTEMS
+LABORATORY AND FUJI XEROX 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.
+
+ Author: Yasuhiro Kawai Oki Technosystems Laboratory
+ Author: Kazunori Nishihara Fuji Xerox
+
+******************************************************************/
+
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include <sys/stat.h>
+#include <stdio.h>
+
+extern int _Xmbstowcs(
+#if NeedFunctionPrototypes
+ wchar_t *wstr,
+ char *str,
+ int len
+#endif
+);
+
+/*
+ * Parsing File Format:
+ *
+ * FILE ::= { [PRODUCTION] [COMMENT] "\n"}
+ * PRODUCTION ::= LHS ":" RHS [ COMMENT ]
+ * COMMENT ::= "#" {<any character except null or newline>}
+ * LHS ::= EVENT { EVENT }
+ * EVENT ::= [MODIFIER_LIST] "<" keysym ">"
+ * MODIFIER_LIST ::= ("!" {MODIFIER} ) | "None"
+ * MODIFIER ::= ["~"] modifier_name
+ * RHS ::= ( STRING | keysym | STRING keysym )
+ * STRING ::= '"' { CHAR } '"'
+ * CHAR ::= GRAPHIC_CHAR | ESCAPED_CHAR
+ * GRAPHIC_CHAR ::= locale (codeset) dependent code
+ * ESCAPED_CHAR ::= ('\\' | '\"' | OCTAL | HEX )
+ * OCTAL ::= '\' OCTAL_CHAR [OCTAL_CHAR [OCTAL_CHAR]]
+ * OCTAL_CHAR ::= (0|1|2|3|4|5|6|7)
+ * HEX ::= '\' (x|X) HEX_CHAR [HEX_CHAR]]
+ * HEX_CHAR ::= (0|1|2|3|4|5|6|7|8|9|A|B|C|D|E|F|a|b|c|d|e|f)
+ *
+ */
+
+static int
+nextch(fp, lastch)
+ FILE *fp;
+ int *lastch;
+{
+ int c;
+
+ if (*lastch != 0) {
+ c = *lastch;
+ *lastch = 0;
+ } else {
+ c = getc(fp);
+ if (c == '\\') {
+ c = getc(fp);
+ if (c == '\n') {
+ c = getc(fp);
+ } else {
+ ungetc(c, fp);
+ c = '\\';
+ }
+ }
+ }
+ return(c);
+}
+
+static void
+putbackch(c, lastch)
+ int c;
+ int *lastch;
+{
+ *lastch = c;
+}
+
+#define ENDOFFILE 0
+#define ENDOFLINE 1
+#define COLON 2
+#define LESS 3
+#define GREATER 4
+#define EXCLAM 5
+#define TILDE 6
+#define STRING 7
+#define KEY 8
+#define ERROR 9
+
+#ifndef isalnum
+#define isalnum(c) \
+ (('0' <= (c) && (c) <= '9') || \
+ ('A' <= (c) && (c) <= 'Z') || \
+ ('a' <= (c) && (c) <= 'z'))
+#endif
+
+static int
+nexttoken(fp, tokenbuf, lastch)
+ FILE *fp;
+ char *tokenbuf;
+ int *lastch;
+{
+ int c;
+ int token;
+ char *p;
+ int i, j;
+
+ while ((c = nextch(fp, lastch)) == ' ' || c == '\t') {
+ }
+ switch (c) {
+ case EOF:
+ token = ENDOFFILE;
+ break;
+ case '\n':
+ token = ENDOFLINE;
+ break;
+ case '<':
+ token = LESS;
+ break;
+ case '>':
+ token = GREATER;
+ break;
+ case ':':
+ token = COLON;
+ break;
+ case '!':
+ token = EXCLAM;
+ break;
+ case '~':
+ token = TILDE;
+ break;
+ case '"':
+ p = tokenbuf;
+ while ((c = nextch(fp, lastch)) != '"') {
+ if (c == '\n' || c == EOF) {
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ } else if (c == '\\') {
+ c = nextch(fp, lastch);
+ switch (c) {
+ case '\\':
+ case '"':
+ *p++ = c;
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ i = c - '0';
+ c = nextch(fp, lastch);
+ for (j = 0; j < 2 && c >= '0' && c <= '7'; j++) {
+ i <<= 3;
+ i += c - '0';
+ c = nextch(fp, lastch);
+ }
+ putbackch(c, lastch);
+ *p++ = (char)i;
+ break;
+ case 'X':
+ case 'x':
+ i = 0;
+ c = nextch(fp, lastch);
+#define ishexch(c) (((c) >= '0' && (c) <= '9') || \
+ ((c) >= 'A' && (c) <= 'F') || \
+ ((c) >= 'a' && (c) <= 'f'))
+ for (j = 0; j < 2 && ishexch(c); j++) {
+ i <<= 4;
+ if (c >= '0' && c <= '9') {
+ i += c - '0';
+ } else if (c >= 'A' && c <= 'F') {
+ i += c - 'A' + 10;
+ } else {
+ i += c - 'a' + 10;
+ }
+ c = nextch(fp, lastch);
+ }
+ if (j == 0) {
+ token = ERROR;
+ goto string_error;
+ }
+ putbackch(c, lastch);
+ *p++ = (char)i;
+#undef ishexch
+ break;
+ case '\n':
+ case EOF:
+ putbackch(c, lastch);
+ token = ERROR;
+ goto string_error;
+ default:
+ *p++ = c;
+ break;
+ }
+ } else {
+ *p++ = c;
+ }
+ }
+ *p = '\0';
+ token = STRING;
+ break;
+ case '#':
+ while ((c = nextch(fp, lastch)) != '\n' && c != EOF) {
+ }
+ if (c == '\n') {
+ token = ENDOFLINE;
+ } else {
+ token = ENDOFFILE;
+ }
+ break;
+ default:
+ if (isalnum(c) || c == '_' || c == '-') {
+ p = tokenbuf;
+ *p++ = c;
+ c = nextch(fp, lastch);
+ while (isalnum(c) || c == '_' || c == '-') {
+ *p++ = c;
+ c = nextch(fp, lastch);
+ }
+ *p = '\0';
+ putbackch(c, lastch);
+ token = KEY;
+ } else {
+ token = ERROR;
+ }
+ break;
+ }
+string_error:
+ return(token);
+}
+
+static long
+modmask(name)
+ char *name;
+{
+ long mask;
+
+ struct _modtbl {
+ char *name;
+ long mask;
+ };
+ struct _modtbl *p;
+
+ static struct _modtbl tbl[] = {
+ { "Ctrl", ControlMask },
+ { "Lock", LockMask },
+ { "Caps", LockMask },
+ { "Shift", ShiftMask },
+ { "Alt", Mod1Mask },
+ { "Meta", Mod1Mask },
+ { NULL, 0 }};
+
+ p = tbl;
+ mask = 0;
+ for (p = tbl; p->name != NULL; p++) {
+ if (strcmp(name, p->name) == 0) {
+ mask = p->mask;
+ break;
+ }
+ }
+ return(mask);
+}
+
+#define AllMask (ShiftMask | LockMask | ControlMask | Mod1Mask)
+#define LOCAL_WC_BUFSIZE 128
+#define SEQUENCE_MAX 10
+
+static int
+parseline(fp, top, tokenbuf)
+ FILE *fp;
+ DefTree **top;
+ char* tokenbuf;
+{
+ int token;
+ unsigned modifier_mask;
+ unsigned modifier;
+ unsigned tmp;
+ KeySym keysym = NoSymbol;
+ DefTree *p;
+ Bool exclam, tilde;
+ KeySym rhs_keysym;
+ char *rhs_string_mb;
+ int l;
+ int lastch = 0;
+ wchar_t local_wc_buf[LOCAL_WC_BUFSIZE], *rhs_string_wc;
+
+ struct DefBuffer {
+ unsigned modifier_mask;
+ unsigned modifier;
+ KeySym keysym;
+ };
+
+ struct DefBuffer buf[SEQUENCE_MAX];
+ int i, n;
+
+ do {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token == ENDOFLINE);
+
+ if (token == ENDOFFILE) {
+ return(-1);
+ }
+
+ n = 0;
+ do {
+ if ((token == KEY) && (strcmp("None", tokenbuf) == 0)) {
+ modifier = 0;
+ modifier_mask = AllMask;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } else {
+ modifier_mask = modifier = 0;
+ exclam = False;
+ if (token == EXCLAM) {
+ exclam = True;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ while (token == TILDE || token == KEY) {
+ tilde = False;
+ if (token == TILDE) {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ tilde = True;
+ if (token != KEY)
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ tmp = modmask(tokenbuf);
+ if (!tmp) {
+ goto error;
+ }
+ modifier_mask |= tmp;
+ if (tilde) {
+ modifier &= ~tmp;
+ } else {
+ modifier |= tmp;
+ }
+ }
+ if (exclam) {
+ modifier_mask = AllMask;
+ }
+ }
+
+ if (token != LESS) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != KEY) {
+ goto error;
+ }
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != GREATER) {
+ goto error;
+ }
+
+ keysym = XStringToKeysym(tokenbuf);
+ if (keysym == NoSymbol) {
+ goto error;
+ }
+
+ buf[n].keysym = keysym;
+ buf[n].modifier = modifier;
+ buf[n].modifier_mask = modifier_mask;
+ n++;
+ if( n >= SEQUENCE_MAX )
+ goto error;
+ token = nexttoken(fp, tokenbuf, &lastch);
+ } while (token != COLON);
+
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == STRING) {
+ if( (rhs_string_mb = Xmalloc(strlen(tokenbuf) + 1)) == NULL )
+ goto error;
+ strcpy(rhs_string_mb, tokenbuf);
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ Xfree(rhs_string_mb);
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ Xfree(rhs_string_mb);
+ goto error;
+ }
+ } else if (token == KEY) {
+ rhs_keysym = XStringToKeysym(tokenbuf);
+ if (rhs_keysym == NoSymbol) {
+ goto error;
+ }
+ token = nexttoken(fp, tokenbuf, &lastch);
+ if (token != ENDOFLINE && token != ENDOFFILE) {
+ goto error;
+ }
+ if( (rhs_string_mb = Xmalloc(1)) == NULL ) {
+ Xfree( rhs_string_mb );
+ goto error;
+ }
+ rhs_string_mb[0] = '\0';
+ } else {
+ goto error;
+ }
+
+ l = _Xmbstowcs(local_wc_buf, rhs_string_mb, LOCAL_WC_BUFSIZE - 1);
+ if (l == LOCAL_WC_BUFSIZE - 1) {
+ local_wc_buf[l] = (wchar_t)'\0';
+ }
+ if( (rhs_string_wc = (wchar_t *)Xmalloc((l + 1) * sizeof(wchar_t))) == NULL ) {
+ Xfree( rhs_string_mb );
+ return( 0 );
+ }
+ memcpy((char *)rhs_string_wc, (char *)local_wc_buf, (l + 1) * sizeof(wchar_t) );
+
+ for (i = 0; i < n; i++) {
+ for (p = *top; p; p = p->next) {
+ if (buf[i].keysym == p->keysym &&
+ buf[i].modifier == p->modifier &&
+ buf[i].modifier_mask == p->modifier_mask) {
+ break;
+ }
+ }
+ if (p) {
+ top = &p->succession;
+ } else {
+ if( (p = (DefTree*)Xmalloc(sizeof(DefTree))) == NULL ) {
+ Xfree( rhs_string_mb );
+ goto error;
+ }
+ p->keysym = buf[i].keysym;
+ p->modifier = buf[i].modifier;
+ p->modifier_mask = buf[i].modifier_mask;
+ p->succession = NULL;
+ p->next = *top;
+ p->mb = NULL;
+ p->wc = NULL;
+ p->ks = NoSymbol;
+ *top = p;
+ top = &p->succession;
+ }
+ }
+
+ if( p->mb != NULL )
+ Xfree( p->mb );
+ p->mb = rhs_string_mb;
+ if( p->wc != NULL )
+ Xfree( p->wc );
+ p->wc = rhs_string_wc;
+ p->ks = rhs_keysym;
+ return(n);
+error:
+ while (token != ENDOFLINE && token != ENDOFFILE) {
+ token = nexttoken(fp, tokenbuf, &lastch);
+ }
+ return(0);
+}
+
+void
+_XimParseStringFile(fp, ptop)
+ FILE *fp;
+ DefTree **ptop;
+{
+ char tb[65535];
+ char* tbp;
+ struct stat st;
+
+ if (fstat (fileno (fp), &st) != -1) {
+ unsigned long size = (unsigned long) st.st_size;
+ if (size < sizeof tb) tbp = tb;
+ else tbp = malloc (size);
+
+ if (tbp != NULL) {
+ while (parseline(fp, ptop, tbp) >= 0) {}
+ if (tbp != tb) free (tbp);
+ }
+ }
+}
diff --git a/modules/im/ximcp/imLcSIc.c b/modules/im/ximcp/imLcSIc.c
new file mode 100644
index 00000000..16ada9bc
--- /dev/null
+++ b/modules/im/ximcp/imLcSIc.c
@@ -0,0 +1,54 @@
+/* $Xorg: imLcSIc.c,v 1.3 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1990, 1991, 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Public char *
+_XimLocalSetICValues(xic, values)
+ XIC xic;
+ XIMArg *values;
+{
+ XimDefICValues ic_values;
+ Xic ic = (Xic)xic;
+ char *name;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ name = _XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_SETICVALUES, True);
+ _XimSetCurrentICValues(ic, &ic_values);
+ return(name);
+}
diff --git a/modules/im/ximcp/imRm.c b/modules/im/ximcp/imRm.c
new file mode 100644
index 00000000..0455b39e
--- /dev/null
+++ b/modules/im/ximcp/imRm.c
@@ -0,0 +1,3135 @@
+/* $Xorg: imRm.c,v 1.4 2000/08/17 19:45:14 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1990, 1991, 1992,1993, 1994 by FUJITSU LIMITED
+ Copyright 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific,
+written prior permission. FUJITSU LIMITED and Sony Corporation make
+no representations about the suitability of this software for any
+purpose. It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND
+SONY CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "Xresource.h"
+
+typedef struct _XimValueOffsetInfo {
+ char *name;
+ XrmQuark quark;
+ unsigned int offset;
+ Bool (*defaults)(
+#if NeedNestedPrototypes
+ struct _XimValueOffsetInfo *, XPointer, XPointer, unsigned long
+#endif
+ );
+ Bool (*encode)(
+#if NeedNestedPrototypes
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+#endif
+ );
+ Bool (*decode)(
+#if NeedNestedPrototypes
+ struct _XimValueOffsetInfo *, XPointer, XPointer
+#endif
+ );
+} XimValueOffsetInfoRec, *XimValueOffsetInfo;
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimCheckBool(str)
+ char *str;
+{
+ if(!strcmp(str, "True") || !strcmp(str, "true") ||
+ !strcmp(str, "Yes") || !strcmp(str, "yes") ||
+ !strcmp(str, "ON") || !strcmp(str, "on"))
+ return True;
+ return False;
+}
+
+Public void
+_XimSetProtoResource(im)
+ Xim im;
+{
+ char res_name_buf[256];
+ char* res_name;
+ char res_class_buf[256];
+ char* res_class;
+ char* str_type;
+ XrmValue value;
+ XIMStyle preedit_style = 0;
+ XIMStyle status_style = 0;
+ XIMStyles* imstyles;
+ char* dotximdot = ".xim.";
+ char* ximdot = "xim.";
+ char* dotXimdot = ".Xim.";
+ char* Ximdot = "Xim.";
+
+ if (!im->core.rdb)
+ return;
+
+ if (strlen (im->core.res_name) < 200) res_name = res_name_buf;
+ else res_name = Xmalloc (strlen (im->core.res_name) + 50);
+ if (strlen (im->core.res_class) < 200) res_class = res_class_buf;
+ else res_class = Xmalloc (strlen (im->core.res_class) + 50);
+ /* pretend malloc always works */
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "useAuth");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "UseAuth");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_USE_AUTHORIZATION_FUNC(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "delaybinding");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Delaybinding");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_DELAYBINDABLE(im);
+ }
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "reconnect");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "Reconnect");
+ bzero(&value, sizeof(XrmValue));
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(_XimCheckBool(value.addr)) {
+ MARK_RECONNECTABLE(im);
+ }
+ }
+
+ if(!IS_CONNECTABLE(im)) {
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "preeditDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "PreeditDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMPreeditArea"))
+ preedit_style = XIMPreeditArea;
+ else if(!strcmp(value.addr, "XIMPreeditCallbacks"))
+ preedit_style = XIMPreeditCallbacks;
+ else if(!strcmp(value.addr, "XIMPreeditPosition"))
+ preedit_style = XIMPreeditPosition;
+ else if(!strcmp(value.addr, "XIMPreeditNothing"))
+ preedit_style = XIMPreeditNothing;
+ else if(!strcmp(value.addr, "XIMPreeditNone"))
+ preedit_style = XIMPreeditNone;
+ }
+ if(!preedit_style)
+ preedit_style = XIMPreeditNothing;
+
+ (void) sprintf (res_name, "%s%s%s",
+ im->core.res_name != NULL ? im->core.res_name : "*",
+ im->core.res_name != NULL ? dotximdot : ximdot,
+ "statusDefaultStyle");
+ (void) sprintf (res_class, "%s%s%s",
+ im->core.res_class != NULL ? im->core.res_class : "*",
+ im->core.res_class != NULL ? dotXimdot : Ximdot,
+ "StatusDefaultStyle");
+ if(XrmGetResource(im->core.rdb, res_name, res_class, &str_type, &value)) {
+ if(!strcmp(value.addr, "XIMStatusArea"))
+ status_style = XIMStatusArea;
+ else if(!strcmp(value.addr, "XIMStatusCallbacks"))
+ status_style = XIMStatusCallbacks;
+ else if(!strcmp(value.addr, "XIMStatusNothing"))
+ status_style = XIMStatusNothing;
+ else if(!strcmp(value.addr, "XIMStatusNone"))
+ status_style = XIMStatusNone;
+ }
+ if(!status_style)
+ status_style = XIMStatusNothing;
+
+ if(!(imstyles = (XIMStyles *)Xmalloc(sizeof(XIMStyles) + sizeof(XIMStyle)))){
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+ return;
+ }
+ imstyles->count_styles = 1;
+ imstyles->supported_styles =
+ (XIMStyle *)((char *)imstyles + sizeof(XIMStyles));
+ imstyles->supported_styles[0] = preedit_style | status_style;
+ im->private.proto.default_styles = imstyles;
+ if (res_name != res_name_buf) Xfree (res_name);
+ if (res_class != res_class_buf) Xfree (res_class);
+}
+#endif /* XIM_CONNECTABLE */
+
+static char *supported_local_im_values_list[] = {
+ XNQueryInputStyle,
+ XNResourceName,
+ XNResourceClass,
+ XNDestroyCallback,
+ XNQueryIMValuesList,
+ XNQueryICValuesList,
+ XNVisiblePosition,
+ (char *)NULL
+};
+
+static char *supported_local_ic_values_list[] = {
+ XNInputStyle,
+ XNClientWindow,
+ XNFocusWindow,
+ XNResourceName,
+ XNResourceClass,
+ XNGeometryCallback,
+ XNFilterEvents,
+ XNDestroyCallback,
+ XNStringConversionCallback,
+ XNStringConversion,
+ XNResetState,
+ XNHotKey,
+ XNHotKeyState,
+ XNPreeditAttributes,
+ XNStatusAttributes,
+ XNArea,
+ XNAreaNeeded,
+ XNSpotLocation,
+ XNColormap,
+ XNStdColormap,
+ XNForeground,
+ XNBackground,
+ XNBackgroundPixmap,
+ XNFontSet,
+ XNLineSpace,
+ XNCursor,
+ XNPreeditStartCallback,
+ XNPreeditDoneCallback,
+ XNPreeditDrawCallback,
+ XNPreeditCaretCallback,
+ XNStatusStartCallback,
+ XNStatusDoneCallback,
+ XNStatusDrawCallback,
+ XNPreeditState,
+ XNPreeditStateNotifyCallback,
+ (char *)NULL
+};
+
+static XIMStyle supported_local_styles[] = {
+ XIMPreeditNone | XIMStatusNone,
+ XIMPreeditNothing | XIMStatusNothing,
+ 0 /* dummy */
+};
+
+Private Bool
+_XimDefaultStyles(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm; /* unused */
+ unsigned long mode; /* unused */
+{
+ XIMStyles *styles;
+ XIMStyles **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_styles) - 1;
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ styles = (XIMStyles *)tmp;
+ if (n > 0) {
+ styles->count_styles = (unsigned short)n;
+ styles->supported_styles =
+ (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+ for(i = 0; i < n; i++) {
+ styles->supported_styles[i] = supported_local_styles[i];
+ }
+ }
+
+ out = (XIMStyles **)((char *)top + info->offset);
+ *out = styles;
+ return True;
+}
+
+Private Bool
+_XimDefaultIMValues(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm; /* unused */
+ unsigned long mode; /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_im_values_list) - 1;
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i]
+ = supported_local_im_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultICValues(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm; /* unused */
+ unsigned long mode; /* unused */
+{
+ XIMValuesList *values_list;
+ XIMValuesList **out;
+ register int i;
+ unsigned int n;
+ int len;
+ XPointer tmp;
+
+ n = XIMNumber(supported_local_ic_values_list) - 1;
+ len = sizeof(XIMValuesList) + sizeof(char **) * n;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ values_list = (XIMValuesList *)tmp;
+ if (n > 0) {
+ values_list->count_values = (unsigned short)n;
+ values_list->supported_values
+ = (char **)((char *)tmp + sizeof(XIMValuesList));
+ for(i = 0; i < n; i++) {
+ values_list->supported_values[i]
+ = supported_local_ic_values_list[i];
+ }
+ }
+
+ out = (XIMValuesList **)((char *)top + info->offset);
+ *out = values_list;
+ return True;
+}
+
+Private Bool
+_XimDefaultVisiblePos(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm; /* unused */
+ unsigned long mode; /* unused */
+{
+ Bool *out;
+
+ out = (Bool *)((char *)top + info->offset);
+ *out = False;
+ return True;
+}
+
+Private Bool
+_XimDefaultFocusWindow(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Window *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+
+ out = (Window *)((char *)top + info->offset);
+ *out = ic->core.client_window;
+ return True;
+}
+
+Private Bool
+_XimDefaultResName(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_name == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_name;
+ return True;
+}
+
+Private Bool
+_XimDefaultResClass(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ char **out;
+
+ if(im->core.res_class == (char *)NULL) {
+ return True;
+ }
+
+ out = (char **)((char *)top + info->offset);
+ *out = im->core.res_class;
+ return True;
+}
+
+Private Bool
+_XimDefaultDestroyCB(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = im->core.destroy_callback;
+ return True;
+}
+
+Private Bool
+_XimDefaultResetState(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = XIMInitialState;
+ return True;
+}
+
+Private Bool
+_XimDefaultHotKeyState(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = XIMHotKeyStateOFF;
+ return True;
+}
+
+Private Bool
+_XimDefaultArea(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ Window root_return;
+ int x_return, y_return;
+ unsigned int width_return, height_return;
+ unsigned int border_width_return;
+ unsigned int depth_return;
+ XRectangle area;
+ XRectangle *out;
+
+ if(ic->core.focus_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetGeometry(im->core.display, (Drawable)ic->core.focus_window,
+ &root_return, &x_return, &y_return, &width_return,
+ &height_return, &border_width_return, &depth_return)
+ == (Status)NULL) {
+ return True;
+ }
+ area.x = 0;
+ area.y = 0;
+ area.width = width_return;
+ area.height = height_return;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = area;
+ return True;
+}
+
+Private Bool
+_XimDefaultColormap(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ XWindowAttributes win_attr;
+ Colormap *out;
+
+ if(ic->core.client_window == (Window)NULL) {
+ return True;
+ }
+ if(XGetWindowAttributes(im->core.display, ic->core.client_window,
+ &win_attr) == (Status)NULL) {
+ return True;
+ }
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = win_attr.colormap;
+ return True;
+}
+
+Private Bool
+_XimDefaultStdColormap(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFg(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long fg;
+ unsigned long *out;
+
+ fg = WhitePixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = fg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBg(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ Xim im = (Xim)ic->core.im;
+ unsigned long bg;
+ unsigned long *out;
+
+ bg = BlackPixel(im->core.display, DefaultScreen(im->core.display));
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = bg;
+ return True;
+}
+
+Private Bool
+_XimDefaultBgPixmap(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultFontSet(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = 0;
+ return True;
+}
+
+Private Bool
+_XimDefaultLineSpace(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Xic ic = (Xic)parm;
+ XFontSet fontset;
+ XFontSetExtents *fset_extents;
+ int line_space = 0;
+ int *out;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ fontset = ic->core.preedit_attr.fontset;
+ } else if(mode & XIM_STATUS_ATTR) {
+ fontset = ic->core.status_attr.fontset;
+ } else {
+ return True;
+ }
+ if (fontset) {
+ fset_extents = XExtentsOfFontSet(fontset);
+ line_space = fset_extents->max_logical_extent.height;
+ }
+ out = (int *)((char *)top + info->offset);
+ *out = line_space;
+ return True;
+}
+
+Private Bool
+_XimDefaultCursor(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)0;
+ return True;
+}
+
+Private Bool
+_XimDefaultPreeditState(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = XIMPreeditDisable;
+ return True;
+}
+
+Private Bool
+_XimDefaultNest(info, top, parm, mode)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer parm;
+ unsigned long mode;
+{
+ return True;
+}
+
+Private Bool
+_XimEncodeCallback(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMCallback *out;
+
+ out = (XIMCallback *)((char *)top + info->offset);
+ *out = *((XIMCallback *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeString(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ int len;
+ char *string;
+ char **out;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+ len = strlen((char *)val);
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ (void)strcpy(string, (char *)val);
+ string[len] = '\0';
+
+ out = (char **)((char *)top + info->offset);
+ if(*out) {
+ Xfree(*out);
+ }
+ *out = string;
+ return True;
+}
+
+Private Bool
+_XimEncodeStyle(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMStyle *out;
+
+ out = (XIMStyle *)((char *)top + info->offset);
+ *out = (XIMStyle)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeWindow(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Window *out;
+
+ out = (Window *)((char *)top + info->offset);
+ *out = (Window)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStringConv(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimEncodeResetState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMResetState *out;
+
+ out = (XIMResetState *)((char *)top + info->offset);
+ *out = (XIMResetState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKey(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)val;
+ XIMHotKeyTriggers **out;
+ XIMHotKeyTriggers *key_list;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ if(hotkey == (XIMHotKeyTriggers *)NULL) {
+ return True;
+ }
+
+ if((num = hotkey->num_hot_key) == 0) {
+ return True;
+ }
+
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ key_list = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = hotkey->key[i];
+ }
+
+ key_list->num_hot_key = num;
+ key_list->key = key;
+
+ out = (XIMHotKeyTriggers **)((char *)top + info->offset);
+ *out = key_list;
+ return True;
+}
+
+Private Bool
+_XimEncodeHotKetState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMHotKeyState *out;
+
+ out = (XIMHotKeyState *)((char *)top + info->offset);
+ *out = (XIMHotKeyState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeRectangle(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XRectangle *out;
+
+ out = (XRectangle *)((char *)top + info->offset);
+ *out = *((XRectangle *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeSpot(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XPoint *out;
+
+ out = (XPoint *)((char *)top + info->offset);
+ *out = *((XPoint *)val);
+ return True;
+}
+
+Private Bool
+_XimEncodeColormap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Colormap *out;
+
+ out = (Colormap *)((char *)top + info->offset);
+ *out = (Colormap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeStdColormap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Atom *out;
+
+ out = (Atom *)((char *)top + info->offset);
+ *out = (Atom)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLong(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ unsigned long *out;
+
+ out = (unsigned long *)((char *)top + info->offset);
+ *out = (unsigned long)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeBgPixmap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Pixmap *out;
+
+ out = (Pixmap *)((char *)top + info->offset);
+ *out = (Pixmap)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeFontSet(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XFontSet *out;
+
+ out = (XFontSet *)((char *)top + info->offset);
+ *out = (XFontSet)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeLineSpace(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ int *out;
+
+ out = (int *)((char *)top + info->offset);
+ *out = (int)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeCursor(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Cursor *out;
+
+ out = (Cursor *)((char *)top + info->offset);
+ *out = (Cursor)val;
+ return True;
+}
+
+Private Bool
+_XimEncodePreeditState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMPreeditState *out;
+
+ out = (XIMPreeditState *)((char *)top + info->offset);
+ *out = (XIMPreeditState)val;
+ return True;
+}
+
+Private Bool
+_XimEncodeNest(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ return True;
+}
+
+Private Bool
+_XimDecodeStyles(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMStyles *styles;
+ XIMStyles *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ styles = *((XIMStyles **)((char *)top + info->offset));
+ num = styles->count_styles;
+
+ len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMStyles *)tmp;
+ if(num >0) {
+ out->count_styles = (unsigned short)num;
+ out->supported_styles = (XIMStyle *)((char *)tmp + sizeof(XIMStyles));
+
+ for(i = 0; i < num; i++) {
+ out->supported_styles[i] = styles->supported_styles[i];
+ }
+ }
+ *((XIMStyles **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeValues(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMValuesList *values_list;
+ XIMValuesList *out;
+ register int i;
+ unsigned int num;
+ int len;
+ XPointer tmp;
+
+ if(val == (XPointer)NULL) {
+ return False;
+ }
+
+ values_list = *((XIMValuesList **)((char *)top + info->offset));
+ num = values_list->count_values;
+
+ len = sizeof(XIMValuesList) + sizeof(char **) * num;
+ if(!(tmp = (char *)Xmalloc(len))) {
+ return False;
+ }
+ bzero(tmp, len);
+
+ out = (XIMValuesList *)tmp;
+ if(num) {
+ out->count_values = (unsigned short)num;
+ out->supported_values = (char **)((char *)tmp + sizeof(XIMValuesList));
+
+ for(i = 0; i < num; i++) {
+ out->supported_values[i] = values_list->supported_values[i];
+ }
+ }
+ *((XIMValuesList **)val) = out;
+ return True;
+}
+
+Private Bool
+_XimDecodeCallback(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMCallback *in;
+ XIMCallback *callback;
+
+ in = (XIMCallback *)((char *)top + info->offset);
+ if(!(callback = (XIMCallback *)Xmalloc(sizeof(XIMCallback)))) {
+ return False;
+ }
+ callback->client_data = in->client_data;
+ callback->callback = in->callback;
+
+ *((XIMCallback **)val) = callback;
+ return True;
+}
+
+Private Bool
+_XimDecodeString(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ int len = 0;
+ char *in;
+ char *string;
+
+ in = *((char **)((char *)top + info->offset));
+ if(in != (char *)NULL) {
+ len = strlen(in);
+ }
+ if(!(string = (char *)Xmalloc(len + 1))) {
+ return False;
+ }
+ if(in != (char *)NULL) {
+ (void)strcpy(string, in);
+ }
+ string[len] = '\0';
+ *((char **)val) = string;
+ return True;
+}
+
+Private Bool
+_XimDecodeBool(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Bool *in;
+
+ in = (Bool *)((char *)top + info->offset);
+ *((Bool *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStyle(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMStyle *in;
+
+ in = (XIMStyle *)((char *)top + info->offset);
+ *((XIMStyle *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeWindow(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Window *in;
+
+ in = (Window *)((char *)top + info->offset);
+ *((Window *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStringConv(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ /*
+ * Not yet
+ */
+ return True;
+}
+
+Private Bool
+_XimDecodeResetState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMResetState *in;
+
+ in = (XIMResetState *)((char *)top + info->offset);
+ *((XIMResetState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKey(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMHotKeyTriggers *in;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyTrigger *key;
+ XPointer tmp;
+ int num;
+ int len;
+ register int i;
+
+ in = *((XIMHotKeyTriggers **)((char *)top + info->offset));
+ num = in->num_hot_key;
+ len = sizeof(XIMHotKeyTriggers) + sizeof(XIMHotKeyTrigger) * num;
+ if(!(tmp = (XPointer)Xmalloc(len))) {
+ return False;
+ }
+
+ hotkey = (XIMHotKeyTriggers *)tmp;
+ key = (XIMHotKeyTrigger *)((char *)tmp + sizeof(XIMHotKeyTriggers));
+
+ for(i = 0; i < num; i++) {
+ key[i] = in->key[i];
+ }
+ hotkey->num_hot_key = num;
+ hotkey->key = key;
+
+ *((XIMHotKeyTriggers **)val) = hotkey;
+ return True;
+}
+
+Private Bool
+_XimDecodeHotKetState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMHotKeyState *in;
+
+ in = (XIMHotKeyState *)((char *)top + info->offset);
+ *((XIMHotKeyState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeRectangle(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XRectangle *in;
+ XRectangle *rect;
+
+ in = (XRectangle *)((char *)top + info->offset);
+ if(!(rect = (XRectangle *)Xmalloc(sizeof(XRectangle)))) {
+ return False;
+ }
+ *rect = *in;
+ *((XRectangle **)val) = rect;
+ return True;
+}
+
+Private Bool
+_XimDecodeSpot(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XPoint *in;
+ XPoint *spot;
+
+ in = (XPoint *)((char *)top + info->offset);
+ if(!(spot = (XPoint *)Xmalloc(sizeof(XPoint)))) {
+ return False;
+ }
+ *spot = *in;
+ *((XPoint **)val) = spot;
+ return True;
+}
+
+Private Bool
+_XimDecodeColormap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Colormap *in;
+
+ in = (Colormap *)((char *)top + info->offset);
+ *((Colormap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeStdColormap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Atom *in;
+
+ in = (Atom *)((char *)top + info->offset);
+ *((Atom *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLong(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ unsigned long *in;
+
+ in = (unsigned long *)((char *)top + info->offset);
+ *((unsigned long *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeBgPixmap(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Pixmap *in;
+
+ in = (Pixmap *)((char *)top + info->offset);
+ *((Pixmap *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeFontSet(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XFontSet *in;
+
+ in = (XFontSet *)((char *)top + info->offset);
+ *((XFontSet *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeLineSpace(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ int *in;
+
+ in = (int *)((char *)top + info->offset);
+ *((int *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeCursor(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ Cursor *in;
+
+ in = (Cursor *)((char *)top + info->offset);
+ *((Cursor *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodePreeditState(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ XIMPreeditState *in;
+
+ in = (XIMPreeditState *)((char *)top + info->offset);
+ *((XIMPreeditState *)val) = *in;
+ return True;
+}
+
+Private Bool
+_XimDecodeNest(info, top, val)
+ XimValueOffsetInfo info;
+ XPointer top;
+ XPointer val;
+{
+ return True;
+}
+
+static XIMResource im_resources[] = {
+ {XNQueryInputStyle, 0, XimType_XIMStyles, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource im_inner_resources[] = {
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNQueryIMValuesList, 0, 0, 0, 0, 0},
+ {XNQueryICValuesList, 0, 0, 0, 0, 0},
+ {XNVisiblePosition, 0, 0, 0, 0, 0}
+};
+
+static XIMResource ic_resources[] = {
+ {XNInputStyle, 0, XimType_CARD32, 0, 0, 0},
+ {XNClientWindow, 0, XimType_Window, 0, 0, 0},
+ {XNFocusWindow, 0, XimType_Window, 0, 0, 0},
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNFilterEvents, 0, XimType_CARD32, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNStringConversion, 0, XimType_XIMStringConversion,0, 0, 0},
+ {XNResetState, 0, 0, 0, 0, 0},
+ {XNHotKey, 0, XimType_XIMHotKeyTriggers,0, 0, 0},
+ {XNHotKeyState, 0, XimType_XIMHotKeyState, 0, 0, 0},
+ {XNPreeditAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNStatusAttributes, 0, XimType_NEST, 0, 0, 0},
+ {XNArea, 0, XimType_XRectangle, 0, 0, 0},
+ {XNAreaNeeded, 0, XimType_XRectangle, 0, 0, 0},
+ {XNSpotLocation, 0, XimType_XPoint, 0, 0, 0},
+ {XNColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNStdColormap, 0, XimType_CARD32, 0, 0, 0},
+ {XNForeground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackground, 0, XimType_CARD32, 0, 0, 0},
+ {XNBackgroundPixmap, 0, XimType_CARD32, 0, 0, 0},
+ {XNFontSet, 0, XimType_XFontSet, 0, 0, 0},
+ {XNLineSpace, 0, XimType_CARD32, 0, 0, 0},
+ {XNCursor, 0, XimType_CARD32, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditState, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XIMResource ic_inner_resources[] = {
+ {XNResourceName, 0, XimType_STRING8, 0, 0, 0},
+ {XNResourceClass, 0, XimType_STRING8, 0, 0, 0},
+ {XNGeometryCallback, 0, 0, 0, 0, 0},
+ {XNDestroyCallback, 0, 0, 0, 0, 0},
+ {XNStringConversionCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStartCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDoneCallback, 0, 0, 0, 0, 0},
+ {XNPreeditDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditCaretCallback, 0, 0, 0, 0, 0},
+ {XNStatusStartCallback, 0, 0, 0, 0, 0},
+ {XNStatusDoneCallback, 0, 0, 0, 0, 0},
+ {XNStatusDrawCallback, 0, 0, 0, 0, 0},
+ {XNPreeditStateNotifyCallback, 0, 0, 0, 0, 0},
+};
+
+static XimValueOffsetInfoRec im_attr_info[] = {
+ {XNQueryInputStyle, 0,
+ XOffsetOf(XimDefIMValues, styles),
+ _XimDefaultStyles, NULL, _XimDecodeStyles},
+
+ {XNDestroyCallback, 0,
+ XOffsetOf(XimDefIMValues, destroy_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNResourceName, 0,
+ XOffsetOf(XimDefIMValues, res_name),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {XNResourceClass, 0,
+ XOffsetOf(XimDefIMValues, res_class),
+ NULL, _XimEncodeString, _XimDecodeString},
+
+ {XNQueryIMValuesList, 0,
+ XOffsetOf(XimDefIMValues, im_values_list),
+ _XimDefaultIMValues, NULL, _XimDecodeValues},
+
+ {XNQueryICValuesList, 0,
+ XOffsetOf(XimDefIMValues, ic_values_list),
+ _XimDefaultICValues, NULL, _XimDecodeValues},
+
+ {XNVisiblePosition, 0,
+ XOffsetOf(XimDefIMValues, visible_position),
+ _XimDefaultVisiblePos, NULL, _XimDecodeBool}
+};
+
+static XimValueOffsetInfoRec ic_attr_info[] = {
+ {XNInputStyle, 0,
+ XOffsetOf(XimDefICValues, input_style),
+ NULL, _XimEncodeStyle, _XimDecodeStyle},
+
+ {XNClientWindow, 0,
+ XOffsetOf(XimDefICValues, client_window),
+ NULL, _XimEncodeWindow, _XimDecodeWindow},
+
+ {XNFocusWindow, 0,
+ XOffsetOf(XimDefICValues, focus_window),
+ _XimDefaultFocusWindow, _XimEncodeWindow, _XimDecodeWindow},
+
+ {XNResourceName, 0,
+ XOffsetOf(XimDefICValues, res_name),
+ _XimDefaultResName, _XimEncodeString, _XimDecodeString},
+
+ {XNResourceClass, 0,
+ XOffsetOf(XimDefICValues, res_class),
+ _XimDefaultResClass, _XimEncodeString, _XimDecodeString},
+
+ {XNGeometryCallback, 0,
+ XOffsetOf(XimDefICValues, geometry_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNFilterEvents, 0,
+ XOffsetOf(XimDefICValues, filter_events),
+ NULL, NULL, _XimDecodeLong},
+
+ {XNDestroyCallback, 0,
+ XOffsetOf(XimDefICValues, destroy_callback),
+ _XimDefaultDestroyCB, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStringConversionCallback, 0,
+ XOffsetOf(XimDefICValues, string_conversion_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStringConversion, 0,
+ XOffsetOf(XimDefICValues, string_conversion),
+ NULL, _XimEncodeStringConv, _XimDecodeStringConv},
+
+ {XNResetState, 0,
+ XOffsetOf(XimDefICValues, reset_state),
+ _XimDefaultResetState, _XimEncodeResetState, _XimDecodeResetState},
+
+ {XNHotKey, 0,
+ XOffsetOf(XimDefICValues, hotkey),
+ NULL, _XimEncodeHotKey, _XimDecodeHotKey},
+
+ {XNHotKeyState, 0,
+ XOffsetOf(XimDefICValues, hotkey_state),
+ _XimDefaultHotKeyState, _XimEncodeHotKetState, _XimDecodeHotKetState},
+
+ {XNPreeditAttributes, 0,
+ XOffsetOf(XimDefICValues, preedit_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+
+ {XNStatusAttributes, 0,
+ XOffsetOf(XimDefICValues, status_attr),
+ _XimDefaultNest, _XimEncodeNest, _XimDecodeNest},
+};
+
+static XimValueOffsetInfoRec ic_pre_attr_info[] = {
+ {XNArea, 0,
+ XOffsetOf(ICPreeditAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNAreaNeeded, 0,
+ XOffsetOf(ICPreeditAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNSpotLocation, 0,
+ XOffsetOf(ICPreeditAttributes, spot_location),
+ NULL, _XimEncodeSpot, _XimDecodeSpot},
+
+ {XNColormap, 0,
+ XOffsetOf(ICPreeditAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {XNStdColormap, 0,
+ XOffsetOf(ICPreeditAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {XNForeground, 0,
+ XOffsetOf(ICPreeditAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackground, 0,
+ XOffsetOf(ICPreeditAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackgroundPixmap, 0,
+ XOffsetOf(ICPreeditAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {XNFontSet, 0,
+ XOffsetOf(ICPreeditAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {XNLineSpace, 0,
+ XOffsetOf(ICPreeditAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {XNCursor, 0,
+ XOffsetOf(ICPreeditAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {XNPreeditStartCallback, 0,
+ XOffsetOf(ICPreeditAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditDoneCallback, 0,
+ XOffsetOf(ICPreeditAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditDrawCallback, 0,
+ XOffsetOf(ICPreeditAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditCaretCallback, 0,
+ XOffsetOf(ICPreeditAttributes, caret_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNPreeditState, 0,
+ XOffsetOf(ICPreeditAttributes, preedit_state),
+ _XimDefaultPreeditState, _XimEncodePreeditState,_XimDecodePreeditState},
+
+ {XNPreeditStateNotifyCallback, 0,
+ XOffsetOf(ICPreeditAttributes, state_notify_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+};
+
+static XimValueOffsetInfoRec ic_sts_attr_info[] = {
+ {XNArea, 0,
+ XOffsetOf(ICStatusAttributes, area),
+ _XimDefaultArea, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNAreaNeeded, 0,
+ XOffsetOf(ICStatusAttributes, area_needed),
+ NULL, _XimEncodeRectangle, _XimDecodeRectangle},
+
+ {XNColormap, 0,
+ XOffsetOf(ICStatusAttributes, colormap),
+ _XimDefaultColormap, _XimEncodeColormap, _XimDecodeColormap},
+
+ {XNStdColormap, 0,
+ XOffsetOf(ICStatusAttributes, std_colormap),
+ _XimDefaultStdColormap, _XimEncodeStdColormap, _XimDecodeStdColormap},
+
+ {XNForeground, 0,
+ XOffsetOf(ICStatusAttributes, foreground),
+ _XimDefaultFg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackground, 0,
+ XOffsetOf(ICStatusAttributes, background),
+ _XimDefaultBg, _XimEncodeLong, _XimDecodeLong},
+
+ {XNBackgroundPixmap, 0,
+ XOffsetOf(ICStatusAttributes, background_pixmap),
+ _XimDefaultBgPixmap, _XimEncodeBgPixmap, _XimDecodeBgPixmap},
+
+ {XNFontSet, 0,
+ XOffsetOf(ICStatusAttributes, fontset),
+ _XimDefaultFontSet, _XimEncodeFontSet, _XimDecodeFontSet},
+
+ {XNLineSpace, 0,
+ XOffsetOf(ICStatusAttributes, line_spacing),
+ _XimDefaultLineSpace, _XimEncodeLineSpace, _XimDecodeLineSpace},
+
+ {XNCursor, 0,
+ XOffsetOf(ICStatusAttributes, cursor),
+ _XimDefaultCursor, _XimEncodeCursor, _XimDecodeCursor},
+
+ {XNStatusStartCallback, 0,
+ XOffsetOf(ICStatusAttributes, start_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStatusDoneCallback, 0,
+ XOffsetOf(ICStatusAttributes, done_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback},
+
+ {XNStatusDrawCallback, 0,
+ XOffsetOf(ICStatusAttributes, draw_callback),
+ NULL, _XimEncodeCallback, _XimDecodeCallback}
+};
+
+typedef struct _XimIMMode {
+ char *name;
+ XrmQuark quark;
+ unsigned short mode;
+} XimIMMode;
+
+static XimIMMode im_mode[] = {
+ {XNQueryInputStyle, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNDestroyCallback, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNResourceName, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNResourceClass, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_SET | XIM_MODE_IM_GET)},
+ {XNQueryIMValuesList, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNQueryICValuesList, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)},
+ {XNVisiblePosition, 0,
+ (XIM_MODE_IM_DEFAULT | XIM_MODE_IM_GET)}
+};
+
+typedef struct _XimICMode {
+ char *name;
+ XrmQuark quark;
+ unsigned short preedit_callback_mode;
+ unsigned short preedit_position_mode;
+ unsigned short preedit_area_mode;
+ unsigned short preedit_nothing_mode;
+ unsigned short preedit_none_mode;
+ unsigned short status_callback_mode;
+ unsigned short status_area_mode;
+ unsigned short status_nothing_mode;
+ unsigned short status_none_mode;
+} XimICMode;
+
+static XimICMode ic_mode[] = {
+ {XNInputStyle, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_GET)},
+ {XNClientWindow, 0,
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_ONCE | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_ONCE | XIM_MODE_STS_GET),
+ 0},
+ {XNFocusWindow, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNResourceName, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNResourceClass, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNGeometryCallback, 0,
+ 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNFilterEvents, 0,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ XIM_MODE_PRE_GET,
+ 0,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET,
+ XIM_MODE_STS_GET},
+ {XNDestroyCallback, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStringConversionCallback, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStringConversion, 0,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ XIM_MODE_PRE_SET,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNResetState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNHotKey, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNHotKeyState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditAttributes, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStatusAttributes, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNArea, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNAreaNeeded, 0,
+ 0,
+ 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0},
+ {XNSpotLocation, 0,
+ 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNColormap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNStdColormap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNForeground, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNBackground, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNBackgroundPixmap, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNFontSet, 0,
+ 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNLineSpace, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNCursor, 0,
+ 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ (XIM_MODE_STS_DEFAULT | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0},
+ {XNPreeditStartCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditDoneCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditDrawCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditCaretCallback, 0,
+ (XIM_MODE_PRE_CREATE | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditState, 0,
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_DEFAULT | XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNPreeditStateNotifyCallback, 0,
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ (XIM_MODE_PRE_SET | XIM_MODE_PRE_GET),
+ 0,
+ 0,
+ 0,
+ 0,
+ 0},
+ {XNStatusStartCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {XNStatusDoneCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0},
+ {XNStatusDrawCallback, 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ (XIM_MODE_STS_CREATE | XIM_MODE_STS_SET | XIM_MODE_STS_GET),
+ 0,
+ 0,
+ 0}
+};
+
+Private Bool
+_XimSetResourceList(res_list, list_num, resource, num_resource, id)
+ XIMResourceList *res_list;
+ unsigned int *list_num;
+ XIMResourceList resource;
+ unsigned int num_resource;
+ unsigned short id;
+{
+ register int i;
+ int len;
+ XIMResourceList res;
+
+ len = sizeof(XIMResource) * num_resource;
+ if(!(res = (XIMResourceList)Xmalloc(len))) {
+ return False;
+ }
+ bzero((char *)res, len);
+
+ for(i = 0; i < num_resource; i++, id++) {
+ res[i] = resource[i];
+ res[i].id = id;
+ }
+
+ _XIMCompileResourceList(res, num_resource);
+ *res_list = res;
+ *list_num = num_resource;
+ return True;
+}
+
+Public Bool
+_XimSetIMResourceList(res_list, list_num)
+ XIMResourceList *res_list;
+ unsigned int *list_num;
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_resources, XIMNumber(im_resources), 100);
+}
+
+Public Bool
+_XimSetICResourceList(res_list, list_num)
+ XIMResourceList *res_list;
+ unsigned int *list_num;
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_resources, XIMNumber(ic_resources), 200);
+}
+
+Public Bool
+_XimSetInnerIMResourceList(res_list, list_num)
+ XIMResourceList *res_list;
+ unsigned int *list_num;
+{
+ return _XimSetResourceList(res_list, list_num,
+ im_inner_resources, XIMNumber(im_inner_resources), 100);
+}
+
+Public Bool
+_XimSetInnerICResourceList(res_list, list_num)
+ XIMResourceList *res_list;
+ unsigned int *list_num;
+{
+ return _XimSetResourceList(res_list, list_num,
+ ic_inner_resources, XIMNumber(ic_inner_resources), 200);
+}
+
+Private XIMResourceList
+_XimGetResourceListRecByMode(res_list, list_num, mode)
+ XIMResourceList res_list;
+ unsigned int list_num;
+ unsigned short mode;
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].mode & mode) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public Bool
+_XimCheckCreateICValues(res_list, list_num)
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ if (!_XimGetResourceListRecByMode(res_list, list_num, XIM_MODE_IC_CREATE)) {
+ return True;
+ }
+ return False;
+}
+
+Public XIMResourceList
+_XimGetResourceListRecByQuark(res_list, list_num, quark)
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XrmQuark quark;
+{
+ register int i;
+
+ for(i = 0; i < list_num; i++) {
+ if (res_list[i].xrm_name == quark) {
+ return (XIMResourceList)&res_list[i];
+ }
+ }
+ return (XIMResourceList)NULL;
+}
+
+Public XIMResourceList
+_XimGetResourceListRec(res_list, list_num, name)
+ XIMResourceList res_list;
+ unsigned int list_num;
+ char *name;
+{
+ XrmQuark quark = XrmStringToQuark(name);
+
+ return _XimGetResourceListRecByQuark(res_list, list_num, quark);
+}
+
+Public char *
+_XimSetIMValueData(im, top, values, res_list, list_num)
+ Xim im;
+ XPointer top;
+ XIMArg *values;
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_SETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimEncodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public char *
+_XimGetIMValueData(im, top, values, res_list, list_num)
+ Xim im;
+ XPointer top;
+ XIMArg *values;
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ for(p = values; p->name != NULL; p++) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return p->value;
+ }
+ check = _XimCheckIMMode(res, XIM_GETIMVALUES);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return p->value;
+ }
+
+ if(!_XimDecodeLocalIMAttr(res, top, p->value)) {
+ return p->value;
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimSetIMMode(res_list, list_num)
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, im_mode[i].quark))) {
+ continue;
+ }
+ res->mode = im_mode[i].mode;
+ }
+ return;
+}
+
+Private int
+_XimCheckSetIMDefaultsMode(res)
+ XIMResourceList res;
+{
+ if(res->mode & XIM_MODE_IM_DEFAULT) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+_XimCheckSetIMValuesMode(res)
+ XIMResourceList res;
+{
+ if(res->mode & XIM_MODE_IM_SET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Private int
+ _XimCheckGetIMValuesMode(res)
+ XIMResourceList res;
+{
+ if(res->mode & XIM_MODE_IM_GET) {
+ return XIM_CHECK_VALID;
+ }
+ return XIM_CHECK_INVALID;
+}
+
+Public int
+ _XimCheckIMMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(res->mode == 0) {
+ return XIM_CHECK_INVALID;
+ }
+ if(mode & XIM_SETIMDEFAULTS) {
+ return _XimCheckSetIMDefaultsMode(res);
+ } else if (mode & XIM_SETIMVALUES) {
+ return _XimCheckSetIMValuesMode(res);
+ } else if (mode & XIM_GETIMVALUES) {
+ return _XimCheckGetIMValuesMode(res);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public void
+_XimSetICMode(res_list, list_num, style)
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XIMStyle style;
+{
+ XIMResourceList res;
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+ unsigned int pre_offset;
+ unsigned int sts_offset;
+
+ if(style & XIMPreeditArea) {
+ pre_offset = XOffsetOf(XimICMode, preedit_area_mode);
+ } else if(style & XIMPreeditCallbacks) {
+ pre_offset = XOffsetOf(XimICMode, preedit_callback_mode);
+ } else if(style & XIMPreeditPosition) {
+ pre_offset = XOffsetOf(XimICMode, preedit_position_mode);
+ } else if(style & XIMPreeditNothing) {
+ pre_offset = XOffsetOf(XimICMode, preedit_nothing_mode);
+ } else {
+ pre_offset = XOffsetOf(XimICMode, preedit_none_mode);
+ }
+
+ if(style & XIMStatusArea) {
+ sts_offset = XOffsetOf(XimICMode, status_area_mode);
+ } else if(style & XIMStatusCallbacks) {
+ sts_offset = XOffsetOf(XimICMode, status_callback_mode);
+ } else if(style & XIMStatusNothing) {
+ sts_offset = XOffsetOf(XimICMode, status_nothing_mode);
+ } else {
+ sts_offset = XOffsetOf(XimICMode, status_none_mode);
+ }
+
+ for(i = 0; i < n; i++) {
+ if(!(res = _XimGetResourceListRecByQuark(res_list,
+ list_num, ic_mode[i].quark))) {
+ continue;
+ }
+ res->mode = ( (*(unsigned short *)((char *)&ic_mode[i] + pre_offset))
+ | (*(unsigned short *)((char *)&ic_mode[i] + sts_offset)));
+ }
+ return;
+}
+
+Private int
+_XimCheckSetICDefaultsMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ return XIM_CHECK_ERROR;
+ } else if (!(res->mode & XIM_MODE_PRE_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_STS_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ return XIM_CHECK_ERROR;
+ }
+ if(!(res->mode & XIM_MODE_IC_DEFAULT)) {
+ return XIM_CHECK_INVALID;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckCreateICMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_CREATE) {
+ res->mode &= ~XIM_MODE_PRE_CREATE;
+ } else if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(res->mode & XIM_MODE_PRE_DEFAULT) {
+ res->mode &= ~XIM_MODE_PRE_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_CREATE) {
+ res->mode &= ~XIM_MODE_STS_CREATE;
+ } else if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(res->mode & XIM_MODE_STS_DEFAULT) {
+ res->mode &= ~XIM_MODE_STS_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_CREATE) {
+ res->mode &= ~XIM_MODE_IC_CREATE;
+ } else if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(res->mode & XIM_MODE_IC_DEFAULT) {
+ res->mode &= ~XIM_MODE_IC_DEFAULT;
+ } else if (!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckSetICValuesMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_PRE_ONCE) {
+ res->mode &= ~XIM_MODE_PRE_ONCE;
+ } else if(!(res->mode & XIM_MODE_PRE_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_STS_ONCE) {
+ res->mode &= ~XIM_MODE_STS_ONCE;
+ } else if(!(res->mode & XIM_MODE_STS_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(res->mode & XIM_MODE_IC_ONCE) {
+ res->mode &= ~XIM_MODE_IC_ONCE;
+ } else if(!(res->mode & XIM_MODE_IC_SET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Private int
+_XimCheckGetICValuesMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(mode & XIM_PREEDIT_ATTR) {
+ if(!(res->mode & XIM_MODE_PRE_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_PRE_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else if(mode & XIM_STATUS_ATTR) {
+ if(!(res->mode & XIM_MODE_STS_MASK)) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_STS_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+
+ } else {
+ if(!res->mode) {
+ return XIM_CHECK_INVALID;
+ }
+
+ if(!(res->mode & XIM_MODE_IC_GET)) {
+ return XIM_CHECK_ERROR;
+ }
+ }
+ return XIM_CHECK_VALID;
+}
+
+Public int
+ _XimCheckICMode(res, mode)
+ XIMResourceList res;
+ unsigned long mode;
+{
+ if(mode &XIM_SETICDEFAULTS) {
+ return _XimCheckSetICDefaultsMode(res, mode);
+ } else if (mode & XIM_CREATEIC) {
+ return _XimCheckCreateICMode(res, mode);
+ } else if (mode & XIM_SETICVALUES) {
+ return _XimCheckSetICValuesMode(res, mode);
+ } else if (mode & XIM_GETICVALUES) {
+ return _XimCheckGetICValuesMode(res, mode);
+ } else {
+ return XIM_CHECK_ERROR;
+ }
+}
+
+Public Bool
+_XimSetLocalIMDefaults(im, top, res_list, list_num)
+ Xim im;
+ XPointer top;
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ XimValueOffsetInfo info;
+ unsigned int num;
+ register int i;
+ XIMResourceList res;
+ int check;
+
+ info = im_attr_info;
+ num = XIMNumber(im_attr_info);
+
+ for(i = 0; i < num; i++) {
+ if((res = _XimGetResourceListRecByQuark( res_list, list_num,
+ info[i].quark)) == (XIMResourceList)NULL) {
+ return False;
+ }
+
+ check = _XimCheckIMMode(res, XIM_SETIMDEFAULTS);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if(!info[i].defaults) {
+ continue;
+ }
+ if(!(info[i].defaults(&info[i], top, (XPointer)NULL, 0))) {
+ return False;
+ }
+ }
+ return True;
+}
+
+Public Bool
+_XimSetICDefaults(ic, top, mode, res_list, list_num)
+ Xic ic;
+ XPointer top;
+ unsigned long mode;
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+ register int i;
+ XIMResourceList res;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ for(i = 0; i < num; i++) {
+ if(info[i].quark == pre_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_PREEDIT_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else if (info[i].quark == sts_quark) {
+ if(!_XimSetICDefaults(ic, (XPointer)((char *)top + info[i].offset),
+ (mode | XIM_STATUS_ATTR), res_list, list_num)) {
+ return False;
+ }
+ } else {
+ if(!(res = _XimGetResourceListRecByQuark(res_list, list_num,
+ info[i].quark))) {
+ return False;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID) {
+ continue;
+ } else if (check == XIM_CHECK_ERROR) {
+ return False;
+ }
+
+ if (!info[i].defaults) {
+ continue;
+ }
+ if (!(info[i].defaults(&info[i], top, (XPointer)ic, mode))) {
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeAttr(info, num, res, top, val)
+ XimValueOffsetInfo info;
+ unsigned int num;
+ XIMResourceList res;
+ XPointer top;
+ XPointer val;
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].encode) {
+ return False;
+ }
+ return (*info[i].encode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimEncodeLocalIMAttr(res, top, val)
+ XIMResourceList res;
+ XPointer top;
+ XPointer val;
+{
+ return _XimEncodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimEncodeLocalICAttr(ic, res, top, arg, mode)
+ Xic ic;
+ XIMResourceList res;
+ XPointer top;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimEncodeAttr(info, num, res, top, arg->value);
+}
+
+Private Bool
+_XimEncodeLocalTopValue(ic, res, val, flag)
+ Xic ic;
+ XIMResourceList res;
+ XPointer val;
+ Bool flag;
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
+ ic->core.client_window = (Window)p->value;
+ if (ic->core.focus_window == (Window)0)
+ ic->core.focus_window = ic->core.client_window;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window,
+ KeyPress, KeyPress, _XimLocalFilter, (XPointer)ic);
+ }
+ } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
+ if (ic->core.client_window) {
+ if (flag) {
+ _XUnregisterFilter(ic->core.im->core.display,
+ ic->core.focus_window, _XimLocalFilter, (XPointer)ic);
+ }
+ ic->core.focus_window = (Window)p->value;
+ if (flag) {
+ _XRegisterFilterByType(ic->core.im->core.display,
+ ic->core.focus_window, KeyPress, KeyPress,
+ _XimLocalFilter, (XPointer)ic);
+ }
+ } else
+ ic->core.focus_window = (Window)p->value;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalPreeditValue(ic, res, val)
+ Xic ic;
+ XIMResourceList res;
+ XPointer val;
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeLocalStatusValue(ic, res, val)
+ Xic ic;
+ XIMResourceList res;
+ XPointer val;
+{
+ XIMArg *p = (XIMArg *)val;
+
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+ }
+ return True;
+}
+
+Public char *
+_XimSetICValueData(ic, top, res_list, list_num, values, mode, flag)
+ Xic ic;
+ XPointer top;
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XIMArg *values;
+ unsigned long mode;
+ Bool flag;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR), flag)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if(((name = _XimSetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR), flag)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ if (!_XimEncodeLocalPreeditValue(ic, res, (XPointer)p))
+ return False;
+ } else if(mode & XIM_STATUS_ATTR) {
+ if (!_XimEncodeLocalStatusValue(ic, res, (XPointer)p))
+ return False;
+ } else {
+ if (!_XimEncodeLocalTopValue(ic, res, (XPointer)p, flag))
+ return False;
+ }
+ if(_XimEncodeLocalICAttr(ic, res, top, p, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Private Bool
+_XimCheckInputStyle(styles, style)
+ XIMStyles *styles;
+ XIMStyle style;
+{
+ int num = styles->count_styles;
+ register int i;
+
+ for(i = 0; i < num; i++) {
+ if(styles->supported_styles[i] == style) {
+ return True;
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimCheckLocalInputStyle(ic, top, values, styles, res_list, list_num)
+ Xic ic;
+ XPointer top;
+ XIMArg *values;
+ XIMStyles *styles;
+ XIMResourceList res_list;
+ unsigned int list_num;
+{
+ XrmQuark quark = XrmStringToQuark(XNInputStyle);
+ register XIMArg *p;
+ XIMResourceList res;
+
+ for(p = values; p && p->name != NULL; p++) {
+ if(quark == XrmStringToQuark(p->name)) {
+ if(!(res = _XimGetResourceListRec(res_list, list_num, p->name))) {
+ return False;
+ }
+ if(!_XimEncodeLocalICAttr(ic, res, top, p, 0)) {
+ return False;
+ }
+ if (_XimCheckInputStyle(styles,
+ ((XimDefICValues *)top)->input_style)) {
+ return True;
+ }
+ return False;
+ }
+ }
+ return False;
+}
+
+Private Bool
+_XimDecodeAttr(info, num, res, top, val)
+ XimValueOffsetInfo info;
+ unsigned int num;
+ XIMResourceList res;
+ XPointer top;
+ XPointer val;
+{
+ register int i;
+
+ for(i = 0; i < num; i++ ) {
+ if(info[i].quark == res->xrm_name) {
+ if(!info[i].decode) {
+ return False;
+ }
+ return (*info[i].decode)(&info[i], top, val);
+ }
+ }
+ return False;
+}
+
+Public Bool
+_XimDecodeLocalIMAttr(res, top, val)
+ XIMResourceList res;
+ XPointer top;
+ XPointer val;
+{
+ return _XimDecodeAttr(im_attr_info, XIMNumber(im_attr_info),
+ res, top, val);
+}
+
+Public Bool
+_XimDecodeLocalICAttr(res, top, val, mode)
+ XIMResourceList res;
+ XPointer top;
+ XPointer val;
+ unsigned long mode;
+{
+ unsigned int num;
+ XimValueOffsetInfo info;
+
+ if(mode & XIM_PREEDIT_ATTR) {
+ info = ic_pre_attr_info;
+ num = XIMNumber(ic_pre_attr_info);
+ } else if(mode & XIM_STATUS_ATTR) {
+ info = ic_sts_attr_info;
+ num = XIMNumber(ic_sts_attr_info);
+ } else {
+ info = ic_attr_info;
+ num = XIMNumber(ic_attr_info);
+ }
+
+ return _XimDecodeAttr(info, num, res, top, val);
+}
+
+Public char *
+_XimGetICValueData(ic, top, res_list, list_num, values, mode)
+ Xic ic;
+ XPointer top;
+ XIMResourceList res_list;
+ unsigned int list_num;
+ XIMArg *values;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ char *name;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for(p = values; p->name != NULL; p++) {
+ if((res = _XimGetResourceListRec(res_list, list_num,
+ p->name)) == (XIMResourceList)NULL) {
+ return p->name;
+ }
+ if(res->xrm_name == pre_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->preedit_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ return name;
+ }
+ } else if(res->xrm_name == sts_quark) {
+ if((name = _XimGetICValueData(ic,
+ (XPointer)(&((XimDefICValues *)top)->status_attr),
+ res_list, list_num, (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR)))) {
+ return name;
+ }
+ } else {
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID) {
+ continue;
+ } else if(check == XIM_CHECK_ERROR) {
+ return p->name;
+ }
+
+ if(_XimDecodeLocalICAttr(res, top, p->value, mode) == False) {
+ return p->name;
+ }
+ }
+ }
+ return NULL;
+}
+
+Public void
+_XimGetCurrentIMValues(im, im_values)
+ Xim im;
+ XimDefIMValues *im_values;
+{
+ bzero((char *)im_values, sizeof(XimDefIMValues));
+
+ im_values->styles = im->core.styles;
+ im_values->im_values_list = im->core.im_values_list;
+ im_values->ic_values_list = im->core.ic_values_list;
+ im_values->destroy_callback = im->core.destroy_callback;
+ im_values->res_name = im->core.res_name;
+ im_values->res_class = im->core.res_class;
+ im_values->visible_position = im->core.visible_position;
+}
+
+Public void
+_XimSetCurrentIMValues(im, im_values)
+ Xim im;
+ XimDefIMValues *im_values;
+{
+ im->core.styles = im_values->styles;
+ im->core.im_values_list = im_values->im_values_list;
+ im->core.ic_values_list = im_values->ic_values_list;
+ im->core.destroy_callback = im_values->destroy_callback;
+ im->core.res_name = im_values->res_name;
+ im->core.res_class = im_values->res_class;
+ im->core.visible_position = im_values->visible_position;
+}
+
+Public void
+_XimGetCurrentICValues(ic, ic_values)
+ Xic ic;
+ XimDefICValues *ic_values;
+{
+ bzero((char *)ic_values, sizeof(XimDefICValues));
+
+ ic_values->input_style = ic->core.input_style;
+ ic_values->client_window = ic->core.client_window;
+ ic_values->focus_window = ic->core.focus_window;
+ ic_values->filter_events = ic->core.filter_events;
+ ic_values->geometry_callback = ic->core.geometry_callback;
+ ic_values->res_name = ic->core.res_name;
+ ic_values->res_class = ic->core.res_class;
+ ic_values->destroy_callback = ic->core.destroy_callback;
+ ic_values->string_conversion_callback
+ = ic->core.string_conversion_callback;
+ ic_values->string_conversion = ic->core.string_conversion;
+ ic_values->reset_state = ic->core.reset_state;
+ ic_values->hotkey = ic->core.hotkey;
+ ic_values->hotkey_state = ic->core.hotkey_state;
+ ic_values->preedit_attr = ic->core.preedit_attr;
+ ic_values->status_attr = ic->core.status_attr;
+}
+
+Public void
+_XimSetCurrentICValues(ic, ic_values)
+ Xic ic;
+ XimDefICValues *ic_values;
+{
+ ic->core.input_style = ic_values->input_style;
+ ic->core.client_window = ic_values->client_window;
+ if (ic_values->focus_window)
+ ic->core.focus_window = ic_values->focus_window;
+ ic->core.filter_events = ic_values->filter_events;
+ ic->core.geometry_callback = ic_values->geometry_callback;
+ ic->core.res_name = ic_values->res_name;
+ ic->core.res_class = ic_values->res_class;
+ ic->core.destroy_callback = ic_values->destroy_callback;
+ ic->core.string_conversion_callback
+ = ic_values->string_conversion_callback;
+ ic->core.string_conversion = ic_values->string_conversion;
+ ic->core.reset_state = ic_values->reset_state;
+ ic->core.hotkey = ic_values->hotkey;
+ ic->core.hotkey_state = ic_values->hotkey_state;
+ ic->core.preedit_attr = ic_values->preedit_attr;
+ ic->core.status_attr = ic_values->status_attr;
+}
+
+Private void
+_XimInitialIMOffsetInfo()
+{
+ unsigned int n = XIMNumber(im_attr_info);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_attr_info[i].quark = XrmStringToQuark(im_attr_info[i].name);
+ }
+}
+
+Private void
+_XimInitialICOffsetInfo()
+{
+ unsigned int n;
+ register int i;
+
+ n = XIMNumber(ic_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_attr_info[i].quark = XrmStringToQuark(ic_attr_info[i].name);
+ }
+
+ n = XIMNumber(ic_pre_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_pre_attr_info[i].quark = XrmStringToQuark(ic_pre_attr_info[i].name);
+ }
+
+ n = XIMNumber(ic_sts_attr_info);
+ for(i = 0; i < n; i++) {
+ ic_sts_attr_info[i].quark = XrmStringToQuark(ic_sts_attr_info[i].name);
+ }
+}
+
+Private void
+_XimInitialIMMode()
+{
+ unsigned int n = XIMNumber(im_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ im_mode[i].quark = XrmStringToQuark(im_mode[i].name);
+ }
+}
+
+Private void
+_XimInitialICMode()
+{
+ unsigned int n = XIMNumber(ic_mode);
+ register int i;
+
+ for(i = 0; i < n; i++) {
+ ic_mode[i].quark = XrmStringToQuark(ic_mode[i].name);
+ }
+}
+
+Public void
+_XimInitialResourceInfo()
+{
+ static Bool init_flag = False;
+
+ if(init_flag == True) {
+ return;
+ }
+ _XimInitialIMOffsetInfo();
+ _XimInitialICOffsetInfo();
+ _XimInitialIMMode();
+ _XimInitialICMode();
+ init_flag = True;
+}
diff --git a/modules/im/ximcp/imRmAttr.c b/modules/im/ximcp/imRmAttr.c
new file mode 100644
index 00000000..bcf3a1b7
--- /dev/null
+++ b/modules/im/ximcp/imRmAttr.c
@@ -0,0 +1,1534 @@
+/* $Xorg: imRmAttr.c,v 1.4 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private XIMResourceList
+_XimGetNestedListSeparator(res_list, res_num)
+ XIMResourceList res_list; /* LISTofIMATTR or IMATTR */
+ unsigned int res_num;
+{
+ return _XimGetResourceListRec(res_list, res_num, XNSeparatorofNestedList);
+}
+
+Private Bool
+_XimCheckInnerIMAttributes(im, arg, mode)
+ Xim im;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return True;
+}
+
+Public char *
+_XimMakeIMAttrIDList(im, res_list, res_num, arg, buf, len, mode)
+ Xim im;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ XIMArg *arg;
+ CARD16 *buf;
+ INT16 *len;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+
+ *len = 0;
+ if (!arg)
+ return (char *)NULL;
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimCheckInnerIMAttributes(im, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimCheckInnerICAttributes(ic, arg, mode)
+ Xic ic;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return True;
+}
+
+Public char *
+_XimMakeICAttrIDList(ic, res_list, res_num, arg, buf, len, mode)
+ Xic ic;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ XIMArg *arg;
+ CARD16 *buf;
+ INT16 *len;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ char *name;
+ INT16 new_len;
+
+ *len = 0;
+ if (!arg)
+ return (char *)NULL;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for (p = arg; p && p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimCheckInnerICAttributes(ic, p, mode))
+ continue;
+ *len = -1;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ continue;
+ else if(check == XIM_CHECK_ERROR) {
+ *len = -1;
+ return p->name;
+ }
+
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ if (res->resource_size == XimType_NEST) {
+ if (res->xrm_name == pre_quark) {
+ if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
+ (XIMArg *)p->value, buf, &new_len,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ if (new_len < 0) *len = -1;
+ else *len += new_len;
+ return name;
+ }
+ } else if (res->xrm_name == sts_quark) {
+ if ((name = _XimMakeICAttrIDList(ic, res_list, res_num,
+ (XIMArg *)p->value, buf, &new_len,
+ (mode | XIM_STATUS_ATTR)))) {
+ if (new_len < 0) *len = -1;
+ else *len += new_len;
+ return name;
+ }
+ }
+ *len += new_len;
+ buf = (CARD16 *)((char *)buf + new_len);
+ if (!(res = _XimGetNestedListSeparator(res_list, res_num))) {
+ p++;
+ if (p) {
+ *len = -1;
+ return p->name;
+ }
+ else {
+ return (char *)NULL;
+ }
+ }
+ *buf = res->id;
+ *len += sizeof(CARD16);
+ buf++;
+ }
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimAttributeToValue(ic, res, data, data_len, value, mode)
+ Xic ic;
+ XIMResourceList res;
+ CARD16 *data;
+ INT16 data_len;
+ XPointer value;
+ BITMASK32 mode;
+{
+ switch (res->resource_size) {
+ case XimType_SeparatorOfNestedList:
+ case XimType_NEST:
+ break;
+
+ case XimType_CARD8:
+ case XimType_CARD16:
+ case XimType_CARD32:
+ case XimType_Window:
+ case XimType_XIMHotKeyState:
+ _XCopyToArg((XPointer)data, (XPointer *)&value, data_len);
+ break;
+
+ case XimType_STRING8:
+ {
+ char *str;
+
+ if (!(value))
+ return False;
+
+ if (!(str = (char *)Xmalloc(data_len + 1)))
+ return False;
+
+ (void)memcpy(str, (char *)data, data_len);
+ str[data_len] = '\0';
+
+ *((char **)value) = str;
+ break;
+ }
+
+ case XimType_XIMStyles:
+ {
+ INT16 num = data[0];
+ register CARD32 *style_list = (CARD32 *)&data[2];
+ XIMStyle *style;
+ XIMStyles *rep;
+ register int i;
+ char *p;
+ int alloc_len;
+
+ if (!(value))
+ return False;
+
+ alloc_len = sizeof(XIMStyles) + sizeof(XIMStyle) * num;
+ if (!(p = (char *)Xmalloc(alloc_len)))
+ return False;
+
+ rep = (XIMStyles *)p;
+ style = (XIMStyle *)(p + sizeof(XIMStyles));
+
+ for (i = 0; i < num; i++)
+ style[i] = (XIMStyle)style_list[i];
+
+ rep->count_styles = (unsigned short)num;
+ rep->supported_styles = style;
+ *((XIMStyles **)value) = rep;
+ break;
+ }
+
+ case XimType_XRectangle:
+ {
+ XRectangle *rep;
+
+ if (!(value))
+ return False;
+
+ if (!(rep = (XRectangle *)Xmalloc(sizeof(XRectangle))))
+ return False;
+
+ rep->x = data[0];
+ rep->y = data[1];
+ rep->width = data[2];
+ rep->height = data[3];
+ *((XRectangle **)value) = rep;
+ break;
+ }
+
+ case XimType_XPoint:
+ {
+ XPoint *rep;
+
+ if (!(value))
+ return False;
+
+ if (!(rep = (XPoint *)Xmalloc(sizeof(XPoint))))
+ return False;
+
+ rep->x = data[0];
+ rep->y = data[1];
+ *((XPoint **)value) = rep;
+ break;
+ }
+
+ case XimType_XFontSet:
+ {
+ INT16 len = data[0];
+ char *base_name;
+ XFontSet rep = (XFontSet)NULL;
+ char **missing_list;
+ int missing_count;
+ char *def_string;
+
+ if (!(value))
+ return False;
+ if (!ic)
+ return False;
+
+ if (!(base_name = (char *)Xmalloc(len + 1)))
+ return False;
+
+ (void)strncpy(base_name, (char *)&data[1], (int)len);
+ base_name[len] = '\0';
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!strcmp(base_name, ic->private.proto.preedit_font)) {
+ rep = ic->core.preedit_attr.fontset;
+ } else if (!ic->private.proto.preedit_font_length) {
+ rep = XCreateFontSet(ic->core.im->core.display,
+ base_name, &missing_list,
+ &missing_count, &def_string);
+ }
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!strcmp(base_name, ic->private.proto.status_font)) {
+ rep = ic->core.status_attr.fontset;
+ } else if (!ic->private.proto.status_font_length) {
+ rep = XCreateFontSet(ic->core.im->core.display,
+ base_name, &missing_list,
+ &missing_count, &def_string);
+ }
+ }
+
+ Xfree(base_name);
+ *((XFontSet *)value) = rep;
+ break;
+ }
+
+ case XimType_XIMHotKeyTriggers:
+ {
+ INT32 num = *((CARD32 *)data);
+ register CARD32 *key_list = (CARD32 *)&data[2];
+ XIMHotKeyTrigger *key;
+ XIMHotKeyTriggers *rep;
+ register int i;
+ char *p;
+ int alloc_len;
+
+ if (!(value))
+ return False;
+
+ alloc_len = sizeof(XIMHotKeyTriggers)
+ + sizeof(XIMHotKeyTrigger) * num;
+ if (!(p = (char *)Xmalloc(alloc_len)))
+ return False;
+
+ rep = (XIMHotKeyTriggers *)p;
+ key = (XIMHotKeyTrigger *)(p + sizeof(XIMHotKeyTriggers));
+
+ for (i = 0; i < num; i++, key_list += 3) {
+ key[i].keysym = (KeySym)key_list[0]; /* keysym */
+ key[i].modifier = (int)key_list[1]; /* modifier */
+ key[i].modifier_mask = (int)key_list[2]; /* modifier_mask */
+ }
+
+ rep->num_hot_key = (int)num;
+ rep->key = key;
+ *((XIMHotKeyTriggers **)value) = rep;
+ break;
+ }
+
+ case XimType_XIMStringConversion:
+ {
+ break;
+ }
+
+ default:
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimDecodeInnerIMATTRIBUTE(im, arg)
+ Xim im;
+ XIMArg *arg;
+{
+ XIMResourceList res;
+ XimDefIMValues im_values;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ _XimGetCurrentIMValues(im, &im_values);
+ return _XimDecodeLocalIMAttr(res, (XPointer)&im_values, arg->value);
+}
+
+Public char *
+#if NeedFunctionPrototypes
+_XimDecodeIMATTRIBUTE(
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *data,
+ INT16 data_len,
+ XIMArg *arg,
+ BITMASK32 mode)
+#else
+_XimDecodeIMATTRIBUTE(im, res_list, res_num, data, data_len, arg, mode)
+ Xim im;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ CARD16 *data;
+ INT16 data_len;
+ XIMArg *arg;
+ BITMASK32 mode;
+#endif /* NeedFunctionPrototypes */
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ INT16 len;
+ CARD16 *buf;
+ INT16 total;
+ INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
+ + sizeof(INT16); /* sizeof length */
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimDecodeInnerIMATTRIBUTE(im, p))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ continue;
+ else if(check == XIM_CHECK_ERROR)
+ return p->name;
+
+ total = data_len;
+ buf = data;
+ while (total >= min_len) {
+ if (res->id == buf[0])
+ break;
+
+ len = buf[1];
+ len += XIM_PAD(len) + min_len;
+ buf = (CARD16 *)((char *)buf + len);
+ total -= len;
+ }
+ if (total < min_len)
+ return p->name;
+
+ if (!(_XimAttributeToValue((Xic) im->private.local.current_ic,
+ res, &buf[2], buf[1], p->value, mode)))
+ return p->name;
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimDecodeInnerICATTRIBUTE(ic, arg, mode)
+ Xic ic;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ XIMResourceList res;
+ XimDefICValues ic_values;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ _XimGetCurrentICValues(ic, &ic_values);
+ if (!_XimDecodeLocalICAttr(res, (XPointer)&ic_values, arg->value, mode))
+ return False;
+ _XimSetCurrentICValues(ic, &ic_values);
+ return True;
+}
+
+Public char *
+#if NeedFunctionPrototypes
+_XimDecodeICATTRIBUTE(
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *data,
+ INT16 data_len,
+ XIMArg *arg,
+ BITMASK32 mode)
+#else
+_XimDecodeICATTRIBUTE(ic, res_list, res_num, data, data_len, arg, mode)
+ Xic ic;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ CARD16 *data;
+ INT16 data_len;
+ XIMArg *arg;
+ BITMASK32 mode;
+#endif /* NeedFunctionPrototypes */
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ INT16 len;
+ CARD16 *buf;
+ INT16 total;
+ char *name;
+ INT16 min_len = sizeof(CARD16) /* sizeof attributeID */
+ + sizeof(INT16); /* sizeof length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+
+ if (!arg)
+ return (char *)NULL;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimDecodeInnerICATTRIBUTE(ic, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ total = data_len;
+ buf = data;
+ while (total >= min_len) {
+ if (res->id == buf[0])
+ break;
+
+ len = buf[1];
+ len += XIM_PAD(len) + min_len;
+ buf = (CARD16 *)((char *)buf + len);
+ total -= len;
+ }
+ if (total < min_len)
+ return p->name;
+
+ if (res->resource_size == XimType_NEST) {
+ if (res->xrm_name == pre_quark) {
+ if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
+ &buf[2], buf[1], (XIMArg *)p->value,
+ (mode | XIM_PREEDIT_ATTR))))
+ return name;
+ } else if (res->xrm_name == sts_quark) {
+ if ((name = _XimDecodeICATTRIBUTE(ic, res_list, res_num,
+ &buf[2], buf[1], (XIMArg *)p->value,
+ (mode | XIM_STATUS_ATTR))))
+ return name;
+ }
+ } else {
+ if (!(_XimAttributeToValue(ic, res, &buf[2], buf[1],
+ p->value, mode)))
+ return p->name;
+ }
+ }
+ return (char *)NULL;
+}
+
+Private Bool
+_XimValueToAttribute(res, buf, buf_size, value, len, mode, param)
+ XIMResourceList res;
+ XPointer buf;
+ int buf_size;
+ XPointer value;
+ int *len;
+ unsigned long mode;
+ XPointer param;
+{
+ int ret_len;
+
+ switch (res->resource_size) {
+ case XimType_SeparatorOfNestedList:
+ case XimType_NEST:
+ *len = 0;
+ break;
+
+ case XimType_CARD8:
+ ret_len = sizeof(CARD8);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD8 *)buf) = (CARD8)(long)value;
+ *len = ret_len;
+ break;
+
+ case XimType_CARD16:
+ ret_len = sizeof(CARD16);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD16 *)buf) = (CARD16)(long)value;
+ *len = ret_len;
+ break;
+
+ case XimType_CARD32:
+ case XimType_Window:
+ case XimType_XIMHotKeyState:
+ ret_len = sizeof(CARD32);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ *((CARD32 *)buf) = (CARD32)value;
+ *len = ret_len;
+ break;
+
+ case XimType_STRING8:
+ if (!value) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = strlen((char *)value);
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ (void)memcpy((char *)buf, (char *)value, ret_len);
+ *len = ret_len;
+ break;
+
+ case XimType_XRectangle:
+ {
+ XRectangle *rect = (XRectangle *)value;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!rect) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(INT16) /* sizeof X */
+ + sizeof(INT16) /* sizeof Y */
+ + sizeof(CARD16) /* sizeof width */
+ + sizeof(CARD16); /* sizeof height */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (CARD16)rect->x; /* X */
+ buf_s[1] = (CARD16)rect->y; /* Y */
+ buf_s[2] = (CARD16)rect->width; /* width */
+ buf_s[3] = (CARD16)rect->height; /* heght */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XPoint:
+ {
+ XPoint *point = (XPoint *)value;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!point) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(INT16) /* sizeof X */
+ + sizeof(INT16); /* sizeof Y */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (CARD16)point->x; /* X */
+ buf_s[1] = (CARD16)point->y; /* Y */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XFontSet:
+ {
+ XFontSet font = (XFontSet)value;
+ Xic ic = (Xic)param;
+ char *base_name = NULL;
+ int length;
+ CARD16 *buf_s = (CARD16 *)buf;
+
+ if (!font) {
+ *len = 0;
+ return False;
+ }
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ base_name = ic->private.proto.preedit_font;
+ length = ic->private.proto.preedit_font_length;
+ } else if (mode & XIM_STATUS_ATTR) {
+ base_name = ic->private.proto.status_font;
+ length = ic->private.proto.status_font_length;
+ }
+
+ if (!base_name) {
+ *len = 0;
+ return False;
+ }
+
+ ret_len = sizeof(CARD16) /* sizeof length of Base name */
+ + length; /* sizeof Base font name list */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_s[0] = (INT16)length; /* length of Base font name */
+ (void)memcpy((char *)&buf_s[1], base_name, length);
+ /* Base font name list */
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XIMHotKeyTriggers:
+ {
+ XIMHotKeyTriggers *hotkey = (XIMHotKeyTriggers *)value;
+ INT32 num;
+ CARD32 *buf_l = (CARD32 *)buf;
+ register CARD32 *key = (CARD32 *)&buf_l[1];
+ register int i;
+
+ if (!hotkey) {
+ *len = 0;
+ return False;
+ }
+ num = (INT32)hotkey->num_hot_key;
+
+ ret_len = sizeof(INT32) /* sizeof number of key list */
+ + (sizeof(CARD32) /* sizeof keysyn */
+ + sizeof(CARD32) /* sizeof modifier */
+ + sizeof(CARD32)) /* sizeof modifier_mask */
+ * num; /* number of key list */
+ if (buf_size < ret_len + XIM_PAD(ret_len)) {
+ *len = -1;
+ return False;
+ }
+
+ buf_l[0] = num; /* number of key list */
+ for (i = 0; i < num; i++, key += 3) {
+ key[0] = (CARD32)(hotkey->key[i].keysym);
+ /* keysym */
+ key[1] = (CARD32)(hotkey->key[i].modifier);
+ /* modifier */
+ key[2] = (CARD32)(hotkey->key[i].modifier_mask);
+ /* modifier_mask */
+ }
+ *len = ret_len;
+ break;
+ }
+
+ case XimType_XIMStringConversion:
+ {
+ *len = 0;
+ break;
+ }
+
+ default:
+ return False;
+ }
+ return True;
+}
+
+Private Bool
+_XimSetInnerIMAttributes(im, top, arg, mode)
+ Xim im;
+ XPointer top;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(im->private.proto.im_inner_resources,
+ im->private.proto.im_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckIMMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return _XimEncodeLocalIMAttr(res, top, arg->value);
+}
+
+Public char *
+_XimEncodeIMATTRIBUTE(im, res_list, res_num, arg, arg_ret, buf, size, ret_len, top, mode)
+ Xim im;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ XIMArg *arg;
+ XIMArg **arg_ret;
+ char *buf;
+ int size;
+ int *ret_len;
+ XPointer top;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+
+ *ret_len = 0;
+ for (p = arg; p->name; p++) {
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimSetInnerIMAttributes(im, top, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckIMMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ if (!(_XimEncodeLocalIMAttr(res, top, p->value)))
+ return p->name;
+
+ buf_s = (CARD16 *)buf;
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2], (size - min_len),
+ p->value, &len, mode, (XPointer)NULL)))
+ return p->name;
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *arg_ret = p;
+ return (char *)NULL;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *arg_ret = (XIMArg *)NULL;
+ return (char *)NULL;
+}
+
+#ifdef XIM_CONNECTABLE
+Public Bool
+_XimEncodeSavedIMATTRIBUTE(im, res_list, res_num, idx, buf, size, ret_len, top, mode)
+ Xim im;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ int *idx;
+ char *buf;
+ int size;
+ int *ret_len;
+ XPointer top;
+ unsigned long mode;
+{
+ register int i;
+ int num = im->private.proto.num_saved_imvalues;
+ XrmQuark *quark_list = im->private.proto.saved_imvalues;
+ XIMResourceList res;
+ XPointer value;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+
+ if (!im->private.proto.saved_imvalues) {
+ *idx = -1;
+ *ret_len = 0;
+ return True;
+ }
+
+ *ret_len = 0;
+ for (i = *idx; i < num; i++) {
+ if (!(res = _XimGetResourceListRecByQuark(res_list,
+ res_num, quark_list[i])))
+ continue;
+
+ if (!_XimDecodeLocalIMAttr(res, top, value))
+ return False;
+
+ buf_s = (CARD16 *)buf;
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), value, &len, mode, (XPointer)NULL)))
+ return False;
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *idx = i;
+ return True;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *idx = -1;
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private Bool
+_XimEncodeTopValue(ic, res, p)
+ Xic ic;
+ XIMResourceList res;
+ XIMArg *p;
+{
+ if (res->xrm_name == XrmStringToQuark(XNClientWindow)) {
+ ic->core.client_window = (Window)p->value;
+ if (ic->core.focus_window == (Window)0)
+ ic->core.focus_window = ic->core.client_window;
+ _XimRegisterFilter(ic);
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFocusWindow)) {
+ if (ic->core.client_window) {
+ _XimUnregisterFilter(ic);
+ ic->core.focus_window = (Window)p->value;
+ _XimRegisterFilter(ic);
+ } else /* client_window not yet */
+ ic->core.focus_window = (Window)p->value;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodePreeditValue(ic, res, p)
+ Xic ic;
+ XIMResourceList res;
+ XIMArg *p;
+{
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (!p->value)
+ return False;
+
+ if (ic->private.proto.preedit_font)
+ Xfree(ic->private.proto.preedit_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)p->value,
+ &struct_list, &name_list);
+ for (i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if (!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.preedit_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for (i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.preedit_font = tmp;
+ ic->private.proto.preedit_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeStatusValue(ic, res, p)
+ Xic ic;
+ XIMResourceList res;
+ XIMArg *p;
+{
+ if (res->xrm_name == XrmStringToQuark(XNStdColormap)) {
+ XStandardColormap *colormap_ret;
+ int count;
+
+ if (!(XGetRGBColormaps(ic->core.im->core.display,
+ ic->core.focus_window, &colormap_ret,
+ &count, (Atom)p->value)))
+ return False;
+
+ } else if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (!p->value)
+ return False;
+
+ if (ic->private.proto.status_font)
+ Xfree(ic->private.proto.status_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)p->value,
+ &struct_list, &name_list);
+ for (i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if (!(tmp = Xmalloc(len+1))) {
+ ic->private.proto.status_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.status_font = tmp;
+ ic->private.proto.status_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimSetInnerICAttributes(ic, top, arg, mode)
+ Xic ic;
+ XPointer top;
+ XIMArg *arg;
+ unsigned long mode;
+{
+ XIMResourceList res;
+ int check;
+
+ if (!(res = _XimGetResourceListRec(ic->private.proto.ic_inner_resources,
+ ic->private.proto.ic_num_inner_resources, arg->name)))
+ return False;
+
+ check = _XimCheckICMode(res, mode);
+ if(check == XIM_CHECK_INVALID)
+ return True;
+ else if(check == XIM_CHECK_ERROR)
+ return False;
+
+ return _XimEncodeLocalICAttr(ic, res, top, arg, mode);
+}
+
+Public char *
+_XimEncodeICATTRIBUTE(ic, res_list, res_num, arg, arg_ret, buf, size, ret_len, top, flag, mode)
+ Xic ic;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ XIMArg *arg;
+ XIMArg **arg_ret;
+ char *buf;
+ int size;
+ int *ret_len;
+ XPointer top;
+ BITMASK32 *flag;
+ unsigned long mode;
+{
+ register XIMArg *p;
+ XIMResourceList res;
+ int check;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ char *name;
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+
+ *ret_len = 0;
+ for (p = arg; p && p->name; p++) {
+ buf_s = (CARD16 *)buf;
+ if (!(res = _XimGetResourceListRec(res_list, res_num, p->name))) {
+ if (_XimSetInnerICAttributes(ic, top, p, mode))
+ continue;
+ return p->name;
+ }
+
+ check = _XimCheckICMode(res, mode);
+ if (check == XIM_CHECK_INVALID)
+ continue;
+ else if (check == XIM_CHECK_ERROR)
+ return p->name;
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!(_XimEncodePreeditValue(ic, res, p)))
+ return p->name;
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!(_XimEncodeStatusValue(ic, res, p)))
+ return p->name;
+ } else {
+ if (!(_XimEncodeTopValue(ic, res, p)))
+ return p->name;
+ }
+
+ if (res->resource_size == XimType_NEST) {
+ XimDefICValues *ic_attr = (XimDefICValues *)top;
+
+ if (res->xrm_name == pre_quark) {
+ XIMArg *arg_rt;
+ if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
+ (XIMArg *)p->value, &arg_rt,
+ (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->preedit_attr, flag,
+ (mode | XIM_PREEDIT_ATTR)))) {
+ return name;
+ }
+
+ } else if (res->xrm_name == sts_quark) {
+ XIMArg *arg_rt;
+ if ((name = _XimEncodeICATTRIBUTE(ic, res_list, res_num,
+ (XIMArg *)p->value, &arg_rt,
+ (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->status_attr, flag,
+ (mode | XIM_STATUS_ATTR)))) {
+ return name;
+ }
+ }
+ } else {
+#ifdef EXT_MOVE
+ if (flag)
+ *flag |= _XimExtenArgCheck(p);
+#endif
+ if (!(_XimEncodeLocalICAttr(ic, res, top, p, mode)))
+ return p->name;
+
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), p->value,
+ &len, mode, (XPointer)ic)))
+ return p->name;
+ }
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ *arg_ret = p;
+ return (char *)NULL;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *arg_ret = (XIMArg *)NULL;
+ return (char *)NULL;
+}
+
+#ifdef XIM_CONNECTABLE
+Private Bool
+_XimEncodeSavedPreeditValue(ic, res, value)
+ Xic ic;
+ XIMResourceList res;
+ XPointer value;
+{
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ if (!value)
+ return False;
+
+ if (ic->private.proto.preedit_font)
+ Xfree(ic->private.proto.preedit_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)value,
+ &struct_list, &name_list);
+ for(i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if(!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.preedit_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.preedit_font = tmp;
+ ic->private.proto.preedit_font_length = len - 1;
+ }
+ return True;
+}
+
+Private Bool
+_XimEncodeSavedStatusValue(ic, res, value)
+ Xic ic;
+ XIMResourceList res;
+ XPointer value;
+{
+ int list_ret;
+ XFontStruct **struct_list;
+ char **name_list;
+ char *tmp;
+ int len;
+ register int i;
+
+ if (res->xrm_name == XrmStringToQuark(XNFontSet)) {
+ if (!value)
+ return False;
+
+ if (ic->private.proto.status_font)
+ Xfree(ic->private.proto.status_font);
+
+ list_ret = XFontsOfFontSet((XFontSet)value,
+ &struct_list, &name_list);
+ for(i = 0, len = 0; i < list_ret; i++) {
+ len += (strlen(name_list[i]) + sizeof(char));
+ }
+ if(!(tmp = Xmalloc(len + 1))) {
+ ic->private.proto.status_font = NULL;
+ return False;
+ }
+
+ tmp[0] = '\0';
+ for(i = 0; i < list_ret; i++) {
+ strcat(tmp, name_list[i]);
+ strcat(tmp, ",");
+ }
+ tmp[len - 1] = 0;
+ ic->private.proto.status_font = tmp;
+ ic->private.proto.status_font_length = len - 1;
+ }
+ return True;
+}
+
+Public Bool
+_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num, idx, buf, size, ret_len, top, mode)
+ Xic ic;
+ XIMResourceList res_list;
+ unsigned int res_num;
+ int *idx;
+ char *buf;
+ int size;
+ int *ret_len;
+ XPointer top;
+ unsigned long mode;
+{
+ int i;
+ int num = ic->private.proto.num_saved_icvalues;
+ XrmQuark *quark_list = ic->private.proto.saved_icvalues;
+ XIMResourceList res;
+ XPointer value;
+ CARD16 *buf_s;
+ int len;
+ int min_len = sizeof(CARD16) /* sizeof attribute ID */
+ + sizeof(INT16); /* sizeof value length */
+ XrmQuark pre_quark;
+ XrmQuark sts_quark;
+ XrmQuark separator;
+
+ if (!ic->private.proto.saved_icvalues) {
+ *idx = -1;
+ *ret_len = 0;
+ return True;
+ }
+
+ pre_quark = XrmStringToQuark(XNPreeditAttributes);
+ sts_quark = XrmStringToQuark(XNStatusAttributes);
+ separator = XrmStringToQuark(XNSeparatorofNestedList);
+
+ *ret_len = 0;
+ for (i = *idx; i < num; i++) {
+ if (quark_list[i] == separator) {
+ *idx = i;
+ return True;
+ }
+
+ if (!(res = _XimGetResourceListRecByQuark(res_list,
+ res_num, quark_list[i])))
+ continue;
+
+ if (!_XimDecodeLocalICAttr(res, top,(XPointer)&value, mode))
+ return False;
+
+ if (mode & XIM_PREEDIT_ATTR) {
+ if (!(_XimEncodeSavedPreeditValue(ic, res, value))) {
+ return False;
+ }
+ } else if (mode & XIM_STATUS_ATTR) {
+ if (!(_XimEncodeSavedStatusValue(ic, res, value))) {
+ return False;
+ }
+ }
+
+ buf_s = (CARD16 *)buf;
+ if (res->resource_size == XimType_NEST) {
+ XimDefICValues *ic_attr = (XimDefICValues *)top;
+
+ i++;
+ if (res->xrm_name == pre_quark) {
+ if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
+ &i, (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->preedit_attr,
+ (mode | XIM_PREEDIT_ATTR))) {
+ return False;
+ }
+
+ } else if (res->xrm_name == sts_quark) {
+ if (!_XimEncodeSavedICATTRIBUTE(ic, res_list, res_num,
+ &i, (char *)&buf_s[2], (size - min_len),
+ &len, (XPointer)&ic_attr->status_attr,
+ (mode | XIM_STATUS_ATTR))) {
+ return False;
+ }
+ }
+ } else {
+ if (!(_XimValueToAttribute(res, (XPointer)&buf_s[2],
+ (size - min_len), value,
+ &len, mode, (XPointer)ic))) {
+ return False;
+ }
+ }
+
+ if (len == 0) {
+ continue;
+ } else if (len < 0) {
+ if (quark_list[i] == separator)
+ i++;
+ *idx = i;
+ return True;
+ }
+
+ buf_s[0] = res->id; /* attribute ID */
+ buf_s[1] = len; /* value length */
+ XIM_SET_PAD(&buf_s[2], len); /* pad */
+ len += min_len;
+
+ buf += len;
+ *ret_len += len;
+ size -= len;
+ }
+ *idx = -1;
+ return True;
+}
+#endif /* XIM_CONNECTABLE */
+
+Private unsigned int
+_XimCountNumberOfAttr(total, attr, names_len)
+ INT16 total;
+ CARD16 *attr;
+ int *names_len;
+{
+ unsigned int n;
+ INT16 len;
+ INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ + sizeof(CARD16) /* sizeof type of value */
+ + sizeof(INT16); /* sizeof length of attribute */
+
+ n = 0;
+ *names_len = 0;
+ while (total > min_len) {
+ len = attr[2];
+ *names_len += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ total -= len;
+ attr = (CARD16 *)((char *)attr + len);
+ n++;
+ }
+ return n;
+}
+
+Public Bool
+_XimGetAttributeID(im, buf)
+ Xim im;
+ CARD16 *buf;
+{
+ unsigned int n;
+ XIMResourceList res;
+ int res_len;
+ char *names;
+ int names_len;
+ XPointer tmp;
+ XIMValuesList *values_list;
+ char **values;
+ int values_len;
+ register int i;
+ INT16 len;
+ INT16 min_len = sizeof(CARD16) /* sizeof attrinute ID */
+ + sizeof(CARD16) /* sizeof type of value */
+ + sizeof(INT16); /* sizeof length of attr */
+ /*
+ * IM attribute ID
+ */
+
+ if (!(n = _XimCountNumberOfAttr(buf[0], &buf[1], &names_len)))
+ return False;
+ res_len = sizeof(XIMResource) * n;
+
+ if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ return False;
+ bzero((char *)res, res_len);
+
+ values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
+ if (!(tmp = (XPointer)Xmalloc(values_len)))
+ return False;
+ bzero(tmp, values_len);
+
+ values_list = (XIMValuesList *)tmp;
+ values = (char **)((char *)tmp + sizeof(XIMValuesList));
+ names = (char *)((char *)values + (sizeof(char **) * n));
+
+ values_list->count_values = n;
+ values_list->supported_values = values;
+
+ buf++;
+ for (i = 0; i < n; i++) {
+ len = buf[2];
+ (void)memcpy(names, (char *)&buf[3], len);
+ values[i] = names;
+ names[len] = '\0';
+ res[i].resource_name = names;
+ res[i].resource_size = buf[1];
+ res[i].id = buf[0];
+ names += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ buf = (CARD16 *)((char *)buf + len);
+ }
+ _XIMCompileResourceList(res, n);
+
+ if (im->core.im_resources)
+ Xfree(im->core.im_resources);
+ if (im->core.im_values_list)
+ Xfree(im->core.im_values_list);
+ im->core.im_resources = res;
+ im->core.im_num_resources = n;
+ im->core.im_values_list = values_list;
+
+ /*
+ * IC attribute ID
+ */
+
+ if (!(n = _XimCountNumberOfAttr(buf[0], &buf[2], &names_len)))
+ return False;
+ res_len = sizeof(XIMResource) * n;
+
+ if (!(res = (XIMResourceList)Xmalloc(res_len)))
+ return False;
+ bzero((char *)res, res_len);
+
+ values_len = sizeof(XIMValuesList) + (sizeof(char **) * n) + names_len;
+ if (!(tmp = (XPointer)Xmalloc(values_len)))
+ return False;
+ bzero(tmp, values_len);
+
+ values_list = (XIMValuesList *)tmp;
+ values = (char **)((char *)tmp + sizeof(XIMValuesList));
+ names = (char *)((char *)values + (sizeof(char **) * n));
+
+ values_list->count_values = n;
+ values_list->supported_values = values;
+
+ buf += 2;
+ for (i = 0; i < n; i++) {
+ len = buf[2];
+ (void)memcpy(names, (char *)&buf[3], len);
+ values[i] = names;
+ names[len] = '\0';
+ res[i].resource_name = names;
+ res[i].resource_size = buf[1];
+ res[i].id = buf[0];
+ names += (len + 1);
+ len += (min_len + XIM_PAD(len + 2));
+ buf = (CARD16 *)((char *)buf + len);
+ }
+ _XIMCompileResourceList(res, n);
+
+ if (im->core.ic_resources)
+ Xfree(im->core.ic_resources);
+ if (im->core.ic_values_list)
+ Xfree(im->core.ic_values_list);
+ im->core.ic_resources = res;
+ im->core.ic_num_resources = n;
+ im->core.ic_values_list = values_list;
+
+ return True;
+}
diff --git a/modules/im/ximcp/imThaiFlt.c b/modules/im/ximcp/imThaiFlt.c
new file mode 100644
index 00000000..fb609ef3
--- /dev/null
+++ b/modules/im/ximcp/imThaiFlt.c
@@ -0,0 +1,1215 @@
+/* $Xorg: imThaiFlt.c,v 1.5 2001/02/09 02:03:39 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+/*
+**++
+** FACILITY:
+**
+** Xlib
+**
+** ABSTRACT:
+**
+** Thai specific functions.
+** Handles character classifications, composibility checking,
+** Input sequence check and other Thai specific requirements
+** according to WTT specification and DEC extensions.
+**
+** MODIFICATION HISTORY:
+**
+**/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/keysym.h>
+#include <X11/Xutil.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimThai.h"
+
+#define SPACE 32
+
+/* character classification table */
+#define TACTIS_CHARS 256
+Private
+char tactis_chtype[TACTIS_CHARS] = {
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 0 - 7 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 8 - 15 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 16 - 23 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 24 - 31 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 32 - 39 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 40 - 47 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 48 - 55 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 56 - 63 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 64 - 71 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 72 - 79 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 80 - 87 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 88 - 95 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 96 - 103 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 104 - 111 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 112 - 119 */
+ NON, NON, NON, NON, NON, NON, NON, CTRL, /* 120 - 127 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 128 - 135 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 136 - 143 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 144 - 151 */
+ CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, CTRL, /* 152 - 159 */
+ NON, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 160 - 167 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 168 - 175 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 176 - 183 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, CONS, /* 184 - 191 */
+ CONS, CONS, CONS, CONS, FV3, CONS, FV3, CONS, /* 192 - 199 */
+ CONS, CONS, CONS, CONS, CONS, CONS, CONS, NON, /* 200 - 207 */
+ FV1, AV2, FV1, FV1, AV1, AV3, AV2, AV3, /* 208 - 215 */
+ BV1, BV2, BD, NON, NON, NON, NON, NON, /* 216 - 223 */
+ LV, LV, LV, LV, LV, FV2, NON, AD2, /* 224 - 231 */
+ TONE, TONE, TONE, TONE, AD1, AD1, AD3, NON, /* 232 - 239 */
+ NON, NON, NON, NON, NON, NON, NON, NON, /* 240 - 247 */
+ NON, NON, NON, NON, NON, NON, NON, CTRL /* 248 - 255 */
+};
+
+/* Composibility checking tables */
+#define NC 0 /* NOT COMPOSIBLE - following char displays in next cell */
+#define CP 1 /* COMPOSIBLE - following char is displayed in the same cell
+ as leading char, also implies ACCEPT */
+#define XC 3 /* Non-display */
+#define AC 4 /* ACCEPT - display the following char in the next cell */
+#define RJ 5 /* REJECT - discard that following char, ignore it */
+
+#define CH_CLASSES 17 /* 17 classes of chars */
+
+Private
+char write_rules_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 0: writing/outputing rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*CTRL*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*NON*/
+ ,{XC, NC, NC, NC, NC, NC, NC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*LV*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*FV3*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, CP, NC, NC, NC, NC, NC}/*BV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, NC, NC, NC, NC, NC}/*BV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*BD*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*TONE*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC, NC}/*AD3*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, CP, NC, NC, NC, NC, NC}/*AV1*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, NC, NC, NC, NC, NC}/*AV2*/
+ ,{XC, NC, NC, NC, NC, NC, NC, NC, NC, NC, CP, NC, CP, NC, NC, NC, NC}/*AV3*/
+};
+
+Private
+char wtt_isc1_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 1: WTT default input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*TONE*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+Private
+char wtt_isc2_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 2: WTT strict input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV3*/
+ ,{XC, AC, AC, AC, AC, RJ, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*TONE*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, RJ, RJ, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+Private
+char thaicat_isc_lookup[CH_CLASSES][CH_CLASSES] = {
+ /* Table 3: Thaicat input sequence check rules */
+ /* row: leading char, column: following char */
+/* CTRL NON CONS LV FV1 FV2 FV3 BV1 BV2 BD TONE AD1 AD2 AD3 AV1 AV2 AV3 */
+ {XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*CTRL*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*NON*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, CP, CP, CP, CP, CP, CP, CP, CP}/*CONS*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*LV*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*FV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ} /*FV3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*BV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*BV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*BD*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, CP, RJ, RJ, RJ, RJ, RJ, CP, CP, CP}/*TONE*/
+ ,{XC, AC, AC, AC, AC, AC, AC, CP, RJ, RJ, RJ, RJ, RJ, RJ, CP, RJ, RJ}/*AD1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, CP}/*AD2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ, RJ}/*AD3*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, CP, RJ, RJ, RJ, RJ, RJ}/*AV1*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, RJ, RJ, RJ, RJ, RJ}/*AV2*/
+ ,{XC, AC, AC, AC, AC, AC, AC, RJ, RJ, RJ, CP, RJ, CP, RJ, RJ, RJ, RJ}/*AV3*/
+};
+
+
+/* returns classification of a char */
+Private int
+#if NeedFunctionPrototypes
+THAI_chtype (unsigned char ch)
+#else
+THAI_chtype (ch)
+ unsigned char ch;
+#endif
+{
+ return tactis_chtype[ch];
+}
+
+
+/* returns the display level */
+Private int
+#if NeedFunctionPrototypes
+THAI_chlevel (unsigned char ch)
+#else
+THAI_chlevel (ch)
+ unsigned char ch;
+#endif
+{
+ int chlevel;
+
+ switch (tactis_chtype[ch])
+ {
+ case CTRL:
+ chlevel = NON;
+ break;
+ case BV1:
+ case BV2:
+ case BD:
+ chlevel = BELOW;
+ break;
+ case TONE:
+ case AD1:
+ case AD2:
+ chlevel = TOP;
+ break;
+ case AV1:
+ case AV2:
+ case AV3:
+ case AD3:
+ chlevel = ABOVE;
+ break;
+ case NON:
+ case CONS:
+ case LV:
+ case FV1:
+ case FV2:
+ case FV3:
+ default: /* if tactis_chtype is invalid */
+ chlevel = BASE;
+ break;
+ }
+ return chlevel;
+}
+
+
+/* return True if char is non-spacing */
+Private Bool
+#if NeedFunctionPrototypes
+THAI_isdead (unsigned char ch)
+#else
+THAI_isdead (ch)
+ unsigned char ch;
+#endif
+{
+ return ((tactis_chtype[ch] == CTRL) || (tactis_chtype[ch] == BV1) ||
+ (tactis_chtype[ch] == BV2) || (tactis_chtype[ch] == BD) ||
+ (tactis_chtype[ch] == TONE) || (tactis_chtype[ch] == AD1) ||
+ (tactis_chtype[ch] == AD2) || (tactis_chtype[ch] == AD3) ||
+ (tactis_chtype[ch] == AV1) || (tactis_chtype[ch] == AV2) ||
+ (tactis_chtype[ch] == AV3));
+}
+
+
+/* return True if char is consonant */
+Private Bool
+#if NeedFunctionPrototypes
+THAI_iscons (unsigned char ch)
+#else
+THAI_iscons (ch)
+ unsigned char ch;
+#endif
+{
+ return (tactis_chtype[ch] == CONS);
+}
+
+
+/* return True if char is vowel */
+Private Bool
+#if NeedFunctionPrototypes
+THAI_isvowel (unsigned char ch)
+#else
+THAI_isvowel (ch)
+ unsigned char ch;
+#endif
+{
+ return ((tactis_chtype[ch] == LV) || (tactis_chtype[ch] == FV1) ||
+ (tactis_chtype[ch] == FV2) || (tactis_chtype[ch] == FV3) ||
+ (tactis_chtype[ch] == BV1) || (tactis_chtype[ch] == BV2) ||
+ (tactis_chtype[ch] == AV1) || (tactis_chtype[ch] == AV2) ||
+ (tactis_chtype[ch] == AV3));
+}
+
+
+/* return True if char is tonemark */
+Private Bool
+#if NeedFunctionPrototypes
+THAI_istone (unsigned char ch)
+#else
+THAI_istone (ch)
+ unsigned char ch;
+#endif
+{
+ return (tactis_chtype[ch] == TONE);
+}
+
+
+Private Bool
+#if NeedFunctionPrototypes
+THAI_iscomposible (
+ unsigned char follow_ch,
+ unsigned char lead_ch)
+#else
+THAI_iscomposible (follow_ch, lead_ch)
+ unsigned char follow_ch;
+ unsigned char lead_ch;
+#endif
+{/* "Can follow_ch be put in the same display cell as lead_ch?" */
+
+ return (write_rules_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)]
+ == CP);
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+THAI_isaccepted (
+ unsigned char follow_ch,
+ unsigned char lead_ch,
+ unsigned char mode)
+#else
+THAI_isaccepted (follow_ch, lead_ch, mode)
+ unsigned char follow_ch;
+ unsigned char lead_ch;
+ unsigned char mode;
+#endif
+{
+ Bool iskeyvalid; /* means "Can follow_ch be keyed in after lead_ch?" */
+
+ switch (mode)
+ {
+ case WTT_ISC1:
+ iskeyvalid =
+ (wtt_isc1_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ case WTT_ISC2:
+ iskeyvalid =
+ (wtt_isc2_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ case THAICAT_ISC:
+ iskeyvalid =
+ (thaicat_isc_lookup[THAI_chtype(lead_ch)][THAI_chtype(follow_ch)] != RJ);
+ break;
+ default:
+ iskeyvalid = True;
+ break;
+ }
+
+ return iskeyvalid;
+}
+
+Private void
+#if NeedFunctionPrototypes
+THAI_apply_write_rules(
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char insert_ch,
+ int *num_insert_ch)
+#else
+THAI_apply_write_rules(instr, outstr, insert_ch, num_insert_ch)
+ unsigned char *instr;
+ unsigned char *outstr;
+ unsigned char insert_ch;
+ int *num_insert_ch;
+#endif
+{
+/*
+Input parameters:
+ instr - input string
+ insert_ch specify what char to be added when invalid composition is found
+Output parameters:
+ outstr - output string after input string has been applied the rules
+ num_insert_ch - number of insert_ch added to outstr.
+*/
+ unsigned char *lead_ch = NULL, *follow_ch = NULL, *out_ch = NULL;
+
+ *num_insert_ch = 0;
+ lead_ch = follow_ch = instr;
+ out_ch = outstr;
+ if ((*lead_ch == '\0') || !(THAI_find_chtype(instr,DEAD)))
+ { /* Empty string or can't find any non-spacing char*/
+ strcpy((char *)outstr, (char *)instr);
+ } else { /* String of length >= 1, keep looking */
+ follow_ch++;
+ if (THAI_isdead(*lead_ch)) { /* is first char non-spacing? */
+ *out_ch++ = SPACE;
+ (*num_insert_ch)++;
+ }
+ *out_ch++ = *lead_ch;
+ while (*follow_ch != '\0') /* more char in string to check */
+ {
+ if (THAI_isdead(*follow_ch) &&
+ !THAI_iscomposible(*follow_ch,*lead_ch))
+ {
+ *out_ch++ = SPACE;
+ (*num_insert_ch)++;
+ }
+ *out_ch++ = *follow_ch;
+ lead_ch = follow_ch;
+ follow_ch++;
+ }
+ *out_ch = '\0';
+ }
+}
+
+Private int
+#if NeedFunctionPrototypes
+THAI_find_chtype (
+ unsigned char *instr,
+ int chtype)
+#else
+THAI_find_chtype (instr, chtype)
+ unsigned char *instr;
+ int chtype;
+#endif
+{
+/*
+Input parameters:
+ instr - input string
+ chtype - type of character to look for
+Output parameters:
+ function returns first position of character with matched chtype
+ function returns -1 if it does not find.
+*/
+ int i = 0, position = -1;
+
+ switch (chtype)
+ {
+ case DEAD:
+ for (i = 0; *instr != '\0' && THAI_isdead(*instr); i++, instr++)
+ ;
+ if (*instr != '\0') position = i;
+ break;
+ default:
+ break;
+ }
+ return position;
+}
+
+
+Private int
+#if NeedFunctionPrototypes
+THAI_apply_scm(
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char spec_ch,
+ int num_sp,
+ unsigned char insert_ch)
+#else
+THAI_apply_scm(instr, outstr, spec_ch, num_sp, insert_ch)
+ unsigned char *instr;
+ unsigned char *outstr;
+ unsigned char spec_ch;
+ int num_sp;
+ unsigned char insert_ch;
+#endif
+{
+ unsigned char *scan, *outch;
+ int i, dead_count, found_count;
+ Bool isconsecutive;
+
+ scan = instr;
+ outch = outstr;
+ dead_count = found_count = 0;
+ isconsecutive = False;
+ while (*scan != '\0') {
+ if (THAI_isdead(*scan))
+ dead_count++; /* count number of non-spacing char */
+ if (*scan == spec_ch)
+ if (!isconsecutive)
+ found_count++; /* count number consecutive spec char found */
+ *outch++ = *scan++;
+ if (found_count == num_sp) {
+ for (i = 0; i < dead_count; i++)
+ *outch++ = insert_ch;
+ dead_count = found_count = 0;
+ }
+ }
+ /* what to return? */
+ return 0; /* probably not right but better than returning garbage */
+}
+
+/* The following functions are copied from XKeyBind.c */
+
+Private void ComputeMaskFromKeytrans();
+Private int IsCancelComposeKey();
+Private void SetLed();
+Private CARD8 FindKeyCode();
+
+/* The following functions are specific to this module */
+
+Private int XThaiTranslateKey();
+Private int XThaiTranslateKeySym();
+
+Private KeySym HexIMNormalKey();
+Private KeySym HexIMFirstComposeKey();
+Private KeySym HexIMSecondComposeKey();
+Private KeySym HexIMComposeSequence();
+Private void InitIscMode();
+Private Bool ThaiComposeConvert();
+
+/*
+ * Definitions
+ */
+
+#define BellVolume 0
+
+/*
+ * Macros to save and recall last input character in XIC
+ */
+#define IC_SavePreviousChar(ic,ch) \
+ *((ic)->private.local.context->mb) = (char) (ch)
+#define IC_GetPreviousChar(ic,ch) \
+ (ch) = (unsigned char) *((ic)->private.local.context->mb)
+/*
+ * Input sequence check mode in XIC
+ */
+#define IC_IscMode(ic) ((ic)->private.local.thai.input_mode)
+
+/*
+ * Max. size of string handled by the two String Lookup functions.
+ */
+#define STR_LKUP_BUF_SIZE 256
+
+/*
+ * Size of buffer to contain previous locale name.
+ */
+#define SAV_LOCALE_NAME_SIZE 256
+
+/*
+ * Size of buffer to contain the IM modifier.
+ */
+#define MAXTHAIIMMODLEN 20
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+
+#define IsISOControlKey(ks) ((ks) >= XK_2 && (ks) <= XK_8)
+
+#define IsValidControlKey(ks) (((ks)>=XK_A && (ks)<=XK_asciitilde || \
+ (ks)==XK_space || (ks)==XK_Delete) && \
+ ((ks)!=0))
+
+#define COMPOSE_LED 2
+
+typedef KeySym (*StateProc)();
+
+/*
+ * macros to classify XKeyEvent state field
+ */
+
+#define IsShift(state) (((state) & ShiftMask) != 0)
+#define IsLock(state) (((state) & LockMask) != 0)
+#define IsControl(state) (((state) & ControlMask) != 0)
+#define IsMod1(state) (((state) & Mod1Mask) != 0)
+#define IsMod2(state) (((state) & Mod2Mask) != 0)
+#define IsMod3(state) (((state) & Mod3Mask) != 0)
+#define IsMod4(state) (((state) & Mod4Mask) != 0)
+#define IsMod5(state) (((state) & Mod5Mask) != 0)
+
+/*
+ * key starts Thai compose sequence (Hex input method) if :
+ */
+
+#define IsComposeKey(ks, event) \
+ (( ks==XK_Alt_L && \
+ IsControl((event)->state) && \
+ !IsShift((event)->state)) \
+ ? True : False)
+
+/*
+ * State handler to implement the Thai hex input method.
+ */
+
+Private int nstate_handlers = 3;
+Private StateProc state_handler[] = {
+ HexIMNormalKey,
+ HexIMFirstComposeKey,
+ HexIMSecondComposeKey
+};
+
+/*
+ * Table for 'Thai Compose' character input.
+ * The current implementation uses latin-1 keysyms.
+ */
+struct _XMapThaiKey {
+ KeySym from;
+ KeySym to;
+};
+
+Private struct _XMapThaiKey ThaiComposeTable[] = {
+ { /* 0xa4 */ XK_currency, /* 0xa5 */ XK_yen },
+ { /* 0xa2 */ XK_cent, /* 0xa3 */ XK_sterling },
+ { /* 0xe6 */ XK_ae, /* 0xef */ XK_idiaeresis },
+ { /* 0xd3 */ XK_Oacute, /* 0xee */ XK_icircumflex },
+ { /* 0xb9 */ XK_onesuperior, /* 0xfa */ XK_uacute },
+ { /* 0xd2 */ XK_Ograve, /* 0xe5 */ XK_aring },
+ { /* 0xbc */ XK_onequarter, /* 0xfb */ XK_ucircumflex },
+ { XK_VoidSymbol, XK_VoidSymbol }
+};
+
+struct _XKeytrans {
+ struct _XKeytrans *next;/* next on list */
+ char *string; /* string to return when the time comes */
+ int len; /* length of string (since NULL is legit)*/
+ KeySym key; /* keysym rebound */
+ unsigned int state; /* modifier state */
+ KeySym *modifiers; /* modifier keysyms you want */
+ int mlen; /* length of modifier list */
+};
+
+/* Convert keysym to 'Thai Compose' keysym */
+/* The current implementation use latin-1 keysyms */
+Private Bool
+ThaiComposeConvert(dpy, insym, outsym ,lower, upper)
+ Display *dpy;
+ KeySym insym;
+ KeySym *outsym,*lower,*upper;
+{
+ struct _XMapThaiKey *table_entry = ThaiComposeTable;
+
+ while (table_entry->from != XK_VoidSymbol) {
+ if (table_entry->from == insym) {
+ *outsym = table_entry->to;
+ *lower = *outsym;
+ *upper = *outsym;
+ return True;
+ }
+ table_entry++;
+ }
+ return False;
+}
+
+Private int
+XThaiTranslateKey(dpy, keycode, modifiers, modifiers_return, keysym_return,
+ lsym_return, usym_return)
+ register Display *dpy;
+ KeyCode keycode;
+ register unsigned int modifiers;
+ unsigned int *modifiers_return;
+ KeySym *keysym_return,*lsym_return,*usym_return;
+{
+ int per;
+ register KeySym *syms;
+ KeySym sym = 0, lsym = 0, usym = 0;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ *modifiers_return = (ShiftMask|LockMask) | dpy->mode_switch;
+ if (((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
+ {
+ *keysym_return = NoSymbol;
+ return 1;
+ }
+ per = dpy->keysyms_per_keycode;
+ syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if ((per > 2) && (modifiers & dpy->mode_switch)) {
+ syms += 2;
+ per -= 2;
+ }
+ if (!(modifiers & ShiftMask) &&
+ (!(modifiers & LockMask) || (dpy->lock_meaning == NoSymbol))) {
+ if ((per == 1) || (syms[1] == NoSymbol))
+ XConvertCase(syms[0], keysym_return, &usym);
+ else {
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = syms[0];
+ }
+ } else if (!(modifiers & LockMask) ||
+ (dpy->lock_meaning != XK_Caps_Lock)) {
+ if ((per == 1) || ((usym = syms[1]) == NoSymbol))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ } else {
+ if ((per == 1) || ((sym = syms[1]) == NoSymbol))
+ sym = syms[0];
+ XConvertCase(sym, &lsym, &usym);
+ if (!(modifiers & ShiftMask) && (sym != syms[0]) &&
+ ((sym != usym) || (lsym == usym)))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ }
+ /*
+ * ThaiCat keyboard support :
+ * When the Shift and Thai keys are hold for some keys a 'Thai Compose'
+ * character code is generated which is different from column 3 and
+ * 4 of the keymap.
+ * Since we don't know whether ThaiCat keyboard or WTT keyboard is
+ * in use, the same mapping is done for all Thai input.
+ * We just arbitary choose to use column 3 keysyms as the indices of
+ * this mapping.
+ * When the control key is also hold, this mapping has no effect.
+ */
+ if ((modifiers & Mod1Mask) &&
+ (modifiers & ShiftMask) &&
+ !(modifiers & ControlMask)) {
+ if (ThaiComposeConvert(dpy, syms[0], &sym, &lsym, &usym))
+ *keysym_return = sym;
+ }
+
+ if (*keysym_return == XK_VoidSymbol)
+ *keysym_return = NoSymbol;
+ *lsym_return = lsym;
+ *usym_return = usym;
+ return 1;
+}
+
+/*
+ * XThaiTranslateKeySym
+ *
+ * Translate KeySym to TACTIS code output.
+ * The current implementation uses ISO latin-1 keysym.
+ * Should be changed to TACTIS keysyms when they are defined by the
+ * standard.
+ */
+Private int
+XThaiTranslateKeySym(dpy, symbol, lsym, usym, modifiers, buffer, nbytes)
+ Display *dpy;
+ register KeySym symbol, lsym, usym;
+ unsigned int modifiers;
+ char *buffer;
+ int nbytes;
+{
+ KeySym ckey;
+ register struct _XKeytrans *p;
+ int length;
+ unsigned long hiBytes;
+ register unsigned char c;
+
+ /*
+ * initialize length = 1 ;
+ */
+ length = 1;
+
+ if (!symbol)
+ return 0;
+ /* see if symbol rebound, if so, return that string. */
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((modifiers & AllMods) == p->state) && (symbol == p->key)) {
+ length = p->len;
+ if (length > nbytes) length = nbytes;
+ memcpy (buffer, p->string, length);
+ return length;
+ }
+ }
+ /* try to convert to TACTIS, handling control */
+ hiBytes = symbol >> 8;
+ if (!(nbytes &&
+ ((hiBytes == 0) ||
+ ((hiBytes == 0xFF) &&
+ (((symbol >= XK_BackSpace) && (symbol <= XK_Clear)) ||
+ (symbol == XK_Return) ||
+ (symbol == XK_Escape) ||
+ (symbol == XK_KP_Space) ||
+ (symbol == XK_KP_Tab) ||
+ (symbol == XK_KP_Enter) ||
+ ((symbol >= XK_KP_Multiply) && (symbol <= XK_KP_9)) ||
+ (symbol == XK_KP_Equal) ||
+ (symbol == XK_Scroll_Lock) ||
+#ifdef DXK_PRIVATE /* DEC private keysyms */
+ (symbol == DXK_Remove) ||
+#endif
+ (symbol == NoSymbol) ||
+ (symbol == XK_Delete))))))
+ return 0;
+
+ /* if X keysym, convert to ascii by grabbing low 7 bits */
+ if (symbol == XK_KP_Space)
+ c = XK_space & 0x7F; /* patch encoding botch */
+/* not for Thai
+ else if (symbol == XK_hyphen)
+ c = XK_minus & 0xFF; */ /* map to equiv character */
+ else if (hiBytes == 0xFF)
+ c = symbol & 0x7F;
+ else
+ c = symbol & 0xFF;
+ /* only apply Control key if it makes sense, else ignore it */
+ if (modifiers & ControlMask) {
+ if (!(IsKeypadKey(lsym) || lsym==XK_Return || lsym==XK_Tab)) {
+ if (IsISOControlKey(lsym)) ckey = lsym;
+ else if (IsISOControlKey(usym)) ckey = usym;
+ else if (lsym == XK_question) ckey = lsym;
+ else if (usym == XK_question) ckey = usym;
+ else if (IsValidControlKey(lsym)) ckey = lsym;
+ else if (IsValidControlKey(usym)) ckey = usym;
+ else length = 0;
+
+ if (length != 0) {
+ if (ckey == XK_2) c = '\000';
+ else if (ckey >= XK_3 && ckey <= XK_7)
+ c = (char)(ckey-('3'-'\033'));
+ else if (ckey == XK_8) c = '\177';
+ else if (ckey == XK_Delete) c = '\030';
+ else if (ckey == XK_question) c = '\037';
+ else if (ckey == XK_quoteleft) c = '\036'; /* KLee 1/24/91 */
+ else c = (char)(ckey & 0x1f);
+ }
+ }
+ }
+ /*
+ * ThaiCat has a key that generates two TACTIS codes D1 & E9.
+ * It is represented by the latin-1 keysym XK_thorn (0xfe).
+ * If c is XK_thorn, this key is pressed and it is converted to
+ * 0xd1 0xe9.
+ */
+ if (c == XK_thorn) {
+ buffer[0] = 0xd1;
+ buffer[1] = 0xe9;
+ buffer[2] = '\0';
+ return 2;
+ }
+ else {
+ /* Normal case */
+ buffer[0] = c;
+ buffer[1] = '\0';
+ return 1;
+ }
+}
+
+/*
+ * given a KeySym, returns the first keycode containing it, if any.
+ */
+Private CARD8
+FindKeyCode(dpy, code)
+ register Display *dpy;
+ register KeySym code;
+{
+
+ register KeySym *kmax = dpy->keysyms +
+ (dpy->max_keycode - dpy->min_keycode + 1) * dpy->keysyms_per_keycode;
+ register KeySym *k = dpy->keysyms;
+ while (k < kmax) {
+ if (*k == code)
+ return (((k - dpy->keysyms) / dpy->keysyms_per_keycode) +
+ dpy->min_keycode);
+ k += 1;
+ }
+ return 0;
+}
+
+
+/*
+ * given a list of modifiers, computes the mask necessary for later matching.
+ * This routine must lookup the key in the Keymap and then search to see
+ * what modifier it is bound to, if any. Sets the AnyModifier bit if it
+ * can't map some keysym to a modifier.
+ */
+Private void
+ComputeMaskFromKeytrans(dpy, p)
+ Display *dpy;
+ register struct _XKeytrans *p;
+{
+ register int i;
+ register CARD8 code;
+ register XModifierKeymap *m = dpy->modifiermap;
+
+ p->state = AnyModifier;
+ for (i = 0; i < p->mlen; i++) {
+ /* if not found, then not on current keyboard */
+ if ((code = FindKeyCode(dpy, p->modifiers[i])) == 0)
+ return;
+ /* code is now the keycode for the modifier you want */
+ {
+ register int j = m->max_keypermod<<3;
+
+ while ((--j >= 0) && (code != m->modifiermap[j]))
+ ;
+ if (j < 0)
+ return;
+ p->state |= (1<<(j/m->max_keypermod));
+ }
+ }
+ p->state &= AllMods;
+}
+
+
+/************************************************************************
+ *
+ *
+ * Compose handling routines - compose handlers 0,1,2
+ *
+ *
+ ************************************************************************/
+
+#define NORMAL_KEY_STATE 0
+#define FIRST_COMPOSE_KEY_STATE 1
+#define SECOND_COMPOSE_KEY_STATE 2
+
+Private
+KeySym HexIMNormalKey (thai_part, symbol, event)
+ XicThaiPart *thai_part;
+ KeySym symbol;
+ XKeyEvent *event;
+
+{
+ if (IsComposeKey (symbol, event)) /* start compose sequence */
+ {
+ SetLed (event->display,COMPOSE_LED, LedModeOn);
+ thai_part->comp_state = FIRST_COMPOSE_KEY_STATE;
+ return NoSymbol;
+ }
+ return symbol;
+}
+
+
+Private
+KeySym HexIMFirstComposeKey (thai_part, symbol, event)
+ XicThaiPart *thai_part;
+ KeySym symbol;
+ XKeyEvent *event;
+
+{
+ if (IsModifierKey (symbol)) return symbol; /* ignore shift etc. */
+ if (IsCancelComposeKey (&symbol, event)) /* cancel sequence */
+ {
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ thai_part->comp_state = NORMAL_KEY_STATE;
+ return symbol;
+ }
+ if (IsComposeKey (symbol, event)) /* restart sequence ?? */
+ {
+ return NoSymbol; /* no state change necessary */
+ }
+
+ thai_part->keysym = symbol; /* save key pressed */
+ thai_part->comp_state = SECOND_COMPOSE_KEY_STATE;
+ return NoSymbol;
+}
+
+Private
+KeySym HexIMSecondComposeKey (thai_part, symbol, event)
+ XicThaiPart *thai_part;
+ KeySym symbol;
+ XKeyEvent *event;
+
+{
+ if (IsModifierKey (symbol)) return symbol; /* ignore shift etc. */
+ if (IsComposeKey (symbol, event)) /* restart sequence ? */
+ {
+ thai_part->comp_state =FIRST_COMPOSE_KEY_STATE;
+ return NoSymbol;
+ }
+ SetLed (event->display,COMPOSE_LED, LedModeOff);
+ if (IsCancelComposeKey (&symbol, event)) /* cancel sequence ? */
+ {
+ thai_part->comp_state = NORMAL_KEY_STATE;
+ return symbol;
+ }
+
+ if ((symbol = HexIMComposeSequence (thai_part->keysym, symbol))
+ ==NoSymbol)
+ { /* invalid compose sequence */
+ XBell(event->display, BellVolume);
+ }
+ thai_part->comp_state = NORMAL_KEY_STATE; /* reset to normal state */
+ return symbol;
+}
+
+
+/*
+ * Interprets two keysyms entered as hex digits and return the Thai keysym
+ * correspond to the TACTIS code formed.
+ * The current implementation of this routine returns ISO Latin Keysyms.
+ */
+
+Private
+KeySym HexIMComposeSequence (ks1, ks2)
+
+KeySym ks1, ks2;
+{
+int hi_digit;
+int lo_digit;
+int tactis_code;
+
+ if ((ks1 >= XK_0) && (ks1 <= XK_9))
+ hi_digit = ks1 - XK_0;
+ else if ((ks1 >= XK_A) && (ks1 <= XK_F))
+ hi_digit = ks1 - XK_A + 10;
+ else if ((ks1 >= XK_a) && (ks1 <= XK_f))
+ hi_digit = ks1 - XK_a + 10;
+ else /* out of range */
+ return NoSymbol;
+
+ if ((ks2 >= XK_0) && (ks2 <= XK_9))
+ lo_digit = ks2 - XK_0;
+ else if ((ks2 >= XK_A) && (ks2 <= XK_F))
+ lo_digit = ks2 - XK_A + 10;
+ else if ((ks2 >= XK_a) && (ks2 <= XK_f))
+ lo_digit = ks2 - XK_a + 10;
+ else /* out of range */
+ return NoSymbol;
+
+ tactis_code = hi_digit * 0x10 + lo_digit ;
+
+ return (KeySym)tactis_code;
+
+}
+
+/*
+ * routine determines
+ * 1) whether key event should cancel a compose sequence
+ * 2) whether cancelling key event should be processed or ignored
+ */
+
+Private
+int IsCancelComposeKey(symbol, event)
+ KeySym *symbol;
+ XKeyEvent *event;
+{
+ if (*symbol==XK_Delete && !IsControl(event->state) &&
+ !IsMod1(event->state)) {
+ *symbol=NoSymbol; /* cancel compose sequence, and ignore key */
+ return True;
+ }
+ if (IsComposeKey(*symbol, event)) return False;
+ return (
+ IsControl (event->state) ||
+ IsMod1(event->state) ||
+ IsKeypadKey (*symbol) ||
+ IsFunctionKey (*symbol) ||
+ IsMiscFunctionKey (*symbol) ||
+#ifdef DXK_PRIVATE /* DEC private keysyms */
+ *symbol == DXK_Remove ||
+#endif
+ IsPFKey (*symbol) ||
+ IsCursorKey (*symbol) ||
+ *symbol >= XK_Tab && *symbol < XK_Multi_key
+ ? True : False); /* cancel compose sequence and pass */
+ /* cancelling key through */
+}
+
+
+/*
+ * set specified keyboard LED on or off
+ */
+
+Private
+void SetLed (dpy, num, state)
+ Display *dpy;
+ int num;
+ int state;
+{
+ XKeyboardControl led_control;
+
+ led_control.led_mode = state;
+ led_control.led = num;
+ XChangeKeyboardControl (dpy, KBLed | KBLedMode, &led_control);
+}
+
+
+/*
+ * Initialize ISC mode from im modifier
+ */
+Private void InitIscMode(ic)
+Xic ic;
+{
+ Xim im;
+ char *im_modifier_name;
+
+ /* If already defined, just return */
+
+ if (IC_IscMode(ic)) return;
+
+ /* Get IM modifier */
+
+ im = (Xim) XIMOfIC((XIC)ic);
+ im_modifier_name = im->core.im_name;
+
+ /* Match with predefined value, default is Basic Check */
+
+ if (!strncmp(im_modifier_name,"BasicCheck",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = WTT_ISC1;
+ else if (!strncmp(im_modifier_name,"Strict",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = WTT_ISC2;
+ else if (!strncmp(im_modifier_name,"Thaicat",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = THAICAT_ISC;
+ else if (!strncmp(im_modifier_name,"Passthrough",MAXTHAIIMMODLEN+1))
+ IC_IscMode(ic) = NOISC;
+ else
+ IC_IscMode(ic) = WTT_ISC1;
+
+ return;
+}
+
+/*
+ * Filter function for TACTIS
+ */
+Bool
+_XimThaiFilter(d, w, ev, client_data)
+Display *d;
+Window w;
+XEvent *ev;
+XPointer client_data;
+{
+ Xic ic = (Xic)client_data;
+ unsigned int modifiers;
+ KeySym symbol;
+ KeySym lsym,usym;
+ int count;
+ int isc_mode; /* Thai Input Sequence Check mode */
+ unsigned char previous_char; /* Last inputted Thai char */
+ int state;
+ XicThaiPart *thai_part;
+ char buf[10];
+ int i;
+
+ if ((ev->type != KeyPress)
+ || (ev->xkey.keycode == 0))
+ return False;
+
+ if (!IC_IscMode(ic)) InitIscMode(ic);
+
+ if (! XThaiTranslateKey(ev->xkey.display, ev->xkey.keycode, ev->xkey.state,
+ &modifiers, &symbol, &lsym, &usym))
+ return False;
+
+ /*
+ * Hex input method processing
+ */
+
+ thai_part = &ic->private.local.thai;
+ state = thai_part->comp_state;
+ if (state >= 0 && state < nstate_handlers) /* call handler for state */
+ {
+ symbol = (* state_handler[state])(thai_part, symbol, (XKeyEvent *)ev);
+ }
+
+ /*
+ * Translate KeySym into mb.
+ */
+ count = XThaiTranslateKeySym(ev->xkey.display, symbol, lsym,
+ usym, ev->xkey.state, buf, 10);
+
+ if (!symbol && !count)
+ return True;
+
+ /* Return symbol if cannot convert to character */
+ if (!count)
+ return False;
+
+ /*
+ * Thai Input sequence check
+ */
+ isc_mode = IC_IscMode(ic);
+ if ((IC_GetPreviousChar(ic, previous_char))) {
+ if (!THAI_isaccepted(buf[0],previous_char, isc_mode)) {
+ /* reject character */
+ XBell(ev->xkey.display, BellVolume);
+ return True;
+ }
+ }
+ /* Remember the last character inputted. */
+ IC_SavePreviousChar(ic, buf[count-1]);
+ for (i=0; i<count; i++)
+ ic->private.local.composed->mb[i] = buf[i];
+ ic->private.local.composed->mb[count] = '\0';
+
+ i = _Xlcmbstowcs(ic->core.im->core.lcd, ic->private.local.composed->wc,
+ ic->private.local.composed->mb, count);
+
+ if (!((buf[0] > 0 && buf[0] <= 0x1f) || (buf[0] == 0) || (buf[0] == 0x7f)))
+ ic->private.local.composed->keysym = NoSymbol;
+ else
+ ic->private.local.composed->keysym = symbol;
+ ev->xkey.keycode = 0;
+ XPutBackEvent(d, ev);
+ return True;
+}
diff --git a/modules/im/ximcp/imThaiIc.c b/modules/im/ximcp/imThaiIc.c
new file mode 100644
index 00000000..bead0285
--- /dev/null
+++ b/modules/im/ximcp/imThaiIc.c
@@ -0,0 +1,215 @@
+/* $Xorg: imThaiIc.c,v 1.3 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+
+Private void
+_XimThaiUnSetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)NULL;
+
+ if (ic->core.focus_window)
+ _XUnregisterFilter(ic->core.im->core.display, ic->core.focus_window,
+ _XimThaiFilter, (XPointer)ic);
+ return;
+}
+
+Private void
+_XimThaiDestroyIC(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ if(((Xim)ic->core.im)->private.local.current_ic == (XIC)ic) {
+ _XimThaiUnSetFocus(xic);
+ }
+ if(ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ ic->private.local.ic_resources = NULL;
+ }
+
+ Xfree(ic->private.local.context->mb);
+ Xfree(ic->private.local.context->wc);
+ Xfree(ic->private.local.context);
+ Xfree(ic->private.local.composed->mb);
+ Xfree(ic->private.local.composed->wc);
+ Xfree(ic->private.local.composed);
+ return;
+}
+
+Private void
+_XimThaiSetFocus(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ XIC current_ic = ((Xim)ic->core.im)->private.local.current_ic;
+
+ if (current_ic == (XIC)ic)
+ return;
+
+ if (current_ic != (XIC)NULL) {
+ _XimThaiUnSetFocus(current_ic);
+ }
+ ((Xim)ic->core.im)->private.local.current_ic = (XIC)ic;
+
+ if (ic->core.focus_window)
+ _XRegisterFilterByType(ic->core.im->core.display, ic->core.focus_window,
+ KeyPress, KeyPress, _XimThaiFilter, (XPointer)ic);
+ return;
+}
+
+Private char *
+_XimThaiMbReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.thai.comp_state = 0;
+ ic->private.local.thai.keysym = 0;
+ ic->private.local.composed->mb[0] = '\0';
+ ic->private.local.composed->wc[0] = 0;
+ return((char *)NULL);
+}
+
+Private wchar_t *
+_XimThaiWcReset(xic)
+ XIC xic;
+{
+ Xic ic = (Xic)xic;
+ ic->private.local.thai.comp_state = 0;
+ ic->private.local.thai.keysym = 0;
+ ic->private.local.composed->mb[0] = '\0';
+ ic->private.local.composed->wc[0] = 0;
+ return((wchar_t *)NULL);
+}
+
+Private XICMethodsRec Thai_ic_methods = {
+ _XimThaiDestroyIC, /* destroy */
+ _XimThaiSetFocus, /* set_focus */
+ _XimThaiUnSetFocus, /* unset_focus */
+ _XimLocalSetICValues, /* set_values */
+ _XimLocalGetICValues, /* get_values */
+ _XimThaiMbReset, /* mb_reset */
+ _XimThaiWcReset, /* wc_reset */
+ _XimLocalMbLookupString, /* mb_lookup_string */
+ _XimLocalWcLookupString, /* wc_lookup_string */
+};
+
+XIC
+_XimThaiCreateIC(im, values)
+ XIM im;
+ XIMArg *values;
+{
+ Xic ic;
+ XimDefICValues ic_values;
+ XIMResourceList res;
+ unsigned int num;
+ int len;
+
+ if((ic = (Xic)Xmalloc(sizeof(XicRec))) == (Xic)NULL) {
+ return ((XIC)NULL);
+ }
+ bzero((char *)ic, sizeof(XicRec));
+
+ ic->methods = &Thai_ic_methods;
+ ic->core.im = im;
+ ic->core.filter_events = KeyPressMask;
+ if ((ic->private.local.context = (DefTree *)Xmalloc(sizeof(DefTree)))
+ == (DefTree *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.context->mb = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.context->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
+ == (wchar_t *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed = (DefTree *)Xmalloc(sizeof(DefTree)))
+ == (DefTree *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed->mb = (char *)Xmalloc(10))
+ == (char *)NULL)
+ goto Set_Error;
+ if ((ic->private.local.composed->wc = (wchar_t *)Xmalloc(10*sizeof(wchar_t)))
+ == (wchar_t *)NULL)
+ goto Set_Error;
+
+ ic->private.local.thai.comp_state = 0;
+ ic->private.local.thai.keysym = 0;
+ ic->private.local.thai.input_mode = 0;
+
+ num = im->core.ic_num_resources;
+ len = sizeof(XIMResource) * num;
+ if((res = (XIMResourceList)Xmalloc(len)) == (XIMResourceList)NULL) {
+ goto Set_Error;
+ }
+ (void)memcpy((char *)res, (char *)im->core.ic_resources, len);
+ ic->private.local.ic_resources = res;
+ ic->private.local.ic_num_resources = num;
+
+ bzero((char *)&ic_values, sizeof(XimDefICValues));
+ if(_XimCheckLocalInputStyle(ic, (XPointer)&ic_values, values,
+ im->core.styles, res, num) == False) {
+ goto Set_Error;
+ }
+
+ _XimSetICMode(res, num, ic_values.input_style);
+
+ if(_XimSetICValueData(ic, (XPointer)&ic_values,
+ ic->private.local.ic_resources,
+ ic->private.local.ic_num_resources,
+ values, XIM_CREATEIC, True)) {
+ goto Set_Error;
+ }
+ if(_XimSetICDefaults(ic, (XPointer)&ic_values,
+ XIM_SETICDEFAULTS, res, num) == False) {
+ goto Set_Error;
+ }
+ ic_values.filter_events = KeyPressMask;
+ _XimSetCurrentICValues(ic, &ic_values);
+
+ return ((XIC)ic);
+
+Set_Error :
+ if (ic->private.local.ic_resources) {
+ Xfree(ic->private.local.ic_resources);
+ }
+ Xfree(ic);
+ return((XIC)NULL);
+}
diff --git a/modules/im/ximcp/imThaiIm.c b/modules/im/ximcp/imThaiIm.c
new file mode 100644
index 00000000..faa8d846
--- /dev/null
+++ b/modules/im/ximcp/imThaiIm.c
@@ -0,0 +1,198 @@
+/* $Xorg: imThaiIm.c,v 1.3 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xlib.h>
+#include <X11/Xmd.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include "Ximint.h"
+
+Private XIMMethodsRec Xim_im_thai_methods = {
+ _XimThaiCloseIM, /* close */
+ _XimLocalSetIMValues, /* set_values */
+ _XimLocalGetIMValues, /* get_values */
+ _XimThaiCreateIC, /* create_ic */
+ _XimLcctstombs, /* ctstombs */
+ _XimLcctstowcs /* ctstowcs */
+};
+
+#define THAI_LANGUAGE_NAME "th"
+
+Bool
+_XimCheckIfThaiProcessing(im)
+ Xim im;
+{
+ char *language;
+
+ _XGetLCValues(im->core.lcd, XlcNLanguage, &language, NULL);
+ if(strcmp(language, THAI_LANGUAGE_NAME) == 0) {
+ return(True);
+ }
+ return(False);
+}
+
+Public Bool
+_XimThaiOpenIM(im)
+ Xim im;
+{
+ XLCd lcd = im->core.lcd;
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+ XimDefIMValues im_values;
+
+ _XimInitialResourceInfo();
+ if(_XimSetIMResourceList(&im->core.im_resources,
+ &im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ if(_XimSetICResourceList(&im->core.ic_resources,
+ &im->core.ic_num_resources) == False) {
+ goto Open_Error;
+ }
+
+ _XimSetIMMode(im->core.im_resources, im->core.im_num_resources);
+
+ _XimGetCurrentIMValues(im, &im_values);
+ if(_XimSetLocalIMDefaults(im, (XPointer)&im_values,
+ im->core.im_resources, im->core.im_num_resources) == False) {
+ goto Open_Error;
+ }
+ _XimSetCurrentIMValues(im, &im_values);
+
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte)))
+ goto Open_Error;
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar)))
+ goto Open_Error;
+
+ im->methods = &Xim_im_thai_methods;
+ im->private.local.current_ic = (XIC)NULL;
+ im->private.local.ctom_conv = ctom_conv;
+ im->private.local.ctow_conv = ctow_conv;
+
+ return(True);
+
+Open_Error :
+ if (im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if (im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if (im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if (im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if (im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if (im->private.local.ctom_conv) {
+ _XlcCloseConverter(im->private.local.ctom_conv);
+ }
+ if (im->private.local.ctow_conv) {
+ _XlcCloseConverter(im->private.local.ctow_conv);
+ }
+ return(False);
+}
+
+Public void
+_XimThaiIMFree(im)
+ Xim im;
+{
+ if(im->core.im_resources) {
+ Xfree(im->core.im_resources);
+ im->core.im_resources = NULL;
+ }
+ if(im->core.ic_resources) {
+ Xfree(im->core.ic_resources);
+ im->core.ic_resources = NULL;
+ }
+ if(im->core.im_values_list) {
+ Xfree(im->core.im_values_list);
+ im->core.im_values_list = NULL;
+ }
+ if(im->core.ic_values_list) {
+ Xfree(im->core.ic_values_list);
+ im->core.ic_values_list = NULL;
+ }
+ if(im->core.styles) {
+ Xfree(im->core.styles);
+ im->core.styles = NULL;
+ }
+ if(im->core.res_name) {
+ Xfree(im->core.res_name);
+ im->core.res_name = NULL;
+ }
+ if(im->core.res_class) {
+ Xfree(im->core.res_class);
+ im->core.res_class = NULL;
+ }
+ if(im->core.im_name) {
+ Xfree(im->core.im_name);
+ im->core.im_name = NULL;
+ }
+ return;
+}
+
+Public Status
+_XimThaiCloseIM(xim)
+ XIM xim;
+{
+ Xim im = (Xim)xim;
+ XIC ic;
+ XIC next;
+
+ ic = im->core.ic_chain;
+ while (ic) {
+ (*ic->methods->destroy) (ic);
+ next = ic->core.next;
+ Xfree ((char *) ic);
+ ic = next;
+ }
+ _XimThaiIMFree(im);
+ return(True);
+}
diff --git a/modules/im/ximcp/imTrX.c b/modules/im/ximcp/imTrX.c
new file mode 100644
index 00000000..01bc8286
--- /dev/null
+++ b/modules/im/ximcp/imTrX.c
@@ -0,0 +1,519 @@
+/* $Xorg: imTrX.c,v 1.4 2000/08/17 19:45:15 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <string.h>
+#include <X11/Xatom.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimTrInt.h"
+#include "XimTrX.h"
+
+Private Bool
+_XimXRegisterDispatcher(im, callback, call_data)
+ Xim im;
+ Bool (*callback)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ );
+ XPointer call_data;
+{
+ XIntrCallbackPtr rec;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if (!(rec = (XIntrCallbackPtr)Xmalloc(sizeof(XIntrCallbackRec))))
+ return False;
+
+ rec->func = callback;
+ rec->call_data = call_data;
+ rec->next = spec->intr_cb;
+ spec->intr_cb = rec;
+ return True;
+}
+
+Private void
+_XimXFreeIntrCallback(im)
+ Xim im;
+{
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ register XIntrCallbackPtr rec, next;
+
+ for (rec = spec->intr_cb; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ return;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimXCallDispatcher(Xim im, INT16 len, XPointer data)
+#else
+_XimXCallDispatcher(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+#endif
+{
+ register XIntrCallbackRec *rec;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ for (rec = spec->intr_cb; rec; rec = rec->next) {
+ if ((*rec->func)(im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+_XimXFilterWaitEvent(d, w, ev, arg)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer arg;
+{
+ Xim im = (Xim)arg;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ Bool ret;
+
+ spec->ev = (XPointer)ev;
+ ret = _XimFilterWaitEvent(im);
+
+ /*
+ * If ev is a pointer to a stack variable, there could be
+ * a coredump later on if the pointer is dereferenced.
+ * Therefore, reset to NULL to force reinitialization in
+ * _XimXRead().
+ *
+ * Keep in mind _XimXRead may be called again when the stack
+ * is very different.
+ */
+ spec->ev = (XPointer)NULL;
+
+ return ret;
+}
+
+Private Bool
+_CheckConnect(display, event, xim)
+ Display *display;
+ XEvent *event;
+ XPointer xim;
+{
+ Xim im = (Xim)xim;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if ((event->type == ClientMessage)
+ && (event->xclient.message_type == spec->imconnectid)) {
+ return True;
+ }
+ return False;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimXConnect(Xim im)
+#else
+_XimXConnect(im)
+ Xim im;
+#endif
+{
+ XEvent event;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ CARD32 major_code;
+ CARD32 minor_code;
+
+ if (!(spec->lib_connect_wid = XCreateSimpleWindow(im->core.display,
+ DefaultRootWindow(im->core.display), 0, 0, 1, 1, 1, 0, 0))) {
+ return False;
+ }
+
+ event.xclient.type = ClientMessage;
+ event.xclient.display = im->core.display;
+ event.xclient.window = im->private.proto.im_window;
+ event.xclient.message_type = spec->imconnectid;
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = (CARD32)spec->lib_connect_wid;
+ event.xclient.data.l[1] = spec->major_code;
+ event.xclient.data.l[2] = spec->minor_code;
+
+ if(event.xclient.data.l[1] == 1 || event.xclient.data.l[1] == 2) {
+ XWindowAttributes atr;
+ long event_mask;
+
+ XGetWindowAttributes(im->core.display, spec->lib_connect_wid, &atr);
+ event_mask = atr.your_event_mask | PropertyChangeMask;
+ XSelectInput(im->core.display, spec->lib_connect_wid, event_mask);
+ _XRegisterFilterByType(im->core.display, spec->lib_connect_wid,
+ PropertyNotify, PropertyNotify,
+ _XimXFilterWaitEvent, (XPointer)im);
+ }
+
+ XSendEvent(im->core.display, im->private.proto.im_window,
+ False, NoEventMask, &event);
+ XFlush(im->core.display);
+
+ for (;;) {
+ XIfEvent(im->core.display, &event, _CheckConnect, (XPointer)im);
+ if (event.xclient.type != ClientMessage) {
+ return False;
+ }
+ if (event.xclient.message_type == spec->imconnectid)
+ break;
+ }
+
+ spec->ims_connect_wid = (Window)event.xclient.data.l[0];
+ major_code = (CARD32)event.xclient.data.l[1];
+ minor_code = (CARD32)event.xclient.data.l[2];
+
+ if (((major_code == 0) && (minor_code <= 2)) ||
+ ((major_code == 1) && (minor_code == 0)) ||
+ ((major_code == 2) && (minor_code <= 1))) {
+ spec->major_code = major_code;
+ spec->minor_code = minor_code;
+ }
+ if (((major_code == 0) && (minor_code == 2)) ||
+ ((major_code == 2) && (minor_code == 1))) {
+ spec->BoundarySize = (CARD32)event.xclient.data.l[3];
+ }
+
+ /* ClientMessage Event Filter */
+ _XRegisterFilterByType(im->core.display, spec->lib_connect_wid,
+ ClientMessage, ClientMessage,
+ _XimXFilterWaitEvent, (XPointer)im);
+ return True;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimXShutdown(Xim im)
+#else
+_XimXShutdown(im)
+ Xim im;
+#endif
+{
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+
+ if (!spec)
+ return True;
+
+ /* ClientMessage Event Filter */
+ _XUnregisterFilter(im->core.display,
+ ((XSpecRec *)im->private.proto.spec)->lib_connect_wid,
+ _XimXFilterWaitEvent, (XPointer)im);
+ XDestroyWindow(im->core.display,
+ ((XSpecRec *)im->private.proto.spec)->lib_connect_wid);
+ _XimXFreeIntrCallback(im);
+ Xfree(spec);
+ im->private.proto.spec = 0;
+ return True;
+}
+
+Private char *
+_NewAtom(atomName)
+ char *atomName;
+{
+ static int sequence = 0;
+
+ (void)sprintf(atomName, "_client%d", sequence);
+ sequence = ((sequence < 20) ? sequence + 1 : 0);
+ return atomName;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimXWrite(Xim im, INT16 len, XPointer data)
+#else
+_XimXWrite(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+#endif
+{
+ Atom atom;
+ char atomName[16];
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ XEvent event;
+ CARD8 *p;
+ CARD32 major_code = spec->major_code;
+ CARD32 minor_code = spec->minor_code;
+ int BoundSize;
+
+ bzero(&event,sizeof(XEvent));
+ event.xclient.type = ClientMessage;
+ event.xclient.display = im->core.display;
+ event.xclient.window = spec->ims_connect_wid;
+ if(major_code == 1 && minor_code == 0) {
+ BoundSize = 0;
+ } else if((major_code == 0 && minor_code == 2) ||
+ (major_code == 2 && minor_code == 1)) {
+ BoundSize = spec->BoundarySize;
+ } else if(major_code == 0 && minor_code == 1) {
+ BoundSize = len;
+ } else {
+ BoundSize = XIM_CM_DATA_SIZE;
+ }
+ if (len > BoundSize) {
+ event.xclient.message_type = spec->improtocolid;
+ atom = XInternAtom(im->core.display, _NewAtom(atomName), False);
+ XChangeProperty(im->core.display, spec->ims_connect_wid,
+ atom, XA_STRING, 8, PropModeAppend,
+ (unsigned char *)data, len);
+ if(major_code == 0) {
+ event.xclient.format = 32;
+ event.xclient.data.l[0] = (long)len;
+ event.xclient.data.l[1] = (long)atom;
+ XSendEvent(im->core.display, spec->ims_connect_wid,
+ False, NoEventMask, &event);
+ }
+ } else {
+ int length;
+
+ event.xclient.format = 8;
+ for(length = 0 ; length < len ; length += XIM_CM_DATA_SIZE) {
+ p = (CARD8 *)&event.xclient.data.b[0];
+ if((length + XIM_CM_DATA_SIZE) >= len) {
+ event.xclient.message_type = spec->improtocolid;
+ bzero(p, XIM_CM_DATA_SIZE);
+ memcpy((char *)p, (data + length), (len - length));
+ } else {
+ event.xclient.message_type = spec->immoredataid;
+ memcpy((char *)p, (data + length), XIM_CM_DATA_SIZE);
+ }
+ XSendEvent(im->core.display, spec->ims_connect_wid,
+ False, NoEventMask, &event);
+ }
+ }
+
+ return True;
+}
+
+Private Bool
+_XimXGetReadData(im, buf, buf_len, ret_len, event)
+ Xim im;
+ char *buf;
+ int buf_len;
+ int *ret_len;
+ XEvent *event;
+{
+ char *data;
+ int len;
+
+ char tmp_buf[XIM_CM_DATA_SIZE];
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ unsigned long length;
+ Atom prop;
+ int return_code;
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems;
+ unsigned long bytes_after_ret;
+ unsigned char *prop_ret;
+
+ if ((event->type == ClientMessage) && (event->xclient.format == 8)) {
+ data = event->xclient.data.b;
+ if (buf_len >= XIM_CM_DATA_SIZE) {
+ (void)memcpy(buf, data, XIM_CM_DATA_SIZE);
+ *ret_len = XIM_CM_DATA_SIZE;
+ } else {
+ (void)memcpy(buf, data, buf_len);
+ len = XIM_CM_DATA_SIZE - buf_len;
+ (void)memcpy(tmp_buf, &data[buf_len], len);
+ bzero(data, XIM_CM_DATA_SIZE);
+ (void)memcpy(data, tmp_buf, len);
+ XPutBackEvent(im->core.display, event);
+ *ret_len = buf_len;
+ }
+ } else if ((event->type == ClientMessage)
+ && (event->xclient.format == 32)) {
+ length = (unsigned long)event->xclient.data.l[0];
+ prop = (Atom)event->xclient.data.l[1];
+ return_code = XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ (long)((length + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ if (return_code != Success || format_ret == 0 || nitems == 0) {
+ if (return_code == Success)
+ XFree(prop_ret);
+ return False;
+ }
+ if (buf_len >= length) {
+ (void)memcpy(buf, prop_ret, (int)nitems);
+ *ret_len = (int)nitems;
+ if (bytes_after_ret > 0) {
+ XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret,
+ &prop_ret);
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[length],
+ (nitems - length));
+ }
+ } else {
+ (void)memcpy(buf, prop_ret, buf_len);
+ *ret_len = buf_len;
+ len = nitems - buf_len;
+
+ if (bytes_after_ret > 0) {
+ XFree(prop_ret);
+ XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ ((length + bytes_after_ret + 3)/ 4), True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ }
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len);
+ event->xclient.data.l[0] = (long)len;
+ event->xclient.data.l[1] = (long)prop;
+ XPutBackEvent(im->core.display, event);
+ }
+ XFree(prop_ret);
+ } else if (event->type == PropertyNotify) {
+ prop = event->xproperty.atom;
+ return_code = XGetWindowProperty(im->core.display,
+ spec->lib_connect_wid, prop, 0L,
+ 1000000L, True, AnyPropertyType,
+ &type_ret, &format_ret, &nitems, &bytes_after_ret, &prop_ret);
+ if (return_code != Success || format_ret == 0 || nitems == 0) {
+ if (return_code == Success)
+ XFree(prop_ret);
+ return False;
+ }
+ if (buf_len >= nitems) {
+ (void)memcpy(buf, prop_ret, (int)nitems);
+ *ret_len = (int)nitems;
+ } else {
+ (void)memcpy(buf, prop_ret, buf_len);
+ *ret_len = buf_len;
+ len = nitems - buf_len;
+ XChangeProperty(im->core.display, spec->lib_connect_wid, prop,
+ XA_STRING, 8, PropModePrepend, &prop_ret[buf_len], len);
+ }
+ XFree(prop_ret);
+ }
+ return True;
+}
+
+Private Bool
+_CheckCMEvent(display, event, xim)
+ Display *display;
+ XEvent *event;
+ XPointer xim;
+{
+ Xim im = (Xim)xim;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ CARD32 major_code = spec->major_code;
+
+ if ((event->type == ClientMessage)
+ &&((event->xclient.message_type == spec->improtocolid) ||
+ (event->xclient.message_type == spec->immoredataid)))
+ return True;
+ if((major_code == 1 || major_code == 2) &&
+ (event->type == PropertyNotify) &&
+ (event->xproperty.state == PropertyNewValue))
+ return True;
+ return False;
+}
+
+Private Bool
+#if NeedFunctionPrototypes
+_XimXRead(Xim im, XPointer recv_buf, int buf_len, int *ret_len)
+#else
+_XimXRead(im, recv_buf, buf_len, ret_len)
+ Xim im;
+ XPointer recv_buf;
+ int buf_len;
+ int *ret_len;
+#endif
+{
+ XEvent *ev;
+ XEvent event;
+ int len;
+ XSpecRec *spec = (XSpecRec *)im->private.proto.spec;
+ XPointer arg = spec->ev;
+
+ if (!arg) {
+ bzero(&event, sizeof(XEvent));
+ ev = &event;
+ XIfEvent(im->core.display, ev, _CheckCMEvent, (XPointer)im);
+ } else {
+ ev = (XEvent *)arg;
+ spec->ev = (XPointer)NULL;
+ }
+ if (!(_XimXGetReadData(im, recv_buf, buf_len, &len, ev)))
+ return False;
+ *ret_len = len;
+ return True;
+}
+
+Private void
+#if NeedFunctionPrototypes
+_XimXFlush(Xim im)
+#else
+_XimXFlush(im)
+ Xim im;
+#endif
+{
+ XFlush(im->core.display);
+ return;
+}
+
+Public Bool
+_XimXConf(im, address)
+ Xim im;
+ char *address;
+{
+ XSpecRec *spec;
+
+ if (!(spec = (XSpecRec *)Xmalloc(sizeof(XSpecRec))))
+ return False;
+ bzero(spec, sizeof(XSpecRec));
+
+ spec->improtocolid = XInternAtom(im->core.display, _XIM_PROTOCOL, False);
+ spec->imconnectid = XInternAtom(im->core.display, _XIM_XCONNECT, False);
+ spec->immoredataid = XInternAtom(im->core.display, _XIM_MOREDATA, False);
+ spec->major_code = MAJOR_TRANSPORT_VERSION;
+ spec->minor_code = MINOR_TRANSPORT_VERSION;
+
+ im->private.proto.spec = (XPointer)spec;
+ im->private.proto.connect = _XimXConnect;
+ im->private.proto.shutdown = _XimXShutdown;
+ im->private.proto.write = _XimXWrite;
+ im->private.proto.read = _XimXRead;
+ im->private.proto.flush = _XimXFlush;
+ im->private.proto.register_dispatcher = _XimXRegisterDispatcher;
+ im->private.proto.call_dispatcher = _XimXCallDispatcher;
+
+ return True;
+}
diff --git a/modules/im/ximcp/imTrans.c b/modules/im/ximcp/imTrans.c
new file mode 100644
index 00000000..53ca201c
--- /dev/null
+++ b/modules/im/ximcp/imTrans.c
@@ -0,0 +1,315 @@
+/* $Xorg: imTrans.c,v 1.3 2000/08/17 19:45:16 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include <stdio.h>
+#include <X11/Xatom.h>
+#include <X11/Xmd.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/Xtrans.h>
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XimTrans.h"
+
+
+#ifndef XIM_CONNECTION_RETRIES
+#define XIM_CONNECTION_RETRIES 5
+#endif
+
+
+Private Bool
+_XimTransConnect(im)
+ Xim im;
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ int connect_stat, retry;
+ Window window;
+
+ for (retry = XIM_CONNECTION_RETRIES; retry >= 0; retry--)
+ {
+ if ((spec->trans_conn = _XimXTransOpenCOTSClient (
+ spec->address)) == NULL)
+ {
+ break;
+ }
+
+ if ((connect_stat = _XimXTransConnect (
+ spec->trans_conn, spec->address)) < 0)
+ {
+ _XimXTransClose (spec->trans_conn);
+ spec->trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+ else
+ break;
+ }
+
+ if (spec->trans_conn == NULL)
+ return False;
+
+ spec->fd = _XimXTransGetConnectionNumber (spec->trans_conn);
+
+ if (!(window = XCreateSimpleWindow(im->core.display,
+ DefaultRootWindow(im->core.display), 0, 0, 1, 1, 1, 0, 0)))
+ return False;
+ spec->window = window;
+
+ _XRegisterFilterByType(im->core.display, window, KeyPress, KeyPress,
+ _XimTransFilterWaitEvent, (XPointer)im);
+
+ return _XRegisterInternalConnection(im->core.display, spec->fd,
+ (_XInternalConnectionProc)_XimTransInternalConnection,
+ (XPointer)im);
+}
+
+
+Private Bool
+_XimTransShutdown(im)
+ Xim im;
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ _XimXTransDisconnect(spec->trans_conn);
+ (void)_XimXTransClose(spec->trans_conn);
+ _XimFreeTransIntrCallback(im);
+ _XUnregisterInternalConnection(im->core.display, spec->fd);
+ _XUnregisterFilter(im->core.display, spec->window,
+ _XimTransFilterWaitEvent, (XPointer)im);
+ XDestroyWindow(im->core.display, spec->window);
+ Xfree(spec->address);
+ Xfree(spec);
+ return True;
+}
+
+
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimTransRegisterDispatcher(
+ Xim im,
+ Bool (*callback)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+ XPointer call_data)
+#else
+_XimTransRegisterDispatcher(im, callback, call_data)
+ Xim im;
+ Bool (*callback)();
+ XPointer call_data;
+#endif
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ TransIntrCallbackPtr rec;
+
+ if (!(rec = (TransIntrCallbackPtr)Xmalloc(sizeof(TransIntrCallbackRec))))
+ return False;
+
+ rec->func = callback;
+ rec->call_data = call_data;
+ rec->next = spec->intr_cb;
+ spec->intr_cb = rec;
+ return True;
+}
+
+
+Public void
+_XimFreeTransIntrCallback(im)
+ Xim im;
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ register TransIntrCallbackPtr rec, next;
+
+ for (rec = spec->intr_cb; rec;) {
+ next = rec->next;
+ Xfree(rec);
+ rec = next;
+ }
+ return;
+}
+
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimTransCallDispatcher(Xim im, INT16 len, XPointer data)
+#else
+_XimTransCallDispatcher(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+#endif
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ TransIntrCallbackRec *rec;
+
+ for (rec = spec->intr_cb; rec; rec = rec->next) {
+ if ((*rec->func)(im, len, data, rec->call_data))
+ return True;
+ }
+ return False;
+}
+
+
+Public Bool
+_XimTransFilterWaitEvent(d, w, ev, arg)
+ Display *d;
+ Window w;
+ XEvent *ev;
+ XPointer arg;
+{
+ Xim im = (Xim)arg;
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ spec->is_putback = False;
+ return _XimFilterWaitEvent(im);
+}
+
+
+Public void
+_XimTransInternalConnection(d, fd, arg)
+ Display *d;
+ int fd;
+ XPointer arg;
+{
+ Xim im = (Xim)arg;
+ XEvent ev;
+ XKeyEvent *kev;
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+
+ if (spec->is_putback)
+ return;
+ kev = (XKeyEvent *)&ev;
+ kev->type = KeyPress;
+ kev->send_event = False;
+ kev->display = im->core.display;
+ kev->window = spec->window;
+ kev->keycode = 0;
+ XPutBackEvent(im->core.display, &ev);
+ XFlush(im->core.display);
+ spec->is_putback = True;
+ return;
+}
+
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimTransWrite(Xim im, INT16 len, XPointer data)
+#else
+_XimTransWrite(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+#endif
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ char *buf = (char *)data;
+ register int nbyte;
+
+ while (len > 0) {
+ if ((nbyte = _XimXTransWrite(spec->trans_conn, buf, len)) <= 0)
+ return False;
+ len -= nbyte;
+ buf += nbyte;
+ }
+ return True;
+}
+
+
+Public Bool
+_XimTransRead(im, recv_buf, buf_len, ret_len)
+ Xim im;
+ XPointer recv_buf;
+ int buf_len;
+ int *ret_len;
+{
+ TransSpecRec *spec = (TransSpecRec *)im->private.proto.spec;
+ int len;
+
+ if (buf_len == 0) {
+ *ret_len = 0;
+ return True;
+ }
+ if ((len = _XimXTransRead(spec->trans_conn, recv_buf, buf_len)) <= 0)
+ return False;
+ *ret_len = len;
+ return True;
+}
+
+
+Public void
+_XimTransFlush(im)
+ Xim im;
+{
+ return;
+}
+
+
+
+Public Bool
+_XimTransConf(im, address)
+ Xim im;
+ char *address;
+{
+ char *paddr;
+ TransSpecRec *spec;
+
+ if (!(paddr = (char *)Xmalloc(strlen(address) + 1)))
+ return False;
+
+ if (!(spec = (TransSpecRec *) Xmalloc(sizeof(TransSpecRec)))) {
+ Xfree(paddr);
+ return False;
+ }
+
+ bzero(spec, sizeof(TransSpecRec));
+
+ (void)strcpy(paddr, address);
+ spec->address = paddr;
+
+ im->private.proto.spec = (XPointer)spec;
+ im->private.proto.connect = _XimTransConnect;
+ im->private.proto.shutdown = _XimTransShutdown;
+ im->private.proto.write = _XimTransWrite;
+ im->private.proto.read = _XimTransRead;
+ im->private.proto.flush = _XimTransFlush;
+ im->private.proto.register_dispatcher = _XimTransRegisterDispatcher;
+ im->private.proto.call_dispatcher = _XimTransCallDispatcher;
+
+ return True;
+}
diff --git a/modules/im/ximcp/imTransR.c b/modules/im/ximcp/imTransR.c
new file mode 100644
index 00000000..01681bf6
--- /dev/null
+++ b/modules/im/ximcp/imTransR.c
@@ -0,0 +1,311 @@
+/* $Xorg: imTransR.c,v 1.4 2000/08/17 19:45:16 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XimTrInt.h"
+#include "Ximint.h"
+
+Public TransportSW _XimTransportRec[] = {
+ "X", _XimXConf, /* 1st entry must be X.
+ This will be a fallback */
+#ifdef TCPCONN
+ "tcp", _XimTransConf, /* use X transport lib */
+#endif /* TCPCONN */
+#ifdef UNIXCONN
+ "local", _XimTransConf, /* use X transport lib */
+#endif /* UNIXCONN */
+#ifdef DNETCONN
+ "dnet", _XimTransConf, /* use X transport lib */
+#endif /* DNETCONN */
+#ifdef STREAMSCONN
+ "streams", _XimTransConf, /* use X transport lib */
+#endif /* STREAMSCONN */
+ (char *)NULL, (Bool (*)())NULL,
+};
+
+Public Bool
+_XimConnect(im)
+ Xim im;
+{
+ return im->private.proto.connect(im);
+}
+
+Public Bool
+_XimShutdown(im)
+ Xim im;
+{
+ return im->private.proto.shutdown(im);
+}
+
+Public Bool
+#if NeedFunctionPrototypes
+_XimWrite(Xim im, INT16 len, XPointer data)
+#else
+_XimWrite(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+#endif
+{
+ return im->private.proto.write(im, len, data);
+}
+
+Private int
+_CheckProtocolData(im, recv_buf)
+ Xim im;
+ char *recv_buf;
+{
+ int data_len;
+
+ data_len = (int)(((*((CARD16 *)recv_buf + 1)) * 4) + XIM_HEADER_SIZE);
+ return data_len;
+}
+
+Private int
+_XimReadData(im, len, buf, buf_size)
+ Xim im;
+ INT16 *len;
+ XPointer buf;
+ int buf_size;
+{
+ char *hold_buf;
+ char *tmp;
+ int data_len;
+ int packet_size;
+ int ret_len;
+ register int i;
+
+ if (buf_size < XIM_HEADER_SIZE) {
+ *len = (INT16)XIM_HEADER_SIZE;
+ return XIM_OVERFLOW;
+ }
+
+ bzero(buf, buf_size);
+ packet_size = 0;
+ data_len = 0;
+
+ if ((hold_buf = im->private.proto.hold_data)) {
+ data_len = im->private.proto.hold_data_len;
+ if (data_len >= XIM_HEADER_SIZE) {
+ packet_size = _CheckProtocolData(im, hold_buf);
+ if (packet_size > buf_size) {
+ *len = (INT16)packet_size;
+ return XIM_OVERFLOW;
+ }
+ if (packet_size <= data_len) {
+ memcpy(buf, hold_buf, packet_size);
+ for (i = packet_size; i < data_len; i++) {
+ if (hold_buf[i])
+ break;
+ }
+ data_len -= i;
+
+ if (data_len) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, &hold_buf[i], data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ } else {
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+ Xfree(hold_buf);
+ *len = (INT16)packet_size;
+ return XIM_TRUE;
+ }
+ }
+ memcpy(buf, hold_buf, data_len);
+ buf_size -= data_len;
+ Xfree(hold_buf);
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+
+ if (!packet_size) {
+ while (data_len < XIM_HEADER_SIZE) {
+ if (!(im->private.proto.read(im,
+ (XPointer)&buf[data_len], buf_size, &ret_len))) {
+ return XIM_FALSE;
+ }
+ data_len += ret_len;
+ buf_size -= ret_len;
+ }
+ packet_size = _CheckProtocolData(im, buf);
+ }
+
+ if (packet_size > buf_size) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, buf, data_len);
+ bzero(buf, data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ *len = (INT16)packet_size;
+ return XIM_OVERFLOW;
+ }
+
+ while (data_len < packet_size) {
+ if (!(im->private.proto.read(im,
+ (XPointer)&buf[data_len], buf_size, &ret_len))) {
+ return XIM_FALSE;
+ }
+ data_len += ret_len;
+ buf_size -= ret_len;
+ }
+
+ for (i = packet_size; i < data_len; i++) {
+ if (buf[i])
+ break;
+ }
+ data_len -= i;
+
+ if (data_len) {
+ if (!(tmp = (char *)Xmalloc(data_len))) {
+ return XIM_FALSE;
+ }
+ memcpy(tmp, &buf[i], data_len);
+ bzero(&buf[i], data_len);
+ im->private.proto.hold_data = tmp;
+ im->private.proto.hold_data_len = data_len;
+ } else {
+ im->private.proto.hold_data = 0;
+ im->private.proto.hold_data_len = 0;
+ }
+ *len = (INT16)packet_size;
+ return XIM_TRUE;
+}
+
+Private Bool
+_XimCallDispatcher(im, len, data)
+ Xim im;
+ INT16 len;
+ XPointer data;
+{
+ return im->private.proto.call_dispatcher(im, len, data);
+}
+
+Public int
+_XimRead(im, len, buf, buf_size, predicate, arg)
+ Xim im;
+ INT16 *len;
+ XPointer buf;
+ int buf_size;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ );
+ XPointer arg;
+{
+ INT16 read_len;
+ int ret_code;
+
+ for (;;) {
+ ret_code = _XimReadData(im, &read_len, buf, buf_size);
+ if(ret_code != XIM_TRUE) {
+ return ret_code;
+ }
+ if ((*predicate)(im, read_len, buf, arg))
+ break;
+ if (_XimCallDispatcher(im, read_len, buf))
+ continue;
+ _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL);
+ }
+ *len = read_len;
+ return True;
+}
+
+Public Bool
+_XimRegisterDispatcher(im, callback, call_data)
+ Xim im;
+ Bool (*callback)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ );
+ XPointer call_data;
+{
+ return im->private.proto.register_dispatcher(im, callback, call_data);
+}
+
+Public void
+_XimFlush(im)
+ Xim im;
+{
+ im->private.proto.flush(im);
+ return;
+}
+
+Public Bool
+_XimFilterWaitEvent(im)
+ Xim im;
+{
+ INT16 read_len;
+ CARD32 reply32[BUFSIZE/4];
+ char *reply = (char *)reply32;
+ XPointer preply;
+ int buf_size;
+ int ret_code;
+
+ buf_size = BUFSIZE;
+ ret_code = _XimReadData(im, &read_len, (XPointer)reply, buf_size);
+ if(ret_code == XIM_TRUE) {
+ preply = reply;
+ } else if(ret_code == XIM_OVERFLOW) {
+ if(read_len <= 0) {
+ preply = reply;
+ } else {
+ buf_size = (int)read_len;
+ preply = (XPointer)Xmalloc(buf_size);
+ ret_code = _XimReadData(im, &read_len, preply, buf_size);
+ if(ret_code != XIM_TRUE) {
+ if (preply != reply)
+ Xfree(preply);
+ return False;
+ }
+ }
+ } else {
+ return False;
+ }
+ if (_XimCallDispatcher(im, read_len, preply)) {
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+ }
+ _XimError(im, 0, XIM_BadProtocol, (INT16)0, (CARD16)0, (char *)NULL);
+ if(reply != preply)
+ Xfree(preply);
+ return True;
+}
diff --git a/modules/lc/def/lcDefConv.c b/modules/lc/def/lcDefConv.c
new file mode 100644
index 00000000..156bbe1a
--- /dev/null
+++ b/modules/lc/def/lcDefConv.c
@@ -0,0 +1,362 @@
+/* $Xorg: lcDefConv.c,v 1.3 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+typedef struct _StateRec {
+ XlcCharSet charset;
+ XlcCharSet GL_charset;
+ XlcCharSet GR_charset;
+ XlcConv ct_conv;
+ int (*to_converter)();
+} StateRec, *State;
+
+static int
+strtostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register char *src, *dst;
+ unsigned char side;
+ register int length;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (char *) *from;
+ dst = (char *) *to;
+
+ length = min(*from_left, *to_left);
+
+ if (num_args > 0) {
+ side = (length > 0) ? *((unsigned char *) src) & 0x80 : 0;
+ while (length-- > 0 && side == (*((unsigned char *) src) & 0x80))
+ *dst++ = *src++;
+ } else {
+ while (length-- > 0)
+ *dst++ = *src++;
+ }
+
+ *from_left -= src - (char *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (char *) *to;
+ *to = (XPointer) dst;
+
+ if (num_args > 0) {
+ State state = (State) conv->state;
+
+ *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
+ }
+
+ return 0;
+}
+
+static int
+wcstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register wchar_t *src, side;
+ register char *dst;
+ register int length;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ src = (wchar_t *) *from;
+ dst = (char *) *to;
+
+ length = min(*from_left, *to_left);
+
+ if (num_args > 0) {
+ side = (length > 0) ? *src & 0x80 : 0;
+ while (length-- > 0 && side == (*src & 0x80))
+ *dst++ = *src++;
+ } else {
+ while (length-- > 0)
+ *dst++ = *src++;
+ }
+
+ *from_left -= src - (wchar_t *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (char *) *to;
+ *to = (XPointer) dst;
+
+ if (num_args > 0) {
+ State state = (State) conv->state;
+
+ *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
+ }
+
+ return 0;
+}
+
+static int
+cstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register char *src, *dst;
+ unsigned char side;
+ register int length;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args > 0) {
+ State state = (State) conv->state;
+ XlcCharSet charset = (XlcCharSet) args[0];
+
+ if (charset != state->GL_charset && charset != state->GR_charset)
+ return -1;
+ }
+
+ src = (char *) *from;
+ dst = (char *) *to;
+
+ length = min(*from_left, *to_left);
+
+ if (num_args > 0) {
+ side = (length > 0) ? *((unsigned char *) src) & 0x80 : 0;
+ while (length-- > 0 && side == (*((unsigned char *) src) & 0x80))
+ *dst++ = *src++;
+ } else {
+ while (length-- > 0)
+ *dst++ = *src++;
+ }
+
+ *from_left -= src - (char *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (char *) *to;
+ *to = (XPointer) dst;
+
+ if (num_args > 0) {
+ State state = (State) conv->state;
+
+ *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
+ }
+
+ return 0;
+}
+
+static int
+strtowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register char *src;
+ register wchar_t *dst;
+ register int length;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ if (num_args > 0) {
+ State state = (State) conv->state;
+ XlcCharSet charset = (XlcCharSet) args[0];
+
+ if (charset != state->GL_charset && charset != state->GR_charset)
+ return -1;
+ }
+
+ src = (char *) *from;
+ dst = (wchar_t *) *to;
+
+ length = min(*from_left, *to_left);
+
+ while (length-- > 0)
+ *dst++ = (wchar_t) *src++;
+
+ *from_left -= src - (char *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (wchar_t *) *to;
+ *to = (XPointer) dst;
+
+ return 0;
+}
+
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ if (conv->state)
+ Xfree((char *) conv->state);
+
+ Xfree((char *) conv);
+}
+
+static XlcConv
+create_conv(methods)
+ XlcConvMethods methods;
+{
+ register XlcConv conv;
+ State state;
+ static XlcCharSet GL_charset = NULL;
+ static XlcCharSet GR_charset = NULL;
+
+ if (GL_charset == NULL) {
+ GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+ GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+ }
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ state = (State) Xmalloc(sizeof(StateRec));
+ if (state == NULL)
+ goto err;
+
+ state->GL_charset = state->charset = GL_charset;
+ state->GR_charset = GR_charset;
+
+ conv->methods = methods;
+ conv->state = (XPointer) state;
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec strtostr_methods = {
+ close_converter,
+ strtostr,
+ NULL
+} ;
+
+static XlcConv
+open_strtostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&strtostr_methods);
+}
+
+static XlcConvMethodsRec wcstostr_methods = {
+ close_converter,
+ wcstostr,
+ NULL
+} ;
+
+static XlcConv
+open_wcstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&wcstostr_methods);
+}
+
+static XlcConvMethodsRec cstostr_methods = {
+ close_converter,
+ cstostr,
+ NULL
+} ;
+
+static XlcConv
+open_cstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&cstostr_methods);
+}
+
+static XlcConvMethodsRec strtowcs_methods = {
+ close_converter,
+ strtowcs,
+ NULL
+} ;
+
+static XlcConv
+open_strtowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&strtowcs_methods);
+}
+
+XLCd
+_XlcDefaultLoader(name)
+ char *name;
+{
+ XLCd lcd;
+
+ if (strcmp(name, "C"))
+ return (XLCd) NULL;
+
+ lcd = _XlcCreateLC(name, _XlcPublicMethods);
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_strtowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_strtostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_strtostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_strtostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_strtostr);/* XXX */
+
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstostr);
+
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtostr);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstostr);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_strtowcs);
+
+ return lcd;
+}
diff --git a/modules/lc/gen/lcGenConv.c b/modules/lc/gen/lcGenConv.c
new file mode 100644
index 00000000..39405609
--- /dev/null
+++ b/modules/lc/gen/lcGenConv.c
@@ -0,0 +1,2882 @@
+/* $Xorg: lcGenConv.c,v 1.5 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Masayoshi Shimamura FUJITSU LIMITED
+ *
+ */
+
+
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+#include <stdio.h>
+
+#if !defined(X_NOT_STDC_ENV) && !defined(macII) && !defined(X_LOCALE)
+#define STDCVT
+#endif
+
+typedef struct _CTDataRec {
+ char *name;
+ char *encoding; /* Compound Text encoding */
+} CTDataRec, *CTData;
+
+extern CTDataRec *default_ct_data_list();
+extern size_t default_ct_data_list_num();
+
+static CTDataRec directionality_data[] =
+{
+ { "BEGIN_LEFT-TO-RIGHT_TEXT", "\2331]" },
+ { "BEGIN_RIGHT-TO-LEFT_TEXT", "\2332]" },
+ { "END_OF_STRING", "\233]" },
+};
+
+typedef struct _StateRec {
+ XLCd lcd;
+ XlcCharSet charset; /* charset of current state */
+ XlcCharSet GL_charset; /* charset of initial state in GL */
+ XlcCharSet GR_charset; /* charset of initial state in GR */
+} StateRec, *State;
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+#define ESC 0x1b
+#define CSI 0x9b
+#define STX 0x02
+
+#define isleftside(c) (((c) & GR) ? 0 : 1)
+#define isrightside(c) (!isleftside(c))
+
+
+/* Forward declarations for local routines. */
+static int mbstocts();
+static int ctstombs();
+
+
+/* ------------------------------------------------------------------------- */
+/* Misc */
+/* ------------------------------------------------------------------------- */
+
+static int
+compare(src, encoding, length)
+ register char *src;
+ register char *encoding;
+ register int length;
+{
+ char *start = src;
+
+ while (length-- > 0) {
+ if (*src++ != *encoding++)
+ return 0;
+ if (*encoding == '\0')
+ return src - start;
+ }
+
+ return 0;
+}
+
+static unsigned long
+conv_to_dest(conv, code)
+ Conversion conv;
+ unsigned long code;
+{
+ int i;
+ int conv_num = conv->conv_num;
+ FontScope convlist = conv->convlist;
+
+ for (i = 0; i < conv_num; i++) {
+ if (convlist[i].start <= code && code <= convlist[i].end) {
+ switch (convlist[i].shift_direction) {
+ case '+':
+ return(code + convlist[i].shift);
+ case '-':
+ return(code - convlist[i].shift);
+ default:
+ return(code);
+ }
+ }
+ }
+
+ return(code);
+}
+
+static unsigned long
+conv_to_source(conv, code)
+ Conversion conv;
+ unsigned long code;
+{
+ int i;
+ int conv_num;
+ FontScope convlist;
+ unsigned long start_p;
+ unsigned long start_m;
+ unsigned long end_p;
+ unsigned long end_m;
+
+ if (!conv)
+ return(code);
+
+ conv_num = conv->conv_num;
+ convlist = conv->convlist;
+
+ for (i = 0; i < conv_num; i++) {
+ start_p = convlist[i].start + convlist[i].shift;
+ start_m = convlist[i].start - convlist[i].shift;
+ end_p = convlist[i].end + convlist[i].shift;
+ end_m = convlist[i].end - convlist[i].shift;
+
+ switch (convlist[i].shift_direction) {
+ case '+':
+ if (start_p <= code && code <= end_p)
+ return(code - convlist[i].shift);
+ break;
+ case '-':
+ if (start_m <= code && code <= end_m)
+ return(code + convlist[i].shift);
+ break;
+ default:
+ continue;
+ }
+ }
+
+ return(code);
+}
+
+static unsigned long
+mb_to_gi(mb, codeset)
+ unsigned long mb;
+ CodeSet codeset;
+{
+ int i;
+ unsigned long mb_tmp, mask = 0;
+
+ if (codeset->mbconv) {
+ mb_tmp = conv_to_dest(codeset->mbconv, mb);
+ if (mb_tmp != mb)
+ return(mb_tmp);
+ }
+
+ if (codeset->side == XlcC0 || codeset->side == XlcGL ||
+ codeset->side == XlcC1 || codeset->side == XlcGR) {
+
+ for (i = 0; i < codeset->length; i++)
+ mask = (mask << 8) | GL;
+ mb = mb & mask;
+ }
+
+ return(mb);
+}
+
+static unsigned long
+gi_to_mb(glyph_index, codeset)
+ unsigned long glyph_index;
+ CodeSet codeset;
+{
+ int i;
+ unsigned long mask = 0;
+
+ if (codeset->side == XlcC1 || codeset->side == XlcGR) {
+ for (i = 0; i < codeset->length; i++)
+ mask = (mask << 8) | GR;
+ glyph_index = glyph_index | mask;
+ }
+
+ if (codeset->mbconv)
+ return( conv_to_source(codeset->mbconv, glyph_index) );
+
+ return(glyph_index);
+}
+
+static Bool
+gi_to_wc(lcd, glyph_index, codeset, wc)
+ XLCd lcd;
+ unsigned long glyph_index;
+ CodeSet codeset;
+ wchar_t *wc;
+{
+ unsigned char mask = 0;
+ unsigned long wc_encoding = codeset->wc_encoding;
+ int i, length = codeset->length;
+ unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+
+ for (i = wc_shift_bits; i > 0; i--)
+ mask = (mask << 1) | 0x01;
+
+ for (*wc = 0, length--; length >= 0; length--)
+ *wc = (*wc << wc_shift_bits) | ((glyph_index >> (length * 8 )) & mask);
+
+ *wc = *wc | wc_encoding;
+
+ return(True);
+}
+
+static Bool
+wc_to_gi(lcd, wc, glyph_index, codeset)
+ XLCd lcd;
+ wchar_t wc;
+ unsigned long *glyph_index;
+ CodeSet *codeset;
+{
+ int i;
+ unsigned char mask = 0;
+ unsigned long wc_encoding;
+ unsigned long wc_encode_mask = XLC_GENERIC(lcd, wc_encode_mask);
+ unsigned long wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ wc_encoding = wc & wc_encode_mask;
+ for (*codeset = NULL, i = 0; i < codeset_num; i++) {
+ if (wc_encoding == codeset_list[i]->wc_encoding) {
+ *codeset = codeset_list[i];
+ break;
+ }
+ }
+ if (*codeset == NULL)
+ return(False);
+
+ for (i = wc_shift_bits; i > 0; i--)
+ mask = (mask << 1) | 0x01;
+
+ wc = wc & ~wc_encode_mask;
+ for (*glyph_index = 0, i = (*codeset)->length - 1; i >= 0; i--)
+ *glyph_index = (*glyph_index << 8) |
+ ( ((unsigned long)wc >> (i * wc_shift_bits)) & mask );
+
+ return(True);
+}
+
+static CodeSet
+byteM_parse_codeset(lcd, inbufptr)
+ XLCd lcd;
+ XPointer inbufptr;
+{
+ unsigned char ch;
+ CodeSet codeset;
+ ByteInfoList byteM;
+ ByteInfoListRec byteM_rec;
+ ByteInfo byteinfo;
+ ByteInfoRec byteinfo_rec;
+ Bool hit;
+ int i, j, k;
+
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+ byteM = codeset->byteM;
+ if (codeset->side != XlcNONE || byteM == NULL)
+ continue;
+
+ for (j = 0; j < codeset->length; j++) {
+ ch = *((unsigned char *)(inbufptr + j));
+ byteM_rec = byteM[j];
+ byteinfo = byteM_rec.byteinfo;
+
+ for (hit=False,k=0; k < byteM_rec.byteinfo_num; k++) {
+ byteinfo_rec = byteinfo[k];
+ if (byteinfo_rec.start <= ch && ch <= byteinfo_rec.end) {
+ hit = True;
+ break;
+ }
+ }
+
+ if (!hit)
+ break;
+ }
+
+ if (hit)
+ return(codeset);
+ }
+
+ return(NULL);
+}
+
+static CodeSet
+GLGR_parse_codeset(lcd, ch)
+ XLCd lcd;
+ unsigned char ch;
+{
+ int i;
+ CodeSet initial_state_GL = XLC_GENERIC(lcd, initial_state_GL);
+ CodeSet initial_state_GR = XLC_GENERIC(lcd, initial_state_GR);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ XlcSide side = XlcGL;
+ CodeSet codeset = initial_state_GL;
+
+ if (isrightside(ch)) {
+ side = XlcGR;
+ codeset = initial_state_GR;
+ }
+
+ if (codeset)
+ return(codeset);
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+ if (codeset->side == side)
+ return(codeset);
+ }
+
+ return(NULL);
+}
+
+static XlcCharSet
+gi_parse_charset(glyph_index, codeset)
+ unsigned long glyph_index;
+ CodeSet codeset;
+{
+ int i;
+ XlcCharSet *charset_list = codeset->charset_list;
+ int num_charsets = codeset->num_charsets;
+ ExtdSegment ctextseg = codeset->ctextseg;
+ XlcCharSet charset;
+ int area_num;
+ FontScope area;
+ CTDataRec *default_ct_data = default_ct_data_list();
+ size_t table_size = default_ct_data_list_num();
+
+ /* lockup ct sequence */
+ for (i = 0; i < num_charsets; i++) {
+ charset = charset_list[i];
+ if (*charset->ct_sequence != '\0')
+ break;
+ }
+ if (i >= num_charsets)
+ return(NULL);
+
+ /* Standard Character Set Encoding ? */
+ for (i = 0; i < table_size; i++)
+ if (compare(charset->ct_sequence,
+ default_ct_data[i].encoding, strlen(charset->ct_sequence)))
+ goto check_extended_seg;
+
+ return(charset);
+
+check_extended_seg:
+ if (!ctextseg)
+ return(charset);
+
+ area = ctextseg->area;
+ area_num = ctextseg->area_num;
+
+ for (i = 0; i < area_num; i++) {
+
+ if (area[i].start <= glyph_index && glyph_index <= area[i].end) {
+
+ charset = ctextseg->charset;
+
+ if (*charset->ct_sequence == '\0')
+ return(NULL);
+
+ break;
+ }
+ }
+
+ return(charset);
+}
+
+static Bool
+ct_parse_csi(inbufptr, ctr_seq_len)
+ XPointer inbufptr;
+ int *ctr_seq_len;
+{
+ int i;
+ int num = sizeof(directionality_data) / sizeof(directionality_data[0]);
+
+ for (i = 0; i < num; i++) {
+ if ( !(*ctr_seq_len = strlen(directionality_data[i].encoding)) )
+ continue;
+
+ if ( strncmp(inbufptr, directionality_data[i].encoding,
+ *ctr_seq_len) == 0)
+ return(True);
+ }
+
+ return(False);
+}
+
+static int
+cmp_esc_sequence(inbufptr, ct_sequence, encoding_name)
+ XPointer inbufptr;
+ char *ct_sequence;
+ char *encoding_name;
+{
+ int i, seq_len, name_len, total_len;
+ unsigned char byte_m, byte_l;
+ CTDataRec *default_ct_data = default_ct_data_list();
+ size_t table_size = default_ct_data_list_num();
+
+ /* check esc sequence */
+ if ( !(seq_len = strlen(ct_sequence) ) )
+ return(0);
+ if ( strncmp(inbufptr, ct_sequence, seq_len) != 0)
+ return(0);
+
+ /* Standard Character Set Encoding ? */
+ for (i = 0; i < table_size; i++) {
+ if (compare(ct_sequence,
+ default_ct_data[i].encoding, strlen(ct_sequence)))
+ return(seq_len);
+ }
+
+ /*
+ * Non-Standard Character Set Encoding
+ *
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * | esc sequence | M | L | encoding name | STX |
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * 4bytes 1byte 1byte variable length 1byte
+ * | |
+ * +-----------------------------------------+
+ * name length = ((M - 128) * 128) + (L - 128)
+ */
+
+ /* get length of encoding name */
+ inbufptr += seq_len;
+ byte_m = *inbufptr++;
+ byte_l = *inbufptr++;
+ name_len = ((byte_m - 128) * 128) + (byte_l - 128);
+ total_len = seq_len + name_len;
+
+ /* compare encoding names */
+ if ( strncmp(inbufptr, encoding_name, name_len - 3) != 0 )
+ return(0);
+
+ /* check STX (Start of Text) */
+ inbufptr = inbufptr + name_len - 3;
+ if ( *inbufptr != STX )
+ return(0);
+
+ return(total_len);
+}
+
+static Bool
+ct_parse_charset(lcd, inbufptr, charset, ctr_seq_len)
+ XLCd lcd;
+ XPointer inbufptr;
+ XlcCharSet *charset;
+ int *ctr_seq_len;
+{
+ int i, j;
+ ExtdSegment ctextseg;
+ int num_charsets;
+ XlcCharSet *charset_list;
+ CodeSet codeset;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+ int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num);
+ SegConv segment_conv = XLC_GENERIC(lcd, segment_conv);
+
+
+ /* get charset from XLC_XLOCALE by escape sequence */
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+
+ num_charsets = codeset->num_charsets;
+ charset_list = codeset->charset_list;
+ ctextseg = codeset->ctextseg;
+
+ for (j = 0; j < num_charsets; j++) {
+ *charset = charset_list[j];
+ if (( *ctr_seq_len = cmp_esc_sequence(inbufptr,
+ (*charset)->ct_sequence, (*charset)->encoding_name) ))
+ return(True);
+ }
+
+ if (ctextseg) {
+ *charset = ctextseg->charset;
+ if (( *ctr_seq_len = cmp_esc_sequence(inbufptr,
+ (*charset)->ct_sequence, (*charset)->encoding_name) ))
+ return(True);
+ }
+ }
+
+ /* get charset from XLC_SEGMENTCONVERSION by escape sequence */
+
+ if (!segment_conv)
+ return(False);
+
+ for (i = 0; i < segment_conv_num; i++) {
+ *charset = segment_conv[i].source;
+ if (( *ctr_seq_len = cmp_esc_sequence(inbufptr,
+ (*charset)->ct_sequence, (*charset)->encoding_name) ))
+ return(True);
+ *charset = segment_conv[i].dest;
+ if (( *ctr_seq_len = cmp_esc_sequence(inbufptr,
+ (*charset)->ct_sequence, (*charset)->encoding_name) ))
+ return(True);
+ }
+
+ return(False);
+}
+
+static Bool
+segment_conversion(lcd, charset, glyph_index)
+ XLCd lcd;
+ XlcCharSet *charset;
+ unsigned long *glyph_index;
+{
+ int i;
+ int segment_conv_num = XLC_GENERIC(lcd, segment_conv_num);
+ SegConv segment_conv = XLC_GENERIC(lcd, segment_conv);
+ FontScopeRec range;
+ ConversionRec conv_rec;
+
+ if (!segment_conv)
+ return(True);
+
+ for (i = 0; i < segment_conv_num; i++) {
+ if (segment_conv[i].source == *charset)
+ break;
+ }
+
+ if (i >= segment_conv_num)
+ return(True);
+
+ range = segment_conv[i].range;
+ if (*glyph_index < range.start || range.end < *glyph_index)
+ return(True);
+
+ *charset = segment_conv[i].dest;
+ conv_rec.conv_num = segment_conv[i].conv_num;
+ conv_rec.convlist = segment_conv[i].conv;
+ *glyph_index = conv_to_dest(&conv_rec, *glyph_index);
+
+ return(True);
+}
+
+CodeSet
+_XlcGetCodeSetFromName(lcd, name)
+ XLCd lcd;
+ char *name;
+{
+ int i, j;
+ XlcCharSet charset;
+ int num_charsets;
+ XlcCharSet *charset_list;
+ CodeSet codeset;
+
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+
+ for (i = 0; i < codeset_num; i++) {
+ codeset = codeset_list[i];
+
+ num_charsets = codeset->num_charsets;
+ charset_list = codeset->charset_list;
+
+ for (j = 0; j < num_charsets; j++) {
+ charset = charset_list[j];
+
+ if (!strlen(charset->name))
+ continue;
+ if ( strcmp(charset->name, name) == 0)
+ return(codeset);
+ }
+ }
+
+ return(NULL);
+}
+
+static Bool
+_XlcGetCodeSetFromCharSet(lcd, charset, codeset, glyph_index)
+ XLCd lcd;
+ XlcCharSet charset;
+ CodeSet *codeset;
+ unsigned long *glyph_index;
+{
+ int i, j, num;
+ CodeSet *codeset_list = XLC_GENERIC(lcd, codeset_list);
+ XlcCharSet *charset_list;
+ int codeset_num, num_charsets;
+ Conversion ctconv;
+ unsigned long glyph_index_tmp;
+ ExtdSegment ctextseg;
+ CTDataRec *default_ct_data = default_ct_data_list();
+ size_t table_size = default_ct_data_list_num();
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for (num = 0 ; num < codeset_num; num++) {
+ *codeset = codeset_list[num];
+ ctconv = (*codeset)->ctconv;
+ ctextseg = (*codeset)->ctextseg;
+
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ glyph_index_tmp = conv_to_source(ctconv, *glyph_index);
+
+ /* Standard Character Set Encoding ? */
+ for (i = 0; i < table_size; i++) {
+ if (compare(charset->ct_sequence,
+ default_ct_data[i].encoding, strlen(charset->ct_sequence)))
+ break;
+ }
+
+ if (i < table_size) {
+
+ /* Standard Character Set Encoding */
+ if (glyph_index_tmp == *glyph_index) {
+ for (j = 0; j < num_charsets; j++) {
+ if (charset_list[j] == charset) {
+ goto end_loop;
+ }
+ }
+ }
+
+ } else {
+
+ /* Non-Standard Character Set Encoding */
+ for (j = 0; j < num_charsets; j++) {
+ if (charset_list[j] == charset) {
+ goto end_loop;
+ }
+ }
+
+ if (glyph_index_tmp != *glyph_index) {
+ if (ctextseg->charset == charset) {
+ goto end_loop;
+ }
+ }
+
+ }
+
+ }
+
+end_loop:
+ if (num < codeset_num) {
+ *glyph_index = glyph_index_tmp;
+ return(True);
+ }
+
+ return(False);
+}
+
+static Bool
+check_string_encoding(codeset)
+ CodeSet codeset;
+{
+ int i;
+ XlcCharSet charset;
+ XlcCharSet *charset_list = codeset->charset_list;
+ int num_charsets = codeset->num_charsets;
+
+ for (i = 0; i < num_charsets; i++) {
+ charset = charset_list[i];
+ if ( strcmp(charset->encoding_name, "ISO8859-1") == 0 ||
+ charset->string_encoding)
+ return(True);
+ }
+
+ return(False);
+}
+
+static void
+output_ulong_value(outbufptr, code, length, side)
+ XPointer outbufptr;
+ unsigned long code;
+ int length;
+ XlcSide side;
+{
+ int i;
+ unsigned long mask = 0xff;
+
+ for (i = 0; i < length; i++) {
+ *outbufptr = ( code >> (8 * (length - i - 1)) ) & mask;
+
+ if (side == XlcC0 || side == XlcGL) {
+ *outbufptr = *outbufptr & GL;
+ } else if (side == XlcC1 || side == XlcGR) {
+ *outbufptr = *outbufptr | GR;
+ }
+
+ outbufptr++;
+ }
+}
+
+/* -------------------------------------------------------------------------- */
+/* Init */
+/* -------------------------------------------------------------------------- */
+
+static void
+init_state(conv)
+ XlcConv conv;
+{
+ register State state = (State) conv->state;
+
+ /* for CT */
+ state->charset = NULL;
+ state->GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+ state->GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+}
+
+/* -------------------------------------------------------------------------- */
+/* Convert */
+/* -------------------------------------------------------------------------- */
+
+static int
+mbstowcs_org(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+ wchar_t wc;
+
+ int length = 0, len_left = 0;
+ int unconv_num = 0;
+ int num;
+ Bool ss_flag = 0;
+
+ CodeSet codeset = NULL;
+ ParseInfo parse_info;
+
+ XPointer inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ int from_size = *from_left;
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+ ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (len_left) {
+ unconv_num += (length - len_left);
+ len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output_one_wc;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table) {
+ if ((num = mb_parse_table[ch]) > 0) {
+ parse_info = mb_parse_list[num - 1];
+
+ codeset = parse_info->codeset;
+ length = len_left = codeset->length;
+ mb = 0;
+ ss_flag = 1;
+
+ continue;
+ }
+ }
+
+ /* next mb char data for byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next mb char data for GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(lcd, ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num++;
+ continue;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+ ss_flag = 0;
+
+output_one_wc:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ gi_to_wc(lcd, mb_to_gi(mb, codeset), codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+ }
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (len_left) {
+ inbufptr -= (length - len_left + ss_flag);
+ (*from_left) += (length - len_left + ss_flag);
+ unconv_num += (length - len_left + ss_flag);
+ }
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ char *src = *((char **) from);
+ wchar_t *dst = *((wchar_t **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = mbtowc(dst, src, src_left);
+
+ if (length > 0) {
+ src += length;
+ src_left -= length;
+ if (dst)
+ dst++;
+ dst_left--;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ } else {
+ /* null ? */
+ src++;
+ src_left--;
+ if (dst)
+ *dst++ = L'\0';
+ dst_left--;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static int
+wcstombs_org(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ wchar_t wc;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ wchar_t *inbufptr = (wchar_t *) *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+ char *default_string = XLC_PUBLIC(lcd, default_string);
+ int defstr_len = strlen(default_string);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+
+ /* output default_string of XDefaultString() */
+ if (*to_left < defstr_len)
+ break;
+ if (outbufptr) {strncpy((char *)outbufptr, default_string, defstr_len);}
+
+ if (outbufptr) {outbufptr += defstr_len;}
+ (*to_left) -= defstr_len;
+
+ unconv_num++;
+
+ } else {
+ mb = gi_to_mb(glyph_index, codeset);
+ if (codeset->parse_info) {
+
+ /* output shift sequence */
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+ if (outbufptr) {strncpy((char *)outbufptr, encoding, length);}
+
+ if (outbufptr) {outbufptr += length;}
+ (*to_left) -= length;
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+ }
+
+ } /* end of while */
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ wchar_t *src = *((wchar_t **) from);
+ char *dst = *((char **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length, unconv_num = 0;
+
+ while (src_left > 0 && dst_left >= MB_CUR_MAX) {
+ length = wctomb(dst, *src); /* XXX */
+
+ if (length > 0) {
+ src++;
+ src_left--;
+ if (dst)
+ dst += length;
+ dst_left -= length;
+ } else if (length < 0) {
+ src++;
+ src_left--;
+ unconv_num++;
+ }
+ }
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return unconv_num;
+}
+
+static int
+wcstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ CTDataRec *default_ct_data = default_ct_data_list();
+ size_t table_size = default_ct_data_list_num();
+
+ unsigned long glyph_index;
+ wchar_t wc;
+
+ int i, total_len, seq_len, name_len;
+ int unconv_num = 0;
+ Bool first_flag = True, standard_flag;
+ XlcSide side;
+
+ CodeSet codeset;
+ XlcCharSet charset, old_charset = NULL;
+ char *ct_sequence;
+
+ wchar_t *inbufptr = (wchar_t *) *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+ unconv_num++;
+ continue;
+ }
+
+ /* parse charset */
+ if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) {
+ unconv_num++;
+ continue;
+ }
+
+ /* Standard Character Set Encoding ? */
+ standard_flag = False;
+ for (i = 0; i < table_size; i++)
+ if (compare(charset->ct_sequence,
+ default_ct_data[i].encoding, strlen(charset->ct_sequence)))
+ standard_flag = True;
+
+ /*
+ * Non-Standard Character Set Encoding
+ *
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * | esc sequence | M | L | encoding name | STX |
+ * +-----+-----+-----+-----+-----+-----+-----+---- ----+-----+-----+
+ * 4bytes 1byte 1byte variable length 1byte
+ * | |
+ * +-----------------------------------------+
+ * name length = ((M - 128) * 128) + (L - 128)
+ */
+
+ /* make encoding data */
+ ct_sequence = charset->ct_sequence;
+ side = charset->side;
+ seq_len = strlen(charset->ct_sequence);
+ if (standard_flag) {
+ name_len = 0;
+ total_len = seq_len;
+ } else {
+ name_len = 2 + strlen(charset->encoding_name) + 1;
+ total_len = seq_len + name_len;
+ }
+
+ /* output escape sequence of CT */
+ if ( (charset != old_charset) &&
+ !(first_flag && (strcmp(charset->encoding_name,"ISO8859-1")==0))) {
+
+ if (*to_left < total_len + 1) {
+ unconv_num++;
+ break;
+ }
+
+ if (outbufptr) {
+ strcpy((char *)outbufptr, charset->ct_sequence);
+ outbufptr += seq_len;
+
+ if (!standard_flag) {
+ *outbufptr++ = name_len / 128 + 128;
+ *outbufptr++ = name_len % 128 + 128;
+ strcpy((char *)outbufptr, charset->encoding_name);
+ outbufptr = outbufptr + name_len - 2 - 1;
+ *outbufptr++ = STX;
+ }
+ }
+
+ (*to_left) -= total_len;
+
+ first_flag = False;
+ old_charset = charset;
+ }
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < charset->char_size) {
+ unconv_num++;
+ break;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, charset->char_size, side);
+ outbufptr += charset->char_size;
+ }
+
+ (*to_left) -= charset->char_size;
+
+ } /* end of while */
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = stdc_wcstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = mbstocts(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+ctstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long glyph_index = 0;
+ wchar_t wc;
+
+ int ctr_seq_len = 0, gi_len_left = 0, gi_len = 0;
+ int unconv_num = 0;
+
+ CodeSet codeset = NULL;
+ XlcCharSet charset_tmp;
+
+ XPointer inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ int from_size = *from_left;
+
+
+ init_state(conv);
+
+ if (from == NULL || *from == NULL) {
+ init_state(conv);
+ return( 0 );
+ }
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (gi_len_left) {
+ unconv_num += (gi_len - gi_len_left);
+ gi_len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same glyph_index data */
+ if (gi_len_left)
+ goto output_one_wc;
+
+ /* control sequence ? */
+ if (ch == CSI) {
+ if ( !ct_parse_csi(inbufptr - 1, &ctr_seq_len) )
+ goto skip_the_seg;
+
+ if (*from_left < ctr_seq_len) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num += *from_left;
+ break;
+ }
+
+ /* skip the control sequence */
+ inbufptr += (ctr_seq_len - 1);
+ *from_left -= (ctr_seq_len - 1);
+
+ continue;
+ }
+
+ /* escape sequence ? */
+ if (ch == ESC) {
+ if ( !ct_parse_charset(lcd,
+ inbufptr - 1, &state->charset, &ctr_seq_len) )
+ goto skip_the_seg;
+
+ if (state->charset->side == XlcC0 ||
+ state->charset->side == XlcGL)
+ {
+ state->GL_charset = state->charset;
+ }
+ else if (state->charset->side == XlcC1 ||
+ state->charset->side == XlcGR)
+ {
+ state->GR_charset = state->charset;
+ }
+ else if (state->charset->side == XlcGLGR)
+ {
+ state->GL_charset = state->charset;
+ state->GR_charset = state->charset;
+ }
+
+ if (*from_left < ctr_seq_len) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num += *from_left;
+ break;
+ }
+
+ /* skip the escape sequence */
+ inbufptr += (ctr_seq_len - 1);
+ *from_left -= (ctr_seq_len - 1);
+
+ continue;
+ }
+
+ /* check current state */
+ if (isleftside(ch))
+ state->charset = state->GL_charset;
+ else
+ state->charset = state->GR_charset;
+
+ gi_len = gi_len_left = state->charset->char_size;
+ glyph_index = 0;
+
+output_one_wc:
+ if (state->charset->side == XlcC1 || state->charset->side == XlcGR)
+ glyph_index = (glyph_index << 8) | (ch & GL);
+ else
+ glyph_index = (glyph_index << 8) | ch;
+
+ gi_len_left--;
+
+ /* last of one glyph_index data */
+ if (!gi_len_left) {
+
+ /* segment conversion */
+ charset_tmp = state->charset;
+ if ( !segment_conversion(lcd, &charset_tmp, &glyph_index) ) {
+ unconv_num += gi_len;
+ continue;
+ }
+
+ /* get codeset */
+ if ( !_XlcGetCodeSetFromCharSet(lcd, charset_tmp,
+ &codeset, &glyph_index) ) {
+ unconv_num += gi_len;
+ continue;
+ }
+
+ /* convert glyph index to wicd char */
+ gi_to_wc(lcd, glyph_index, codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+ }
+
+ continue;
+
+skip_the_seg:
+ /* skip until next escape or control sequence */
+ while ( *from_left ) {
+ ch = *inbufptr++;
+ (*from_left)--;
+ unconv_num++;
+
+ if (ch == ESC || ch == CSI) {
+ inbufptr--;
+ (*from_left)++;
+ unconv_num--;
+ break;
+ }
+ }
+
+ if ( !(*from_left) )
+ break;
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (gi_len_left) {
+ inbufptr -= (gi_len - gi_len_left);
+ (*from_left) += (gi_len - gi_len_left);
+ unconv_num += (gi_len - gi_len_left);
+ }
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = ctstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = stdc_mbstowcs(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+mbstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left);
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = mbstowcs_org(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t);
+
+ unconv_num2 += wcstocts(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+mbstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+
+
+ int length = 0, len_left = 0;
+ int unconv_num = 0;
+ int num;
+ Bool ss_flag = 0;
+
+ CodeSet codeset = NULL;
+ ParseInfo parse_info;
+
+ XPointer inbufptr = *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+ ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ /* error check */
+ if (len_left) {
+ unconv_num += (length - len_left);
+ len_left = 0;
+ }
+
+ continue;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output_one_mb;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table) {
+ if ((num = mb_parse_table[ch]) > 0) {
+ parse_info = mb_parse_list[num - 1];
+
+ codeset = parse_info->codeset;
+ length = len_left = codeset->length;
+ mb = 0;
+ ss_flag = 1;
+
+ continue;
+ }
+ }
+
+ /* next char data : byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next char data : GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(lcd, ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num++;
+ continue;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+ ss_flag = 0;
+
+output_one_mb:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ if (check_string_encoding(codeset)) {
+ if (outbufptr) {*outbufptr++ = mb & 0xff;}
+ (*to_left)--;
+ } else {
+ unconv_num++;
+ }
+ }
+
+ } /* end of while */
+
+ /* error check on last char */
+ if (len_left) {
+ inbufptr -= (length - len_left + ss_flag);
+ (*from_left) += (length - len_left + ss_flag);
+ unconv_num += (length - len_left + ss_flag);
+ }
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+}
+
+static int
+mbtocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long mb = 0;
+ unsigned long glyph_index;
+
+ int length = 0, len_left = 0, char_len;
+ int unconv_num = 0;
+ int num;
+ XlcSide side;
+
+ CodeSet codeset = NULL;
+ XlcCharSet charset;
+ ParseInfo parse_info;
+
+ XPointer inbufptr = *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+
+ unsigned char *mb_parse_table = XLC_GENERIC(lcd, mb_parse_table);
+ ParseInfo *mb_parse_list = XLC_GENERIC(lcd, mb_parse_list);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ unconv_num = 1;
+ if (len_left)
+ unconv_num += (length - len_left);
+ break;
+ }
+
+ /* same mb char data */
+ if (len_left)
+ goto output;
+
+ /* next mb char data for single shift ? */
+ if (mb_parse_table) {
+ if ((num = mb_parse_table[ch]) > 0) {
+ parse_info = mb_parse_list[num - 1];
+
+ codeset = parse_info->codeset;
+ length = len_left = codeset->length;
+ mb = 0;
+
+ continue;
+ }
+ }
+
+ /* next mb char data for byteM ? */
+ if ((codeset = byteM_parse_codeset(lcd, (inbufptr - 1))))
+ goto next_mb_char;
+
+ /* next mb char data for GL or GR side ? */
+ if ((codeset = GLGR_parse_codeset(lcd, ch)))
+ goto next_mb_char;
+
+ /* can't find codeset for the ch */
+ unconv_num = 1;
+ break;
+
+next_mb_char:
+ length = len_left = codeset->length;
+ mb = 0;
+
+output:
+ mb = (mb << 8) | ch; /* 1 byte left shift */
+ len_left--;
+
+ /* last of one mb char data */
+ if (!len_left) {
+ glyph_index = mb_to_gi(mb, codeset);
+ if (!(charset = gi_parse_charset(glyph_index, codeset))) {
+ unconv_num = length;
+ break;
+ }
+ char_len = charset->char_size;
+ side = charset->side;
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < char_len) {
+ unconv_num = length;
+ break;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, char_len, side);
+ outbufptr += char_len;
+ }
+
+ (*to_left) -= char_len;
+
+ break;
+ }
+
+ } /* end of while */
+
+ /* error end */
+ if (unconv_num) {
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = inbufptr;
+ *to = outbufptr;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+mbstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ XPointer inbufptr;
+ int in_left;
+ XPointer outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+ inbufptr = *from;
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+
+ while ( ret == 0 && *from_left && *to_left && charset_old == charset ) {
+ charset_old = charset;
+ inbufptr = *from;
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ }
+
+ *from = inbufptr;
+ *from_left = in_left;
+ *to = outbufptr;
+ *to_left = out_left;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+static int
+wcstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ wchar_t wc;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ wchar_t *inbufptr = (wchar_t *) *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+ char *default_string = XLC_PUBLIC(lcd, default_string);
+ int defstr_len = strlen(default_string);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+
+ /* output default_string of XDefaultString() */
+ if (*to_left < defstr_len)
+ break;
+ if (outbufptr) {strncpy((char *)outbufptr, default_string, defstr_len);}
+
+ if (outbufptr) {outbufptr += defstr_len;}
+ (*to_left) -= defstr_len;
+
+ unconv_num++;
+
+ } else {
+ mb = gi_to_mb(glyph_index, codeset);
+ if (codeset->parse_info) {
+
+ /* output shift sequence */
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+ if (check_string_encoding(codeset)) {
+ if (outbufptr) {strncpy((char *)outbufptr, encoding, length);}
+ if (outbufptr) {outbufptr += length;}
+ (*to_left) -= length;
+ }
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+ if (check_string_encoding(codeset)) {
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+ } else {
+ unconv_num++;
+ }
+ }
+
+ } /* end of while */
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_wcstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = stdc_wcstombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = mbstostr(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+wctocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ wchar_t wc;
+ unsigned long glyph_index;
+
+ int char_len;
+ int unconv_num = 0;
+ XlcSide side;
+
+ CodeSet codeset;
+ XlcCharSet charset;
+
+ wchar_t *inbufptr = (wchar_t *) *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ if (*from_left && *to_left) {
+
+ wc = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!wc) {
+ unconv_num = 1;
+ goto end;
+ }
+
+ /* convert */
+ if ( !wc_to_gi(lcd, wc, &glyph_index, &codeset) ) {
+ unconv_num = 1;
+ goto end;
+ }
+
+ if ( !(charset = gi_parse_charset(glyph_index, codeset)) ) {
+ unconv_num = 1;
+ goto end;
+ }
+ char_len = charset->char_size;
+ side = charset->side;
+
+ /* output glyph index */
+ if (codeset->ctconv)
+ glyph_index = conv_to_dest(codeset->ctconv, glyph_index);
+ if (*to_left < char_len) {
+ unconv_num++;
+ goto end;
+ }
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, glyph_index, char_len, side);
+ outbufptr += char_len;
+ }
+
+ (*to_left) -= char_len;
+
+ }
+
+end:
+
+ /* error end */
+ if (unconv_num) {
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = (XPointer)inbufptr;
+ *to = outbufptr;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+stdc_wctocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ wchar_t wch, *src = *((wchar_t **) from);
+ XPointer tmp_from, save_from = *from;
+ char tmp[32];
+ int length, ret, src_left = *from_left;
+ int from_size = *from_left;
+
+ if (src_left > 0 && *to_left > 0) {
+ if ((wch = *src)) {
+ length = wctomb(tmp, wch);
+ } else {
+ goto end;
+ }
+
+ if (length < 0)
+ goto end;
+
+ tmp_from = (XPointer) tmp;
+ ret = mbtocs(conv, &tmp_from, &length, to, to_left, args, num_args);
+ if (ret < 0)
+ goto end;
+
+ src++;
+ src_left--;
+ }
+
+end:
+ /* error end */
+ if (save_from == (XPointer) src) {
+ *from = *from + from_size;
+ *from_left = 0;
+ return -1;
+ }
+
+ /* nomal end */
+ *from = (XPointer) src;
+ *from_left = src_left;
+
+ return 0;
+}
+
+static int
+wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ wchar_t *inbufptr;
+ int in_left;
+ XPointer outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+ inbufptr = (wchar_t *)(*from);
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+
+ while ( ret == 0 && *from_left && *to_left && charset_old == charset ) {
+ charset_old = charset;
+ inbufptr = (wchar_t *)(*from);
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ }
+
+ *from = (XPointer)inbufptr;
+ *from_left = in_left;
+ *to = outbufptr;
+ *to_left = out_left;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+static int
+stdc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ int ret;
+ XlcCharSet charset_old, charset = NULL;
+ XPointer tmp_args[1];
+
+ wchar_t *inbufptr;
+ int in_left;
+ XPointer outbufptr;
+ int out_left;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ charset_old = charset;
+ inbufptr = (wchar_t *)(*from);
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+
+ while ( ret == 0 && *from_left && *to_left && charset_old == charset ) {
+ charset_old = charset;
+ inbufptr = (wchar_t *)(*from);
+ in_left = *from_left;
+ outbufptr = *to;
+ out_left = *to_left;
+ ret = stdc_wctocs(conv, from, from_left, to, to_left, tmp_args, 1);
+ }
+
+ *from = (XPointer)inbufptr;
+ *from_left = in_left;
+ *to = outbufptr;
+ *to_left = out_left;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset_old;
+
+ /* error end */
+ if (ret != 0)
+ return( -1 );
+
+ return(0);
+}
+
+static int
+ctstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * sizeof(wchar_t));
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left);
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = ctstowcs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = (buf_ptr1 - buf_ptr2) / sizeof(wchar_t);
+
+ unconv_num2 += wcstombs_org(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+static int
+strtombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ char *encoding;
+ unsigned long mb, glyph_index;
+ unsigned char ch;
+
+ int length;
+ int unconv_num = 0;
+
+ CodeSet codeset;
+
+ XPointer inbufptr = *from;
+ XPointer outbufptr = *to;
+ int from_size = *from_left;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = '\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if (isleftside(ch)) {
+ glyph_index = ch;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GL");
+ } else {
+ glyph_index = ch & GL;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GR");
+ }
+
+ if (!codeset) {
+ unconv_num++;
+ continue;
+ }
+
+ mb = gi_to_mb(glyph_index, codeset);
+ if (codeset->parse_info) {
+
+ /* output shift sequence */
+ encoding = codeset->parse_info->encoding;
+ length = strlen(encoding);
+ if (*to_left < length)
+ break;
+ if (outbufptr) {strncpy((char *)outbufptr, encoding, length);}
+
+ if (outbufptr) {outbufptr += length;}
+ (*to_left) -= length;
+ }
+
+ /* output characters */
+ length = codeset->length;
+ if (*to_left < length)
+ break;
+
+ if (outbufptr) {
+ output_ulong_value(outbufptr, mb, length, XlcNONE);
+ outbufptr += length;
+ }
+
+ (*to_left) -= length;
+
+ } /* end of while */
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = outbufptr;
+
+ return unconv_num;
+}
+
+static int
+strtowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+
+ unsigned char ch;
+ unsigned long glyph_index;
+ wchar_t wc;
+
+ int unconv_num = 0;
+ CodeSet codeset;
+
+ XPointer inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *)*to;
+ int from_size = *from_left;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ while (*from_left && *to_left) {
+
+ ch = *inbufptr++;
+ (*from_left)--;
+
+ /* null ? */
+ if (!ch) {
+ if (outbufptr) {*outbufptr++ = L'\0';}
+ (*to_left)--;
+
+ continue;
+ }
+
+ /* convert */
+ if (isleftside(ch)) {
+ glyph_index = ch;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GL");
+ } else {
+ glyph_index = ch & GL;
+ codeset = _XlcGetCodeSetFromName(lcd, "ISO8859-1:GR");
+ }
+
+ if (!codeset) {
+ unconv_num++;
+ continue;
+ }
+
+ gi_to_wc(lcd, glyph_index, codeset, &wc);
+ if (outbufptr) {*outbufptr++ = wc;}
+ (*to_left)--;
+
+ } /* end of while */
+
+ *from = *from + from_size;
+ *from_left = 0;
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+}
+
+static int
+stdc_strtowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer buf = Xmalloc((*from_left) * MB_CUR_MAX);
+ XPointer buf_ptr1 = buf;
+ int buf_left1 = (*from_left) * MB_CUR_MAX;
+ XPointer buf_ptr2 = buf_ptr1;
+ int buf_left2;
+ int unconv_num1 = 0, unconv_num2 = 0;
+
+ unconv_num1 = strtombs(conv,
+ from, from_left, &buf_ptr1, &buf_left1, args, num_args);
+ if (unconv_num1 < 0)
+ goto ret;
+
+ buf_left2 = buf_ptr1 - buf_ptr2;
+
+ unconv_num2 = stdc_mbstowcs(conv,
+ &buf_ptr2, &buf_left2, to, to_left, args, num_args);
+ if (unconv_num2 < 0)
+ goto ret;
+
+ret:
+ if (buf)
+ Xfree((char *)buf);
+
+ return (unconv_num1 + unconv_num2);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Close */
+/* -------------------------------------------------------------------------- */
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ if (conv->state) {
+ Xfree((char *) conv->state);
+ }
+
+ if (conv->methods) {
+ Xfree((char *) conv->methods);
+ }
+
+ Xfree((char *) conv);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Open */
+/* -------------------------------------------------------------------------- */
+
+static XlcConv
+create_conv(lcd, methods)
+ XLCd lcd;
+ XlcConvMethods methods;
+{
+ XlcConv conv;
+ State state;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
+ if (conv->methods == NULL)
+ goto err;
+ *conv->methods = *methods;
+ if (XLC_PUBLIC(lcd, is_state_depend))
+ conv->methods->reset = init_state;
+
+ conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ if (conv->state == NULL)
+ goto err;
+ bzero((char *) conv->state, sizeof(StateRec));
+
+ state = (State) conv->state;
+ state->lcd = lcd;
+ init_state(conv);
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec mbstocts_methods = {
+ close_converter,
+ mbstocts,
+ NULL
+} ;
+
+static XlcConv
+open_mbstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbstocts_methods);
+}
+
+static XlcConvMethodsRec mbstostr_methods = {
+ close_converter,
+ mbstostr,
+ NULL
+} ;
+
+static XlcConv
+open_mbstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbstostr_methods);
+}
+
+static XlcConvMethodsRec mbstocs_methods = {
+ close_converter,
+ mbstocs,
+ NULL
+} ;
+
+static XlcConv
+open_mbstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbstocs_methods);
+}
+
+static XlcConvMethodsRec mbtocs_methods = {
+ close_converter,
+ mbtocs,
+ NULL
+} ;
+
+static XlcConv
+open_mbtocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbtocs_methods);
+}
+
+static XlcConvMethodsRec ctstombs_methods = {
+ close_converter,
+ ctstombs,
+ NULL
+} ;
+
+static XlcConv
+open_ctstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &ctstombs_methods);
+}
+
+static XlcConvMethodsRec strtombs_methods = {
+ close_converter,
+ strtombs,
+ NULL
+} ;
+
+static XlcConv
+open_strtombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &strtombs_methods);
+}
+
+#ifdef STDCVT
+
+static XlcConvMethodsRec stdc_mbstowcs_methods = {
+ close_converter,
+ stdc_mbstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_mbstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_mbstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstombs_methods = {
+ close_converter,
+ stdc_wcstombs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstombs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocts_methods = {
+ close_converter,
+ stdc_wcstocts,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstocts_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstostr_methods = {
+ close_converter,
+ stdc_wcstostr,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstostr_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocs_methods = {
+ close_converter,
+ stdc_wcstocs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstocs_methods);
+}
+
+static XlcConvMethodsRec stdc_wctocs_methods = {
+ close_converter,
+ stdc_wctocs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wctocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wctocs_methods);
+}
+
+static XlcConvMethodsRec stdc_ctstowcs_methods = {
+ close_converter,
+ stdc_ctstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_ctstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_ctstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_strtowcs_methods = {
+ close_converter,
+ stdc_strtowcs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_strtowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_strtowcs_methods);
+}
+
+#endif /* STDCVT */
+
+static XlcConvMethodsRec mbstowcs_methods = {
+ close_converter,
+ mbstowcs_org,
+ NULL
+} ;
+
+static XlcConv
+open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbstowcs_methods);
+}
+
+static XlcConvMethodsRec wcstombs_methods = {
+ close_converter,
+ wcstombs_org,
+ NULL
+} ;
+
+static XlcConv
+open_wcstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wcstombs_methods);
+}
+
+static XlcConvMethodsRec wcstocts_methods = {
+ close_converter,
+ wcstocts,
+ NULL
+} ;
+
+static XlcConv
+open_wcstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wcstocts_methods);
+}
+
+static XlcConvMethodsRec wcstostr_methods = {
+ close_converter,
+ wcstostr,
+ NULL
+} ;
+
+static XlcConv
+open_wcstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wcstostr_methods);
+}
+
+static XlcConvMethodsRec wcstocs_methods = {
+ close_converter,
+ wcstocs,
+ NULL
+} ;
+
+static XlcConv
+open_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wcstocs_methods);
+}
+
+static XlcConvMethodsRec wctocs_methods = {
+ close_converter,
+ wctocs,
+ NULL
+} ;
+
+static XlcConv
+open_wctocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wctocs_methods);
+}
+
+static XlcConvMethodsRec ctstowcs_methods = {
+ close_converter,
+ ctstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &ctstowcs_methods);
+}
+
+static XlcConvMethodsRec strtowcs_methods = {
+ close_converter,
+ strtowcs,
+ NULL
+} ;
+
+static XlcConv
+open_strtowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &strtowcs_methods);
+}
+
+/* -------------------------------------------------------------------------- */
+/* Loader */
+/* -------------------------------------------------------------------------- */
+
+XLCd
+_XlcGenericLoader(name)
+ char *name;
+{
+ XLCd lcd;
+ XLCdGenericPart *gen;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+
+ if (lcd == NULL)
+ return lcd;
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNString, open_mbstostr);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNMultiByte, open_strtombs);
+
+#ifdef STDCVT
+ gen = XLC_GENERIC_PART(lcd);
+
+ if (gen->use_stdc_env != True) {
+#endif
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_wctocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_strtowcs);
+#ifdef STDCVT
+ }
+#endif
+
+#ifdef STDCVT
+ if (gen->use_stdc_env == True) {
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_stdc_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_stdc_wcstombs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_stdc_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNString, open_stdc_wcstostr);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_stdc_wcstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNChar, open_stdc_wctocs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_stdc_ctstowcs);
+ _XlcSetConverter(lcd, XlcNString, lcd, XlcNWideChar, open_stdc_strtowcs);
+ }
+#endif
+
+ return lcd;
+}
+
diff --git a/modules/lc/xlocale/lcEuc.c b/modules/lc/xlocale/lcEuc.c
new file mode 100644
index 00000000..2027302f
--- /dev/null
+++ b/modules/lc/xlocale/lcEuc.c
@@ -0,0 +1,1505 @@
+/* $Xorg: lcEuc.c,v 1.3 2000/08/17 19:45:17 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
+
+Permission to use, copy, modify, distribute and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Fujitsu Open Systems Solutions, Inc. not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+written prior permission.
+FUJITSU LIMITED and Fujitsu Open Systems Solutions, Inc. makes no
+representations about the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND FUJITSU OPEN SYSTEMS SOLUTIONS, INC. DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU OPEN SYSTEMS
+SOLUTIONS, INC. AND FUJITSU LIMITED 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.
+
+ Authors: Shigeru Yamada (yamada@ossi.com)
+ Jeffrey Bloomfield (jeffb@ossi.com)
+ Yoshiyuki Segawa (segawa@ossi.com)
+
+*****************************************************************/
+
+#ifdef X_LOCALE
+
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+#include <ctype.h>
+#ifdef WIN32
+#define isascii __isascii
+#endif
+
+#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
+#define CS1 codesets[1] /* Codeset 1 - Kanji */
+#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
+#define CS3 codesets[3] /* Codeset 3 - User defined */
+
+#define SS2 0x8e /* Single-shift char: CS2 */
+#define SS3 0x8f /* Single-shift char: CS3 */
+
+#define ASCII_CODESET 0
+#define KANJI_CODESET 1
+#define KANA_CODESET 2
+#define USERDEF_CODESET 3
+#define MAX_CODESETS
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+
+#define isleftside(c) (((c) & GR) ? 0 : 1)
+#define isrightside(c) (!isleftside(c))
+
+#define BIT8OFF(c) ((c) & GL)
+#define BIT8ON(c) ((c) | GR)
+
+typedef unsigned char Uchar;
+typedef unsigned long Ulong;
+typedef unsigned int Uint;
+
+static CodeSet GetCodeSetFromCharSet();
+static CodeSet wc_codeset();
+
+#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
+ BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
+ BIT8OFF(c) != 0x1b)
+
+/*
+ * Notes:
+ * 1. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
+ * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
+ * 2. Using direct converters (e.g. mbstowcs()) decreases conversion
+ * times by 20-40% (depends on specific converter used).
+ */
+
+static int
+euc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+
+ XLCd lcd = (XLCd)conv->state;
+
+ register Uchar ch;
+ register int chr_len = 0;
+ register int sshift = False;
+ register int shift_mult = 0;
+ register Uint chrcode;
+
+ Uint wc_encode = 0;
+ Uint wc_tmp = 0;
+
+ int cs0flg = False;
+ int cs1flg = False;
+ int length;
+ int num_conv;
+ int unconv_num = 0;
+
+ Bool new_char;
+
+ XPointer inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (new_char = True; *from_left > 0;) {
+
+ ch = *inbufptr++;
+
+ if (isleftside(ch)) { /* CS0 */
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if( cs0flg == True) {
+ new_char = True;
+ cs0flg = False;
+ }
+ length = CS0->length;
+ *outbufptr++ = (wchar_t)ch;
+ (*from_left)--;
+ continue;
+ }
+ else if (ch == SS2) { /* CS2 */
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == True || cs1flg == True) {
+ cs1flg = False;
+ unconv_num++;
+ continue;
+ }
+ length = CS2->length;
+ wc_encode = CS2->wc_encoding;
+ chrcode = 0;
+ sshift = True;
+ cs0flg = True;
+ (*from_left)--;
+ continue;
+ }
+ else if (ch == SS3) { /* CS3 */
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == True || cs1flg == True) {
+ cs1flg = False;
+ unconv_num++;
+ continue;
+ }
+ length = CS3->length;
+ if (*from_left < 1 )
+ unconv_num++;
+ wc_encode = CS3->wc_encoding;
+ chrcode = 0;
+ sshift = True;
+ cs0flg = True;
+ (*from_left)--;
+ continue;
+
+ } else { /* CS1 */
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (sshift == False) {
+ length = CS1->length;
+ if (*from_left < 1)
+ unconv_num++;
+ wc_encode = CS1->wc_encoding;
+ }
+ chrcode = BIT8OFF(ch);
+ cs0flg = True;
+ cs1flg = True;
+ (*from_left)--;
+ }
+
+ if (new_char) { /* begin new character */
+ chr_len = length;
+ shift_mult = length - 1;
+ new_char = False;
+ }
+
+ chrcode <<= (wc_shift * shift_mult);
+ shift_mult--;
+ wc_tmp |= chrcode;
+
+ if (--chr_len == 0) {
+ wc_tmp |= wc_encode;
+ *outbufptr++ = wc_tmp;
+
+ new_char = True;
+ sshift = False;
+ cs0flg = False;
+ cs1flg = False;
+ wc_tmp = (Uint)0;
+ }
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if (cs0flg == True || cs1flg == True) /* error check on last char */
+ unconv_num++;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ *to_left = (*to_left) - num_conv;
+
+ return unconv_num;
+}
+
+
+static int
+euc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ wchar_t *inbufptr = (wchar_t *) *from;
+ register XPointer outbufptr = *to;
+ XPointer outbuf_base = outbufptr;
+ wchar_t wch;
+ register int length;
+ Uchar tmp;
+ int num_conv;
+ int unconv_num = 0;
+
+ XLCd lcd = (XLCd)conv->state;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if (codeset->parse_info) /* put out SS2 or SS3 */
+ *outbufptr++ = *codeset->parse_info->encoding;
+
+ do {
+ length--;
+ tmp = (wch>>(wchar_t)(length * wc_shift));
+
+ if (codeset->side == XlcGR)
+ tmp = BIT8ON(tmp);
+
+ *outbufptr++ = (Uchar)tmp;
+ } while (length);
+ }
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ *to_left -= num_conv;
+
+ return unconv_num;
+}
+
+
+static int
+euc_mbtocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ XlcCharSet charset;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ int length;
+ int unconv_num = 0;
+ int min_ch = 0;
+ register char *src = *from, *dst = *to;
+
+
+ if (isleftside(*src)) { /* 7-bit (CS0) */
+ if (ASCII_CODESET >= codeset_num)
+ return -1;
+ charset = *CS0->charset_list;
+ }
+ else if ((Uchar)*src == SS2) { /* half-kana (CS2) */
+ if (KANA_CODESET >= codeset_num)
+ return -1;
+ charset = *CS2->charset_list;
+ src++;
+ (*from_left)--;
+ }
+ else if ((Uchar)*src == SS3) { /* user-def */
+ if (USERDEF_CODESET >= codeset_num)
+ return -1;
+ charset = *CS3->charset_list;
+ src++;
+ (*from_left)--;
+ }
+ else { /* Kanji (CS1) */
+ if (KANJI_CODESET >= codeset_num)
+ return -1;
+ charset = *CS1->charset_list;
+ }
+
+ if(*from_left < charset->char_size || *to_left < charset->char_size)
+ return -1;
+
+ min_ch = 0x20;
+ if (charset->set_size == 94)
+ if (charset->char_size > 1 || charset->side == XlcGR)
+ min_ch = 0x21;
+
+ length = charset->char_size;
+ do {
+ if(BADCHAR(min_ch, *src)) {
+ unconv_num++;
+ src++;
+ break;
+ }
+ switch (charset->side) {
+ case XlcGL:
+ *dst++ = BIT8OFF(*src++);
+ break;
+ case XlcGR:
+ *dst++ = BIT8ON(*src++);
+ break;
+ default:
+ *dst++ = *src++;
+ break;
+ }
+ } while (--length);
+
+ *to = dst;
+ *from = src;
+ *from_left -= charset->char_size;
+ *to_left -= charset->char_size - length;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+euc_mbstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ char *tmp_from, *tmp_to;
+ int tmp_from_left, tmp_to_left;
+ XlcCharSet charset, tmp_charset;
+ XPointer tmp_args[1];
+ int unconv_num = 0, ret;
+
+
+/* Determine the charset of the segment and convert one characater: */
+
+ tmp_args[0] = (XPointer) &charset; /* charset from euc_mbtocs() */
+ while
+ ((ret = euc_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
+ unconv_num += ret;
+ if ( ret < 0 )
+ return ret;
+
+ tmp_from = *from;
+ tmp_from_left = *from_left;
+ tmp_to_left = *to_left;
+ tmp_to = *to;
+
+
+/* Convert remainder of the segment: */
+
+ tmp_args[0] = (XPointer) &tmp_charset;
+ while( (ret = euc_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to,
+ &tmp_to_left, tmp_args, 1)) >= 0 ) {
+
+ if (ret > 0) {
+ unconv_num += ret;
+ continue;
+ }
+
+ if (tmp_charset != charset) /* quit on end of segment */
+ break;
+
+ *from = tmp_from;
+ *from_left = tmp_from_left;
+ *to = tmp_to;
+ *to_left = tmp_to_left;
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+euc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ wchar_t *wcptr = (wchar_t *) *from;
+ register char *bufptr = (char *) *to;
+ wchar_t wch;
+ char *tmpptr;
+ register int length;
+ CodeSet codeset;
+ Ulong wc_encoding;
+ int wcstr_len = *from_left, buf_len = *to_left;
+
+
+ if (!(codeset = wc_codeset(lcd, *wcptr)))
+ return -1;
+
+ wc_encoding = codeset->wc_encoding;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+
+ length = codeset->length;
+
+ buf_len -= length;
+ bufptr += length;
+ tmpptr = bufptr - 1;
+
+ while (length--) {
+ *tmpptr-- = codeset->length == 1 && codeset->side == XlcGR ?
+ BIT8ON(wch) : BIT8OFF(wch);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - (wchar_t *) *from;
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *to;
+ *to = bufptr;
+
+ return 0;
+}
+
+
+static int
+euc_cstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ register char *csptr = *from;
+ register char *bufptr = *to;
+ int csstr_len = *from_left;
+ register int buf_len = *to_left;
+ int length;
+ CodeSet codeset;
+ int cvt_length;
+
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ cvt_length = 0;
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length;
+
+ if (codeset->parse_info)
+ csstr_len *= 2;
+
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * codeset->length;
+
+ if (bufptr) {
+ while (buf_len--) {
+ if (codeset->parse_info) /* put out SS2 or SS3 */
+ *bufptr++ = *codeset->parse_info->encoding;
+
+ length = codeset->length;
+ while (length--)
+ *bufptr++ = codeset->side == XlcGR ?
+ BIT8ON(*csptr++) : BIT8OFF(*csptr++);
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = csptr;
+ if (bufptr)
+ *to += cvt_length;
+ *to_left -= cvt_length;
+
+ return 0;
+}
+
+
+static int
+euc_cstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ register char *csptr = *from;
+ wchar_t *bufptr = (wchar_t *) *to;
+ wchar_t *toptr = (wchar_t *) *to;
+ int csstr_len = *from_left;
+ register int buf_len = *to_left;
+ wchar_t wch;
+ int length;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ CodeSet codeset;
+
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+ *to_left -= buf_len;
+
+ if (bufptr) {
+
+ toptr += buf_len;
+ *to = (XPointer) toptr;
+
+ while (buf_len--) {
+
+ wch = (wchar_t) BIT8OFF(*csptr);
+ csptr++;
+
+ length = codeset->length - 1;
+ while (length--) {
+ wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
+ csptr++;
+ }
+ *bufptr++ = wch | codeset->wc_encoding;
+ }
+ }
+ *from_left -= csptr - *from;
+ *from = csptr;
+
+ return 0;
+}
+
+
+static CodeSet
+wc_codeset(lcd, wch)
+ XLCd lcd;
+ wchar_t wch;
+{
+
+ register CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ register int end = XLC_GENERIC(lcd, codeset_num);
+ register Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+
+ for (; --end >= 0; codesets++)
+ if ( widech == (*codesets)->wc_encoding )
+ return *codesets;
+
+ return NULL;
+}
+
+
+static CodeSet
+GetCodeSetFromCharSet(lcd, charset)
+ XLCd lcd;
+ XlcCharSet charset;
+{
+ register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ register XlcCharSet *charset_list;
+ register int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+
+static XlcConv
+create_conv(lcd, methods)
+ XLCd lcd;
+ XlcConvMethods methods;
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) lcd;
+ return conv;
+}
+
+
+/*
+ * Stripped down Direct CT converters for EUC
+ *
+ */
+
+typedef struct _CTDataRec {
+ int side;
+ int length;
+ char *name;
+ Ulong wc_encoding;
+ char sshift;
+ char *ct_encoding;
+ int ct_encoding_len;
+ int set_size;
+ Uchar min_ch;
+ Uchar ct_type;
+} CTDataRec, *CTData;
+
+typedef struct _StateRec {
+ CTData GL_charset;
+ CTData GR_charset;
+ CTData charset;
+} StateRec, *State;
+
+#define CT_STD 0
+#define CT_NSTD 1
+#define CT_DIR 2
+#define CT_EXT0 3
+#define CT_EXT1 4
+#define CT_EXT2 5
+#define CT_VER 6
+
+static CTDataRec ctdata[] =
+{
+ { XlcGL, 1, "ISO8859-1:GL", 0, 0, "\033(B" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "ISO8859-1:GR", 0, 0, "\033-A" , 3, 0, 0, CT_STD },
+ { XlcGL, 1, "JISX0201.1976-0:GL", 0, 0, "\033(J" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "JISX0201.1976-0:GR", 0, 0, "\033)I" , 3, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0208.1983-0:GL", 0, 0, "\033$(B" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0208.1983-0:GR", 0, 0, "\033$)B" , 4, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0212.1990-0:GL", 0, 0, "\033$(D" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0212.1990-0:GR", 0, 0, "\033$)D" , 4, 0, 0, CT_STD },
+ { XlcUnknown, 0, "Ignore-Ext-Status?", 0, 0, "\033#" , 2, 0, 0, CT_VER },
+ { XlcUnknown, 0, "NonStd-?-OctetChar", 0, 0, "\033%/0" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 1, "NonStd-1-OctetChar", 0, 0, "\033%/1" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 2, "NonStd-2-OctetChar", 0, 0, "\033%/2" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 3, "NonStd-3-OctetChar", 0, 0, "\033%/3" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 4, "NonStd-4-OctetChar", 0, 0, "\033%/4" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 0, "Extension-2" , 0, 0, "\033%/" , 3, 0, 0, CT_EXT2 },
+ { XlcUnknown, 0, "Extension-0" , 0, 0, "\033" , 1, 0, 0, CT_EXT0 },
+ { XlcUnknown, 0, "Begin-L-to-R-Text", 0, 0, "\2331]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Begin-R-to-L-Text", 0, 0, "\2332]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "End-Of-String", 0, 0, "\233]" , 2, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Extension-1" , 0, 0, "\233" , 1, 0, 0, CT_EXT1 },
+};
+
+/* Note on above table: euc_ctstombs() and euc_ctstowcs() parser depends on
+ * certain table entries occuring in decreasing string length--
+ * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
+ * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
+ */
+
+static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
+static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
+
+#define Ascii 0
+#define Kanji 1
+#define Kana 2
+#define Userdef 3
+
+/*
+ * initCTptr(): Set ctdptr[] to point at ctdata[], indexed by codeset_num.
+ */
+static void
+initCTptr(lcd)
+ XLCd lcd;
+{
+ int num_codesets = XLC_GENERIC(lcd, codeset_num);
+ int num_charsets;
+ int i, j;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ CodeSet codeset;
+ XlcCharSet charset;
+ CTData ctdp = ctdata;
+
+ ctdptr[Ascii] = &ctdata[0]; /* failsafe */
+
+ for (i = 0; i < num_codesets; i++) {
+
+ codeset = codesets[i];
+ num_charsets = codeset->num_charsets;
+
+ for (j = 0; j < num_charsets; j++) {
+
+ charset = codeset->charset_list[j];
+
+ for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
+
+ if (! strcmp(ctdp->name, charset->name)) {
+
+ ctdptr[codeset->cs_num] = ctdp;
+
+ ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
+
+ ctdptr[codeset->cs_num]->set_size =
+ charset->set_size;
+
+ ctdptr[codeset->cs_num]->min_ch =
+ charset->set_size == 94 &&
+ (ctdptr[codeset->cs_num]->length > 1 ||
+ ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
+
+ if (codeset->parse_info) {
+ ctdptr[codeset->cs_num]->sshift =
+ *codeset->parse_info->encoding;
+ }
+
+ break;
+ }
+ }
+ }
+}
+
+
+#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
+#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
+
+static int
+euc_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ register XPointer inbufptr = *from;
+ XPointer inbuf_base;
+ register wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+ register int clen, length;
+ int num_conv;
+ int unconv_num = 0;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ register int shift_mult;
+ wchar_t wc_tmp;
+ wchar_t wch;
+ Ulong wc_encoding;
+ CTData ctdp = ctdata;
+ Bool save_outbuf = True;
+ /* If outbufptr is NULL, doen't save output, but just counts
+ a length to hold the output */
+ if (outbufptr == NULL) save_outbuf = False;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if (ctdp->length) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ *(from_left) -= 2;
+ continue;
+ }
+
+ wc_encoding = (ctdp == ctdptr[Kana] && isleftside(*inbufptr)) ?
+ ctdptr[Ascii]->wc_encoding: ctdp->wc_encoding;
+
+ shift_mult = length - 1;
+ wch = (wchar_t)0;
+ clen = length;
+
+ do {
+ wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
+ wch |= wc_tmp;
+ shift_mult--;
+ } while (--clen);
+
+ if (save_outbuf == True)
+ *outbufptr++ = wch | wc_encoding;
+ if (--*to_left == 0 && *from_left != length) {
+ *to = (XPointer)outbufptr;
+ unconv_num = *from_left;
+ return unconv_num;
+ }
+ }
+
+ *to = (XPointer)outbufptr;
+
+ return unconv_num;
+
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+#define kanji (codeset->cs_num == 1)
+#define kana (codeset->cs_num == 2)
+#define userdef (codeset->cs_num == 3)
+
+static int
+euc_wcstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register int ct_len = *to_left;
+ register wchar_t *inbufptr = (wchar_t *) *from;
+ register char *ctptr = *to;
+ XPointer ct_base = ctptr;
+ wchar_t wch;
+ register int length;
+ register int unconv_num = 0;
+ Uchar tmp;
+ Uchar t1 = 0;
+ int num_conv;
+
+ StateRec ct_state;
+ XLCd lcd = (XLCd)conv->state;
+ CTData charset;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+
+/* Initial State: */
+ ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ charset = ctdptr[codeset->cs_num];
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
+
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
+ ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
+ }
+ }
+
+ if (charset->side == XlcGR) {
+ ct_state.GR_charset = charset;
+ ct_state.GL_charset = NULL;
+ } else if (charset->side == XlcGL) {
+ ct_state.GL_charset = charset;
+ ct_state.GR_charset = NULL;
+ }
+
+ do {
+
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana) {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)BIT8ON(tmp);
+ }
+
+ else if (byte1 && (kanji || userdef))
+ t1 = tmp;
+
+ else if (byte2 && (kanji || userdef)) {
+ if (BADCHAR(charset->min_ch, (char)t1) ||
+ BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ if (charset->side == XlcGR) {
+ *ctptr++ = (char)BIT8ON(t1);
+ *ctptr++ = (char)BIT8ON(tmp);
+ } else {
+ *ctptr++ = (char)BIT8OFF(t1);
+ *ctptr++ = (char)BIT8OFF(tmp);
+ }
+ }
+
+ else {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)tmp;
+ }
+
+
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+#undef kana
+#undef kanji
+#undef userdef
+
+
+#define byte1 (ctdp->length == clen)
+#define kana (ctdp == ctdptr[Kana] && isrightside(*inbufptr))
+/* #define kanji (ctdp == ctdptr[Kanji]) */
+#define kanji (strstr(ctdp->name, "JISX0208"))
+#define userdef (ctdp == ctdptr[Userdef])
+
+static int
+euc_ctstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register XPointer inbufptr = *from;
+ register XPointer outbufptr = *to;
+ XPointer inbuf_base;
+ XPointer outbuf_base = outbufptr;
+ register int clen, length;
+ int unconv_num = 0;
+ int num_conv;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ CTData ctdp = &ctdata[0]; /* default */
+ Bool save_outbuf = True;
+ /* If outbufptr is NULL, doen't save output, but just counts
+ a length to hold the output */
+ if (outbufptr == NULL) save_outbuf = False;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if (ctdp->length) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ *(from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ *(from_left) -= 2;
+ continue;
+ }
+
+ clen = length;
+ do {
+
+ if (byte1)
+ if (kanji) {
+ *inbufptr = BIT8ON(*inbufptr);
+ *(inbufptr+1) = BIT8ON(*(inbufptr+1));
+ }
+ else if (kana || userdef) {
+ if (save_outbuf == True) {
+ *outbufptr++ = ctdp->sshift;
+ }
+ (*to_left)--;
+ }
+ if (save_outbuf == True) {
+ *outbufptr++ = *inbufptr;
+ }
+ (*to_left)--;
+ inbufptr++;
+
+ if (*to_left == 0 && *from_left != length) {
+ *to = (XPointer)outbufptr;
+ unconv_num = *from_left;
+ return unconv_num;
+ }
+ } while (--clen);
+ }
+
+ *to = outbufptr;
+
+ return unconv_num;
+
+}
+#undef byte1
+#undef kana
+#undef kanji
+#undef userdef
+
+
+static int
+euc_mbstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register int ct_len = *to_left;
+ int cs_num;
+ int clen, length;
+ int unconv_num = 0;
+ int num_conv;
+ XPointer inbufptr = *from;
+ register char *ctptr = *to;
+ XPointer ct_base = ctptr;
+
+ StateRec ct_state;
+ CTData charset;
+ XLCd lcd = (XLCd) conv->state;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+
+/* Initial State: */
+ ct_state.GL_charset = NULL;
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (;*from_left > 0; (*from_left) -= length) {
+
+ if (isleftside(*inbufptr)) { /* 7-bit (CS0) */
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Ascii;
+ charset = ctdptr[Ascii];
+ }
+ else if ((Uchar)*inbufptr == SS2) { /* Kana */
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kana;
+ charset = ctdptr[Kana];
+ inbufptr++;
+ (*from_left)--;
+ }
+ else if ((Uchar)*inbufptr == SS3) { /* Userdef */
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Userdef;
+ charset = ctdptr[Userdef];
+ inbufptr++;
+ (*from_left)--;
+ }
+ else {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kanji;
+ charset = ctdptr[Kanji];
+ }
+
+ length = charset->length;
+
+ if (BADCHAR(charset->min_ch, *inbufptr))
+ continue;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
+ ctptr += ctdptr[cs_num]->ct_encoding_len;
+ }
+ }
+
+ if (charset->side == XlcGR) {
+ ct_state.GR_charset = charset;
+ ct_state.GL_charset = NULL;
+ } else if (charset->side == XlcGL) {
+ ct_state.GL_charset = charset;
+ ct_state.GR_charset = NULL;
+ }
+
+ clen = length;
+
+ do {
+ *ctptr++ = charset == ct_state.GR_charset ?
+ BIT8ON(*inbufptr++) : BIT8OFF(*inbufptr++);
+ } while (--clen);
+ }
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+ return unconv_num;
+
+}
+
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ Xfree((char *) conv);
+}
+
+enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
+ CTSTOWCS, CTSTOMBS, WCSTOCTS, MBSTOCTS };
+
+static XlcConvMethodsRec conv_methods[] = {
+ {close_converter, euc_mbstocs, NULL },
+ {close_converter, euc_wcstocs, NULL },
+ {close_converter, euc_mbtocs, NULL },
+ {close_converter, euc_cstombs, NULL },
+ {close_converter, euc_cstowcs, NULL },
+ {close_converter, euc_mbstowcs, NULL },
+ {close_converter, euc_wcstombs, NULL },
+ {close_converter, euc_ctstowcs, NULL },
+ {close_converter, euc_ctstombs, NULL },
+ {close_converter, euc_wcstocts, NULL },
+ {close_converter, euc_mbstocts, NULL },
+};
+
+
+static XlcConv
+open_mbstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCS]);
+}
+
+static XlcConv
+open_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCS]);
+}
+
+static XlcConv
+open_mbtocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBTOCS]);
+}
+
+static XlcConv
+open_cstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CSTOMBS]);
+}
+
+static XlcConv
+open_cstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CSTOWCS]);
+}
+
+static XlcConv
+open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
+}
+
+static XlcConv
+open_wcstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
+}
+
+static XlcConv
+open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
+}
+
+static XlcConv
+open_ctstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
+}
+
+static XlcConv
+open_wcstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
+}
+
+static XlcConv
+open_mbstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
+}
+
+XLCd
+#ifdef DYNAMIC_LOAD
+_XlcGenericLoader(name)
+#else
+_XlcEucLoader(name)
+#endif
+ char *name;
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcNCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "euc", 3))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ initCTptr(lcd);
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+
+#ifndef FORCE_INDIRECT_CONVERTER
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+#endif
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/modules/lc/xlocale/lcJis.c b/modules/lc/xlocale/lcJis.c
new file mode 100644
index 00000000..eae9ee95
--- /dev/null
+++ b/modules/lc/xlocale/lcJis.c
@@ -0,0 +1,925 @@
+/* $Xorg: lcJis.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#ifdef X_LOCALE
+
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+#include <stdio.h>
+
+#if !defined(X_NOT_STDC_ENV) && !defined(macII) && !defined(X_LOCALE)
+#define STDCVT
+#endif
+
+typedef struct _StateRec {
+ XLCd lcd;
+ XlcCharSet charset;
+ XlcCharSet GL_charset;
+ XlcCharSet GR_charset;
+} StateRec, *State;
+
+static void
+init_state(conv)
+ XlcConv conv;
+{
+ register State state = (State) conv->state;
+ register XLCdGenericPart *gen = XLC_GENERIC_PART(state->lcd);
+ register CodeSet codeset;
+
+ codeset = gen->initial_state_GL;
+ if (codeset && codeset->charset_list)
+ state->GL_charset = *codeset->charset_list;
+ codeset = gen->initial_state_GR;
+ if (codeset && codeset->charset_list)
+ state->GR_charset = *codeset->charset_list;
+
+ if (state->GL_charset == NULL)
+ if (codeset = *gen->codeset_list)
+ state->GL_charset = *codeset->charset_list;
+}
+
+static int
+compare(src, encoding, length)
+ register char *src;
+ register char *encoding;
+ register int length;
+{
+ char *start = src;
+
+ while (length-- > 0) {
+ if (*src++ != *encoding++)
+ return 0;
+ if (*encoding == '\0')
+ return src - start;
+ }
+
+ return 0;
+}
+
+static int
+mbtocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ register char *src, *dst;
+ unsigned char ch, *mb_parse_table;
+ ParseInfo *parse_list, parse_info;
+ XlcCharSet charset;
+ int length, number, encoding_len = 0;
+ register int i;
+
+ src = *((char **) from);
+ dst = *((char **) to);
+
+ if (mb_parse_table = XLC_GENERIC(lcd, mb_parse_table)) {
+ number = mb_parse_table[(unsigned char) *src];
+ if (number > 0) {
+ parse_list = XLC_GENERIC(lcd, mb_parse_list) + number - 1;
+ for ( ; parse_info = *parse_list; parse_list++) {
+ encoding_len = compare(src, parse_info->encoding, *from_left);
+ if (encoding_len > 0) {
+ switch (parse_info->type) {
+ case E_SS:
+ src += encoding_len;
+ charset = *parse_info->codeset->charset_list;
+ goto found;
+ case E_LSL:
+ case E_LSR:
+ src += encoding_len;
+ charset = *parse_info->codeset->charset_list;
+ if (parse_info->type == E_LSL)
+ state->GL_charset = charset;
+ else
+ state->GR_charset = charset;
+ length = 0;
+ goto end;
+ case E_GL:
+ charset = state->GL_charset;
+ goto found;
+ case E_GR:
+ charset = state->GR_charset;
+ goto found;
+ }
+ }
+ }
+ }
+ }
+
+ if ((*src & 0x80) && state->GR_charset)
+ charset = state->GR_charset;
+ else
+ charset = state->GL_charset;
+
+found:
+ if (charset == NULL ||
+ (num_args == 2 && (XlcCharSet) args[1] != charset))
+ return -1;
+
+ length = charset->char_size;
+ if (length > *from_left - encoding_len)
+ return -1;
+
+ if (dst) {
+ if (length > *to_left)
+ return -1;
+ if (charset->side == XlcGL) {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++ & 0x7f;
+ } else if (charset->side == XlcGR) {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++ | 0x80;
+ } else {
+ for (i = 0; i < length; i++)
+ *dst++ = *src++;
+ }
+ *to = (XPointer) dst;
+ *to_left -= length;
+ }
+end:
+ *from = (XPointer) src;
+ *from_left -= encoding_len + length;
+ state->charset = charset;
+ if (num_args == 1)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return 0;
+}
+
+static int
+mbstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XlcCharSet charset = NULL;
+ XPointer tmp_args[2], save_from = *from;
+ int ret, unconv_num = 0, tmp_num = 1;
+
+ tmp_args[0] = (XPointer) &charset;
+
+ while (*from_left > 0 && *to_left > 0) {
+ ret = mbtocs(conv, from, from_left, to, to_left, tmp_args, tmp_num);
+ if (ret < 0)
+ break;
+ unconv_num += ret;
+ if (tmp_num == 1 && charset) {
+ tmp_args[1] = (XPointer) charset;
+ tmp_num = 2;
+ }
+ }
+
+ if (save_from == *from)
+ return -1;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+static CodeSet
+wc_parse_codeset(lcd, wcstr)
+ XLCd lcd;
+ wchar_t *wcstr;
+{
+ register CodeSet *codeset;
+ unsigned long wc_encoding;
+ register int num;
+
+ wc_encoding = *wcstr & XLC_GENERIC(lcd, wc_encode_mask);
+ num = XLC_GENERIC(lcd, codeset_num);
+ codeset = XLC_GENERIC(lcd, codeset_list);
+ while (num-- > 0) {
+ if (wc_encoding == (*codeset)->wc_encoding)
+ return *codeset;
+ codeset++;
+ }
+
+ return NULL;
+}
+
+static int
+wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ wchar_t *wcptr;
+ register char *bufptr;
+ register wchar_t wch;
+ char *tmpptr;
+ register int length;
+ CodeSet codeset;
+ unsigned long wc_encoding;
+ int wcstr_len, buf_len;
+
+ if (from == NULL || *from == NULL)
+ return 0;
+
+ wcptr = *((wchar_t **) from);
+ bufptr = *((char **) to);
+ wcstr_len = *from_left;
+ buf_len = *to_left;
+
+ codeset = wc_parse_codeset(lcd, wcptr);
+ if (codeset == NULL)
+ return -1;
+ wc_encoding = codeset->wc_encoding;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+ length = codeset->length;
+ buf_len -= length;
+ bufptr += length;
+
+ tmpptr = bufptr - 1;
+ if ((*codeset->charset_list)->side == XlcGL) {
+ while (length--) {
+ *tmpptr-- = (unsigned char) (wch & 0x7f);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ } else if ((*codeset->charset_list)->side == XlcGR) {
+ while (length--) {
+ *tmpptr-- = (unsigned char) (wch | 0x80);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ } else {
+ while (length--) {
+ *tmpptr-- = (unsigned char) wch;
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - *((wchar_t **) from);
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *((char **) to);
+ *to = bufptr;
+
+ return 0;
+}
+
+static CodeSet
+GetCodeSetFromCharSet(lcd, charset)
+ XLCd lcd;
+ XlcCharSet charset;
+{
+ register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ register XlcCharSet *charset_list;
+ register int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+static int
+cstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ register char *csptr;
+ register char *bufptr;
+ int csstr_len;
+ register int buf_len;
+ int num, encoding_len = 0;
+ CodeSet codeset;
+ XlcCharSet charset;
+ EncodingType type;
+ int cvt_length;
+
+ csptr = *((char **) from);
+ bufptr = *((char **) to);
+ csstr_len = *from_left;
+ buf_len = *to_left;
+
+ if (num_args < 1)
+ return -1;
+
+ charset = (XlcCharSet) args[0];
+
+ codeset = GetCodeSetFromCharSet(state->lcd, charset);
+ if (codeset == NULL)
+ return -1;
+
+ cvt_length = 0;
+ if (codeset->parse_info) {
+ switch (type = codeset->parse_info->type) {
+ case E_SS:
+ encoding_len = strlen(codeset->parse_info->encoding);
+ break;
+ case E_LSL:
+ case E_LSR:
+ if (type == E_LSL) {
+ if (charset == state->GL_charset)
+ break;
+ } else {
+ if (charset == state->GR_charset)
+ break;
+ }
+ encoding_len = strlen(codeset->parse_info->encoding);
+ if (encoding_len > buf_len)
+ return -1;
+ cvt_length += encoding_len;
+ if (bufptr) {
+ strcpy(bufptr, codeset->parse_info->encoding);
+ bufptr += encoding_len;
+ }
+ buf_len -= encoding_len;
+ encoding_len = 0;
+ if (type == E_LSL)
+ state->GL_charset = charset;
+ else
+ state->GR_charset = charset;
+ break;
+ }
+ }
+
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length + encoding_len;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * (encoding_len + codeset->length);
+ if (bufptr) {
+ while (buf_len--) {
+ if (encoding_len) {
+ strcpy(bufptr, codeset->parse_info->encoding);
+ bufptr += encoding_len;
+ }
+ num = codeset->length;
+ if (codeset->side == XlcGL) {
+ while (num--)
+ *bufptr++ = *csptr++ & 0x7f;
+ } else if (codeset->side == XlcGR) {
+ while (num--)
+ *bufptr++ = *csptr++ | 0x80;
+ } else {
+ while (num--)
+ *bufptr++ = *csptr++;
+ }
+ }
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ if (bufptr)
+ *to = (XPointer) bufptr;
+ *to_left -= cvt_length;
+
+ return 0;
+}
+
+static int
+cstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XLCd lcd = state->lcd;
+ register char *csptr;
+ wchar_t *bufptr;
+ int csstr_len;
+ register int buf_len;
+ register wchar_t wch;
+ unsigned long code_mask, wc_encoding;
+ int num, length, wc_shift_bits;
+ CodeSet codeset;
+
+ csptr = *((char **) from);
+ bufptr = *((wchar_t **) to);
+ csstr_len = *from_left;
+ buf_len = *to_left;
+
+ if (num_args < 1)
+ return -1;
+
+ codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0]);
+ if (codeset == NULL)
+ return -1;
+
+ length = codeset->length;
+ csstr_len /= length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ code_mask = ~XLC_GENERIC(lcd, wc_encode_mask);
+ wc_encoding = codeset->wc_encoding;
+ wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+
+ *to_left -= buf_len;
+
+ if (bufptr) {
+ while (buf_len--) {
+ wch = (wchar_t) (*csptr++ & 0x7f);
+ num = length - 1;
+ while (num--)
+ wch = (wch << wc_shift_bits) | (*csptr++ & 0x7f);
+
+ *bufptr++ = (wch & code_mask) | wc_encoding;
+ }
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ if (bufptr)
+ *to = (XPointer) bufptr;
+
+ return 0;
+}
+
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ if (conv->state) {
+ Xfree((char *) conv->state);
+ }
+
+ Xfree((char *) conv);
+}
+
+static XlcConv
+create_conv(lcd, methods)
+ XLCd lcd;
+ XlcConvMethods methods;
+{
+ XlcConv conv;
+ State state;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = (XlcConvMethods) Xmalloc(sizeof(XlcConvMethodsRec));
+ if (conv->methods == NULL)
+ goto err;
+ *conv->methods = *methods;
+ if (XLC_PUBLIC(lcd, is_state_depend))
+ conv->methods->reset = init_state;
+
+ conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ if (conv->state == NULL)
+ goto err;
+ bzero((char *) conv->state, sizeof(StateRec));
+
+ state = (State) conv->state;
+ state->lcd = lcd;
+ init_state(conv);
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec mbstocs_methods = {
+ close_converter,
+ mbstocs,
+ NULL
+} ;
+
+static XlcConv
+open_mbstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbstocs_methods);
+}
+
+static XlcConvMethodsRec wcstocs_methods = {
+ close_converter,
+ wcstocs,
+ NULL
+} ;
+
+static XlcConv
+open_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &wcstocs_methods);
+}
+
+static XlcConvMethodsRec mbtocs_methods = {
+ close_converter,
+ mbtocs,
+ NULL
+} ;
+
+static XlcConv
+open_mbtocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &mbtocs_methods);
+}
+
+static XlcConvMethodsRec cstombs_methods = {
+ close_converter,
+ cstombs,
+ NULL
+} ;
+
+static XlcConv
+open_cstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &cstombs_methods);
+}
+
+static XlcConvMethodsRec cstowcs_methods = {
+ close_converter,
+ cstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_cstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &cstowcs_methods);
+}
+
+#ifdef STDCVT
+static int
+stdc_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ char *src = *((char **) from);
+ wchar_t *dst = *((wchar_t **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = mbtowc(dst, src, src_left);
+ if (length < 0)
+ break;
+
+ src += length;
+ src_left -= length;
+ if (dst)
+ dst++;
+ dst_left--;
+
+ if (length == 0) {
+ src++;
+ src_left--;
+ break;
+ }
+ }
+
+ if (*from_left == src_left)
+ return -1;
+
+ *from = (XPointer) src;
+ if (dst)
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return 0;
+}
+
+static int
+stdc_wcstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ wchar_t *src = *((wchar_t **) from);
+ char *dst = *((char **) to);
+ int src_left = *from_left;
+ int dst_left = *to_left;
+ int length;
+
+ while (src_left > 0 && dst_left > 0) {
+ length = wctomb(dst, *src); /* XXX */
+ if (length < 0 || dst_left < length)
+ break;
+
+ src++;
+ src_left--;
+ dst += length;
+ dst_left -= length;
+
+ if (length == 0) {
+ dst++;
+ dst_left--;
+ break;
+ }
+ }
+
+ if (*from_left == src_left)
+ return -1;
+
+ *from = (XPointer) src;
+ *to = (XPointer) dst;
+ *from_left = src_left;
+ *to_left = dst_left;
+
+ return 0;
+}
+
+static int
+stdc_wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ wchar_t wch, *src = *((wchar_t **) from);
+ XlcCharSet charset = NULL;
+ XPointer tmp_args[2], tmp_from, save_from = *from;
+ char tmp[32];
+ int length, ret, src_left = *from_left;
+ int unconv_num = 0, tmp_num = 1;
+
+ tmp_args[0] = (XPointer) &charset;
+
+ while (src_left > 0 && *to_left > 0) {
+ if (wch = *src) {
+ length = wctomb(tmp, wch);
+ } else {
+ length = 1;
+ *tmp = '\0';
+ }
+
+ if (length < 0)
+ break;
+
+ tmp_from = (XPointer) tmp;
+ ret = mbtocs(conv, &tmp_from, &length, to, to_left, tmp_args, tmp_num);
+ if (ret < 0)
+ break;
+ unconv_num += ret;
+ if (tmp_num == 1 && charset) {
+ tmp_args[1] = (XPointer) charset;
+ tmp_num = 2;
+ }
+
+ src++;
+ src_left--;
+ }
+
+ if (save_from == (XPointer) src)
+ return -1;
+
+ *from = (XPointer) src;
+ *from_left = src_left;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char*) Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+static int
+stdc_cstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = ((State) conv->state)->lcd;
+ DefineLocalBuf;
+ XPointer buf, save_buf;
+ int length, left, ret;
+
+ left = length = *to_left * XLC_PUBLIC(lcd, mb_cur_max);
+ buf = save_buf = (XPointer) AllocLocalBuf(length);
+ if (buf == NULL)
+ return -1;
+
+ ret = cstombs(conv, from, from_left, &buf, &left, args, num_args);
+ if (ret < 0)
+ goto err;
+
+ buf = save_buf;
+ length -= left;
+ if (stdc_mbstowcs(conv, &buf, &length, to, to_left, args, num_args) < 0)
+ ret = -1;
+
+err:
+ FreeLocalBuf(save_buf);
+
+ return ret;
+}
+
+static XlcConvMethodsRec stdc_mbstowcs_methods = {
+ close_converter,
+ stdc_mbstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_mbstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_mbstowcs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstombs_methods = {
+ close_converter,
+ stdc_wcstombs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstombs_methods);
+}
+
+static XlcConvMethodsRec stdc_wcstocs_methods = {
+ close_converter,
+ stdc_wcstocs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_wcstocs_methods);
+}
+
+static XlcConvMethodsRec stdc_cstowcs_methods = {
+ close_converter,
+ stdc_cstowcs,
+ NULL
+} ;
+
+static XlcConv
+open_stdc_cstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &stdc_cstowcs_methods);
+}
+#endif /* STDCVT */
+
+XLCd
+_XlcJisLoader(name)
+ char *name;
+{
+ XLCd lcd;
+ XLCdGenericPart *gen;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "JIS7"))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+
+#ifdef STDCVT
+ gen = XLC_GENERIC_PART(lcd);
+
+ if (gen->use_stdc_env == True) {
+ _XlcSetConverter(lcd,XlcNMultiByte,lcd,XlcNWideChar,open_stdc_mbstowcs);
+ _XlcSetConverter(lcd,XlcNWideChar,lcd,XlcNMultiByte,open_stdc_wcstombs);
+ }
+ if (gen->force_convert_to_mb == True) {
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet,open_stdc_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar,open_stdc_cstowcs);
+ } else {
+#endif
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+#ifdef STDCVT
+ }
+#endif
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/modules/lc/xlocale/lcSjis.c b/modules/lc/xlocale/lcSjis.c
new file mode 100644
index 00000000..95d9ed8d
--- /dev/null
+++ b/modules/lc/xlocale/lcSjis.c
@@ -0,0 +1,1569 @@
+/* $Xorg: lcSjis.c,v 1.3 2000/08/17 19:45:19 cpqbld Exp $ */
+/****************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+ Copyright 1993 by Fujitsu Open Systems Solutions, Inc.
+ Copyright 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED,
+Fujitsu Open Systems Solutions, Inc. and Sony Corporation not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+FUJITSU LIMITED, Fujitsu Open Systems Solutions, Inc. and
+Sony Corporation make no representations about the suitability of
+this software for any purpose. It is provided "as is" without
+express or implied warranty.
+
+FUJITSU LIMITED, FUJITSU OPEN SYSTEMS SOLUTIONS, INC. AND SONY
+CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL FUJITSU OPEN SYSTEMS SOLUTIONS, INC., FUJITSU LIMITED
+AND SONY CORPORATION 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.
+
+ Authors: Jeffrey Bloomfield (jeffb@ossi.com)
+ Shigeru Yamada (yamada@ossi.com)
+ Yoshiyuki Segawa (segawa@ossi.com)
+ Modifier:Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+*****************************************************************/
+
+#ifdef X_LOCALE
+
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+#include <ctype.h>
+#ifdef WIN32
+#define isascii __isascii
+#endif
+
+#define CS0 codesets[0] /* Codeset 0 - 7-bit ASCII */
+#define CS1 codesets[1] /* Codeset 1 - Kanji */
+#define CS2 codesets[2] /* Codeset 2 - Half-Kana */
+#define CS3 codesets[3] /* Codeset 3 - User defined */
+
+#define ascii (codeset->cs_num == 0)
+#define kanji (codeset->cs_num == 1)
+#define kana (codeset->cs_num == 2)
+#define userdef (codeset->cs_num == 3)
+
+#define ASCII_CODESET 0
+#define KANJI_CODESET 1
+#define KANA_CODESET 2
+#define USERDEF_CODESET 3
+#define MAX_CODESETS 4
+
+#define GR 0x80 /* begins right-side (non-ascii) region */
+#define GL 0x7f /* ends left-side (ascii) region */
+
+#define isleftside(c) (((c) & GR) ? 0 : 1)
+#define isrightside(c) (!isleftside(c))
+
+typedef unsigned char Uchar;
+typedef unsigned long Ulong;
+typedef unsigned int Uint;
+
+/* Acceptable range for 2nd byte of SJIS multibyte char */
+#define VALID_MULTIBYTE(c) \
+ ((0x40<=((Uchar)c) && ((Uchar)c)<=0x7e) \
+ || (0x80<=((Uchar)c) && ((Uchar)c)<=0xfc))
+
+#ifndef iskanji
+#define iskanji(c) ((0x81<=((Uchar)c) && ((Uchar)c)<=0x9f) \
+ || (0xe0<=((Uchar)c) && ((Uchar)c)<=0xef))
+#endif /* !iskanji */
+
+#ifndef iskana
+#define iskana(c) (0xa1<=((Uchar)c) && ((Uchar)c)<=0xdf)
+#endif /* !iskana */
+
+#define isuserdef(c) (0xf0<=((Uchar)c) && ((Uchar)c)<=0xfc)
+
+#define BIT8OFF(c) ((c) & GL)
+#define BIT8ON(c) ((c) | GR)
+
+
+static void jis_to_sjis();
+static void sjis_to_jis();
+static CodeSet wc_codeset();
+
+
+/*
+ * Notes:
+ * 1. 16-bit widechar format is limited to 14 data bits. Since the 2nd byte
+ * of SJIS multibyte chars are in the ranges of 0x40 - 7E and 0x80 - 0xFC,
+ * SJIS cannot map directly into 16 bit widechar format within the confines
+ * of a single codeset. Therefore, for SJIS widechar conversion, SJIS Kanji
+ * is mapped into the JIS codeset. (The algorithms used in jis_to_sjis()
+ * and sjis_to_jis() are from Ken Lunde (lunde@mv.us.adobe.com) and are in
+ * the public domain.)
+ * 2. Defining FORCE_INDIRECT_CONVERTER (see _XlcEucLoader())
+ * forces indirect (charset) conversions (e.g. wcstocs()<->cstombs()).
+ * 3. Using direct converters (e.g. mbstowcs()) decreases conversion
+ * times by 20-40% (depends on specific converter used).
+ */
+
+
+static int
+sjis_mbstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+
+ XLCd lcd = (XLCd)conv->state;
+
+ register int chr_len = 0;
+ register int shift_mult = 0;
+ register Uint chrcode = 0;
+
+ Uchar ch, ch2;
+ Uint wc_encode = 0;
+ Uint wc_tmp = 0;
+
+ Bool new_char;
+
+ int firstbyte;
+ int length;
+ int num_conv;
+ int unconv_num = 0;
+
+ XPointer inbufptr = *from;
+ wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (new_char = True, firstbyte = True; *from_left > 0; (*from_left)--) {
+
+ ch = *inbufptr++;
+
+ if (firstbyte) {
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ if (isascii(ch)) {
+ length = CS0->length;
+ *outbufptr++ = (wchar_t)ch;
+ continue;
+ }
+ else if (iskanji(ch)) {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ firstbyte = False;
+ length = CS1->length;
+ if (*from_left < length || *to_left < length)
+ return -1;
+ wc_encode = CS1->wc_encoding;
+ ch2 = *inbufptr;
+ sjis_to_jis(&ch, &ch2);
+ chrcode = ch;
+ }
+ else if (iskana(ch)) {
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ length = CS2->length;
+ wc_encode = CS2->wc_encoding;
+ chrcode = BIT8OFF(ch);
+ }
+ else if (isuserdef(ch)) {
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ firstbyte = False;
+ length = CS3->length;
+ if (*from_left < length || *to_left < length)
+ return -1;
+ wc_encode = CS3->wc_encoding;
+ ch2 = *inbufptr;
+ sjis_to_jis(&ch, &ch2);
+ chrcode = ch;
+ }
+ else /* unknown */ {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ } else { /* 2nd byte of multibyte char */
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr-1))) {
+ unconv_num++;
+ firstbyte = True;
+ }
+ chrcode = ch2;
+ }
+
+ if (new_char) {
+ chr_len = length;
+ shift_mult = length - 1;
+ new_char = False;
+ }
+
+ chrcode <<= (wc_shift * shift_mult);
+ shift_mult--;
+ wc_tmp |= chrcode;
+ if (--chr_len == 0) {
+ wc_tmp |= wc_encode;
+ *outbufptr++ = wc_tmp;
+
+ firstbyte = True;
+ new_char = True;
+ wc_tmp = (Uint)0;
+ }
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = outbufptr - outbuf_base) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+
+static int
+sjis_wcstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register wchar_t *inbufptr = (wchar_t *) *from;
+ register XPointer outbufptr = *to;
+ XPointer outbuf_base = outbufptr;
+ wchar_t wch;
+ register int length;
+ Uchar tmp;
+ Uchar t1, t2;
+ int num_conv;
+ int unconv_num = 0;
+
+ XLCd lcd = (XLCd)conv->state;
+ CodeSet codeset;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ do {
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana)
+ tmp = BIT8ON(tmp);
+
+ else if (byte1 && (kanji || userdef)) {
+ t1 = BIT8OFF(tmp);
+ continue;
+ }
+
+ else if (byte2 && (kanji || userdef)) {
+ t2 = BIT8OFF(tmp);
+ jis_to_sjis(&t1, &t2);
+ *outbufptr++ = (char)t1;
+ tmp = t2;
+ }
+
+ *outbufptr++ = (char)tmp;
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+
+/*
+ * sjis<->jis conversion for widechar kanji (See Note at top of file)
+ */
+static void
+sjis_to_jis(p1, p2)
+ Uchar *p1;
+ Uchar *p2;
+{
+ register Uchar c1 = *p1;
+ register Uchar c2 = *p2;
+ register Uchar adjust = c2 < 0x9f;
+ register Uchar rowOffset = c1 < 0xa0 ? 0x70 : 0xb0;
+ register Uchar cellOffset = adjust ? (0x1f + (c2 > 0x7f)) : 0x7e;
+
+ *p1 = ((c1 - rowOffset) << 1) - adjust;
+ *p2 -= cellOffset;
+}
+
+static void
+jis_to_sjis(p1, p2)
+ Uchar *p1;
+ Uchar *p2;
+{
+ register Uchar c1 = *p1;
+ register Uchar c2 = *p2;
+ register Uchar rowOffset = c1 < 0x5f ? 0x70 : 0xb0;
+ register Uchar cellOffset = c1 % 2 ? 0x1f + (c2 > 0x5f) : 0x7e;
+
+ *p1 = ((Uchar)(c1 + 1) >> 1) + rowOffset;
+ *p2 = c2 + cellOffset;
+}
+
+static CodeSet
+wc_codeset(lcd, wch)
+ XLCd lcd;
+ wchar_t wch;
+{
+ register CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+#if !defined(__sony_news) || defined(SVR4)
+ register int end = XLC_GENERIC(lcd, codeset_num);
+ register Ulong widech = (Ulong)(wch & XLC_GENERIC(lcd, wc_encode_mask));
+
+ for (; --end >= 0; codesets++)
+ if ( widech == (*codesets)->wc_encoding )
+ return *codesets;
+
+ return NULL;
+#else
+ if( iskanji(wch >> 8) )
+ return( codesets[1] );
+ if( iskana(wch & 0xff) )
+ return( codesets[2] );
+ return( codesets[0] );
+#endif
+}
+
+
+static int
+sjis_mbtocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ XlcCharSet charset = NULL;
+ int char_size = 0;
+ int unconv_num = 0;
+ register char *src = *from, *dst = *to;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+
+ if (iskanji(*src)) {
+ if (KANJI_CODESET >= codeset_num)
+ return -1;
+ charset = *CS1->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
+ unconv_num++;
+ sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
+ } else
+ return -1;
+ }
+ else if (isuserdef(*src)) {
+ if (USERDEF_CODESET >= codeset_num)
+ return -1;
+ charset = *CS3->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size) {
+ *dst++ = *src++;
+ *dst++ = *src++;
+ if (!VALID_MULTIBYTE((Uchar) *(src-1))) /* check 2nd byte */
+ unconv_num++;
+ sjis_to_jis((Uchar *)(dst-2), (Uchar *)(dst-1));
+ } else
+ return -1;
+ }
+ else if (isascii(*src)) {
+ if (ASCII_CODESET >= codeset_num)
+ return -1;
+ charset = *CS0->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size)
+ *dst++ = *src++;
+ else
+ return -1;
+ }
+ else if (iskana(*src)) {
+ if (KANA_CODESET >= codeset_num)
+ return -1;
+ charset = *CS2->charset_list;
+ char_size = charset->char_size;
+
+ if (*from_left >= char_size && *to_left >= char_size)
+ *dst++ = *src++;
+ else
+ return -1;
+ }
+ else /* unknown */
+ return -1;
+
+ *from_left -= char_size;
+ *to_left -= char_size;
+
+ *to = dst;
+ *from = src;
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+
+static int
+sjis_mbstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ char *tmp_from, *tmp_to;
+ int tmp_from_left, tmp_to_left;
+ XlcCharSet charset, tmp_charset;
+ XPointer tmp_args[1];
+ int unconv_num = 0, ret;
+
+
+
+/* Determine the charset of the segment and convert one character: */
+
+ tmp_args[0] = (XPointer) &charset; /* charset from sjis_mbtocs() */
+ while
+ ((ret = sjis_mbtocs(conv, from, from_left, to, to_left, tmp_args, 1)) > 0)
+ unconv_num += ret;
+ if ( ret < 0 )
+ return ret;
+
+ tmp_from = *from;
+ tmp_from_left = *from_left;
+ tmp_to_left = *to_left;
+ tmp_to = *to;
+
+/* Convert remainder of the segment: */
+
+ tmp_args[0] = (XPointer) &tmp_charset;
+ while( (ret = sjis_mbtocs(conv, &tmp_from, &tmp_from_left, &tmp_to,
+ &tmp_to_left, tmp_args, 1)) >= 0 ) {
+
+ if (ret > 0) {
+ unconv_num += ret;
+ continue;
+ }
+
+ if (tmp_charset != charset) /* quit on end of segment */
+ break;
+
+ *from = tmp_from;
+ *from_left = tmp_from_left;
+ *to = tmp_to;
+ *to_left = tmp_to_left;
+ }
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = charset;
+
+ return unconv_num;
+}
+
+static int
+sjis_wcstocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd) conv->state;
+ wchar_t *wcptr = *((wchar_t **)from);
+ register char *bufptr = *((char **) to);
+ wchar_t wch;
+ char *tmpptr;
+ register int length;
+ CodeSet codeset;
+ Ulong wc_encoding;
+ int buf_len = *to_left;
+ int wcstr_len = *from_left;
+
+
+ if (!(codeset = wc_codeset(lcd, *wcptr)))
+ return -1;
+
+ if (wcstr_len < buf_len / codeset->length)
+ buf_len = wcstr_len * codeset->length;
+
+#if !defined(__sony_news) || defined(SVR4)
+ wc_encoding = codeset->wc_encoding;
+
+ for ( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len--) {
+ wch = *wcptr;
+
+ if ((wch & XLC_GENERIC(lcd, wc_encode_mask)) != wc_encoding)
+ break;
+
+ length = codeset->length;
+
+ buf_len -= length;
+ bufptr += length;
+ tmpptr = bufptr - 1;
+
+ while (length--) {
+ *tmpptr-- = kana ? BIT8ON(wch) : BIT8OFF(wch);
+ wch >>= (wchar_t)XLC_GENERIC(lcd, wc_shift_bits);
+ }
+ }
+#else
+ length = codeset->length;
+ for( ; wcstr_len > 0 && buf_len > 0; wcptr++, wcstr_len-- ) {
+ wch = *wcptr;
+ if( codeset != wc_codeset( lcd, wch ) )
+ break;
+
+ buf_len -= length;
+ if( length == 2 ) {
+ unsigned short code;
+
+ code = sjis2jis( wch & 0xffff );
+ *bufptr++ = code >> 8;
+ *bufptr++ = code & 0xff;
+ }
+ else
+ *bufptr++ = wch & 0xff;
+ }
+#endif
+
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = *codeset->charset_list;
+
+ *from_left -= wcptr - (wchar_t *) *from;
+ *from = (XPointer) wcptr;
+
+ *to_left -= bufptr - *to;
+ *to = bufptr;
+
+ return 0;
+}
+
+static CodeSet
+GetCodeSetFromCharSet(lcd, charset)
+ XLCd lcd;
+ XlcCharSet charset;
+{
+ register CodeSet *codeset = XLC_GENERIC(lcd, codeset_list);
+ register XlcCharSet *charset_list;
+ register int codeset_num, num_charsets;
+
+ codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+ for ( ; codeset_num-- > 0; codeset++) {
+ num_charsets = (*codeset)->num_charsets;
+ charset_list = (*codeset)->charset_list;
+
+ for ( ; num_charsets-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return *codeset;
+ }
+
+ return (CodeSet) NULL;
+}
+
+
+static int
+sjis_cstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ char **from;
+ int *from_left;
+ char **to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd) conv->state;
+ register char *csptr = *from;
+ register char *bufptr = *to;
+ int csstr_len = *from_left;
+ register int buf_len = *to_left;
+ int length;
+ CodeSet codeset;
+ EncodingType type;
+ int cvt_length = 0;
+
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ buf_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ cvt_length += buf_len * codeset->length;
+
+ if (bufptr) {
+ while (buf_len--) {
+ length = codeset->length;
+ while (length--)
+ *bufptr++ = codeset->length == 1 && codeset->side == XlcGR ?
+ BIT8ON(*csptr++) : BIT8OFF(*csptr++);
+
+ if (codeset->length == 2)
+ jis_to_sjis((Uchar *)(bufptr-2), (Uchar *)(bufptr-1));
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = csptr;
+
+ if (bufptr)
+ *to += cvt_length;
+ *to_left -= cvt_length;
+
+
+ return 0;
+}
+
+static int
+sjis_cstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd) conv->state;
+ register char *csptr = (char *) *from;
+ wchar_t *bufptr = (wchar_t *) *to;
+ wchar_t *toptr = (wchar_t *) *to;
+ int csstr_len = *from_left;
+ register int buf_len = *to_left;
+ wchar_t wch;
+ int length;
+ Ulong wc_shift_bits = (int)XLC_GENERIC(lcd, wc_shift_bits);
+ CodeSet codeset;
+
+
+ if (num_args < 1)
+ return -1;
+
+ if (!(codeset = GetCodeSetFromCharSet(lcd, (XlcCharSet) args[0])))
+ return -1;
+
+ csstr_len /= codeset->length;
+ if (csstr_len < buf_len)
+ buf_len = csstr_len;
+
+ *to_left -= buf_len;
+
+ if (bufptr) {
+
+ toptr += buf_len;
+ *to = (XPointer) toptr;
+
+ while (buf_len--) {
+ wch = (wchar_t) BIT8OFF(*csptr);
+ csptr++;
+
+ length = codeset->length - 1;
+ while (length--) {
+ wch = (wch << wc_shift_bits) | BIT8OFF(*csptr);
+ csptr++;
+ }
+ *bufptr++ = wch | codeset->wc_encoding;
+ }
+ }
+
+ *from_left -= csptr - *from;
+ *from = csptr;
+
+ return 0;
+}
+
+
+/*
+ * Stripped down Direct CT converters for SJIS
+ *
+ */
+
+#define BADCHAR(min_ch, c) (BIT8OFF(c) < (char)min_ch && BIT8OFF(c) != 0x0 && \
+ BIT8OFF(c) != '\t' && BIT8OFF(c) != '\n' && \
+ BIT8OFF(c) != 0x1b)
+
+typedef struct _CTDataRec {
+ int side;
+ int length;
+ char *name;
+ Ulong wc_encoding;
+ char *ct_encoding;
+ int ct_encoding_len;
+ int set_size;
+ Uchar min_ch;
+ Uchar ct_type;
+} CTDataRec, *CTData;
+
+typedef struct _StateRec {
+ CTData GL_charset;
+ CTData GR_charset;
+ CTData charset;
+} StateRec, *State;
+
+#define CT_STD 0
+#define CT_NSTD 1
+#define CT_DIR 2
+#define CT_EXT0 3
+#define CT_EXT1 4
+#define CT_EXT2 5
+#define CT_VER 6
+
+static CTDataRec ctdata[] =
+{
+ { XlcGL, 1, "ISO8859-1:GL", 0, "\033(B" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "ISO8859-1:GR", 0, "\033-A" , 3, 0, 0, CT_STD },
+ { XlcGL, 1, "JISX0201.1976-0:GL", 0, "\033(J" , 3, 0, 0, CT_STD },
+ { XlcGR, 1, "JISX0201.1976-0:GR", 0, "\033)I" , 3, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0208.1983-0:GL", 0, "\033$(B" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0208.1983-0:GR", 0, "\033$)B" , 4, 0, 0, CT_STD },
+ { XlcGL, 2, "JISX0212.1990-0:GL", 0, "\033$(D" , 4, 0, 0, CT_STD },
+ { XlcGR, 2, "JISX0212.1990-0:GR", 0, "\033$)D" , 4, 0, 0, CT_STD },
+ { XlcUnknown, 0, "Ignore-Ext-Status?", 0, "\033#" , 2, 0, 0, CT_VER },
+ { XlcUnknown, 0, "NonStd-?-OctetChar", 0, "\033%/0" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 1, "NonStd-1-OctetChar", 0, "\033%/1" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 2, "NonStd-2-OctetChar", 0, "\033%/2" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 3, "NonStd-3-OctetChar", 0, "\033%/3" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 4, "NonStd-4-OctetChar", 0, "\033%/4" , 4, 0, 0, CT_NSTD },
+ { XlcUnknown, 0, "Extension-2" , 0, "\033%/" , 3, 0, 0, CT_EXT2 },
+ { XlcUnknown, 0, "Extension-0" , 0, "\033" , 1, 0, 0, CT_EXT0 },
+ { XlcUnknown, 0, "Begin-L-to-R-Text", 0, "\2331]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Begin-R-to-L-Text", 0, "\2332]" , 3, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "End-Of-String", 0, "\233]" , 2, 0, 0, CT_DIR },
+ { XlcUnknown, 0, "Extension-1" , 0, "\233" , 1, 0, 0, CT_EXT1 },
+};
+
+/* Note on above table: sjis_ctstombs() and sjis_ctstowcs() parser depends on
+ * certain table entries occuring in decreasing string length--
+ * 1. CT_EXT2 and CT_EXT0 entries must occur after CT_NSTD entries.
+ * 2. CT_DIR and CT_EXT1 entries must occur after CT_DIR entries.
+ */
+
+static CTData ctdptr[sizeof(ctdata) / sizeof(CTDataRec)];
+static CTData ctd_endp = ctdata + ((sizeof(ctdata) / sizeof(CTDataRec))) - 1;
+
+#define Ascii 0
+#define Kanji 1
+#define Kana 2
+#define Userdef 3
+
+/*
+ * initCTptr(): Set ctptr[] to point at ctdata[], indexed by codeset_num.
+ */
+static void
+initCTptr(lcd)
+ XLCd lcd;
+{
+ int num_codesets = XLC_GENERIC(lcd, codeset_num);
+ int num_charsets;
+ int i, j;
+ CodeSet *codesets = XLC_GENERIC(lcd, codeset_list);
+ CodeSet codeset;
+ XlcCharSet charset;
+ CTData ctdp = ctdata;
+
+ ctdptr[Ascii] = &ctdata[0]; /* failsafe */
+
+ for (i = 0; i < num_codesets; i++) {
+
+ codeset = codesets[i];
+ num_charsets = codeset->num_charsets;
+
+ for (j = 0; j < num_charsets; j++) {
+
+ charset = codeset->charset_list[j];
+
+ for (ctdp = ctdata; ctdp <= ctd_endp; ctdp++)
+
+ if (! strcmp(ctdp->name, charset->name)) {
+
+ ctdptr[codeset->cs_num] = ctdp;
+
+ ctdptr[codeset->cs_num]->wc_encoding = codeset->wc_encoding;
+
+ ctdptr[codeset->cs_num]->set_size =
+ charset->set_size;
+
+ ctdptr[codeset->cs_num]->min_ch =
+ charset->set_size == 94 &&
+ (ctdptr[codeset->cs_num]->length > 1 ||
+ ctdptr[codeset->cs_num]->side == XlcGR) ? 0x21 : 0x20;
+
+ break;
+ }
+ }
+ }
+}
+
+
+static int
+sjis_mbstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register int ct_len = *to_left;
+ int cs_num;
+ int clen;
+ int unconv_num = 0;
+ int num_conv;
+ XPointer inbufptr = *from;
+ register char *ctptr = *to;
+ XPointer ct_base = ctptr;
+
+ StateRec ct_state;
+ CTData charset;
+ XLCd lcd = (XLCd) conv->state;
+ int codeset_num = XLC_GENERIC(lcd, codeset_num);
+
+
+/* Initial State: */
+
+ ct_state.GL_charset = ctdptr[Ascii];
+ ct_state.GR_charset = NULL;
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (;*from_left > 0; (*from_left) -= charset->length) {
+
+ if (iskanji(*inbufptr)) {
+ if (KANJI_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kanji;
+ charset = ctdptr[Kanji];
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
+ unconv_num++;
+ }
+ else if (isuserdef(*inbufptr)) {
+ if (USERDEF_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Userdef;
+ charset = ctdptr[Userdef];
+ if (!VALID_MULTIBYTE((Uchar) *(inbufptr+1)))
+ unconv_num++;
+ }
+ else if (isascii(*inbufptr)) {
+ if (ASCII_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Ascii;
+ charset = ctdptr[Ascii];
+ }
+ else if (iskana(*inbufptr)) {
+ if (KANA_CODESET >= codeset_num) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+ cs_num = Kana;
+ charset = ctdptr[Kana];
+ }
+ else { /* unknown */
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[cs_num]->ct_encoding);
+ ctptr += ctdptr[cs_num]->ct_encoding_len;
+ }
+ }
+
+ clen = charset->length;
+ do {
+ *ctptr++ = *inbufptr++;
+ } while (--clen);
+
+ if (charset->length >= 2) {
+ sjis_to_jis((Uchar *)(ctptr-2), (Uchar *)(ctptr-1));
+ if (BADCHAR(charset->min_ch, *(ctptr-2)) ||
+ BADCHAR(charset->min_ch, *(ctptr-1))) {
+ unconv_num++;
+ continue;
+ }
+ }
+ else
+ if (BADCHAR(charset->min_ch, *(ctptr-1))) {
+ unconv_num++;
+ continue;
+ }
+
+ if (charset->side == XlcGR)
+ ct_state.GR_charset = charset;
+ else if (charset->side == XlcGL)
+ ct_state.GL_charset = charset;
+ }
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+
+}
+
+
+#define byte1 (length == codeset->length - 1)
+#define byte2 (byte1 == 0)
+
+static int
+sjis_wcstocts(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register int ct_len = *to_left;
+ register wchar_t *inbufptr = (wchar_t *) *from;
+ register char *ctptr = *to;
+ XPointer ct_base = ctptr;
+ wchar_t wch;
+ register int length;
+ Uchar tmp;
+ Uchar t1 = 0;
+ int num_conv;
+
+ StateRec ct_state;
+ XLCd lcd = (XLCd)conv->state;
+ CTData charset;
+ CodeSet codeset;
+ int unconv_num = 0;
+ Ulong wc_shift = XLC_GENERIC(lcd, wc_shift_bits);
+
+/* Initial State: */
+ ct_state.GL_charset = ctdptr[0]; /* Codeset 0 */
+ ct_state.GR_charset = NULL;
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (; *from_left > 0 ; (*from_left)-- ) {
+
+ wch = *inbufptr++;
+
+ if (!(codeset = wc_codeset(lcd, wch))) {
+ unconv_num++;
+ (*from_left)--;
+ continue;
+ }
+
+ charset = ctdptr[codeset->cs_num];
+
+ length = codeset->length;
+ wch ^= (wchar_t)codeset->wc_encoding;
+
+ if ( (charset->side == XlcGR && charset != ct_state.GR_charset) ||
+ (charset->side == XlcGL && charset != ct_state.GL_charset) ) {
+
+ ct_len -= ctdptr[codeset->cs_num]->ct_encoding_len;
+ if (ct_len < 0) {
+ unconv_num++;
+ break;
+ }
+
+ if (ctptr) {
+ strcpy(ctptr, ctdptr[codeset->cs_num]->ct_encoding);
+ ctptr += ctdptr[codeset->cs_num]->ct_encoding_len;
+ }
+
+ }
+
+ if (charset->side == XlcGR)
+ ct_state.GR_charset = charset;
+ else if (charset->side == XlcGL)
+ ct_state.GL_charset = charset;
+
+ do {
+ length--;
+ tmp = wch>>(wchar_t)( (Ulong)length * wc_shift);
+
+ if (kana) {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)BIT8ON(tmp);
+ }
+
+ else if (byte1 && (kanji || userdef)) {
+ t1 = tmp;
+ }
+
+ else if (byte2 && (kanji || userdef)) {
+ if (BADCHAR(charset->min_ch, (char)t1) ||
+ BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+
+ *ctptr++ = (char)BIT8OFF(t1);
+ *ctptr++ = (char)BIT8OFF(tmp);
+ }
+
+ else {
+ if (BADCHAR(charset->min_ch, (char)tmp)) {
+ unconv_num++;
+ break;
+ }
+ *ctptr++ = (char)tmp;
+ }
+ } while (length);
+
+ } /* end for */
+
+ *to = (XPointer)ctptr;
+
+ if ((num_conv = (int)(ctptr - ct_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+#undef byte1
+#undef byte2
+
+#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
+#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
+
+static int
+sjis_ctstombs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register XPointer inbufptr = *from;
+ register XPointer outbufptr = *to;
+ XPointer inbuf_base;
+ XPointer outbuf_base = outbufptr;
+ register int clen, length;
+ int unconv_num = 0;
+ int num_conv;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type;
+ CTData ctdp = ctdata; /* default */
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (length = ctdata[Ascii].length; *from_left > 0 ; (*from_left) -= length)
+ {
+ ct_type = CT_STD;
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if( ctdp->length ) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following code insures that non-standard encodings, direction, extension,
+ * and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ (*from_left) -= 2;
+ continue;
+ }
+
+ if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
+ clen = length;
+ } else {
+ clen = 1;
+ *from_left += length - clen;
+ }
+ do {
+ Uchar mask = (length == 2) ? GL : -1;
+ *outbufptr++ = *inbufptr++ & mask;
+ } while (--clen);
+
+ if (length >= 2)
+ jis_to_sjis((Uchar *)(outbufptr-2), (Uchar *)(outbufptr-1));
+ }
+
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv;
+
+ return unconv_num;
+}
+
+
+static int
+sjis_ctstowcs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XLCd lcd = (XLCd)conv->state;
+ Ulong wc_shift_bits = XLC_GENERIC(lcd, wc_shift_bits);
+ register XPointer inbufptr = *from;
+ XPointer inbuf_base;
+ register wchar_t *outbufptr = (wchar_t *) *to;
+ wchar_t *outbuf_base = outbufptr;
+ register int clen, length;
+ int num_conv;
+ int unconv_num = 0;
+ unsigned int ct_seglen = 0;
+ Uchar ct_type = 0;
+ register int shift_mult;
+ wchar_t wc_tmp;
+ wchar_t wch;
+ Ulong wc_encoding;
+ CTData ctdp = ctdata;
+
+
+ if (*from_left > *to_left)
+ *from_left = *to_left;
+
+ for (length = ctdata[Ascii].length; *from_left > 0; (*from_left) -= length )
+ {
+ ct_type = CT_STD;
+ if (*inbufptr == '\033' || *inbufptr == (char)'\233') {
+ for (ctdp = ctdata; ctdp <= ctd_endp ; ctdp++) {
+
+ if(!strncmp(inbufptr, ctdp->ct_encoding, ctdp->ct_encoding_len))
+ {
+ inbufptr += ctdp->ct_encoding_len;
+ (*from_left) -= ctdp->ct_encoding_len;
+ if( ctdp->length ) {
+ length = ctdp->length;
+ if( *from_left < length ) {
+ *to = (XPointer)outbufptr;
+ *to_left -= outbufptr - outbuf_base;
+ return( unconv_num + *from_left );
+ }
+ }
+ ct_type = ctdp->ct_type;
+ break;
+ }
+ }
+ if (ctdp > ctd_endp) /* failed to match CT sequence */
+ unconv_num++;
+ }
+
+/* The following block of code insures that non-standard encodings, direction,
+ * extension, and version strings are ignored; subject to change in future.
+ */
+ switch (ct_type) {
+ case CT_STD:
+ break;
+ case CT_EXT2:
+ inbufptr++;
+ (*from_left)--;
+ case CT_NSTD:
+ ct_seglen = (BIT8OFF(*inbufptr) << 7) + BIT8OFF(*(inbufptr+1)) + 2;
+ inbufptr += ct_seglen;
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT0:
+ inbuf_base = inbufptr;
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_EXT1:
+ inbuf_base = inbufptr;
+ SKIP_P(inbufptr);
+ SKIP_I(inbufptr);
+ inbufptr++;
+ ct_seglen = (unsigned)(inbufptr - inbuf_base);
+ (*from_left) -= ct_seglen;
+ continue;
+ case CT_DIR:
+ continue;
+ case CT_VER:
+ inbufptr += 2;
+ (*from_left) -= 2;
+ continue;
+ }
+#if !defined(__sony_news) || defined(SVR4)
+ if (ctdp->side == XlcGL || isrightside (*inbufptr)) {
+ clen = length;
+ wc_encoding = ctdp->wc_encoding;
+ } else {
+ clen = 1;
+ *from_left += length - clen;
+ wc_encoding = ctdptr[Ascii]->wc_encoding;
+ }
+ shift_mult = clen - 1;
+ wch = (wchar_t)0;
+
+ do {
+ wc_tmp = BIT8OFF(*inbufptr++) << (wc_shift_bits * shift_mult);
+ wch |= wc_tmp;
+ shift_mult--;
+ } while (--clen);
+ *outbufptr++ = wch | wc_encoding;
+#else
+ if( length == 1 )
+ *outbufptr++ = (unsigned char)*inbufptr++;
+ else if( length == 2 ) {
+ unsigned short code;
+ code = (*inbufptr << 8) | *(inbufptr+1);
+ *outbufptr++ = jis2sjis( code );
+ inbufptr += 2;
+ }
+#endif
+ }
+ *to = (XPointer)outbufptr;
+
+ if ((num_conv = (int)(outbufptr - outbuf_base)) > 0)
+ (*to_left) -= num_conv ;
+
+ return unconv_num;
+
+}
+#undef BADCHAR
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ Xfree((char *) conv);
+}
+
+
+static XlcConv
+create_conv(lcd, methods)
+ XLCd lcd;
+ XlcConvMethods methods;
+{
+ XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->methods = methods;
+ conv->state = (XPointer) lcd;
+ return conv;
+}
+
+
+enum { MBSTOCS, WCSTOCS, MBTOCS, CSTOMBS, CSTOWCS, MBSTOWCS, WCSTOMBS,
+ WCSTOCTS, MBSTOCTS, CTSTOMBS, CTSTOWCS };
+
+static XlcConvMethodsRec conv_methods[] = {
+ {close_converter, sjis_mbstocs, NULL },
+ {close_converter, sjis_wcstocs, NULL },
+ {close_converter, sjis_mbtocs, NULL },
+ {close_converter, sjis_cstombs, NULL },
+ {close_converter, sjis_cstowcs, NULL },
+ {close_converter, sjis_mbstowcs, NULL },
+ {close_converter, sjis_wcstombs, NULL },
+ {close_converter, sjis_wcstocts, NULL },
+ {close_converter, sjis_mbstocts, NULL },
+ {close_converter, sjis_ctstombs, NULL },
+ {close_converter, sjis_ctstowcs, NULL },
+};
+
+
+static XlcConv
+open_mbstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCS]);
+}
+
+static XlcConv
+open_wcstocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCS]);
+}
+
+static XlcConv
+open_mbtocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBTOCS]);
+}
+
+static XlcConv
+open_cstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CSTOMBS]);
+}
+
+static XlcConv
+open_cstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CSTOWCS]);
+}
+
+static XlcConv
+open_mbstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOWCS]);
+}
+
+static XlcConv
+open_wcstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOMBS]);
+}
+
+static XlcConv
+open_wcstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[WCSTOCTS]);
+}
+
+static XlcConv
+open_mbstocts(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[MBSTOCTS]);
+}
+
+static XlcConv
+open_ctstombs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOMBS]);
+}
+
+static XlcConv
+open_ctstowcs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(from_lcd, &conv_methods[CTSTOWCS]);
+}
+
+XLCd
+_XlcSjisLoader(name)
+ char *name;
+{
+ XLCd lcd;
+
+ lcd = _XlcCreateLC(name, _XlcGenericMethods);
+ if (lcd == NULL)
+ return lcd;
+
+ if (!XLC_PUBLIC_PART(lcd)->codeset ||
+ (_XlcCompareISOLatin1(XLC_PUBLIC_PART(lcd)->codeset, "SJIS"))) {
+ _XlcDestroyLC(lcd);
+ return (XLCd) NULL;
+ }
+
+ initCTptr(lcd);
+
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet, open_mbstocs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCharSet, open_wcstocs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNMultiByte, open_cstombs);
+ _XlcSetConverter(lcd, XlcNCharSet, lcd, XlcNWideChar, open_cstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNChar, open_mbtocs);
+
+#ifndef FORCE_INDIRECT_CONVERTER
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte, open_ctstombs);
+ _XlcSetConverter(lcd, XlcNCompoundText, lcd, XlcNWideChar, open_ctstowcs);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNCompoundText, open_mbstocts);
+ _XlcSetConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar, open_mbstowcs);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNCompoundText, open_wcstocts);
+ _XlcSetConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte, open_wcstombs);
+#endif
+
+
+ return lcd;
+}
+
+#else
+typedef int dummy;
+#endif /* X_LOCALE */
diff --git a/modules/om/generic/omDefault.c b/modules/om/generic/omDefault.c
new file mode 100644
index 00000000..5d913464
--- /dev/null
+++ b/modules/om/generic/omDefault.c
@@ -0,0 +1,406 @@
+/* $Xorg: omDefault.c,v 1.3 2000/08/17 19:45:21 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+static Bool
+wcs_to_mbs(oc, to, from, length)
+ XOC oc;
+ char *to;
+ wchar_t *from;
+ int length;
+{
+ XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
+ XLCd lcd;
+ int ret, to_left = length;
+
+ if (conv == NULL) {
+ lcd = oc->core.om->core.lcd;
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return False;
+ XOC_GENERIC(oc)->wcs_to_cs = conv;
+ } else
+ _XlcResetConverter(conv);
+
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+#else
+_XmbDefaultTextEscapement(oc, text, length)
+ XOC oc;
+ char *text;
+ int length;
+#endif
+{
+ return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultTextEscapement(oc, text, length)
+ XOC oc;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XmbDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ int direction, logical_ascent, logical_descent;
+ XCharStruct overall;
+
+ XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
+ &logical_ascent, &logical_descent, &overall);
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XwcDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XmbDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+ XCharStruct *def, *cs, overall;
+ Bool first = True;
+
+ if (buf_size < length)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ *num_chars = 0;
+
+ CI_GET_DEFAULT_INFO_1D(font, def)
+
+ while (length-- > 0) {
+ CI_GET_CHAR_INFO_1D(font, *text, def, cs)
+ text++;
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing, overall.width +
+ cs->lbearing);
+ overall.rbearing = max(overall.rbearing, overall.width +
+ cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(font->ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = font->ascent + font->descent;
+ }
+
+ return 1;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XwcDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+#else
+_XmbDefaultDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+
+ XSetFont(dpy, gc, font->fid);
+ XDrawString(dpy, d, gc, x, y, text, length);
+
+ return XTextWidth(font, text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+void
+#if NeedFunctionPrototypes
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+#else
+_XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
+ XDrawImageString(dpy, d, gc, x, y, text, length);
+}
+
+void
+#if NeedFunctionPrototypes
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
diff --git a/modules/om/generic/omGeneric.c b/modules/om/generic/omGeneric.c
new file mode 100644
index 00000000..a4fdb02f
--- /dev/null
+++ b/modules/om/generic/omGeneric.c
@@ -0,0 +1,2178 @@
+/* $Xorg: omGeneric.c,v 1.6 2000/08/17 19:45:21 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/*
+ * Fixed the algorithms in parse_fontname() and parse_fontdata()
+ * to improve the logic for determining which font should be
+ * returned for a given CharSet. We even added some comments
+ * so that you can figure out what in the heck we're doing. We
+ * realize this is a departure from the norm, but hey, we're
+ * rebels! :-) :-)
+ *
+ * Modifiers: Jeff Walls, Paul Anderson: HEWLETT-PACKARD
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+#include <string.h>
+#include <ctype.h>
+
+#define MAXFONTS 100
+#define PIXEL_SIZE_FIELD 7
+#define POINT_SIZE_FIELD 8
+#define CHARSET_ENCODING_FIELD 14
+
+extern int _XmbDefaultTextEscapement(), _XwcDefaultTextEscapement();
+extern int _XmbDefaultTextExtents(), _XwcDefaultTextExtents();
+extern Status _XmbDefaultTextPerCharExtents(), _XwcDefaultTextPerCharExtents();
+extern int _XmbDefaultDrawString(), _XwcDefaultDrawString();
+extern void _XmbDefaultDrawImageString(), _XwcDefaultDrawImageString();
+
+extern int _XmbGenericTextEscapement(), _XwcGenericTextEscapement();
+extern int _XmbGenericTextExtents(), _XwcGenericTextExtents();
+extern Status _XmbGenericTextPerCharExtents(), _XwcGenericTextPerCharExtents();
+extern int _XmbGenericDrawString(), _XwcGenericDrawString();
+extern void _XmbGenericDrawImageString(), _XwcGenericDrawImageString();
+
+extern void _XlcDbg_printValue();
+
+/* For VW/UDC start */
+
+static FontData
+init_fontdata(font_data, font_data_count)
+ FontData font_data;
+ int font_data_count;
+{
+ FontData fd;
+ int i;
+
+ fd = (FontData)Xmalloc(sizeof(FontDataRec) * font_data_count);
+ if(fd == (FontData) NULL)
+ return False;
+
+ memset(fd, 0x00, sizeof(FontData) * font_data_count);
+ for(i = 0 ; i < font_data_count ; i++)
+ fd[i] = font_data[i];
+
+ return fd;
+}
+
+static VRotate
+init_vrotate(font_data, font_data_count, type, code_range, code_range_num)
+ FontData font_data;
+ int font_data_count;
+ int type;
+ CodeRange code_range;
+ int code_range_num;
+{
+ VRotate vrotate;
+ int i;
+
+ if(type == VROTATE_NONE)
+ return (VRotate)NULL;
+
+ vrotate = (VRotate)Xmalloc(sizeof(VRotateRec) * font_data_count);
+ if(vrotate == (VRotate) NULL)
+ return False;
+
+ memset(vrotate, 0x00, sizeof(VRotateRec) * font_data_count);
+ for(i = 0 ; i < font_data_count ; i++) {
+ vrotate[i].charset_name = font_data[i].name;
+ vrotate[i].side = font_data[i].side;
+ if(type == VROTATE_PART) {
+ vrotate[i].num_cr = code_range_num;
+ vrotate[i].code_range = code_range;
+ }
+ }
+
+ return vrotate;
+}
+
+static Bool
+init_fontset(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen;
+ FontSet font_set;
+ OMData data;
+ int count;
+
+ count = XOM_GENERIC(oc->core.om)->data_num;
+ data = XOM_GENERIC(oc->core.om)->data;
+
+ font_set = (FontSet) Xmalloc(sizeof(FontSetRec) * count);
+ if (font_set == NULL)
+ return False;
+ memset((char *) font_set, 0x00, sizeof(FontSetRec) * count);
+
+ gen = XOC_GENERIC(oc);
+ gen->font_set_num = count;
+ gen->font_set = font_set;
+
+ for ( ; count-- > 0; data++, font_set++) {
+ font_set->charset_count = data->charset_count;
+ font_set->charset_list = data->charset_list;
+
+ if((font_set->font_data = init_fontdata(data->font_data,
+ data->font_data_count)) == NULL)
+ goto err;
+ font_set->font_data_count = data->font_data_count;
+ if((font_set->substitute = init_fontdata(data->substitute,
+ data->substitute_num)) == NULL)
+ goto err;
+ font_set->substitute_num = data->substitute_num;
+ if((font_set->vmap = init_fontdata(data->vmap,
+ data->vmap_num)) == NULL)
+ goto err;
+ font_set->vmap_num = data->vmap_num;
+
+ if(data->vrotate_type != VROTATE_NONE) {
+ /* A vrotate member is specified primary font data */
+ /* as initial value. */
+ if((font_set->vrotate = init_vrotate(data->font_data,
+ data->font_data_count,
+ data->vrotate_type,
+ data->vrotate,
+ data->vrotate_num)) == NULL)
+ goto err;
+ font_set->vrotate_num = data->font_data_count;
+ }
+ }
+ return True;
+
+err:
+ if(font_set->font_data)
+ Xfree(font_set->font_data);
+ if(font_set->substitute)
+ Xfree(font_set->substitute);
+ if(font_set->vmap)
+ Xfree(font_set->vmap);
+ if(font_set->vrotate)
+ Xfree(font_set->vrotate);
+ if(font_set)
+ Xfree(font_set);
+ gen->font_set = (FontSet) NULL;
+ gen->font_set_num = 0;
+ return False;
+}
+
+/* For VW/UDC end */
+
+static char *
+get_prop_name(dpy, fs)
+ Display *dpy;
+ XFontStruct *fs;
+{
+ unsigned long fp;
+
+ if (XGetFontProperty(fs, XA_FONT, &fp))
+ return XGetAtomName(dpy, fp);
+
+ return (char *) NULL;
+}
+
+/* For VW/UDC start */
+
+static Bool
+load_fontdata(oc, font_data, font_data_num)
+ XOC oc;
+ FontData font_data;
+ int font_data_num;
+{
+ Display *dpy = oc->core.om->core.display;
+ FontData fd = font_data;
+
+ if(font_data == NULL) return(True);
+ for( ; font_data_num-- ; fd++) {
+ if(fd->xlfd_name != (char *) NULL && fd->font == NULL) {
+ fd->font = XLoadQueryFont(dpy, fd->xlfd_name);
+ if (fd->font == NULL){
+ return False;
+ }
+ }
+ }
+ return True;
+}
+
+static Bool
+load_fontset_data(oc, font_set)
+ XOC oc;
+ FontSet font_set;
+{
+ Display *dpy = oc->core.om->core.display;
+
+ if(font_set->font_name == (char *)NULL) return False ;
+
+ /* If font_set->font is not NULL, it contains the *best*
+ * match font for this FontSet.
+ * -- jjw/pma (HP)
+ */
+ if(font_set->font == NULL) {
+ font_set->font = XLoadQueryFont(dpy, font_set->font_name);
+ if (font_set->font == NULL){
+ return False;
+ }
+ }
+ return True;
+}
+
+static Bool
+load_font(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ int num = gen->font_set_num;
+
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ if (load_fontset_data (oc, font_set) != True)
+ return False;
+
+ if(load_fontdata(oc, font_set->font_data,
+ font_set->font_data_count) != True)
+ return False;
+
+ if(load_fontdata(oc, font_set->substitute,
+ font_set->substitute_num) != True)
+ return False;
+
+#if 0
+ /* ### This code is no longer needed. This block essentially
+ * ### took the font used for this FontSet and figured out
+ * ### which font structure to use. This is now accomplished
+ * ### via load_fontset_data(), which takes the *best* font
+ * ### for this FontSet and performs an XLoadQueryFont() to
+ * ### obtain the font structure. Note that this should work
+ * ### for either Primary or Substitute fonts.
+ * ### -- jjw/pma (HP)
+ */
+ if(font_set->font_data_count > 0 && font_set->font_data->font ) {
+ for (i=0; i<font_set->font_data_count; i++)
+ {
+ if (!strcmp (font_set->font_data[i].xlfd_name,
+ font_set->font_name))
+ {
+ font_set->font = font_set->font_data[i].font;
+ break;
+ }
+ }
+ } else if(font_set->substitute_num > 0 ) {
+ for(i=0;i<font_set->substitute_num;i++){
+ if(font_set->substitute[i].font != NULL){
+ font_set->font = font_set->substitute[i].font;
+ break ;
+ }
+ }
+ }
+#endif
+
+/* Add 1996.05.20 */
+ if( oc->core.orientation == XOMOrientation_TTB_RTL ||
+ oc->core.orientation == XOMOrientation_TTB_LTR ){
+ if (font_set->vpart_initialize == 0) {
+ load_fontdata(oc, font_set->vmap, font_set->vmap_num);
+ load_fontdata(oc, (FontData) font_set->vrotate,
+ font_set->vrotate_num);
+ font_set->vpart_initialize = 1;
+ }
+ }
+
+ if (font_set->font->min_byte1 || font_set->font->max_byte1)
+ font_set->is_xchar2b = True;
+ else
+ font_set->is_xchar2b = False;
+ }
+
+ return True;
+}
+
+/* For VW/UDC end */
+
+static Bool
+load_font_info(oc)
+ XOC oc;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char **fn_list;
+ int fn_num, num = gen->font_set_num;
+
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ if (font_set->info == NULL) {
+ fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
+ &font_set->info);
+ if (font_set->info == NULL)
+ return False;
+
+ XFreeFontNames(fn_list);
+ }
+ }
+
+ return True;
+}
+
+/* For Vertical Writing start */
+
+static void
+check_fontset_extents(overall, logical_ascent, logical_descent, font)
+ XCharStruct *overall;
+ int *logical_ascent, *logical_descent;
+ XFontStruct *font;
+{
+ overall->lbearing = min(overall->lbearing, font->min_bounds.lbearing);
+ overall->rbearing = max(overall->rbearing, font->max_bounds.rbearing);
+ overall->ascent = max(overall->ascent, font->max_bounds.ascent);
+ overall->descent = max(overall->descent, font->max_bounds.descent);
+ overall->width = max(overall->width, font->max_bounds.width);
+ *logical_ascent = max(*logical_ascent, font->ascent);
+ *logical_descent = max(*logical_descent, font->descent);
+}
+
+/* For Vertical Writing end */
+
+static void
+set_fontset_extents(oc)
+ XOC oc;
+{
+ XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
+ XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
+ XFontStruct **font_list, *font;
+ XCharStruct overall;
+ int logical_ascent, logical_descent;
+ int num = oc->core.font_info.num_font;
+
+ font_list = oc->core.font_info.font_struct_list;
+ font = *font_list++;
+ overall = font->max_bounds;
+ overall.lbearing = font->min_bounds.lbearing;
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+
+ /* For Vertical Writing start */
+
+ while (--num > 0) {
+ font = *font_list++;
+ check_fontset_extents(&overall, &logical_ascent, &logical_descent,
+ font);
+ }
+
+ {
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ FontData font_data;
+ int font_set_num = gen->font_set_num;
+ int font_data_count;
+
+ for( ; font_set_num-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ font_data = font_set->vmap;
+ font_data_count = font_set->vmap_num;
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->font != NULL) {
+ check_fontset_extents(&overall, &logical_ascent,
+ &logical_descent,
+ font_data->font);
+ }
+ }
+ }
+
+ if(font_set->vrotate_num > 0) {
+ font_data = (FontData) font_set->vrotate;
+ font_data_count = font_set->vrotate_num;
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data != NULL)
+ if(font_data->font != NULL) {
+ check_fontset_extents(&overall, &logical_ascent,
+ &logical_descent,
+ font_data->font);
+ }
+ }
+ }
+ }
+ }
+
+ /* For Vertical Writing start */
+
+ ink->x = overall.lbearing;
+ ink->y = -(overall.ascent);
+ ink->width = overall.rbearing - overall.lbearing;
+ ink->height = overall.ascent + overall.descent;
+
+ logical->x = 0;
+ logical->y = -(logical_ascent);
+ logical->width = overall.width;
+ logical->height = logical_ascent + logical_descent;
+}
+
+static Bool
+init_core_part(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ int font_set_num;
+ XFontStruct **font_struct_list;
+ char **font_name_list, *font_name_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ count = length = 0;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ length += strlen(font_set->font_name) + 1;
+ count++;
+ }
+ if (count == 0)
+ return False;
+
+ font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *) * count);
+ if (font_struct_list == NULL)
+ return False;
+
+ font_name_list = (char **) Xmalloc(sizeof(char *) * count);
+ if (font_name_list == NULL)
+ goto err;
+
+ font_name_buf = (char *) Xmalloc(length);
+ if (font_name_buf == NULL)
+ goto err;
+
+ oc->core.font_info.num_font = count;
+ oc->core.font_info.font_name_list = font_name_list;
+ oc->core.font_info.font_struct_list = font_struct_list;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ for (count = 0; font_set_num-- > 0; font_set++, count++) {
+ if (font_set->font_name == NULL)
+ continue;
+
+ font_set->id = count;
+ if (font_set->font)
+ *font_struct_list++ = font_set->font;
+ else
+ *font_struct_list++ = font_set->info;
+ strcpy(font_name_buf, font_set->font_name);
+ Xfree(font_set->font_name);
+ *font_name_list++ = font_set->font_name = font_name_buf;
+ font_name_buf += strlen(font_name_buf) + 1;
+ }
+
+ set_fontset_extents(oc);
+
+ return True;
+
+err:
+ if (font_name_list)
+ Xfree(font_name_list);
+ Xfree(font_struct_list);
+
+ return False;
+}
+
+static char *
+get_font_name(oc, pattern)
+ XOC oc;
+ char *pattern;
+{
+ char **list, *name;
+ int count = 0;
+
+ list = XListFonts(oc->core.om->core.display, pattern, 1, &count);
+ if (list == NULL)
+ return NULL;
+
+ name = (char *) Xmalloc(strlen(*list) + 1);
+ if (name)
+ strcpy(name, *list);
+
+ XFreeFontNames(list);
+
+ return name;
+}
+
+/* For VW/UDC start*/
+
+static char
+*get_rotate_fontname(font_name)
+ char *font_name;
+{
+ char *pattern = NULL, *ptr = NULL;
+ char *fields[CHARSET_ENCODING_FIELD];
+ char str_pixel[32], str_point[4];
+ char *rotate_font_ptr = NULL;
+ int pixel_size = 0;
+ int field_num = 0, len = 0;
+
+ if(font_name == (char *) NULL || (len = strlen(font_name)) <= 0 || len > 255)
+ return NULL;
+
+ pattern = (char *)Xmalloc(len + 1);
+ if(!pattern)
+ return NULL;
+ strcpy(pattern, font_name);
+
+ memset(fields, 0, sizeof(char *) * 14);
+ ptr = pattern;
+ while(isspace(*ptr)) {
+ ptr++;
+ }
+ if(*ptr == '-')
+ ptr++;
+
+ for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD && ptr && *ptr ;
+ ptr++, field_num++) {
+ fields[field_num] = ptr;
+
+ if((ptr = strchr(ptr, '-'))) {
+ *ptr = '\0';
+ }
+ }
+
+ if(field_num < CHARSET_ENCODING_FIELD)
+ return NULL;
+
+ /* Pixel Size field : fields[6] */
+ for(ptr = fields[PIXEL_SIZE_FIELD - 1] ; ptr && *ptr; ptr++) {
+ if(!isdigit(*ptr)) {
+ if(*ptr == '['){ /* 960730 */
+ strcpy(pattern, font_name);
+ return(pattern);
+ }
+ if(pattern)
+ Xfree(pattern);
+ return NULL;
+ }
+ }
+ pixel_size = atoi(fields[PIXEL_SIZE_FIELD - 1]);
+ sprintf(str_pixel, "[ 0 ~%d %d 0 ]", pixel_size, pixel_size);
+ fields[6] = str_pixel;
+
+ /* Point Size field : fields[7] */
+ strcpy(str_point, "*");
+ fields[POINT_SIZE_FIELD - 1] = str_point;
+
+ len = 0;
+ for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD &&
+ fields[field_num] ; field_num++)
+ len += 1 + strlen (fields[field_num]);
+
+ if (len > 255)
+ return NULL;
+
+ rotate_font_ptr = (char *)Xmalloc(len + 1);
+ if(!rotate_font_ptr)
+ return NULL;
+
+ *rotate_font_ptr = '\0';
+ for(field_num = 0 ; field_num < CHARSET_ENCODING_FIELD &&
+ fields[field_num] ; field_num++) {
+ sprintf(rotate_font_ptr, "%s-%s", rotate_font_ptr, fields[field_num]);
+ }
+
+ if(pattern)
+ Xfree(pattern);
+
+ return rotate_font_ptr;
+}
+
+static Bool
+is_match_charset(font_data, font_name)
+ FontData font_data;
+ char *font_name;
+{
+ char *last;
+ int length, name_len;
+
+ name_len = strlen(font_name);
+ last = font_name + name_len;
+
+ length = strlen(font_data->name);
+ if (length > name_len)
+ return False;
+
+ if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
+ return True;
+
+ return False;
+}
+
+static char *
+get_font_name_from_list(oc, pattern, font_data)
+ XOC oc;
+ char *pattern;
+ FontData font_data;
+{
+ char **list, *name = (char *)NULL, *fname;
+ int count = 0, i;
+
+ list = XListFonts(oc->core.om->core.display, pattern, MAXFONTS, &count);
+ if (list == NULL)
+ return NULL;
+
+ for (i = 0; i < count; i++) {
+ fname = list[i];
+ if(is_match_charset(font_data, fname) == True) {
+ name = (char *) Xmalloc(strlen(fname) + 1);
+ if (name)
+ strcpy(name, fname);
+ break;
+ }
+ }
+
+ XFreeFontNames(list);
+
+ return name;
+}
+
+static int
+parse_all_name(oc, font_data, pattern)
+ XOC oc;
+ FontData font_data;
+ char *pattern;
+{
+
+#ifdef OLDCODE
+ if(is_match_charset(font_data, pattern) != True)
+ return False;
+
+ font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ if(font_data->xlfd_name == NULL)
+ return (-1);
+
+ strcpy(font_data->xlfd_name, pattern);
+ return True;
+#else /* OLDCODE */
+ Display *dpy = oc->core.om->core.display;
+ char **fn_list = NULL, *prop_fname = NULL;
+ int list_num;
+ XFontStruct *fs_list;
+ if(is_match_charset(font_data, pattern) != True) {
+ if ((fn_list = XListFontsWithInfo(dpy, pattern,
+ MAXFONTS,
+ &list_num, &fs_list)) == NULL) {
+ return False;
+ }
+ else if ((prop_fname = get_prop_name(dpy, fs_list)) == NULL) {
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return False;
+ }
+ else if ((is_match_charset(font_data, prop_fname) != True)) {
+ XFree(prop_fname);
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return False;
+ }
+ else {
+ font_data->xlfd_name = prop_fname;
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ return True;
+ }
+ }
+
+ font_data->xlfd_name = (char *)Xmalloc(strlen(pattern)+1);
+ if(font_data->xlfd_name == NULL)
+ return (-1);
+
+ strcpy(font_data->xlfd_name, pattern);
+ return True;
+#endif /* OLDCODE */
+}
+
+static int
+parse_omit_name(oc, font_data, pattern)
+ XOC oc;
+ FontData font_data;
+ char *pattern;
+{
+ char* last = (char *) NULL;
+ char* base_name;
+ char buf[BUFSIZE]; /* no XLFD name should be this long */
+ int length = 0;
+ int num_fields;
+
+ /* If the font specified by "pattern" is expandable to be
+ * a member of "font_data"'s FontSet, we've found a match.
+ */
+ if(is_match_charset(font_data, pattern) == True) {
+ if ((font_data->xlfd_name = get_font_name(oc, pattern)) != NULL) {
+ return True;
+ }
+ }
+
+ /* If an XLFD name is arbitrarily (too) long, allocate a buffer,
+ * and some extra space to tack stuff on the end.
+ *
+ * ### This is a hack. What happens is, we substitute pattern's
+ * ### encoding with the default encoding for the FontSet and
+ * ### try to find a match. For example, we may change pattern
+ * ### from:
+ * ### -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990-0 to
+ * ### -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ * ### So, the length of the original pattern may not be enough
+ * ### to store the "new" encoding (e.g., going from ISO8859-1 to
+ * ### JISX0208.1990-0), so the author decided to simply allocate
+ * ### a *bunch* of extra space to handle the potentially longer
+ * ### encoding.
+ * ###
+ * ### The real way to do this would be to figure out the length
+ * ### of the original encoding and the length of the new encoding.
+ * ### Re-alloc the array with the difference. Since it doesn't
+ * ### hurt anything keeping the extra-large buffer, I'll leave
+ * ### it the way it is. --jjw/pma (HP)
+ * ###
+ */
+
+ /*
+ * since BUFSIZE is much bigger than any legal XLFD name
+ * we'll allow the first half for the XLFD pattern, and the
+ * second half for the charset-plus-encoding. If we wanted to
+ * be accomodating, we could allocate memory, but that's
+ * overkill for this. Hackers who are trying to do bad things
+ * don't deserve to be accomodated like that.
+ */
+ if ((length = strlen (pattern)) > BUFSIZE/2) return -1;
+
+ strcpy(buf, pattern);
+ last = buf + length - 1;
+
+ /* Replace the original encoding with the encoding for this FontSet. */
+
+ /* Figure out how many fields have been specified in this xlfd. */
+ for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
+ if (*base_name == '-') num_fields++;
+
+ switch (num_fields) {
+ case 12:
+ /* This is the best way to have specifed the fontset. In this
+ * case, there is no original encoding. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*
+ * To this, we'll append a dash:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ *++last = '-';
+ break;
+ case 13:
+ /* Got the charset, not the encoding, zap the charset In this
+ * case, there is no original encoding, but there is a charset. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990
+ * To this, we remove the charset:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the new encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ last = strrchr (buf, '-');
+ num_fields = 12;
+ break;
+ case 14:
+ /* Both the charset and the encoding are specified. Get rid
+ * of them so that we can append the new charset encoding. E.g.,
+ * -*-*-*-*-*-*-14-*-*-*-*-*-jisx0212.1990-0
+ * To this, we'll remove the encoding and charset to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * then append the new encoding to get:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ */
+ last = strrchr (buf, '-');
+ *last = '\0';
+ last = strrchr (buf, '-');
+ num_fields = 12;
+ break;
+ default:
+ /* punt */
+ if (length > 1 && *last == '*' && *(last - 1) == '-') {
+ if (length > 3 && *(last - 2) == '*' && *(last - 3) == '-')
+ last -= 3;
+ else
+ last--;
+ } else {
+ *++last = '-';
+ }
+ break;
+ }
+ last++;
+
+ /* At this point, "last" is pointing to the last "-" in the
+ * xlfd, and all xlfd's at this point take a form similar to:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-
+ * (i.e., no encoding).
+ * After the strcpy, we'll end up with something similar to:
+ * -*-*-*-*-*-*-14-*-*-*-*-*-JISX0208.1990-0
+ *
+ * If the modified font is found in the current FontSet,
+ * we've found a match.
+ */
+
+ /* don't let hackers trounce the stack... */
+ if (strlen (font_data->name) > BUFSIZE/2)
+ return -1;
+
+ /* ...otherwise there's plenty of room to tack on the charset/encoding */
+ strcpy(last, font_data->name);
+ if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
+ return True;
+
+ /* This happens if the client specifies less than 12 fields
+ * (e.g., -*-*-*) for some reason. We'll keep appending
+ * "-*" until we find something that matches. This "feels"
+ * as if we're being overly nice to "lazy" client programs,
+ * but that's the way X is...nice :-)
+ */
+ while (num_fields < 12) {
+ *last = '*';
+ *(last + 1) = '-';
+ strcpy(last + 2, font_data->name);
+ num_fields++;
+ last+=2;
+ if ((font_data->xlfd_name = get_font_name(oc, buf)) != NULL)
+ return True;
+ }
+
+/*
+ I'm not sure what Teeks was trying to do here. It
+ seems to me that if "get_font_name()" fails,
+ "get_font_name_from_list()" would also fail. I wouldn't
+ put this in the SI until I understood it better.
+ -- jjw/pma (HP)
+
+ Couldn't resolve the wild base fontname !
+ - Teeks
+*/
+ if ((font_data->xlfd_name = get_font_name_from_list(oc, buf, font_data)) != NULL)
+ return True;
+
+ return False;
+}
+
+
+typedef enum{C_PRIMARY, C_SUBSTITUTE, C_VMAP, C_VROTATE } ClassType;
+
+static int
+parse_fontdata(oc, font_set, font_data, font_data_count, name_list, name_list_count,
+ class, font_data_return)
+ XOC oc;
+ FontSet font_set;
+ FontData font_data;
+ int font_data_count;
+ char **name_list;
+ int name_list_count;
+ ClassType class;
+ FontDataRec *font_data_return;
+{
+
+ char **cur_name_list = name_list;
+ char *font_name = (char *) NULL;
+ char *pattern = (char *) NULL;
+ int found_num = 0, ret = 0;
+ int count = name_list_count;
+ Bool is_found = False;
+
+ if(name_list == NULL || count <= 0) {
+ return False;
+ }
+
+ if(font_data == NULL || font_data_count <= 0) {
+ return False;
+ }
+
+ /* Loop through each FontSet defined in the "font_data" CharSet. */
+ for ( ; font_data_count-- > 0; font_data++) {
+ is_found = False;
+ font_name = (char *) NULL;
+ count = name_list_count;
+ cur_name_list = name_list;
+
+ /* Loop through each font specified by the user in the call to XCreateFontset(). */
+ while (count-- > 0) {
+ pattern = *cur_name_list++;
+ if (pattern == NULL || *pattern == '\0')
+ continue;
+
+
+ /* If the current font is fully specified (i.e., the xlfd contains
+ * no wildcards) and the font exists on the X Server, we have a match.
+ */
+ if (strchr(pattern, '*') == NULL &&
+ (font_name = get_font_name(oc, pattern))) {
+
+ /* Find the full xlfd name for this font. If the font is already
+ * in xlfd format, it is simply returned. If the font is an
+ * alias for another font, the xlfd of the aliased font is returned.
+ */
+ ret = parse_all_name(oc, font_data, font_name);
+ Xfree(font_name);
+
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+
+ /* Since there was an exact match of a fully-specified font
+ * or a font alias, we can return now since the desired font
+ * was found for the current FontSet for this CharSet.
+ *
+ * Previous implementations of this algorithm would
+ * not return here. Instead, they continued searching
+ * through the FontSets for this CharSet. The side-effect
+ * of that behavior is you may return a "substitute" match
+ * instead of an "exact" match. We believe there should be a
+ * preference on exact matches. Therefore, as soon as we
+ * find one, we bail.
+ *
+ * Also, previous implementations seemed to think it was
+ * important to find either a primary or substitute font
+ * for each FontSet in the CharSet before returning an
+ * acceptable font. We don't believe this is necessary.
+ * All the client cares about is finding a reasonable font
+ * for what was passed in. If we find an exact match,
+ * there's no reason to look any further.
+ *
+ * -- jjw/pma (HP)
+ */
+ font_data_return->xlfd_name = (char *)Xmalloc
+ (strlen(font_data->xlfd_name) + 1);
+ if (!font_data_return->xlfd_name) return -1;
+
+ strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
+
+ font_data_return->side = font_data->side;
+
+ return True;
+ }
+
+ /* If the font name is not fully specified (i.e., it has wildcards),
+ * we have more work to do. See the comments in parse_omit_name()
+ * for the list of things to do.
+ */
+ ret = parse_omit_name(oc, font_data, pattern);
+
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+
+ /* A font which matched the wild-carded specification was found.
+ * Only update the return data if a font has not yet been found.
+ * This maintains the convention that FontSets listed higher in
+ * a CodeSet in the Locale Database have higher priority than
+ * those FontSets listed lower in the CodeSet. In the following
+ * example:
+ *
+ * fs1 {
+ * charset HP-JIS:GR
+ * font JISX0208.1990-0:GL;\
+ * JISX0208.1990-1:GR;\
+ * JISX0208.1983-0:GL;\
+ * JISX0208.1983-1:GR
+ * }
+ *
+ * a font found in the JISX0208.1990-0 FontSet will have a
+ * higher priority than a font found in the JISX0208.1983-0
+ * FontSet.
+ */
+ if (font_data_return->xlfd_name == NULL)
+ {
+
+ font_data_return->xlfd_name = (char *)Xmalloc
+ (strlen(font_data->xlfd_name) + 1);
+ if (!font_data_return->xlfd_name) return -1;
+
+ strcpy (font_data_return->xlfd_name, font_data->xlfd_name);
+ font_data_return->side = font_data->side;
+ }
+
+ found_num++;
+ is_found = True;
+ }
+
+ switch(class) {
+ case C_PRIMARY:
+ if(is_found == False)
+ {
+ /* Did not find a font for the current FontSet. Check the
+ * FontSet's "substitute" font for a match. If we find a
+ * match, we'll keep searching in hopes of finding an exact
+ * match later down the FontSet list.
+ */
+ ret = parse_fontdata(oc, font_set, font_set->substitute,
+ font_set->substitute_num, name_list,
+ name_list_count, C_SUBSTITUTE,
+ font_data_return);
+ if (ret == -1) return -1;
+ if (ret == False) continue;
+
+ found_num++;
+ is_found = True;
+ }
+
+ break;
+
+ case C_SUBSTITUTE:
+ case C_VMAP:
+ if(is_found == True)
+ return True;
+ break;
+
+ case C_VROTATE:
+ if(is_found == True) {
+ char *rotate_name;
+
+ if((rotate_name = get_rotate_fontname(font_data->xlfd_name)) !=
+ NULL) {
+ Xfree(font_data->xlfd_name);
+ font_data->xlfd_name = rotate_name;
+
+ return True;
+ }
+ Xfree(font_data->xlfd_name);
+ return False;
+ }
+ break;
+ }
+ }
+
+ if(class == C_PRIMARY && found_num >= 1)
+ return True;
+
+ return False;
+}
+
+
+static int
+parse_vw(oc, font_set, name_list, count)
+ XOC oc;
+ FontSet font_set;
+ char **name_list;
+ int count;
+{
+ FontData vmap = font_set->vmap;
+ FontDataRec font_data_return;
+ VRotate vrotate = font_set->vrotate;
+ int vmap_num = font_set->vmap_num;
+ int vrotate_num = font_set->vrotate_num;
+ int ret = 0, i = 0;
+
+ if(vmap_num > 0) {
+ if(parse_fontdata(oc, font_set, vmap, vmap_num, name_list, count, C_VMAP) == -1)
+ return (-1);
+ }
+
+ if(vrotate_num > 0) {
+ ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num,
+ name_list, count, C_VROTATE, &font_data_return);
+ if(ret == -1) {
+ return (-1);
+ } else if(ret == False) {
+ CodeRange code_range;
+ int num_cr;
+ int sub_num = font_set->substitute_num;
+
+ code_range = vrotate[i].code_range;
+ num_cr = vrotate[i].num_cr;
+ for(i = 0 ; i < vrotate_num ; i++) {
+ if(vrotate[i].xlfd_name)
+ Xfree(vrotate[i].xlfd_name);
+ }
+ Xfree(vrotate);
+
+ if(sub_num > 0) {
+ vrotate = font_set->vrotate = (VRotate)Xmalloc
+ (sizeof(VRotateRec) * sub_num);
+ if(font_set->vrotate == (VRotate)NULL)
+ return (-1);
+
+ for(i = 0 ; i < sub_num ; i++) {
+ vrotate[i].charset_name = font_set->substitute[i].name;
+ vrotate[i].side = font_set->substitute[i].side;
+ vrotate[i].code_range = code_range;
+ vrotate[i].num_cr = num_cr;
+ }
+ vrotate_num = font_set->vrotate_num = sub_num;
+ } else {
+ font_set->vrotate = (VRotate)NULL;
+ }
+
+ ret = parse_fontdata(oc, font_set, (FontData) vrotate, vrotate_num,
+ name_list, count, C_VROTATE, &font_data_return);
+ if(ret == -1)
+ return (-1);
+ }
+ }
+
+ return True;
+}
+
+static int
+parse_fontname(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontDataRec font_data_return;
+ char *base_name, **name_list;
+ int font_set_num = 0;
+ int found_num = 0;
+ int count = 0;
+ int ret;
+ int i;
+
+ name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
+ if (name_list == NULL)
+ return -1;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ /* Loop through all of the CharSets defined in the Locale
+ * database for the current Locale.
+ */
+ for( ; font_set_num-- > 0 ; font_set++) {
+ if(font_set->font_name)
+ continue;
+
+ if(font_set->font_data_count > 0) {
+
+ /* If there are a non-zero number of FontSets defined
+ * for this CharSet.
+ */
+ font_data_return.name = NULL;
+ font_data_return.side = XlcUnknown;
+ font_data_return.scopes_num = 0;
+ font_data_return.scopes = NULL;
+ font_data_return.xlfd_name = NULL;
+ font_data_return.font = NULL;
+
+ /* Try to find a font for this CharSet. If we find an
+ * acceptable font, we save the information for return
+ * to the client. If we do not find an acceptable font,
+ * a "missing_charset" will be reported to the client
+ * for this CharSet.
+ */
+ ret = parse_fontdata(oc, font_set, font_set->font_data,
+ font_set->font_data_count,
+ name_list, count, C_PRIMARY,
+ &font_data_return);
+ if(ret == -1) {
+ goto err;
+ } else if(ret == True) {
+ font_set->font_name = (char *)Xmalloc
+ (strlen(font_data_return.xlfd_name) + 1);
+ if(font_set->font_name == (char *) NULL)
+ goto err;
+ strcpy(font_set->font_name, font_data_return.xlfd_name);
+ font_set->side = font_data_return.side;
+
+ Xfree (font_data_return.xlfd_name);
+
+ if(parse_vw(oc, font_set, name_list, count) == -1)
+ goto err;
+ found_num++;
+ }
+
+ } else if(font_set->substitute_num > 0) {
+
+ /* If there are no FontSets defined for this
+ * CharSet. We can only find "substitute" fonts.
+ */
+ font_data_return.name = NULL;
+ font_data_return.side = XlcUnknown;
+ font_data_return.scopes_num = 0;
+ font_data_return.scopes = NULL;
+ font_data_return.xlfd_name = NULL;
+ font_data_return.font = NULL;
+
+ ret = parse_fontdata(oc, font_set, font_set->substitute,
+ font_set->substitute_num,
+ name_list, count, C_SUBSTITUTE, &font_data_return);
+ if(ret == -1) {
+ goto err;
+ } else if(ret == True) {
+ for(i=0;i<font_set->substitute_num;i++){
+ if(font_set->substitute[i].xlfd_name != NULL){
+ break;
+ }
+ }
+ font_set->font_name = (char *)Xmalloc
+ (strlen(font_set->substitute[i].xlfd_name) + 1);
+ if(font_set->font_name == (char *) NULL)
+ goto err;
+ strcpy(font_set->font_name,font_set->substitute[i].xlfd_name);
+ font_set->side = font_set->substitute[i].side;
+ if(parse_vw(oc, font_set, name_list, count) == -1)
+ goto err;
+
+ found_num++;
+ }
+ }
+ }
+
+ base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ if (base_name == NULL)
+ goto err;
+
+ strcpy(base_name, oc->core.base_name_list);
+ oc->core.base_name_list = base_name;
+
+ XFreeStringList(name_list);
+
+ return found_num;
+
+err:
+ XFreeStringList(name_list);
+
+ return -1;
+}
+
+/* For VW/UDC end*/
+
+static Bool
+set_missing_list(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ char **charset_list, *charset_buf;
+ int count, length, font_set_num;
+ int result = 1;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ count = length = 0;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->info || font_set->font) {
+ continue;
+ }
+
+ /* Change 1996.01.23 start */
+ if(font_set->font_data_count <= 0 ||
+ font_set->font_data == (FontData)NULL) {
+ if(font_set->substitute_num <= 0 ||
+ font_set->substitute == (FontData)NULL) {
+ if(font_set->charset_list != NULL){
+ length +=
+ strlen(font_set->charset_list[0]->encoding_name) + 1;
+ } else {
+ length += 1;
+ }
+ } else {
+ length += strlen(font_set->substitute->name) + 1;
+ }
+ } else {
+ length += strlen(font_set->font_data->name) + 1;
+ }
+ /* Change 1996.01.23 end */
+ count++;
+ }
+
+ if (count < 1) {
+ return True;
+ }
+
+ charset_list = (char **) Xmalloc(sizeof(char *) * count);
+ if (charset_list == NULL) {
+ return False;
+ }
+
+ charset_buf = (char *) Xmalloc(length);
+ if (charset_buf == NULL) {
+ Xfree(charset_list);
+ return False;
+ }
+
+ oc->core.missing_list.charset_list = charset_list;
+ oc->core.missing_list.charset_count = count;
+
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+
+ for ( ; font_set_num-- > 0; font_set++) {
+ if (font_set->info || font_set->font) {
+ continue;
+ }
+
+ /* Change 1996.01.23 start */
+ if(font_set->font_data_count <= 0 ||
+ font_set->font_data == (FontData)NULL) {
+ if(font_set->substitute_num <= 0 ||
+ font_set->substitute == (FontData)NULL) {
+ if(font_set->charset_list != NULL){
+ strcpy(charset_buf,
+ font_set->charset_list[0]->encoding_name);
+ } else {
+ strcpy(charset_buf, "");
+ }
+ result = 0;
+ } else {
+ strcpy(charset_buf, font_set->substitute->name);
+ }
+ } else {
+ strcpy(charset_buf, font_set->font_data->name);
+ }
+ /* Change 1996.01.23 end */
+ *charset_list++ = charset_buf;
+ charset_buf += strlen(charset_buf) + 1;
+ }
+
+ if(result == 0) {
+ return(False);
+ }
+
+ return True;
+}
+
+static Bool
+create_fontset(oc)
+ XOC oc;
+{
+ XOMGenericPart *gen = XOM_GENERIC(oc->core.om);
+ int found_num;
+
+ if (init_fontset(oc) == False)
+ return False;
+
+ found_num = parse_fontname(oc);
+ if (found_num <= 0) {
+ if (found_num == 0)
+ set_missing_list(oc);
+ return False;
+ }
+
+ if (gen->on_demand_loading == True) {
+ if (load_font_info(oc) == False)
+ return False;
+ } else {
+ if (load_font(oc) == False)
+ return False;
+ }
+
+ if (init_core_part(oc) == False)
+ return False;
+
+ if (set_missing_list(oc) == False)
+ return False;
+
+ return True;
+}
+
+/* For VW/UDC start */
+static void
+free_fontdataOC(dpy,font_data, font_data_count)
+ Display *dpy;
+ FontData font_data;
+ int font_data_count;
+{
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->xlfd_name){
+ Xfree(font_data->xlfd_name);
+ font_data->xlfd_name = NULL;
+ }
+ if(font_data->font){ /* ADD 1996.01.7 */
+ if(font_data->font->fid) /* Add 1996.01.23 */
+ XFreeFont(dpy,font_data->font); /* ADD 1996.01.7 */
+ else /* Add 1996.01.23 */
+ XFreeFontInfo(NULL, font_data->font, 1);/* Add 1996.01.23 */
+ font_data->font = NULL;
+ }
+/* XOM to kyoutuu shite shiyou sushiteiru ryouiki
+ kokoha free_fontdataOM() de free sareru
+
+ if(font_data->scopes){
+ Xfree(font_data->scopes);
+ font_data->scopes = NULL;
+ }
+ if(font_data->name){
+ Xfree(font_data->name);
+ font_data->name = NULL;
+ }
+*/
+ }
+}
+void destroy_fontdata(gen,dpy)
+ XOCGenericPart *gen ;
+ Display *dpy ;
+{
+ FontSet font_set = (FontSet) NULL;
+ int font_set_num = 0;
+
+ if (gen->font_set) {
+ font_set = gen->font_set;
+ font_set_num = gen->font_set_num;
+ for( ; font_set_num-- ; font_set++) {
+ if(font_set->font_data) {
+ free_fontdataOC(dpy,
+ font_set->font_data, font_set->font_data_count);
+ Xfree(font_set->font_data);
+ font_set->font_data = NULL;
+ }
+ if(font_set->substitute) {
+ free_fontdataOC(dpy,
+ font_set->substitute, font_set->substitute_num);
+ Xfree(font_set->substitute);
+ font_set->substitute = NULL;
+ }
+ if(font_set->vmap) {
+ free_fontdataOC(dpy,
+ font_set->vmap, font_set->vmap_num);
+ Xfree(font_set->vmap);
+ font_set->vmap = NULL;
+ }
+ if(font_set->vrotate) {
+ free_fontdataOC(dpy,
+ (FontData)font_set->vrotate,
+ font_set->vrotate_num);
+ Xfree(font_set->vrotate);
+ font_set->vrotate = NULL;
+ }
+ }
+ Xfree(gen->font_set);
+ gen->font_set = NULL;
+ }
+}
+/* For VW/UDC end */
+
+static void
+destroy_oc(oc)
+ XOC oc;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XFontStruct **font_list;
+
+ if (gen->mbs_to_cs)
+ _XlcCloseConverter(gen->mbs_to_cs);
+
+ if (gen->wcs_to_cs)
+ _XlcCloseConverter(gen->wcs_to_cs);
+
+/* For VW/UDC start */ /* Change 1996.01.8 */
+ destroy_fontdata(gen,dpy);
+/*
+*/
+/* For VW/UDC end */
+
+ if (oc->core.base_name_list)
+ Xfree(oc->core.base_name_list);
+
+ if (oc->core.font_info.font_name_list)
+ XFreeStringList(oc->core.font_info.font_name_list);
+
+ if ((font_list = oc->core.font_info.font_struct_list)) {
+ Xfree(oc->core.font_info.font_struct_list);
+ }
+
+ if (oc->core.missing_list.charset_list)
+ XFreeStringList(oc->core.missing_list.charset_list);
+
+#ifdef notdef
+ if (oc->core.res_name)
+ Xfree(oc->core.res_name);
+ if (oc->core.res_class)
+ Xfree(oc->core.res_class);
+#endif
+
+ Xfree(oc);
+}
+
+static char *
+set_oc_values(oc, args, num_args)
+ XOC oc;
+ XlcArgList args;
+ int num_args;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char *ret;
+ int num = gen->font_set_num;
+
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ ret = _XlcSetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcSetMask);
+ if(ret != NULL){
+ return(ret);
+ } else {
+ for ( ; num-- > 0; font_set++) {
+ if (font_set->font_name == NULL)
+ continue;
+ if (font_set->vpart_initialize != 0)
+ continue;
+ if( oc->core.orientation == XOMOrientation_TTB_RTL ||
+ oc->core.orientation == XOMOrientation_TTB_LTR ){
+ load_fontdata(oc, font_set->vmap, font_set->vmap_num);
+ load_fontdata(oc, (FontData) font_set->vrotate,
+ font_set->vrotate_num);
+ font_set->vpart_initialize = 1;
+ }
+ }
+ return(NULL);
+ }
+}
+
+static char *
+get_oc_values(oc, args, num_args)
+ XOC oc;
+ XlcArgList args;
+ int num_args;
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static XOCMethodsRec oc_default_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbDefaultTextEscapement,
+ _XmbDefaultTextExtents,
+ _XmbDefaultTextPerCharExtents,
+ _XmbDefaultDrawString,
+ _XmbDefaultDrawImageString,
+ _XwcDefaultTextEscapement,
+ _XwcDefaultTextExtents,
+ _XwcDefaultTextPerCharExtents,
+ _XwcDefaultDrawString,
+ _XwcDefaultDrawImageString
+};
+
+static XOCMethodsRec oc_generic_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbGenericTextEscapement,
+ _XmbGenericTextExtents,
+ _XmbGenericTextPerCharExtents,
+ _XmbGenericDrawString,
+ _XmbGenericDrawImageString,
+ _XwcGenericTextEscapement,
+ _XwcGenericTextExtents,
+ _XwcGenericTextPerCharExtents,
+ _XwcGenericDrawString,
+ _XwcGenericDrawImageString
+};
+
+typedef struct _XOCMethodsListRec {
+ char *name;
+ XOCMethods methods;
+} XOCMethodsListRec, *XOCMethodsList;
+
+static XOCMethodsListRec oc_methods_list[] = {
+ { "default", &oc_default_methods },
+ { "generic", &oc_generic_methods }
+};
+
+static XlcResource oc_resources[] = {
+ { XNBaseFontName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
+ { XNOMAutomatic, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
+ { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
+ { XNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.default_string), XlcGetMask },
+ { XNOrientation, NULLQUARK, sizeof(XOrientation),
+ XOffsetOf(XOCRec, core.orientation), XlcDefaultMask | XlcSetMask | XlcGetMask },
+ { XNResourceName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
+ { XNResourceClass, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
+ { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
+ XOffsetOf(XOCRec, core.font_info), XlcGetMask }
+};
+
+static XOC
+create_oc(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ XOC oc;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ XOCMethodsList methods_list = oc_methods_list;
+ int count;
+
+ oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ if (oc == NULL)
+ return (XOC) NULL;
+ bzero((char *) oc, sizeof(XOCGenericRec));
+
+ oc->core.om = om;
+
+ if (oc_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
+
+ if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
+ args, num_args, XlcCreateMask | XlcDefaultMask))
+ goto err;
+
+ if (oc->core.base_name_list == NULL)
+ goto err;
+
+ oc->core.resources = oc_resources;
+ oc->core.num_resources = XlcNumber(oc_resources);
+
+ if (create_fontset(oc) == False)
+ goto err;
+
+ oc->methods = &oc_generic_methods;
+
+ if (gen->object_name) {
+ count = XlcNumber(oc_methods_list);
+
+ for ( ; count-- > 0; methods_list++) {
+ if (!_XlcCompareISOLatin1(gen->object_name, methods_list->name)) {
+ oc->methods = methods_list->methods;
+ break;
+ }
+ }
+ }
+
+ return oc;
+
+err:
+ destroy_oc(oc);
+
+ return (XOC) NULL;
+}
+
+static void
+free_fontdataOM(font_data, font_data_count)
+ FontData font_data;
+ int font_data_count;
+{
+ for( ; font_data_count-- ; font_data++) {
+ if(font_data->name){
+ Xfree(font_data->name);
+ font_data->name = NULL;
+ }
+ if(font_data->scopes){
+ Xfree(font_data->scopes);
+ font_data->scopes = NULL;
+ }
+ }
+}
+
+static Status
+close_om(om)
+ XOM om;
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ int count;
+
+ if ((data = gen->data)) {
+ for (count = gen->data_num; count-- > 0; data++) {
+ if (data->charset_list){
+ Xfree(data->charset_list);
+ data->charset_list = NULL;
+ }
+ /* free font_data for om */
+ if (data->font_data) {
+ free_fontdataOM(data->font_data,data->font_data_count);
+ Xfree(data->font_data);
+ data->font_data = NULL;
+ }
+ /* free substitute for om */
+ if (data->substitute) {
+ free_fontdataOM(data->substitute,data->substitute_num);
+ Xfree(data->substitute);
+ data->substitute = NULL;
+ }
+ /* free vmap for om */
+ if (data->vmap) {
+ free_fontdataOM(data->vmap,data->vmap_num);
+ Xfree(data->vmap);
+ data->vmap = NULL;
+ }
+ /* free vrotate for om */
+ if (data->vrotate) {
+ Xfree(data->vrotate);
+ data->vrotate = NULL;
+ }
+ }
+ Xfree(gen->data);
+ gen->data = NULL;
+ }
+
+ if (gen->object_name){
+ Xfree(gen->object_name);
+ gen->object_name = NULL;
+ }
+
+ if (om->core.res_name){
+ Xfree(om->core.res_name);
+ om->core.res_name = NULL;
+ }
+ if (om->core.res_class){
+ Xfree(om->core.res_class);
+ om->core.res_class = NULL;
+ }
+ if (om->core.required_charset.charset_list &&
+ om->core.required_charset.charset_count > 0){
+ XFreeStringList(om->core.required_charset.charset_list);
+ om->core.required_charset.charset_list = NULL;
+ } else {
+ Xfree((char*)om->core.required_charset.charset_list);
+ om->core.required_charset.charset_list = NULL;
+ }
+ if (om->core.orientation_list.orientation){
+ Xfree(om->core.orientation_list.orientation);
+ om->core.orientation_list.orientation = NULL;
+ }
+
+ Xfree(om);
+
+ return 1;
+}
+
+static char *
+set_om_values(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_om_values(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static XOMMethodsRec methods = {
+ close_om,
+ set_om_values,
+ get_om_values,
+ create_oc
+};
+
+static XlcResource om_resources[] = {
+ { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
+ { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
+ XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
+ { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
+ { XNContextualDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
+};
+
+static XOM
+create_om(lcd, dpy, rdb, res_name, res_class)
+ XLCd lcd;
+ Display *dpy;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+{
+ XOM om;
+
+ om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ if (om == NULL)
+ return (XOM) NULL;
+ bzero((char *) om, sizeof(XOMGenericRec));
+
+ om->methods = &methods;
+ om->core.lcd = lcd;
+ om->core.display = dpy;
+ om->core.rdb = rdb;
+ if (res_name) {
+ om->core.res_name = (char *) Xmalloc(strlen(res_name) + 1);
+ if (om->core.res_name == NULL)
+ goto err;
+ strcpy(om->core.res_name, res_name);
+ }
+ if (res_class) {
+ om->core.res_class = (char *) Xmalloc(strlen(res_class) + 1);
+ if (om->core.res_class == NULL)
+ goto err;
+ strcpy(om->core.res_class, res_class);
+ }
+
+ if (om_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
+
+ om->core.resources = om_resources;
+ om->core.num_resources = XlcNumber(om_resources);
+
+ return om;
+
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
+
+static OMData
+add_data(om)
+ XOM om;
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData new;
+ int num;
+
+ if ((num = gen->data_num))
+ new = (OMData) Xrealloc(gen->data, (num + 1) * sizeof(OMDataRec));
+ else
+ new = (OMData) Xmalloc(sizeof(OMDataRec));
+
+ if (new == NULL)
+ return NULL;
+
+ gen->data_num = num + 1;
+ gen->data = new;
+
+ new += num;
+ bzero((char *) new, sizeof(OMDataRec));
+
+ return new;
+}
+
+/* For VW/UDC */
+
+extern FontScope _XlcParse_scopemaps();
+
+FontData
+read_EncodingInfo(count,value)
+int count;
+char **value;
+{
+ FontData font_data,ret;
+ char *buf, *bufptr,*scp;
+ int len;
+ font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ if (font_data == NULL)
+ return NULL;
+ bzero((char *) font_data, sizeof(FontDataRec) * count);
+
+ ret = font_data;
+ for ( ; count-- > 0; font_data++) {
+/*
+ strcpy(buf, *value++);
+*/
+ buf = *value; value++;
+ if ((bufptr = strchr(buf, ':'))) {
+ len = (int)(bufptr - buf);
+ bufptr++ ;
+ }
+ font_data->name = (char *) Xmalloc(len + 1);
+ if (font_data->name == NULL)
+ return NULL;
+ strncpy(font_data->name, buf,len);
+ font_data->name[len] = 0;
+ if (bufptr && _XlcCompareISOLatin1(bufptr, "GL") == 0)
+ font_data->side = XlcGL;
+ else if (bufptr && _XlcCompareISOLatin1(bufptr, "GR") == 0)
+ font_data->side = XlcGR;
+ else
+ font_data->side = XlcGLGR;
+
+ if (bufptr && (scp = strchr(bufptr, '['))){
+ font_data->scopes = _XlcParse_scopemaps(scp,&(font_data->scopes_num));
+ }
+ }
+ return(ret);
+}
+
+static CodeRange read_vrotate(count,value,type,vrotate_num)
+int count;
+char **value;
+int *type;
+int *vrotate_num;
+{
+ CodeRange range;
+ if(!strcmp(value[0],"all")){
+ *type = VROTATE_ALL ;
+ *vrotate_num = 0 ;
+ return (NULL);
+ } else if(*(value[0]) == '['){
+ *type = VROTATE_PART ;
+ range = (CodeRange) _XlcParse_scopemaps(value[0],vrotate_num);
+ return (range);
+ } else {
+ *type = VROTATE_NONE ;
+ *vrotate_num = 0 ;
+ return (NULL);
+ }
+}
+
+static void read_vw(lcd,font_set,num)
+XLCd lcd;
+OMData font_set;
+int num;
+{
+ char **value, buf[BUFSIZ];
+ int count;
+
+ sprintf(buf, "fs%d.font.vertical_map", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ _XlcDbg_printValue(buf,value,count);
+ font_set->vmap_num = count;
+ font_set->vmap = read_EncodingInfo(count,value);
+ }
+
+ sprintf(buf, "fs%d.font.vertical_rotate", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ _XlcDbg_printValue(buf,value,count);
+ font_set->vrotate = read_vrotate(count,value,&(font_set->vrotate_type),
+ &(font_set->vrotate_num));
+ }
+}
+/* VW/UDC end */
+static Bool
+init_om(om)
+ XOM om;
+{
+ XLCd lcd = om->core.lcd;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ XlcCharSet *charset_list;
+ FontData font_data;
+ char **required_list;
+ XOrientation *orientation;
+ char **value, buf[BUFSIZ], *bufptr;
+ int count = 0, num = 0, length = 0;
+
+ _XlcGetResource(lcd, "XLC_FONTSET", "on_demand_loading", &value, &count);
+ if (count > 0 && _XlcCompareISOLatin1(*value, "True") == 0)
+ gen->on_demand_loading = True;
+
+ _XlcGetResource(lcd, "XLC_FONTSET", "object_name", &value, &count);
+ if (count > 0) {
+ gen->object_name = (char *) Xmalloc(strlen(*value) + 1);
+ if (gen->object_name == NULL)
+ return False;
+ strcpy(gen->object_name, *value);
+ }
+
+ for (num = 0; ; num++) {
+
+ sprintf(buf, "fs%d.charset.name", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+
+ if( count < 1){
+ sprintf(buf, "fs%d.charset", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ break;
+ }
+
+ data = add_data(om);
+ if (data == NULL)
+ return False;
+
+ charset_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet) * count);
+ if (charset_list == NULL)
+ return False;
+ data->charset_list = charset_list;
+ data->charset_count = count;
+
+ while (count-- > 0){
+ *charset_list++ = _XlcGetCharSet(*value++);
+ }
+ sprintf(buf, "fs%d.charset.udc_area", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if( count > 0){
+ UDCArea udc;
+ int i,flag = 0;
+ udc = (UDCArea)Xmalloc(count * sizeof(UDCAreaRec));
+ if (udc == NULL)
+ return False;
+ for(i=0;i<count;i++){
+ sscanf(value[i],"\\x%x,\\x%x", &(udc[i].start), &(udc[i].end));
+ }
+ for(i=0;i<data->charset_count;i++){
+ if(data->charset_list[i]->udc_area == NULL){
+ data->charset_list[i]->udc_area = udc;
+ data->charset_list[i]->udc_area_num = count;
+ flag = 1;
+ }
+ }
+ if(flag == 0){
+ Xfree(udc);
+ }
+ }
+
+ sprintf(buf, "fs%d.font.primary", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1){
+ sprintf(buf, "fs%d.font", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1)
+ return False;
+ }
+
+ font_data = read_EncodingInfo(count,value);
+ if (font_data == NULL)
+ return False;
+
+ data->font_data = font_data;
+ data->font_data_count = count;
+
+ sprintf(buf, "fs%d.font.substitute", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count > 0){
+ font_data = read_EncodingInfo(count,value);
+ if (font_data == NULL)
+ return False;
+ data->substitute = font_data;
+ data->substitute_num = count;
+ } else {
+ sprintf(buf, "fs%d.font", num);
+ _XlcGetResource(lcd, "XLC_FONTSET", buf, &value, &count);
+ if (count < 1) {
+ data->substitute = NULL;
+ data->substitute_num = 0;
+ } else {
+ font_data = read_EncodingInfo(count,value);
+ data->substitute = font_data;
+ data->substitute_num = count;
+ }
+ }
+ read_vw(lcd,data,num);
+ length += strlen(data->font_data->name) + 1;
+ }
+
+ /* required charset list */
+ required_list = (char **) Xmalloc(sizeof(char *) * gen->data_num);
+ if (required_list == NULL)
+ return False;
+
+ bufptr = (char *) Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ om->core.required_charset.charset_list = required_list;
+ om->core.required_charset.charset_count = gen->data_num;
+
+ count = gen->data_num;
+ data = gen->data;
+
+ for ( ; count-- > 0; data++) {
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+ }
+
+ /* orientation list */
+ orientation = (XOrientation *) Xmalloc(sizeof(XOrientation) * 2);
+ if (orientation == NULL)
+ return False;
+
+ orientation[0] = XOMOrientation_LTR_TTB;
+ orientation[1] = XOMOrientation_TTB_RTL;
+ om->core.orientation_list.orientation = orientation;
+ om->core.orientation_list.num_orientation = 2;
+
+ /* directional dependent drawing */
+ om->core.directional_dependent = False;
+
+ /* contexual drawing */
+ om->core.contextual_drawing = False;
+
+ /* context dependent */
+ om->core.context_dependent = False;
+
+ return True;
+}
+
+XOM
+#if NeedFunctionPrototypes
+_XomGenericOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+#else
+_XomGenericOpenOM(lcd, dpy, rdb, res_name, res_class)
+ XLCd lcd;
+ Display *dpy;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+#endif
+{
+ XOM om;
+
+ om = create_om(lcd, dpy, rdb, res_name, res_class);
+ if (om == NULL)
+ return (XOM) NULL;
+
+ if (init_om(om) == False)
+ goto err;
+
+ return om;
+
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
+
+Bool
+_XInitOM(lcd)
+ XLCd lcd;
+{
+ lcd->methods->open_om = _XomGenericOpenOM;
+
+ return True;
+}
diff --git a/modules/om/generic/omImText.c b/modules/om/generic/omImText.c
new file mode 100644
index 00000000..2e3ab708
--- /dev/null
+++ b/modules/om/generic/omImText.c
@@ -0,0 +1,100 @@
+/* $Xorg: omImText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+
+extern int _XomGenericTextExtents(), _XomGenericDrawString();
+
+#define GET_VALUE_MASK (GCFunction | GCForeground | GCBackground | GCFillStyle)
+#define SET_VALUE_MASK (GCFunction | GCForeground | GCFillStyle)
+
+static void
+_XomGenericDrawImageString(dpy, d, oc, gc, x, y, type, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ XOMTextType type;
+ XPointer text;
+ int length;
+{
+ XGCValues values;
+ XRectangle extent;
+
+ XGetGCValues(dpy, gc, GET_VALUE_MASK, &values);
+
+ XSetFunction(dpy, gc, GXcopy);
+ XSetForeground(dpy, gc, values.background);
+ XSetFillStyle(dpy, gc, FillSolid);
+
+ _XomGenericTextExtents(oc, type, text, length, 0, &extent);
+ XFillRectangle(dpy, d, gc, x + extent.x, y + extent.y, extent.width,
+ extent.height);
+
+ XChangeGC(dpy, gc, SET_VALUE_MASK, &values);
+
+ _XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length);
+}
+
+void
+#if NeedFunctionPrototypes
+_XmbGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+#else
+_XmbGenericDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+void
+#if NeedFunctionPrototypes
+_XwcGenericDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+#else
+_XwcGenericDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ _XomGenericDrawImageString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
diff --git a/modules/om/generic/omText.c b/modules/om/generic/omText.c
new file mode 100644
index 00000000..c95d8407
--- /dev/null
+++ b/modules/om/generic/omText.c
@@ -0,0 +1,373 @@
+/* $Xorg: omText.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC */
+
+static int
+is_rotate(oc, font)
+ XOC oc;
+ XFontStruct *font;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(oc, font)
+ XOC oc;
+ XFontStruct *font;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+draw_vertical(dpy, d, oc, gc, font, is_xchar2b, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ int x, y;
+ XPointer text;
+ int length;
+{
+ XChar2b *buf2b;
+ char *buf;
+ int wx = 0, wy = 0;
+ int direction = 0;
+ int font_ascent_return = 0, font_descent_return = 0;
+ int i;
+ XCharStruct overall;
+
+ wy = y;
+ if (is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents16(font, buf2b, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString16(dpy, d, gc, wx, wy, buf2b, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ XTextExtents(font, buf, 1,
+ &direction, &font_ascent_return,
+ &font_descent_return, &overall);
+ wx = x - (int)((overall.rbearing - overall.lbearing) >> 1) -
+ (int) overall.lbearing;
+ wy += overall.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += overall.descent;
+ } else {
+ wx = x - (int)((font->max_bounds.rbearing -
+ font->min_bounds.lbearing) >> 1) -
+ (int) font->min_bounds.lbearing;
+ wy += font->max_bounds.ascent;
+ XDrawString(dpy, d, gc, wx, wy, buf, 1);
+ wy += font->max_bounds.descent;
+ }
+ }
+ }
+ return wy;
+}
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+extern FontData _XomGetFontDataFromFontSet();
+
+static int
+DrawStringWithFontSet(dpy, d, oc, fs, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ FontSet fs;
+ GC gc;
+ int x, y;
+ XPointer text;
+ int length;
+{
+ XFontStruct *font;
+ Bool is_xchar2b;
+ unsigned char *ptr;
+ int ptr_len, char_len = 0;
+ FontData fd;
+ int ret;
+
+ ptr = (unsigned char *)text;
+ is_xchar2b = fs->is_xchar2b;
+
+ while (length > 0) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ (char *)ptr,length,&ptr_len,is_xchar2b,FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+
+ /* First, see if the "Best Match" font for the FontSet was set.
+ * If it was, use that font. If it was not set, then use the
+ * font defined by font_set->font_data[0] (which is what
+ * _XomGetFontDataFromFontSet() always seems to return for
+ * non-VW text). Note that given the new algorithm in
+ * parse_fontname() and parse_fontdata(), fs->font will
+ * *always* contain good data. We should probably remove
+ * the check for "fd->font", but we won't :-) -- jjw/pma (HP)
+ */
+ if(fd == (FontData) NULL ||
+ (font = fs->font) == (XFontStruct *) NULL){
+
+ if((font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ XSetFont(dpy, gc, font->fid);
+
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ XDrawString16(dpy, d, gc, x, y, (XChar2b *)ptr, char_len);
+ x += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ XDrawString(dpy, d, gc, x, y, (char *)ptr, char_len);
+ x += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ if(fs->font == font) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ (char *)ptr,length,&ptr_len,is_xchar2b,VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(fs,
+ (char *)ptr,length,&ptr_len,is_xchar2b,VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ XSetFont(dpy, gc, font->fid);
+ y = draw_vertical(dpy, d, oc, gc, font, is_xchar2b, x, y,
+ (char *)ptr, char_len);
+ break;
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ ret = x;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ ret = y;
+ }
+ return ret;
+}
+
+/* For VW/UDC */
+
+int
+_XomGenericDrawString(dpy, d, oc, gc, x, y, type, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ XOMTextType type;
+ XPointer text;
+ int length;
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet fs;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int start_x = x;
+ int start_y = y;
+ int left = 0, buf_len = 0;
+ int next = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return -1;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &fs;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* For VW/UDC */
+ next = DrawStringWithFontSet(dpy, d, oc, fs, gc, x, y,
+ (XPointer)xchar2b_buf, buf_len);
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ x = next;
+ break;
+ case XOMOrientation_TTB_RTL:
+ case XOMOrientation_TTB_LTR:
+ y = next;
+ break;
+ }
+/* For VW/UDC */
+ }
+
+ x -= start_x;
+ y -= start_y;
+
+ return x;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+#else
+_XmbGenericDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMMultiByte,
+ (XPointer) text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcGenericDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+#else
+_XwcGenericDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ return _XomGenericDrawString(dpy, d, oc, gc, x, y, XOMWideChar,
+ (XPointer) text, length);
+}
diff --git a/modules/om/generic/omTextEsc.c b/modules/om/generic/omTextEsc.c
new file mode 100644
index 00000000..7bc73259
--- /dev/null
+++ b/modules/om/generic/omTextEsc.c
@@ -0,0 +1,283 @@
+/* $Xorg: omTextEsc.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* For VW/UDC start */
+
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+static int
+is_rotate(oc, font)
+ XOC oc;
+ XFontStruct *font;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ VRotate vrotate;
+ int font_set_count;
+ int vrotate_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if((font_set->vrotate_num > 0) && (font_set->vrotate != NULL)) {
+ vrotate = font_set->vrotate;
+ vrotate_num = font_set->vrotate_num;
+ for( ; vrotate_num-- ; vrotate++)
+ if(vrotate->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+is_codemap(oc, font)
+ XOC oc;
+ XFontStruct *font;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData vmap;
+ int font_set_count;
+ int vmap_num;
+
+ font_set = gen->font_set;
+ font_set_count = gen->font_set_num;
+ for( ; font_set_count-- ; font_set++) {
+ if(font_set->vmap_num > 0) {
+ vmap = font_set->vmap;
+ vmap_num = font_set->vmap_num;
+ for( ; vmap_num-- ; vmap++)
+ if(vmap->font == font)
+ return True;
+ }
+ }
+ return False;
+}
+
+static int
+escapement_vertical(oc, font, is_xchar2b, text, length)
+ XOC oc;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer text;
+ int length;
+{
+ XChar2b *buf2b;
+ char *buf;
+ int escapement = 0, i;
+
+ if(is_xchar2b) {
+ for(i = 0, buf2b = (XChar2b *) text ; i < length ; i++, buf2b++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight16(font, buf2b, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ } else {
+ for(i = 0, buf = (char *)text ; i < length && *buf ; i++, buf++) {
+ if(is_rotate(oc, font) == True) {
+ escapement += _XTextHeight(font, buf, 1);
+ } else {
+ escapement += (int) (font->max_bounds.ascent +
+ font->max_bounds.descent);
+ }
+ }
+ }
+ return escapement;
+}
+
+
+extern FontData _XomGetFontDataFromFontSet();
+
+static int
+TextWidthWithFontSet(font_set, oc, text, length)
+ FontSet font_set;
+ XOC oc;
+ XPointer text;
+ int length;
+{
+ FontData fd;
+ XFontStruct *font;
+ unsigned char *ptr = (unsigned char *)text;
+ Bool is_xchar2b;
+ int ptr_len = length;
+ int escapement = 0, char_len = 0;
+
+ if(font_set == (FontSet) NULL)
+ return escapement;
+
+ is_xchar2b = font_set->is_xchar2b;
+
+ while(length > 0) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, FONTSCOPE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL) {
+
+ if((font = font_set->font) == (XFontStruct *) NULL)
+ break;
+ }
+
+ switch(oc->core.orientation) {
+ case XOMOrientation_LTR_TTB:
+ case XOMOrientation_RTL_TTB:
+ if (is_xchar2b) {
+ char_len = ptr_len / sizeof(XChar2b);
+ escapement += XTextWidth16(font, (XChar2b *)ptr, char_len);
+ } else {
+ char_len = ptr_len;
+ escapement += XTextWidth(font, (char *)ptr, char_len);
+ }
+ break;
+
+ case XOMOrientation_TTB_LTR:
+ case XOMOrientation_TTB_RTL:
+ if(font_set->font == font) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length, &ptr_len,
+ is_xchar2b, VMAP);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+
+ if(is_codemap(oc, fd->font) == False) {
+ fd = _XomGetFontDataFromFontSet(font_set, ptr, length,
+ &ptr_len, is_xchar2b,
+ VROTATE);
+ if(ptr_len <= 0)
+ break;
+ if(fd == (FontData) NULL ||
+ (font = fd->font) == (XFontStruct *) NULL)
+ break;
+ }
+ }
+
+ if(is_xchar2b)
+ char_len = ptr_len / sizeof(XChar2b);
+ else
+ char_len = ptr_len;
+ escapement += escapement_vertical(oc, font, is_xchar2b,
+ (XPointer) ptr, char_len);
+ }
+
+ if(char_len <= 0)
+ break;
+
+ length -= char_len;
+ ptr += ptr_len;
+ }
+
+ return escapement;
+}
+
+/* For VW/UDC end */
+
+static int
+_XomGenericTextEscapement(oc, type, text, length)
+ XOC oc;
+ XOMTextType type;
+ XPointer text;
+ int length;
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+/* VW/UDC */
+ XPointer args[3];
+ FontSet font_set;
+/* VW/UDC */
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int escapement = 0;
+ int buf_len = 0, left = 0;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return escapement;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+ args[2] = (XPointer) &font_set;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 3) < 0)
+ break;
+ buf_len -= left;
+
+/* VW/UDC */
+ escapement += TextWidthWithFontSet(font_set, oc,
+ (XPointer) xchar2b_buf, buf_len);
+/* VW/UDC */
+ }
+
+ return escapement;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbGenericTextEscapement(XOC oc, _Xconst char *text, int length)
+#else
+_XmbGenericTextEscapement(oc, text, length)
+ XOC oc;
+ char *text;
+ int length;
+#endif
+{
+ return _XomGenericTextEscapement(oc, XOMMultiByte, (XPointer) text, length);
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcGenericTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+#else
+_XwcGenericTextEscapement(oc, text, length)
+ XOC oc;
+ wchar_t *text;
+ int length;
+#endif
+{
+ return _XomGenericTextEscapement(oc, XOMWideChar, (XPointer) text, length);
+}
diff --git a/modules/om/generic/omTextExt.c b/modules/om/generic/omTextExt.c
new file mode 100644
index 00000000..24563167
--- /dev/null
+++ b/modules/om/generic/omTextExt.c
@@ -0,0 +1,144 @@
+/* $Xorg: omTextExt.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+int
+_XomGenericTextExtents(oc, type, text, length, overall_ink,
+ overall_logical)
+ XOC oc;
+ XOMTextType type;
+ XPointer text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *buf;
+ int direction, logical_ascent, logical_descent, tmp_ascent, tmp_descent;
+ XCharStruct overall, tmp_overall;
+ int buf_len, left;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ buf = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &buf, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (is_xchar2b)
+ XTextExtents16(font, xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+ else
+ XTextExtents(font, (char *) xchar2b_buf, buf_len, &direction,
+ &tmp_ascent, &tmp_descent, &tmp_overall);
+
+ if (first) { /* initialize overall */
+ overall = tmp_overall;
+ logical_ascent = tmp_ascent;
+ logical_descent = tmp_descent;
+ first = False;
+ } else {
+ overall.lbearing = min(overall.lbearing,
+ overall.width + tmp_overall.lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + tmp_overall.rbearing);
+ overall.ascent = max(overall.ascent, tmp_overall.ascent);
+ overall.descent = max(overall.descent, tmp_overall.descent);
+ overall.width += tmp_overall.width;
+ logical_ascent = max(logical_ascent, tmp_ascent);
+ logical_descent = max(logical_descent, tmp_descent);
+ }
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+int
+#if NeedFunctionPrototypes
+_XmbGenericTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XmbGenericTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ return _XomGenericTextExtents(oc, XOMMultiByte, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
+
+int
+#if NeedFunctionPrototypes
+_XwcGenericTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XwcGenericTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ return _XomGenericTextExtents(oc, XOMWideChar, (XPointer) text, length,
+ overall_ink, overall_logical);
+}
diff --git a/modules/om/generic/omTextPer.c b/modules/om/generic/omTextPer.c
new file mode 100644
index 00000000..7f7217e7
--- /dev/null
+++ b/modules/om/generic/omTextPer.c
@@ -0,0 +1,216 @@
+/* $Xorg: omTextPer.c,v 1.3 2000/08/17 19:45:22 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+static Status
+_XomGenericTextPerCharExtents(oc, type, text, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink, overall_logical)
+ XOC oc;
+ XOMTextType type;
+ XPointer text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+{
+ XlcConv conv;
+ XFontStruct *font;
+ Bool is_xchar2b;
+ XPointer args[2];
+ XChar2b xchar2b_buf[BUFSIZ], *xchar2b_ptr;
+ char *xchar_ptr;
+ XCharStruct *def, *cs, overall;
+ int buf_len, left, require_num;
+ int logical_ascent, logical_descent;
+ Bool first = True;
+
+ conv = _XomInitConverter(oc, type);
+ if (conv == NULL)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ logical_ascent = logical_descent = require_num = *num_chars = 0;
+
+ args[0] = (XPointer) &font;
+ args[1] = (XPointer) &is_xchar2b;
+
+ while (length > 0) {
+ xchar2b_ptr = xchar2b_buf;
+ left = buf_len = BUFSIZ;
+
+ if (_XomConvert(oc, conv, (XPointer *) &text, &length,
+ (XPointer *) &xchar2b_ptr, &left, args, 2) < 0)
+ break;
+ buf_len -= left;
+
+ if (require_num) {
+ require_num += buf_len;
+ continue;
+ }
+ if (buf_size < buf_len) {
+ require_num = *num_chars + buf_len;
+ continue;
+ }
+ buf_size -= buf_len;
+
+ if (first) {
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+ } else {
+ logical_ascent = max(logical_ascent, font->ascent);
+ logical_descent = max(logical_descent, font->descent);
+ }
+
+ if (is_xchar2b) {
+ CI_GET_DEFAULT_INFO_2D(font, def)
+ xchar2b_ptr = xchar2b_buf;
+ } else {
+ CI_GET_DEFAULT_INFO_1D(font, def)
+ xchar_ptr = (char *) xchar2b_buf;
+ }
+
+ while (buf_len-- > 0) {
+ if (is_xchar2b) {
+ CI_GET_CHAR_INFO_2D(font, xchar2b_ptr->byte1,
+ xchar2b_ptr->byte2, def, cs)
+ xchar2b_ptr++;
+ } else {
+ CI_GET_CHAR_INFO_1D(font, *xchar_ptr, def, cs)
+ xchar_ptr++;
+ }
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing,
+ overall.width + cs->lbearing);
+ overall.rbearing = max(overall.rbearing,
+ overall.width + cs->rbearing);
+ overall.width += cs->width;
+ }
+
+ (*num_chars)++;
+ }
+ }
+
+ if (require_num) {
+ *num_chars = require_num;
+ return 0;
+ } else {
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+ }
+
+ return 1;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XmbGenericTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XmbGenericTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ return _XomGenericTextPerCharExtents(oc, XOMMultiByte, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
+
+Status
+#if NeedFunctionPrototypes
+_XwcGenericTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XwcGenericTextPerCharExtents(oc, text, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ return _XomGenericTextPerCharExtents(oc, XOMWideChar, (XPointer) text,
+ length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink,
+ overall_logical);
+}
diff --git a/modules/om/generic/omXChar.c b/modules/om/generic/omXChar.c
new file mode 100644
index 00000000..eb47e66d
--- /dev/null
+++ b/modules/om/generic/omXChar.c
@@ -0,0 +1,467 @@
+/* $Xorg: omXChar.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+/*
+ * Modifiers: Jeff Walls, Paul Anderson (HEWLETT-PACKARD)
+ */
+
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XomGeneric.h"
+#include <stdio.h>
+
+/* for VW/UDC start */
+static Bool
+ismatch_scopes(fontdata,value, is_shift)
+ FontData fontdata;
+ unsigned long *value;
+ Bool is_shift;
+{
+ register int side, scopes_num = fontdata->scopes_num;
+ FontScope scopes = fontdata->scopes;
+ if (!scopes_num)
+ return False;
+
+ if(fontdata->font == NULL)
+ return False;
+
+ side = fontdata->side;
+
+ for(;scopes_num--;scopes++)
+ if ((scopes->start <= (*value & 0x7f7f)) &&
+ ((scopes->end) >= (*value & 0x7f7f))){
+ if(is_shift == True) {
+ if(scopes->shift){
+ if(scopes->shift_direction == '+'){
+ *value += scopes->shift ;
+ } else if( scopes->shift_direction == '-'){
+ *value -= scopes->shift ;
+ }
+ }
+ }
+ return True;
+ }
+
+ return False;
+}
+
+static int
+check_vertical_fonttype(name)
+ char *name;
+{
+ char *ptr;
+ int type = 0;
+
+ if(name == (char *)NULL || (int) strlen(name) <= 0)
+ return False;
+
+ /* Obtains the pointer of CHARSET_ENCODING_FIELD. */
+ if((ptr = strchr(name, '-')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ /* Obtains the pointer of vertical_map font type. */
+ if((ptr = strchr(ptr, '.')) == (char *) NULL)
+ return False;
+ ptr++;
+
+ switch(*ptr) {
+ case '1':
+ type = 1; break;
+ case '2':
+ type = 2; break;
+ case '3':
+ type = 3; break;
+ }
+ return type;
+}
+
+/*
+*/
+#define VMAP 0
+#define VROTATE 1
+#define FONTSCOPE 2
+
+FontData
+_XomGetFontDataFromFontSet(fs,str,len,len_ret,is2b,type)
+FontSet fs;
+unsigned char *str;
+int len;
+int *len_ret;
+int is2b;
+int type; /* VMAP , VROTATE , else */
+{
+ unsigned long value;
+ int num,i,hit,csize;
+ FontData fontdata;
+ unsigned char *c;
+ int vfont_type;
+
+ c = str;
+ hit = -1;
+ if(type == VMAP){
+ fontdata = fs->vmap;
+ num = fs->vmap_num;
+ } else if(type == VROTATE){
+ fontdata = (FontData)fs->vrotate;
+ num = fs->vrotate_num;
+ } else {
+ if(fs->font_data_count <= 0 || fs->font_data == (FontData)NULL) {
+ fontdata = fs->substitute;
+ num = fs->substitute_num;
+ }else {
+ fontdata = fs->font_data;
+ num = fs->font_data_count;
+ }
+ /* CDExc20229 fix */
+ if(fontdata == NULL || num == 0){
+ return(NULL);
+ }
+ }
+
+
+ if(is2b){
+ csize = 2;
+ } else {
+ csize = 1;
+ }
+
+ for(;len;len--){
+ if(is2b){
+ value = (((unsigned long)*c) << 8)|(unsigned long)*(c + 1);
+ } else {
+ value = (unsigned long)*c;
+ }
+
+ /* ### NOTE: This routine DOES NOT WORK!
+ * ### We can work around the problem in the calling routine,
+ * ### but we really need to understand this better. As it
+ * ### stands, the algorithm ALWAYS returns "fontdata[0]"
+ * ### for non-VW text! This is clearly wrong. In fact,
+ * ### given the new parse_font[name|data]() algorithms,
+ * ### we may not even need this routine to do anything
+ * ### for non-VW text (since font_set->font always contains
+ * ### the best font for this fontset). -- jjw/pma (HP)
+ */
+ for (i=0;i<num;i++) {
+ if(type == VROTATE) {
+ if(fontdata[i].font) {
+ /* If the num_cr equal zero, all character is rotated. */
+ if(fontdata[i].scopes_num == 0) {
+ break;
+ } else {
+ /* The vertical rotate glyph is not have code shift. */
+ if (ismatch_scopes(&(fontdata[i]),&value,False)) {
+ break;
+ }
+ }
+ }
+ } else if(type == VMAP) {
+ if(fontdata[i].font) {
+ vfont_type = check_vertical_fonttype(fontdata[i].name);
+ if(vfont_type == 0 || vfont_type == 1) {
+ break;
+ } else if(vfont_type == 2 || vfont_type == 3) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+
+ if (ismatch_scopes(&(fontdata[i]),&value,True)) {
+ break;
+ }
+ }
+ }
+ } else { /* FONTSCOPE */
+ if(fontdata[i].font) {
+ if(fontdata[i].scopes_num <= 0)
+ break;
+ if (ismatch_scopes(&(fontdata[i]),&value,True)){
+ break;
+ }
+ }
+ }
+ }
+ if((hit != -1) && (i != hit)){
+ break;
+ }
+ if(i == num){
+ if( type == VROTATE || type == VMAP){
+ /* Change 1996.01.23 start */
+ if(fs->font_data_count <= 0 ||
+ fs->font_data == (FontData)NULL)
+ fontdata = fs->substitute;
+ else
+ fontdata = fs->font_data;
+ /* Change 1996.01.23 end */
+ }
+ hit = 0;
+ c += csize;
+ break;
+ }
+ if( hit == -1 ) hit = i;
+ if(is2b){
+ *c = (unsigned char)(value >> 8);
+ *(c + 1) = (unsigned char)(value);
+ } else {
+ *c = (unsigned char)value;
+ }
+ c += csize;
+ }
+ *len_ret = (c - str);
+ return(&(fontdata[hit]));
+}
+/* for VW/UDC end */
+
+static FontSet
+_XomGetFontSetFromCharSet(oc, charset)
+ XOC oc;
+ XlcCharSet charset;
+{
+ register FontSet font_set = XOC_GENERIC(oc)->font_set;
+ register int num = XOC_GENERIC(oc)->font_set_num;
+ XlcCharSet *charset_list;
+ int charset_count;
+
+ for ( ; num-- > 0; font_set++) {
+ charset_count = font_set->charset_count;
+ charset_list = font_set->charset_list;
+ for ( ; charset_count-- > 0; charset_list++)
+ if (*charset_list == charset)
+ return font_set;
+ }
+
+ return (FontSet) NULL;
+}
+
+#ifdef MUSTCOPY
+static void
+cs_to_xchar2b(from, to, length)
+ register char *from;
+ register XChar2b *to;
+ register length;
+{
+ while (length-- > 0) {
+ to->byte1 = *from++;
+ to->byte2 = *from++;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gl(from, to, length)
+ register char *from;
+ register XChar2b *to;
+ register length;
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ & 0x7f;
+ to->byte2 = *from++ & 0x7f;
+ to++;
+ }
+}
+
+static void
+cs_to_xchar2b_gr(from, to, length)
+ register char *from;
+ register XChar2b *to;
+ register length;
+{
+ while (length-- > 0) {
+ to->byte1 = *from++ | 0x80;
+ to->byte2 = *from++ | 0x80;
+ to++;
+ }
+}
+#endif
+
+static void
+shift_to_gl(text, length)
+ register char *text;
+ register int length;
+{
+ while (length-- > 0)
+ *text++ &= 0x7f;
+}
+
+static void
+shift_to_gr(text, length)
+ register char *text;
+ register int length;
+{
+ while (length-- > 0)
+ *text++ |= 0x80;
+}
+
+static Bool
+load_font(oc, font_set)
+ XOC oc;
+ FontSet font_set;
+{
+ font_set->font = XLoadQueryFont(oc->core.om->core.display,
+ oc->core.font_info.font_name_list[font_set->id]);
+ if (font_set->font == NULL)
+ return False;
+
+ oc->core.font_info.font_struct_list[font_set->id] = font_set->font;
+ XFreeFontInfo(NULL, font_set->info, 1);
+ font_set->info = NULL;
+
+ if (font_set->font->min_byte1 || font_set->font->max_byte1)
+ font_set->is_xchar2b = True;
+ else
+ font_set->is_xchar2b = False;
+
+ return True;
+}
+
+int
+_XomConvert(oc, conv, from, from_left, to, to_left, args, num_args)
+ XOC oc;
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ XPointer cs, lc_args[1];
+ XlcCharSet charset;
+ int length, cs_left, ret;
+ FontSet font_set;
+#ifdef MUSTCOPY
+ XChar2b *xchar2b;
+ char *buf, buf_local[BUFSIZ];
+#endif
+
+ cs = *to;
+ cs_left = *to_left;
+ lc_args[0] = (XPointer) &charset;
+
+ ret = _XlcConvert(conv, from, from_left, &cs, &cs_left, lc_args, 1);
+ if (ret < 0)
+ return -1;
+
+ font_set = _XomGetFontSetFromCharSet(oc, charset);
+ if (font_set == NULL)
+ return -1;
+
+ if (font_set->font == NULL && load_font(oc, font_set) == False)
+ return -1;
+
+ length = *to_left - cs_left;
+
+#ifdef MUSTCOPY
+ if (font_set->is_xchar2b) {
+ buf = (length > BUFSIZ) ? Xmalloc(length) : buf_local;
+ if (buf == NULL)
+ return -1;
+ memcpy(buf, (char *) *to, length);
+
+ xchar2b = (XChar2b *) *to;
+ length >>= 1;
+
+ if (font_set->side == charset->side)
+ cs_to_xchar2b(buf, xchar2b, length);
+ else if (font_set->side == XlcGL)
+ cs_to_xchar2b_gl(buf, xchar2b, length);
+ else if (font_set->side == XlcGR)
+ cs_to_xchar2b_gr(buf, xchar2b, length);
+ else
+ cs_to_xchar2b(buf, xchar2b, length);
+
+ if (buf != buf_local)
+ Xfree(buf);
+
+ *to = (XPointer) (xchar2b + length);
+ *to_left -= length;
+ } else
+#endif
+ {
+ if (font_set->side != charset->side) {
+ if (font_set->side == XlcGL)
+ shift_to_gl(*to, length);
+ else if (font_set->side == XlcGR)
+ shift_to_gr(*to, length);
+ }
+
+ if (font_set->is_xchar2b)
+ length >>= 1;
+ *to = cs;
+ *to_left -= length;
+ }
+
+ *((XFontStruct **) args[0]) = font_set->font;
+ *((Bool *) args[1]) = font_set->is_xchar2b;
+ if(num_args >= 3){
+ *((FontSet *) args[2]) = font_set;
+ }
+
+ return ret;
+}
+
+XlcConv
+_XomInitConverter(oc, type)
+ XOC oc;
+ XOMTextType type;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XlcConv conv;
+ char *conv_type;
+ XLCd lcd;
+
+ if (type == XOMWideChar) {
+ conv = gen->wcs_to_cs;
+ conv_type = XlcNWideChar;
+ } else {
+ conv = gen->mbs_to_cs;
+ conv_type = XlcNMultiByte;
+ }
+
+ if (conv) {
+ _XlcResetConverter(conv);
+ return conv;
+ }
+
+ lcd = oc->core.om->core.lcd;
+
+ conv = _XlcOpenConverter(lcd, conv_type, lcd, XlcNCharSet);
+ if (conv == (XlcConv) NULL)
+ return (XlcConv) NULL;
+
+ if (type == XOMWideChar)
+ gen->wcs_to_cs = conv;
+ else
+ gen->mbs_to_cs = conv;
+
+ return conv;
+}
diff --git a/nls/C/XI18N_OBJS b/nls/C/XI18N_OBJS
new file mode 100644
index 00000000..32e4f358
--- /dev/null
+++ b/nls/C/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/ximcp _XimOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/C/XLC_LOCALE.pre b/nls/C/XLC_LOCALE.pre
new file mode 100644
index 00000000..7198f5a1
--- /dev/null
+++ b/nls/C/XLC_LOCALE.pre
@@ -0,0 +1,50 @@
+XCOMM $Xorg: C,v 1.3 2000/08/17 19:46:59 cpqbld Exp $
+XCOMM XLocale Database Sample for C.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name STRING
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL
+}
+
+END XLC_XLOCALE
diff --git a/nls/compose.dir.pre b/nls/compose.dir.pre
new file mode 100644
index 00000000..25ed582d
--- /dev/null
+++ b/nls/compose.dir.pre
@@ -0,0 +1,93 @@
+XCOMM $Xorg: compose.dir,v 1.4 2000/12/12 13:00:42 coskrey Exp $
+XCOMM
+XCOMM This file contains compose table file name.
+XCOMM The first word is the compose table file name and
+XCOMM the second word is full locale name.
+XCOMM
+iso8859-1/Compose: C
+iso8859-1/Compose: af_ZA.ISO8859-1
+iso8859-1/Compose: ca_ES.ISO8859-1
+iso8859-1/Compose: da_DK.ISO8859-1
+iso8859-1/Compose: de_AT.ISO8859-1
+iso8859-1/Compose: de_CH.ISO8859-1
+iso8859-1/Compose: de_DE.ISO8859-1
+iso8859-1/Compose: de_LI.ISO8859-1
+iso8859-1/Compose: de_LU.ISO8859-1
+iso8859-1/Compose: en_AU.ISO8859-1
+iso8859-1/Compose: en_BZ.ISO8859-1
+iso8859-1/Compose: en_CA.ISO8859-1
+iso8859-1/Compose: en_GB.ISO8859-1
+iso8859-1/Compose: en_IE.ISO8859-1
+iso8859-1/Compose: en_JM.ISO8859-1
+iso8859-1/Compose: en_NZ.ISO8859-1
+iso8859-1/Compose: en_TT.ISO8859-1
+iso8859-1/Compose: en_UK.ISO8859-1
+iso8859-1/Compose: en_US.ISO8859-1
+iso8859-1/Compose: en_ZA.ISO8859-1
+iso8859-1/Compose: es_AR.ISO8859-1
+iso8859-1/Compose: es_BO.ISO8859-1
+iso8859-1/Compose: es_CL.ISO8859-1
+iso8859-1/Compose: es_CO.ISO8859-1
+iso8859-1/Compose: es_CR.ISO8859-1
+iso8859-1/Compose: es_DO.ISO8859-1
+iso8859-1/Compose: es_EC.ISO8859-1
+iso8859-1/Compose: es_ES.ISO8859-1
+iso8859-1/Compose: es_GT.ISO8859-1
+iso8859-1/Compose: es_HN.ISO8859-1
+iso8859-1/Compose: es_MX.ISO8859-1
+iso8859-1/Compose: es_NI.ISO8859-1
+iso8859-1/Compose: es_PA.ISO8859-1
+iso8859-1/Compose: es_PE.ISO8859-1
+iso8859-1/Compose: es_PR.ISO8859-1
+iso8859-1/Compose: es_PY.ISO8859-1
+iso8859-1/Compose: es_SV.ISO8859-1
+iso8859-1/Compose: es_UY.ISO8859-1
+iso8859-1/Compose: es_VE.ISO8859-1
+iso8859-1/Compose: eu_ES.ISO8859-1
+iso8859-1/Compose: fi_FI.ISO8859-1
+iso8859-1/Compose: fo_FO.ISO8859-1
+iso8859-1/Compose: fr_BE.ISO8859-1
+iso8859-1/Compose: fr_CA.ISO8859-1
+iso8859-1/Compose: fr_CH.ISO8859-1
+iso8859-1/Compose: fr_FR.ISO8859-1
+iso8859-1/Compose: fr_LU.ISO8859-1
+iso8859-1/Compose: id_ID.ISO8859-1
+iso8859-1/Compose: is_IS.ISO8859-1
+iso8859-1/Compose: it_CH.ISO8859-1
+iso8859-1/Compose: it_IT.ISO8859-1
+iso8859-1/Compose: lt_LN.ISO8859-1
+iso8859-1/Compose: nl_BE.ISO8859-1
+iso8859-1/Compose: nl_NL.ISO8859-1
+iso8859-1/Compose: no_NO.ISO8859-1
+iso8859-1/Compose: pt_BR.ISO8859-1
+iso8859-1/Compose: pt_PT.ISO8859-1
+iso8859-1/Compose: sv_FI.ISO8859-1
+iso8859-1/Compose: sv_SE.ISO8859-1
+iso8859-2/Compose: cs_CZ.ISO8859-2
+iso8859-2/Compose: cz_CZ.ISO8859-2
+iso8859-2/Compose: hr_HR.ISO8859-2
+iso8859-2/Compose: hu_HU.ISO8859-2
+iso8859-2/Compose: pl_PL.ISO8859-2
+iso8859-2/Compose: ro_RO.ISO8859-2
+iso8859-2/Compose: sh_YU.ISO8859-2
+iso8859-2/Compose: sk_SK.ISO8859-2
+iso8859-2/Compose: sl_CS.ISO8859-2
+iso8859-2/Compose: sl_SI.ISO8859-2
+iso8859-2/Compose: sq_AL.ISO8859-2
+iso8859-2/Compose: sr_SP.ISO8859-2
+iso8859-2/Compose: sr_YU.ISO8859-2
+en_US.utf/Compose: en_US.utf
+
+XCOMM Added by Sun
+en_US.UTF-8/Compose: en_US.UTF-8
+
+iso8859-5/Compose: sr_SP.ISO8859-5
+iso8859-5/Compose: bg_BG.ISO8859-5
+iso8859-5/Compose: mk_MK.ISO8859-5
+iso8859-5/Compose: ru.ISO8859-5
+
+iso8859-7/Compose: el.ISO8859-7
+
+iso8859-13/Compose: lt.ISO8859-13
+iso8859-13/Compose: lv.ISO8859-13
+
diff --git a/nls/en_US.UTF-8/Compose.pre b/nls/en_US.UTF-8/Compose.pre
new file mode 100644
index 00000000..f5bdd589
--- /dev/null
+++ b/nls/en_US.UTF-8/Compose.pre
@@ -0,0 +1,2245 @@
+#
+# Copyright (c) 1996-1999 by Sun Microsystems, Inc.
+# All rights reserved.
+#
+#ident "@(#)en_US.UTF-8 1.44 99/11/22 SMI"
+#
+# Compose table for the En_US.UTF8 locale
+#
+
+STATE "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+# Rules to compose Euro Currency Symbol
+AltGraph<e> : "\xe2\x82\xac"
+AltGraph<E> : "\xe2\x82\xac"
+AltGraph<4> : "\xe2\x82\xac"
+AltGraph<5> : "\xe2\x82\xac"
+Alt<e> : "\xe2\x82\xac"
+Alt<E> : "\xe2\x82\xac"
+Alt<4> : "\xe2\x82\xac"
+Alt<5> : "\xe2\x82\xac"
+Meta<e> : "\xe2\x82\xac"
+Meta<E> : "\xe2\x82\xac"
+Meta<4> : "\xe2\x82\xac"
+Meta<5> : "\xe2\x82\xac"
+
+<Multi_key> <plus> <plus> : "\x23" numbersign
+<Multi_key> <apostrophe> <space> : "\x27" apostrophe
+<Multi_key> <space> <apostrophe> : "\x27'" apostrophe
+<Multi_key> <A> <A> : "\x40" at
+<Multi_key> <a> <A> : "\xc4\x84" Aogonek
+<Multi_key> <A> <a> : "\xc4\x84" Aogonek
+<Multi_key> <a> <a> : "\xc4\x85" aogonek
+<Multi_key> <parenleft> <parenleft> : "\x5b" bracketleft
+<Multi_key> <slash> <slash> : "\x5c" backslash
+<Multi_key> <slash> <less> : "\x5c" backslash
+<Multi_key> <less> <slash> : "\x5c" backslash
+<Multi_key> <parenright> <parenright> : "\x5d" bracketright
+<Multi_key> <asciicircum> <space> : "\x5e" asciicircum
+<Multi_key> <space> <asciicircum> : "\x5e" asciicircum
+<Multi_key> <greater> <space> : "\x5e" asciicircum
+<Multi_key> <space> <greater> : "\x5e" asciicircum
+<Multi_key> <grave> <space> : "\x60" grave
+<Multi_key> <space> <grave> : "\x60" grave
+<Multi_key> <parenleft> <minus> : "\x7b" braceleft
+<Multi_key> <minus> <parenleft> : "\x7b" braceleft
+<Multi_key> <slash> <asciicircum> : "\x7c" bar
+<Multi_key> <asciicircum> <slash> : "\x7c" bar
+<Multi_key> <V> <L> : "\x7c" bar
+<Multi_key> <L> <V> : "\x7c" bar
+<Multi_key> <v> <l> : "\x7c" bar
+<Multi_key> <l> <v> : "\x7c" bar
+<Multi_key> <parenright> <minus> : "\x7d" braceright
+<Multi_key> <minus> <parenright> : "\x7d" braceright
+<Multi_key> <asciitilde> <space> : "\x7e" asciitilde
+<Multi_key> <space> <asciitilde> : "\x7e" asciitilde
+<Multi_key> <minus> <space> : "\x7e" asciitilde
+<Multi_key> <space> <minus> : "\x7e" asciitilde
+<Multi_key> <exclam> <exclam> : "\xc2\xa1" exclamdown
+<Multi_key> <C> <acute> : "\xc4\x86" Cacute
+<Multi_key> <c> <acute> : "\xc4\x87" cacute
+<Multi_key> <acute> <C> : "\xc4\x86" Cacute
+<Multi_key> <acute> <c> : "\xc4\x87" cacute
+<Multi_key> <c> <slash> : "\xc2\xa2" cent
+<Multi_key> <slash> <c> : "\xc2\xa2" cent
+<Multi_key> <C> <slash> : "\xc2\xa2" cent
+<Multi_key> <slash> <C> : "\xc2\xa2" cent
+<Multi_key> <C> <bar> : "\xc2\xa2" cent
+<Multi_key> <bar> <C> : "\xc2\xa2" cent
+<Multi_key> <c> <bar> : "\xc2\xa2" cent
+<Multi_key> <bar> <c> : "\xc2\xa2" cent
+<Multi_key> <acute> <L> : "\xc4\xb9" Lacute
+<Multi_key> <L> <acute> : "\xc4\xb9" Lacute
+<Multi_key> <acute> <l> : "\xc4\xba" lacute
+<Multi_key> <l> <acute> : "\xc4\xba" lacute
+<Multi_key> <l> <minus> : "\xc2\xa3" sterling
+<Multi_key> <minus> <l> : "\xc2\xa3" sterling
+<Multi_key> <L> <minus> : "\xc2\xa3" sterling
+<Multi_key> <minus> <L> : "\xc2\xa3" sterling
+<Multi_key> <l> <equal> : "\xc2\xa3" sterling
+<Multi_key> <equal> <l> : "\xc2\xa3" sterling
+<Multi_key> <L> <equal> : "\xc2\xa3" sterling
+<Multi_key> <equal> <L> : "\xc2\xa3" sterling
+<Multi_key> <acute> <N> : "\xc5\x83" Nacute
+<Multi_key> <N> <acute> : "\xc5\x83" Nacute
+<Multi_key> <y> <minus> : "\xc2\xa5" yen
+<Multi_key> <minus> <y> : "\xc2\xa5" yen
+<Multi_key> <Y> <minus> : "\xc2\xa5" yen
+<Multi_key> <minus> <Y> : "\xc2\xa5" yen
+<Multi_key> <y> <equal> : "\xc2\xa5" yen
+<Multi_key> <equal> <y> : "\xc2\xa5" yen
+<Multi_key> <Y> <equal> : "\xc2\xa5" yen
+<Multi_key> <equal> <Y> : "\xc2\xa5" yen
+<Multi_key> <s> <o> : "\xc2\xa7" section
+<Multi_key> <o> <s> : "\xc2\xa7" section
+<Multi_key> <S> <O> : "\xc2\xa7" section
+<Multi_key> <O> <S> : "\xc2\xa7" section
+<Multi_key> <S> <exclam> : "\xc2\xa7" section
+<Multi_key> <exclam> <S> : "\xc2\xa7" section
+<Multi_key> <s> <exclam> : "\xc2\xa7" section
+<Multi_key> <exclam> <s> : "\xc2\xa7" section
+<Multi_key> <S> <0> : "\xc2\xa7" section
+<Multi_key> <0> <S> : "\xc2\xa7" section
+<Multi_key> <s> <0> : "\xc2\xa7" section
+<Multi_key> <0> <s> : "\xc2\xa7" section
+<Multi_key> <x> <o> : "\xc2\xa4" currency
+<Multi_key> <o> <x> : "\xc2\xa4" currency
+<Multi_key> <X> <O> : "\xc2\xa4" currency
+<Multi_key> <O> <X> : "\xc2\xa4" currency
+<Multi_key> <x> <O> : "\xc2\xa4" currency
+<Multi_key> <O> <x> : "\xc2\xa4" currency
+<Multi_key> <X> <o> : "\xc2\xa4" currency
+<Multi_key> <o> <X> : "\xc2\xa4" currency
+<Multi_key> <x> <0> : "\xc2\xa4" currency
+<Multi_key> <0> <x> : "\xc2\xa4" currency
+<Multi_key> <X> <0> : "\xc2\xa4" currency
+<Multi_key> <0> <X> : "\xc2\xa4" currency
+<Multi_key> <c> <o> : "\xc2\xa9" copyright
+<Multi_key> <o> <c> : "\xc2\xa9" copyright
+<Multi_key> <C> <O> : "\xc2\xa9" copyright
+<Multi_key> <O> <C> : "\xc2\xa9" copyright
+<Multi_key> <c> <O> : "\xc2\xa9" copyright
+<Multi_key> <O> <c> : "\xc2\xa9" copyright
+<Multi_key> <C> <o> : "\xc2\xa9" copyright
+<Multi_key> <o> <C> : "\xc2\xa9" copyright
+<Multi_key> <c> <0> : "\xc2\xa9" copyright
+<Multi_key> <0> <c> : "\xc2\xa9" copyright
+<Multi_key> <C> <0> : "\xc2\xa9" copyright
+<Multi_key> <0> <C> : "\xc2\xa9" copyright
+<Multi_key> <a> <minus> : "\xc2\xaa" ordfeminine
+<Multi_key> <minus> <a> : "\xc2\xaa" ordfeminine
+<Multi_key> <A> <minus> : "\xc2\xaa" ordfeminine
+<Multi_key> <minus> <A> : "\xc2\xaa" ordfeminine
+<Multi_key> <o> <minus> : "\xc2\xba" masculine
+<Multi_key> <minus> <o> : "\xc2\xba" masculine
+<Multi_key> <O> <minus> : "\xc2\xba" masculine
+<Multi_key> <minus> <O> : "\xc2\xba" masculine
+<Multi_key> <less> <less> : "\xc2\xab" guillemotleft
+<Multi_key> <greater> <greater> : "\xc2\xbb" guillemotright
+<Multi_key> <0> <asciicircum> : "\xc2\xb0" degree
+<Multi_key> <asciicircum> <0> : "\xc2\xb0" degree
+<Multi_key> <0> <asterisk> : "\xc2\xb0" degree
+<Multi_key> <asterisk> <0> : "\xc2\xb0" degree
+<Multi_key> <plus> <minus> : "\xc2\xb1" plusminus
+<Multi_key> <minus> <plus> : "\xc2\xb1" plusminus
+<Multi_key> <slash> <u> : "\xc2\xb5" mu
+<Multi_key> <u> <slash> : "\xc2\xb5" mu
+<Multi_key> <slash> <U> : "\xc2\xb5" mu
+<Multi_key> <U> <slash> : "\xc2\xb5" mu
+<Multi_key> <1> <asciicircum> : "\xc2\xb9" onesuperior
+<Multi_key> <asciicircum> <1> : "\xc2\xb9" onesuperior
+<Multi_key> <S> <1> : "\xc2\xb9" onesuperior
+<Multi_key> <1> <S> : "\xc2\xb9" onesuperior
+<Multi_key> <s> <1> : "\xc2\xb9" onesuperior
+<Multi_key> <1> <s> : "\xc2\xb9" onesuperior
+<Multi_key> <2> <asciicircum> : "\xc2\xb2" twosuperior
+<Multi_key> <asciicircum> <2> : "\xc2\xb2" twosuperior
+<Multi_key> <S> <2> : "\xc2\xb2" twosuperior
+<Multi_key> <2> <S> : "\xc2\xb2" twosuperior
+<Multi_key> <s> <2> : "\xc2\xb2" twosuperior
+<Multi_key> <2> <s> : "\xc2\xb2" twosuperior
+<Multi_key> <3> <asciicircum> : "\xc2\xb3" threesuperior
+<Multi_key> <asciicircum> <3> : "\xc2\xb3" threesuperior
+<Multi_key> <S> <3> : "\xc2\xb3" threesuperior
+<Multi_key> <3> <S> : "\xc2\xb3" threesuperior
+<Multi_key> <s> <3> : "\xc2\xb3" threesuperior
+<Multi_key> <3> <s> : "\xc2\xb3" threesuperior
+<Multi_key> <p> <exclam> : "\xc2\xb6" paragraph
+<Multi_key> <exclam> <p> : "\xc2\xb6" paragraph
+<Multi_key> <P> <exclam> : "\xc2\xb6" paragraph
+<Multi_key> <exclam> <P> : "\xc2\xb6" paragraph
+<Multi_key> <period> <asciicircum> : "\xc2\xb7" periodcentered
+<Multi_key> <asciicircum> <period> : "\xc2\xb7" periodcentered
+<Multi_key> <period> <period> : "\xc2\xb7" periodcentered
+<Multi_key> <1> <4> : "\xc2\xbc" onequarter
+<Multi_key> <1> <2> : "\xc2\xbd" onehalf
+<Multi_key> <3> <4> : "\xc2\xbe" threequarters
+<Multi_key> <question> <question> : "\xc2\xbf" questiondown
+<Multi_key> <space> <space> : "\xc2\xa0" nobreakspace
+<Multi_key> <bar> <bar> : "\xc2\xa6" brokenbar
+<Multi_key> <exclam> <asciicircum> : "\xc2\xa6" brokenbar
+<Multi_key> <asciicircum> <exclam> : "\xc2\xa6" brokenbar
+<Multi_key> <V> <B> : "\xc2\xa6" brokenbar
+<Multi_key> <B> <V> : "\xc2\xa6" brokenbar
+<Multi_key> <v> <b> : "\xc2\xa6" brokenbar
+<Multi_key> <b> <v> : "\xc2\xa6" brokenbar
+<Multi_key> <minus> <comma> : "\xc2\xac" notsign
+<Multi_key> <comma> <minus> : "\xc2\xac" notsign
+<Multi_key> <minus> <minus> : "\xc2\xad" hyphen
+<Multi_key> <R> <O> : "\xc2\xae" registered
+<Multi_key> <O> <R> : "\xc2\xae" registered
+<Multi_key> <minus> <asciicircum> : "\xc2\xaf" macron
+<Multi_key> <asciicircum> <minus> : "\xc2\xaf" macron
+<Multi_key> <underscore> <asciicircum> : "\xc2\xaf" macron
+<Multi_key> <asciicircum> <underscore> : "\xc2\xaf" macron
+<Multi_key> <underscore> <underscore> : "\xc2\xaf" macron
+<Multi_key> <minus> <colon> : "\xc3\xb7" division
+<Multi_key> <colon> <minus> : "\xc3\xb7" division
+<Multi_key> <x> <x> : "\xc3\x97" multiply
+<Multi_key> <apostrophe> <apostrophe> : "\xc2\xb4" acute
+<Multi_key> <comma> <comma> : "\xc2\xb8" cedilla
+<Multi_key> <quotedbl> <quotedbl> : "\xc2\xa8" diaeresis
+<Multi_key> <A> <grave> : "\xc3\x80" Agrave
+<Multi_key> <grave> <A> : "\xc3\x80" Agrave
+<Multi_key> <A> <acute> : "\xc3\x81" Aacute
+<Multi_key> <acute> <A> : "\xc3\x81" Aacute
+<Multi_key> <A> <apostrophe> : "\xc3\x81" Aacute
+<Multi_key> <apostrophe> <A> : "\xc3\x81" Aacute
+<Multi_key> <A> <asciicircum> : "\xc3\x82" Acircumflex
+<Multi_key> <asciicircum> <A> : "\xc3\x82" Acircumflex
+<Multi_key> <A> <greater> : "\xc3\x82" Acircumflex
+<Multi_key> <greater> <A> : "\xc3\x82" Acircumflex
+<Multi_key> <A> <asciitilde> : "\xc3\x83" Atilde
+<Multi_key> <asciitilde> <A> : "\xc3\x83" Atilde
+<Multi_key> <A> <quotedbl> : "\xc3\x84" Adiaeresis
+<Multi_key> <quotedbl> <A> : "\xc3\x84" Adiaeresis
+<Multi_key> <A> <asterisk> : "\xc3\x85" Aring
+<Multi_key> <asterisk> <A> : "\xc3\x85" Aring
+<Multi_key> <A> <E> : "\xc3\x86" AE
+<Multi_key> <a> <grave> : "\xc3\xa0" agrave
+<Multi_key> <grave> <a> : "\xc3\xa0" agrave
+<Multi_key> <a> <acute> : "\xc3\xa1" aacute
+<Multi_key> <acute> <a> : "\xc3\xa1" aacute
+<Multi_key> <a> <apostrophe> : "\xc3\xa1" aacute
+<Multi_key> <apostrophe> <a> : "\xc3\xa1" aacute
+<Multi_key> <a> <asciicircum> : "\xc3\xa2" acircumflex
+<Multi_key> <asciicircum> <a> : "\xc3\xa2" acircumflex
+<Multi_key> <a> <greater> : "\xc3\xa2" acircumflex
+<Multi_key> <greater> <a> : "\xc3\xa2" acircumflex
+<Multi_key> <a> <asciitilde> : "\xc3\xa3" atilde
+<Multi_key> <asciitilde> <a> : "\xc3\xa3" atilde
+<Multi_key> <a> <quotedbl> : "\xc3\xa4" adiaeresis
+<Multi_key> <quotedbl> <a> : "\xc3\xa4" adiaeresis
+<Multi_key> <a> <asterisk> : "\xc3\xa5" aring
+<Multi_key> <asterisk> <a> : "\xc3\xa5" aring
+<Multi_key> <a> <e> : "\xc3\xa6" ae
+<Multi_key> <C> <comma> : "\xc3\x87" Ccedilla
+<Multi_key> <comma> <C> : "\xc3\x87" Ccedilla
+<Multi_key> <c> <comma> : "\xc3\xa7" ccedilla
+<Multi_key> <comma> <c> : "\xc3\xa7" ccedilla
+#<Multi_key> <minus> <D> : "\xc3\x90" ETH
+#<Multi_key> <minus> <d> : "\xc3\xb0" eth
+<Multi_key> <D> <minus> : "\xc3\x90" ETH
+<Multi_key> <d> <minus> : "\xc3\xb0" eth
+<Multi_key> <slash> <D> : "\xc4\x90" Dstroke
+<Multi_key> <slash> <d> : "\xc4\x91" dstroke
+<Multi_key> <E> <grave> : "\xc3\x88" Egrave
+<Multi_key> <grave> <E> : "\xc3\x88" Egrave
+<Multi_key> <E> <acute> : "\xc3\x89" Eacute
+<Multi_key> <acute> <E> : "\xc3\x89" Eacute
+<Multi_key> <E> <apostrophe> : "\xc3\x89" Eacute
+<Multi_key> <apostrophe> <E> : "\xc3\x89" Eacute
+<Multi_key> <E> <asciicircum> : "\xc3\x8a" Ecircumflex
+<Multi_key> <asciicircum> <E> : "\xc3\x8a" Ecircumflex
+<Multi_key> <E> <greater> : "\xc3\x8a" Ecircumflex
+<Multi_key> <greater> <E> : "\xc3\x8a" Ecircumflex
+<Multi_key> <E> <quotedbl> : "\xc3\x8b" Ediaeresis
+<Multi_key> <quotedbl> <E> : "\xc3\x8b" Ediaeresis
+<Multi_key> <e> <grave> : "\xc3\xa8" egrave
+<Multi_key> <grave> <e> : "\xc3\xa8" egrave
+<Multi_key> <e> <acute> : "\xc3\xa9" eacute
+<Multi_key> <acute> <e> : "\xc3\xa9" eacute
+<Multi_key> <e> <apostrophe> : "\xc3\xa9" eacute
+<Multi_key> <apostrophe> <e> : "\xc3\xa9" eacute
+<Multi_key> <e> <asciicircum> : "\xc3\xaa" ecircumflex
+<Multi_key> <asciicircum> <e> : "\xc3\xaa" ecircumflex
+<Multi_key> <e> <greater> : "\xc3\xaa" ecircumflex
+<Multi_key> <greater> <e> : "\xc3\xaa" ecircumflex
+<Multi_key> <e> <quotedbl> : "\xc3\xab" ediaeresis
+<Multi_key> <quotedbl> <e> : "\xc3\xab" ediaeresis
+<Multi_key> <I> <grave> : "\xc3\x8c" Igrave
+<Multi_key> <grave> <I> : "\xc3\x8c" Igrave
+<Multi_key> <I> <acute> : "\xc3\x8d" Iacute
+<Multi_key> <acute> <I> : "\xc3\x8d" Iacute
+<Multi_key> <I> <apostrophe> : "\xc3\x8d" Iacute
+<Multi_key> <apostrophe> <I> : "\xc3\x8d" Iacute
+<Multi_key> <I> <asciicircum> : "\xc3\x8e" Icircumflex
+<Multi_key> <asciicircum> <I> : "\xc3\x8e" Icircumflex
+<Multi_key> <I> <greater> : "\xc3\x8e" Icircumflex
+<Multi_key> <greater> <I> : "\xc3\x8e" Icircumflex
+<Multi_key> <I> <quotedbl> : "\xc3\x8f" Idiaeresis
+<Multi_key> <quotedbl> <I> : "\xc3\x8f" Idiaeresis
+<Multi_key> <i> <grave> : "\xc3\xac" igrave
+<Multi_key> <grave> <i> : "\xc3\xac" igrave
+<Multi_key> <i> <acute> : "\xc3\xad" iacute
+<Multi_key> <acute> <i> : "\xc3\xad" iacute
+<Multi_key> <i> <apostrophe> : "\xc3\xad" iacute
+<Multi_key> <apostrophe> <i> : "\xc3\xad" iacute
+<Multi_key> <i> <asciicircum> : "\xc3\xae" icircumflex
+<Multi_key> <asciicircum> <i> : "\xc3\xae" icircumflex
+<Multi_key> <i> <greater> : "\xc3\xae" icircumflex
+<Multi_key> <greater> <i> : "\xc3\xae" icircumflex
+<Multi_key> <i> <quotedbl> : "\xc3\xaf" idiaeresis
+<Multi_key> <quotedbl> <i> : "\xc3\xaf" idiaeresis
+<Multi_key> <N> <asciitilde> : "\xc3\x91" Ntilde
+<Multi_key> <asciitilde> <N> : "\xc3\x91" Ntilde
+<Multi_key> <N> <minus> : "\xc3\x91" Ntilde
+<Multi_key> <minus> <N> : "\xc3\x91" Ntilde
+<Multi_key> <n> <asciitilde> : "\xc3\xb1" ntilde
+<Multi_key> <asciitilde> <n> : "\xc3\xb1" ntilde
+<Multi_key> <n> <minus> : "\xc3\xb1" ntilde
+<Multi_key> <minus> <n> : "\xc3\xb1" ntilde
+<Multi_key> <O> <grave> : "\xc3\x92" Ograve
+<Multi_key> <grave> <O> : "\xc3\x92" Ograve
+<Multi_key> <O> <acute> : "\xc3\x93" Oacute
+<Multi_key> <acute> <O> : "\xc3\x93" Oacute
+<Multi_key> <O> <apostrophe> : "\xc3\x93" Oacute
+<Multi_key> <apostrophe> <O> : "\xc3\x93" Oacute
+<Multi_key> <O> <asciicircum> : "\xc3\x94" Ocircumflex
+<Multi_key> <asciicircum> <O> : "\xc3\x94" Ocircumflex
+<Multi_key> <O> <greater> : "\xc3\x94" Ocircumflex
+<Multi_key> <greater> <O> : "\xc3\x94" Ocircumflex
+<Multi_key> <O> <asciitilde> : "\xc3\x95" Otilde
+<Multi_key> <asciitilde> <O> : "\xc3\x95" Otilde
+<Multi_key> <O> <quotedbl> : "\xc3\x96" Odiaeresis
+<Multi_key> <quotedbl> <O> : "\xc3\x96" Odiaeresis
+<Multi_key> <O> <slash> : "\xc3\x98" Ooblique
+<Multi_key> <slash> <O> : "\xc3\x98" Ooblique
+<Multi_key> <o> <grave> : "\xc3\xb2" ograve
+<Multi_key> <grave> <o> : "\xc3\xb2" ograve
+<Multi_key> <o> <acute> : "\xc3\xb3" oacute
+<Multi_key> <acute> <o> : "\xc3\xb3" oacute
+<Multi_key> <o> <apostrophe> : "\xc3\xb3" oacute
+<Multi_key> <apostrophe> <o> : "\xc3\xb3" oacute
+<Multi_key> <o> <asciicircum> : "\xc3\xb4" ocircumflex
+<Multi_key> <asciicircum> <o> : "\xc3\xb4" ocircumflex
+<Multi_key> <o> <greater> : "\xc3\xb4" ocircumflex
+<Multi_key> <greater> <o> : "\xc3\xb4" ocircumflex
+<Multi_key> <o> <asciitilde> : "\xc3\xb5" otilde
+<Multi_key> <asciitilde> <o> : "\xc3\xb5" otilde
+<Multi_key> <o> <quotedbl> : "\xc3\xb6" odiaeresis
+<Multi_key> <quotedbl> <o> : "\xc3\xb6" odiaeresis
+<Multi_key> <o> <slash> : "\xc3\xb8" oslash
+<Multi_key> <slash> <o> : "\xc3\xb8" oslash
+<Multi_key> <U> <grave> : "\xc3\x99" Ugrave
+<Multi_key> <grave> <U> : "\xc3\x99" Ugrave
+<Multi_key> <U> <acute> : "\xc3\x9a" Uacute
+<Multi_key> <acute> <U> : "\xc3\x9a" Uacute
+<Multi_key> <U> <apostrophe> : "\xc3\x9a" Uacute
+<Multi_key> <apostrophe> <U> : "\xc3\x9a" Uacute
+<Multi_key> <U> <asciicircum> : "\xc3\x9b" Ucircumflex
+<Multi_key> <asciicircum> <U> : "\xc3\x9b" Ucircumflex
+<Multi_key> <U> <greater> : "\xc3\x9b" Ucircumflex
+<Multi_key> <greater> <U> : "\xc3\x9b" Ucircumflex
+<Multi_key> <U> <quotedbl> : "\xc3\x9c" Udiaeresis
+<Multi_key> <quotedbl> <U> : "\xc3\x9c" Udiaeresis
+<Multi_key> <u> <grave> : "\xc3\xb9" ugrave
+<Multi_key> <grave> <u> : "\xc3\xb9" ugrave
+<Multi_key> <u> <acute> : "\xc3\xba" uacute
+<Multi_key> <acute> <u> : "\xc3\xba" uacute
+<Multi_key> <u> <apostrophe> : "\xc3\xba" uacute
+<Multi_key> <apostrophe> <u> : "\xc3\xba" uacute
+<Multi_key> <u> <asciicircum> : "\xc3\xbb" ucircumflex
+<Multi_key> <asciicircum> <u> : "\xc3\xbb" ucircumflex
+<Multi_key> <u> <greater> : "\xc3\xbb" ucircumflex
+<Multi_key> <greater> <u> : "\xc3\xbb" ucircumflex
+<Multi_key> <u> <quotedbl> : "\xc3\xbc" udiaeresis
+<Multi_key> <quotedbl> <u> : "\xc3\xbc" udiaeresis
+<Multi_key> <s> <s> : "\xc3\x9f" ssharp
+<Multi_key> <T> <H> : "\xc3\x9e" THORN
+<Multi_key> <t> <h> : "\xc3\xbe" thorn
+<Multi_key> <Y> <acute> : "\xc3\x9d" Yacute
+<Multi_key> <acute> <Y> : "\xc3\x9d" Yacute
+<Multi_key> <Y> <apostrophe> : "\xc3\x9d" Yacute
+<Multi_key> <apostrophe> <Y> : "\xc3\x9d" Yacute
+<Multi_key> <y> <acute> : "\xc3\xbd" yacute
+<Multi_key> <acute> <y> : "\xc3\xbd" yacute
+<Multi_key> <y> <apostrophe> : "\xc3\xbd" yacute
+<Multi_key> <apostrophe> <y> : "\xc3\xbd" yacute
+<Multi_key> <y> <quotedbl> : "\xc3\xbf" ydiaeresis
+<Multi_key> <quotedbl> <y> : "\xc3\xbf" ydiaeresis
+<ecaron> : "\xc4\x9b" ecaron
+<scaron> : "\xc5\xa1" scaron
+<ccaron> : "\xc4\x8d" ccaron
+<rcaron> : "\xc5\x99" rcaron
+<yacute> : "\xc3\xbd" yacute
+<aacute> : "\xc3\xa1" aacute
+<iacute> : "\xc3\xad" iacute
+<eacute> : "\xc3\xa9" eacute
+<uacute> : "\xc3\xba" uacute
+<uring> : "\xc5\xaf" uring
+<section> : "\xc2\xa7" section
+<ssharp> : "\xc3\x9f" ssharp
+<zabovedot> : "\xc5\xbc" zabovedot
+<Zabovedot> : "\xc5\xbb" Zabovedot
+<ogonek> : "\xcb\x9b" ogonek
+<oacute> : "\xc3\xb3" oacute
+<zacute> : "\xc5\xba" zacute
+<lstroke> : "\xc5\x82" lstroke
+<Lstroke> : "\xc5\x81" Lstroke
+<aogonek> : "\xc4\x85" aogonek
+<eogonek> : "\xc4\x99" eogonek
+<currency> : "\xc2\xa4" currency
+<sacute> : "\xc5\x9b" sacute
+<nacute> : "\xc5\x84" nacute
+<cacute> : "\xc4\x87" cacute
+<degree> : "\xc2\xb0" degree
+<Odiaeresis> : "\xc3\x96" Odiaeresis
+<Udiaeresis> : "\xc3\x9c" Udiaeresis
+<odiaeresis> : "\xc3\xb6" odiaeresis
+<udiaeresis> : "\xc3\xbc" udiaeresis
+<Oacute> : "\xc3\x93" Oacute
+<odoubleacute> : "\xc5\x91" odoubleacute
+<Odoubleacute> : "\xc5\x90" Odoubleacute
+<Uacute> : "\xc3\x9a" Uacute
+<Eacute> : "\xc3\x89" Eacute
+<Aacute> : "\xc3\x81" Aacute
+<adiaeresis> : "\xc3\xa4" adiaeresis
+<Adiaeresis> : "\xc3\x84" Adiaeresis
+<udoubleacute> : "\xc5\xb1" udoubleacute
+<Udoubleacute> : "\xc5\xb0" Udoubleacute
+<Iacute> : "\xc3\x8d" Iacute
+<dead_circumflex> <slash> : "\x7c" bar
+<dead_grave> <space> : "\x60" grave
+<dead_acute> <space> : "\x27" apostrophe
+<dead_diaeresis> <space> : "\xc2\xa8" diaeresis
+<dead_circumflex> <space> : "\x5e" asciicircum
+<dead_tilde> <space> : "\x7e" asciitilde
+<dead_circumflex> <0> : "\xc2\xb0" degree
+<dead_circumflex> <1> : "\xc2\xb9" onesuperior
+<dead_circumflex> <2> : "\xc2\xb2" twosuperior
+<dead_circumflex> <3> : "\xc2\xb3" threesuperior
+<dead_circumflex> <period> : "\xc2\xb7" periodcentered
+<dead_circumflex> <exclam> : "\xc2\xa6" brokenbar
+<dead_cedilla> <minus> : "\xc2\xac" notsign
+<dead_circumflex> <minus> : "\xc2\xaf" macron
+<dead_circumflex> <underscore> : "\xc2\xaf" macron
+<dead_acute> <apostrophe> : "\xc2\xb4" acute
+<dead_cedilla> <comma> : "\xc2\xb8" cedilla
+<dead_diaeresis> <quotedbl> : "\xc2\xa8" diaeresis
+<dead_grave> <A> : "\xc3\x80" Agrave
+<dead_acute> <A> : "\xc3\x81" Aacute
+<dead_circumflex> <A> : "\xc3\x82" Acircumflex
+<dead_tilde> <A> : "\xc3\x83" Atilde
+<dead_diaeresis> <A> : "\xc3\x84" Adiaeresis
+<dead_grave> <a> : "\xc3\xa0" agrave
+<dead_acute> <a> : "\xc3\xa1" aacute
+<dead_circumflex> <a> : "\xc3\xa2" acircumflex
+<dead_tilde> <a> : "\xc3\xa3" atilde
+<dead_diaeresis> <a> : "\xc3\xa4" adiaeresis
+<dead_cedilla> <C> : "\xc3\x87" Ccedilla
+<dead_cedilla> <c> : "\xc3\xa7" ccedilla
+<dead_grave> <E> : "\xc3\x88" Egrave
+<dead_acute> <E> : "\xc3\x89" Eacute
+<dead_circumflex> <E> : "\xc3\x8a" Ecircumflex
+<dead_diaeresis> <E> : "\xc3\x8b" Ediaeresis
+<dead_grave> <e> : "\xc3\xa8" egrave
+<dead_acute> <e> : "\xc3\xa9" eacute
+<dead_circumflex> <e> : "\xc3\xaa" ecircumflex
+<dead_diaeresis> <e> : "\xc3\xab" ediaeresis
+<dead_grave> <I> : "\xc3\x8c" Igrave
+<dead_acute> <I> : "\xc3\x8d" Iacute
+<dead_circumflex> <I> : "\xc3\x8e" Icircumflex
+<dead_diaeresis> <I> : "\xc3\x8f" Idiaeresis
+<dead_grave> <i> : "\xc3\xac" igrave
+<dead_acute> <i> : "\xc3\xad" iacute
+<dead_circumflex> <i> : "\xc3\xae" icircumflex
+<dead_diaeresis> <i> : "\xc3\xaf" idiaeresis
+<dead_tilde> <N> : "\xc3\x91" Ntilde
+<dead_tilde> <n> : "\xc3\xb1" ntilde
+<dead_grave> <O> : "\xc3\x92" Ograve
+<dead_acute> <O> : "\xc3\x93" Oacute
+<dead_circumflex> <O> : "\xc3\x94" Ocircumflex
+<dead_tilde> <O> : "\xc3\x95" Otilde
+<dead_diaeresis> <O> : "\xc3\x96" Odiaeresis
+<dead_grave> <o> : "\xc3\xb2" ograve
+<dead_acute> <o> : "\xc3\xb3" oacute
+<dead_circumflex> <o> : "\xc3\xb4" ocircumflex
+<dead_tilde> <o> : "\xc3\xb5" otilde
+<dead_diaeresis> <o> : "\xc3\xb6" odiaeresis
+<dead_cedilla> <S> : "\xc5\x9e" Scedilla
+<dead_cedilla> <s> : "\xc5\x9f" scedilla
+<dead_grave> <U> : "\xc3\x99" Ugrave
+<dead_acute> <U> : "\xc3\x9a" Uacute
+<dead_circumflex> <U> : "\xc3\x9b" Ucircumflex
+<dead_diaeresis> <U> : "\xc3\x9c" Udiaeresis
+<dead_grave> <u> : "\xc3\xb9" ugrave
+<dead_acute> <u> : "\xc3\xba" uacute
+<dead_circumflex> <u> : "\xc3\xbb" ucircumflex
+<dead_diaeresis> <u> : "\xc3\xbc" udiaeresis
+<dead_acute> <Y> : "\xc3\x9d" Yacute
+<dead_acute> <y> : "\xc3\xbd" yacute
+<Multi_key> <caron> <Z> : "\xc5\xbd" Zcaron
+<Multi_key> <Z> <caron> : "\xc5\xbd" Zcaron
+<Multi_key> <v> <Z> : "\xc5\xbd" Zcaron
+<Multi_key> <Z> <v> : "\xc5\xbd" Zcaron
+<zcaron> : "\xc5\xbe" zcaron
+<Multi_key> <caron> <z> : "\xc5\xbe" zcaron
+<Multi_key> <z> <caron> : "\xc5\xbe" zcaron
+<Multi_key> <z> <v> : "\xc5\xbe" zcaron
+<Multi_key> <v> <z> : "\xc5\xbe" zcaron
+<dead_diaeresis> <y> : "\xc3\xbf" ydiaeresis
+Ctrl<T> <plus> <plus> : "\x23" numbersign
+Ctrl<T> <apostrophe> <space> : "\x27" apostrophe
+Ctrl<T> <space> <apostrophe> : "\x27" apostrophe
+Ctrl<T> <A> <A> : "\x40" at
+Ctrl<T> <parenleft> <parenleft> : "\x5b" bracketleft
+Ctrl<T> <slash> <slash> : "\x5c" backslash
+Ctrl<T> <slash> <less> : "\x5c" backslash
+Ctrl<T> <less> <slash> : "\x5c" backslash
+Ctrl<T> <parenright> <parenright> : "\x5d" bracketright
+Ctrl<T> <asciicircum> <space> : "\x5e" asciicircum
+Ctrl<T> <space> <asciicircum> : "\x5e" asciicircum
+Ctrl<T> <greater> <space> : "\x5e" asciicircum
+Ctrl<T> <space> <greater> : "\x5e" asciicircum
+Ctrl<T> <grave> <space> : "\x60" grave
+Ctrl<T> <space> <grave> : "\x60" grave
+Ctrl<T> <parenleft> <minus> : "\x7b" braceleft
+Ctrl<T> <minus> <parenleft> : "\x7b" braceleft
+Ctrl<T> <slash> <asciicircum> : "\x7c" bar
+Ctrl<T> <asciicircum> <slash> : "\x7c" bar
+Ctrl<T> <V> <L> : "\x7c" bar
+Ctrl<T> <L> <V> : "\x7c" bar
+Ctrl<T> <v> <l> : "\x7c" bar
+Ctrl<T> <l> <v> : "\x7c" bar
+Ctrl<T> <parenright> <minus> : "\x7d" braceright
+Ctrl<T> <minus> <parenright> : "\x7d" braceright
+Ctrl<T> <asciitilde> <space> : "\x7e" asciitilde
+Ctrl<T> <space> <asciitilde> : "\x7e" asciitilde
+Ctrl<T> <minus> <space> : "\x7e" asciitilde
+Ctrl<T> <space> <minus> : "\x7e" asciitilde
+Ctrl<T> <exclam> <exclam> : "\xc2\xa1" exclamdown
+Ctrl<T> <c> <slash> : "\xc2\xa2" cent
+Ctrl<T> <slash> <c> : "\xc2\xa2" cent
+Ctrl<T> <C> <slash> : "\xc2\xa2" cent
+Ctrl<T> <slash> <C> : "\xc2\xa2" cent
+Ctrl<T> <C> <bar> : "\xc2\xa2" cent
+Ctrl<T> <bar> <C> : "\xc2\xa2" cent
+Ctrl<T> <c> <bar> : "\xc2\xa2" cent
+Ctrl<T> <bar> <c> : "\xc2\xa2" cent
+Ctrl<T> <acute> <L> : "\xc4\xb9" Lacute
+Ctrl<T> <L> <acute> : "\xc4\xb9" Lacute
+Ctrl<T> <acute> <l> : "\xc4\xba" lacute
+Ctrl<T> <l> <acute> : "\xc4\xba" lacute
+Ctrl<T> <l> <minus> : "\xc2\xa3" sterling
+Ctrl<T> <minus> <l> : "\xc2\xa3" sterling
+Ctrl<T> <L> <minus> : "\xc2\xa3" sterling
+Ctrl<T> <minus> <L> : "\xc2\xa3" sterling
+Ctrl<T> <l> <equal> : "\xc2\xa3" sterling
+Ctrl<T> <equal> <l> : "\xc2\xa3" sterling
+Ctrl<T> <L> <equal> : "\xc2\xa3" sterling
+Ctrl<T> <equal> <L> : "\xc2\xa3" sterling
+Ctrl<T> <y> <minus> : "\xc2\xa5" yen
+Ctrl<T> <minus> <y> : "\xc2\xa5" yen
+Ctrl<T> <Y> <minus> : "\xc2\xa5" yen
+Ctrl<T> <minus> <Y> : "\xc2\xa5" yen
+Ctrl<T> <y> <equal> : "\xc2\xa5" yen
+Ctrl<T> <equal> <y> : "\xc2\xa5" yen
+Ctrl<T> <Y> <equal> : "\xc2\xa5" yen
+Ctrl<T> <equal> <Y> : "\xc2\xa5" yen
+Ctrl<T> <s> <o> : "\xc2\xa7" section
+Ctrl<T> <o> <s> : "\xc2\xa7" section
+Ctrl<T> <S> <O> : "\xc2\xa7" section
+Ctrl<T> <O> <S> : "\xc2\xa7" section
+Ctrl<T> <S> <exclam> : "\xc2\xa7" section
+Ctrl<T> <exclam> <S> : "\xc2\xa7" section
+Ctrl<T> <s> <exclam> : "\xc2\xa7" section
+Ctrl<T> <exclam> <s> : "\xc2\xa7" section
+Ctrl<T> <S> <0> : "\xc2\xa7" section
+Ctrl<T> <0> <S> : "\xc2\xa7" section
+Ctrl<T> <s> <0> : "\xc2\xa7" section
+Ctrl<T> <0> <s> : "\xc2\xa7" section
+Ctrl<T> <x> <o> : "\xc2\xa4" currency
+Ctrl<T> <o> <x> : "\xc2\xa4" currency
+Ctrl<T> <X> <O> : "\xc2\xa4" currency
+Ctrl<T> <O> <X> : "\xc2\xa4" currency
+Ctrl<T> <x> <O> : "\xc2\xa4" currency
+Ctrl<T> <O> <x> : "\xc2\xa4" currency
+Ctrl<T> <X> <o> : "\xc2\xa4" currency
+Ctrl<T> <o> <X> : "\xc2\xa4" currency
+Ctrl<T> <x> <0> : "\xc2\xa4" currency
+Ctrl<T> <0> <x> : "\xc2\xa4" currency
+Ctrl<T> <X> <0> : "\xc2\xa4" currency
+Ctrl<T> <0> <X> : "\xc2\xa4" currency
+Ctrl<T> <c> <o> : "\xc2\xa9" copyright
+Ctrl<T> <o> <c> : "\xc2\xa9" copyright
+Ctrl<T> <C> <O> : "\xc2\xa9" copyright
+Ctrl<T> <O> <C> : "\xc2\xa9" copyright
+Ctrl<T> <c> <O> : "\xc2\xa9" copyright
+Ctrl<T> <O> <c> : "\xc2\xa9" copyright
+Ctrl<T> <C> <o> : "\xc2\xa9" copyright
+Ctrl<T> <o> <C> : "\xc2\xa9" copyright
+Ctrl<T> <c> <0> : "\xc2\xa9" copyright
+Ctrl<T> <0> <c> : "\xc2\xa9" copyright
+Ctrl<T> <C> <0> : "\xc2\xa9" copyright
+Ctrl<T> <0> <C> : "\xc2\xa9" copyright
+Ctrl<T> <a> <underscore> : "\xc2\xaa" ordfeminine
+Ctrl<T> <underscore> <a> : "\xc2\xaa" ordfeminine
+Ctrl<T> <A> <underscore> : "\xc2\xaa" ordfeminine
+Ctrl<T> <underscore> <A> : "\xc2\xaa" ordfeminine
+Ctrl<T> <O> <underscore> : "\xc2\xba" masculine
+Ctrl<T> <o> <underscore> : "\xc2\xba" masculine
+Ctrl<T> <underscore> <o> : "\xc2\xba" masculine
+Ctrl<T> <underscore> <O> : "\xc2\xba" masculine
+Ctrl<T> <less> <less> : "\xc2\xab" guillemotleft
+Ctrl<T> <greater> <greater> : "\xc2\xbb" guillemotright
+Ctrl<T> <0> <asciicircum> : "\xc2\xb0" degree
+Ctrl<T> <asciicircum> <0> : "\xc2\xb0" degree
+Ctrl<T> <0> <asterisk> : "\xc2\xb0" degree
+Ctrl<T> <asterisk> <0> : "\xc2\xb0" degree
+Ctrl<T> <plus> <minus> : "\xc2\xb1" plusminus
+Ctrl<T> <minus> <plus> : "\xc2\xb1" plusminus
+Ctrl<T> <slash> <u> : "\xc2\xb5" mu
+Ctrl<T> <u> <slash> : "\xc2\xb5" mu
+Ctrl<T> <slash> <U> : "\xc2\xb5" mu
+Ctrl<T> <U> <slash> : "\xc2\xb5" mu
+Ctrl<T> <1> <asciicircum> : "\xc2\xb9" onesuperior
+Ctrl<T> <asciicircum> <1> : "\xc2\xb9" onesuperior
+Ctrl<T> <S> <1> : "\xc2\xb9" onesuperior
+Ctrl<T> <1> <S> : "\xc2\xb9" onesuperior
+Ctrl<T> <s> <1> : "\xc2\xb9" onesuperior
+Ctrl<T> <1> <s> : "\xc2\xb9" onesuperior
+Ctrl<T> <2> <asciicircum> : "\xc2\xb2" twosuperior
+Ctrl<T> <asciicircum> <2> : "\xc2\xb2" twosuperior
+Ctrl<T> <S> <2> : "\xc2\xb2" twosuperior
+Ctrl<T> <2> <S> : "\xc2\xb2" twosuperior
+Ctrl<T> <s> <2> : "\xc2\xb2" twosuperior
+Ctrl<T> <2> <s> : "\xc2\xb2" twosuperior
+Ctrl<T> <3> <asciicircum> : "\xc2\xb3" threesuperior
+Ctrl<T> <asciicircum> <3> : "\xc2\xb3" threesuperior
+Ctrl<T> <S> <3> : "\xc2\xb3" threesuperior
+Ctrl<T> <3> <S> : "\xc2\xb3" threesuperior
+Ctrl<T> <s> <3> : "\xc2\xb3" threesuperior
+Ctrl<T> <3> <s> : "\xc2\xb3" threesuperior
+Ctrl<T> <p> <exclam> : "\xc2\xb6" paragraph
+Ctrl<T> <exclam> <p> : "\xc2\xb6" paragraph
+Ctrl<T> <P> <exclam> : "\xc2\xb6" paragraph
+Ctrl<T> <exclam> <P> : "\xc2\xb6" paragraph
+Ctrl<T> <period> <asciicircum> : "\xc2\xb7" periodcentered
+Ctrl<T> <asciicircum> <period> : "\xc2\xb7" periodcentered
+Ctrl<T> <period> <period> : "\xc2\xb7" periodcentered
+Ctrl<T> <1> <4> : "\xc2\xbc" onequarter
+Ctrl<T> <1> <2> : "\xc2\xbd" onehalf
+Ctrl<T> <3> <4> : "\xc2\xbe" threequarters
+Ctrl<T> <question> <question> : "\xc2\xbf" questiondown
+Ctrl<T> <space> <space> : "\xc2\xa0" nobreakspace
+Ctrl<T> <bar> <bar> : "\xc2\xa6" brokenbar
+Ctrl<T> <exclam> <asciicircum> : "\xc2\xa6" brokenbar
+Ctrl<T> <asciicircum> <exclam> : "\xc2\xa6" brokenbar
+Ctrl<T> <V> <B> : "\xc2\xa6" brokenbar
+Ctrl<T> <B> <V> : "\xc2\xa6" brokenbar
+Ctrl<T> <v> <b> : "\xc2\xa6" brokenbar
+Ctrl<T> <b> <v> : "\xc2\xa6" brokenbar
+Ctrl<T> <minus> <comma> : "\xc2\xac" notsign
+Ctrl<T> <comma> <minus> : "\xc2\xac" notsign
+Ctrl<T> <minus> <minus> : "\xc2\xad" hyphen
+Ctrl<T> <R> <O> : "\xc2\xae" registered
+Ctrl<T> <O> <R> : "\xc2\xae" registered
+Ctrl<T> <minus> <asciicircum> : "\xc2\xaf" macron
+Ctrl<T> <asciicircum> <minus> : "\xc2\xaf" macron
+Ctrl<T> <underscore> <asciicircum> : "\xc2\xaf" macron
+Ctrl<T> <asciicircum> <underscore> : "\xc2\xaf" macron
+Ctrl<T> <underscore> <underscore> : "\xc2\xaf" macron
+Ctrl<T> <minus> <colon> : "\xc3\xb7" division
+Ctrl<T> <colon> <minus> : "\xc3\xb7" division
+Ctrl<T> <x> <x> : "\xc3\x97" multiply
+Ctrl<T> <apostrophe> <apostrophe> : "\xc2\xb4" acute
+Ctrl<T> <comma> <comma> : "\xc2\xb8" cedilla
+Ctrl<T> <quotedbl> <quotedbl> : "\xc2\xa8" diaeresis
+Ctrl<T> <A> <grave> : "\xc3\x80" Agrave
+Ctrl<T> <grave> <A> : "\xc3\x80" Agrave
+Ctrl<T> <A> <acute> : "\xc3\x81" Aacute
+Ctrl<T> <acute> <A> : "\xc3\x81" Aacute
+Ctrl<T> <A> <apostrophe> : "\xc3\x81" Aacute
+Ctrl<T> <apostrophe> <A> : "\xc3\x81" Aacute
+Ctrl<T> <A> <asciicircum> : "\xc3\x82" Acircumflex
+Ctrl<T> <asciicircum> <A> : "\xc3\x82" Acircumflex
+Ctrl<T> <A> <greater> : "\xc3\x82" Acircumflex
+Ctrl<T> <greater> <A> : "\xc3\x82" Acircumflex
+Ctrl<T> <A> <asciitilde> : "\xc3\x83" Atilde
+Ctrl<T> <asciitilde> <A> : "\xc3\x83" Atilde
+Ctrl<T> <A> <minus> : "\xc3\x83" Atilde
+Ctrl<T> <minus> <A> : "\xc3\x83" Atilde
+Ctrl<T> <A> <quotedbl> : "\xc3\x84" Adiaeresis
+Ctrl<T> <quotedbl> <A> : "\xc3\x84" Adiaeresis
+Ctrl<T> <A> <asterisk> : "\xc3\x85" Aring
+Ctrl<T> <asterisk> <A> : "\xc3\x85" Aring
+Ctrl<T> <A> <E> : "\xc3\x86" AE
+Ctrl<T> <a> <grave> : "\xc3\xa0" agrave
+Ctrl<T> <grave> <a> : "\xc3\xa0" agrave
+Ctrl<T> <a> <acute> : "\xc3\xa1" aacute
+Ctrl<T> <acute> <a> : "\xc3\xa1" aacute
+Ctrl<T> <a> <apostrophe> : "\xc3\xa1" aacute
+Ctrl<T> <apostrophe> <a> : "\xc3\xa1" aacute
+Ctrl<T> <a> <asciicircum> : "\xc3\xa2" acircumflex
+Ctrl<T> <asciicircum> <a> : "\xc3\xa2" acircumflex
+Ctrl<T> <a> <greater> : "\xc3\xa2" acircumflex
+Ctrl<T> <greater> <a> : "\xc3\xa2" acircumflex
+Ctrl<T> <a> <asciitilde> : "\xc3\xa3" atilde
+Ctrl<T> <asciitilde> <a> : "\xc3\xa3" atilde
+Ctrl<T> <a> <minus> : "\xc3\xa3" atilde
+Ctrl<T> <minus> <a> : "\xc3\xa3" atilde
+Ctrl<T> <a> <quotedbl> : "\xc3\xa4" adiaeresis
+Ctrl<T> <quotedbl> <a> : "\xc3\xa4" adiaeresis
+Ctrl<T> <a> <asterisk> : "\xc3\xa5" aring
+Ctrl<T> <asterisk> <a> : "\xc3\xa5" aring
+Ctrl<T> <a> <e> : "\xc3\xa6" ae
+Ctrl<T> <C> <comma> : "\xc3\x87" Ccedilla
+Ctrl<T> <comma> <C> : "\xc3\x87" Ccedilla
+Ctrl<T> <c> <comma> : "\xc3\xa7" ccedilla
+Ctrl<T> <comma> <c> : "\xc3\xa7" ccedilla
+Ctrl<T> <minus> <D> : "\xc3\x90" ETH
+Ctrl<T> <D> <minus> : "\xc3\x90" ETH
+Ctrl<T> <minus> <d> : "\xc3\xb0" eth
+Ctrl<T> <d> <minus> : "\xc3\xb0" eth
+Ctrl<T> <E> <grave> : "\xc3\x88" Egrave
+Ctrl<T> <grave> <E> : "\xc3\x88" Egrave
+Ctrl<T> <E> <acute> : "\xc3\x89" Eacute
+Ctrl<T> <acute> <E> : "\xc3\x89" Eacute
+Ctrl<T> <E> <apostrophe> : "\xc3\x89" Eacute
+Ctrl<T> <apostrophe> <E> : "\xc3\x89" Eacute
+Ctrl<T> <E> <asciicircum> : "\xc3\x8a" Ecircumflex
+Ctrl<T> <asciicircum> <E> : "\xc3\x8a" Ecircumflex
+Ctrl<T> <E> <greater> : "\xc3\x8a" Ecircumflex
+Ctrl<T> <greater> <E> : "\xc3\x8a" Ecircumflex
+Ctrl<T> <E> <quotedbl> : "\xc3\x8b" Ediaeresis
+Ctrl<T> <quotedbl> <E> : "\xc3\x8b" Ediaeresis
+Ctrl<T> <e> <grave> : "\xc3\xa8" egrave
+Ctrl<T> <grave> <e> : "\xc3\xa8" egrave
+Ctrl<T> <e> <acute> : "\xc3\xa9" eacute
+Ctrl<T> <acute> <e> : "\xc3\xa9" eacute
+Ctrl<T> <e> <apostrophe> : "\xc3\xa9" eacute
+Ctrl<T> <apostrophe> <e> : "\xc3\xa9" eacute
+Ctrl<T> <e> <asciicircum> : "\xc3\xaa" ecircumflex
+Ctrl<T> <asciicircum> <e> : "\xc3\xaa" ecircumflex
+Ctrl<T> <e> <greater> : "\xc3\xaa" ecircumflex
+Ctrl<T> <greater> <e> : "\xc3\xaa" ecircumflex
+Ctrl<T> <e> <quotedbl> : "\xc3\xab" ediaeresis
+Ctrl<T> <quotedbl> <e> : "\xc3\xab" ediaeresis
+Ctrl<T> <I> <grave> : "\xc3\x8c" Igrave
+Ctrl<T> <grave> <I> : "\xc3\x8c" Igrave
+Ctrl<T> <I> <acute> : "\xc3\x8d" Iacute
+Ctrl<T> <acute> <I> : "\xc3\x8d" Iacute
+Ctrl<T> <I> <apostrophe> : "\xc3\x8d" Iacute
+Ctrl<T> <apostrophe> <I> : "\xc3\x8d" Iacute
+Ctrl<T> <I> <asciicircum> : "\xc3\x8e" Icircumflex
+Ctrl<T> <asciicircum> <I> : "\xc3\x8e" Icircumflex
+Ctrl<T> <I> <greater> : "\xc3\x8e" Icircumflex
+Ctrl<T> <greater> <I> : "\xc3\x8e" Icircumflex
+Ctrl<T> <I> <quotedbl> : "\xc3\x8f" Idiaeresis
+Ctrl<T> <quotedbl> <I> : "\xc3\x8f" Idiaeresis
+Ctrl<T> <i> <grave> : "\xc3\xac" igrave
+Ctrl<T> <grave> <i> : "\xc3\xac" igrave
+Ctrl<T> <i> <acute> : "\xc3\xad" iacute
+Ctrl<T> <acute> <i> : "\xc3\xad" iacute
+Ctrl<T> <i> <apostrophe> : "\xc3\xad" iacute
+Ctrl<T> <apostrophe> <i> : "\xc3\xad" iacute
+Ctrl<T> <i> <asciicircum> : "\xc3\xae" icircumflex
+Ctrl<T> <asciicircum> <i> : "\xc3\xae" icircumflex
+Ctrl<T> <i> <greater> : "\xc3\xae" icircumflex
+Ctrl<T> <greater> <i> : "\xc3\xae" icircumflex
+Ctrl<T> <i> <quotedbl> : "\xc3\xaf" idiaeresis
+Ctrl<T> <quotedbl> <i> : "\xc3\xaf" idiaeresis
+Ctrl<T> <N> <asciitilde> : "\xc3\x91" Ntilde
+Ctrl<T> <asciitilde> <N> : "\xc3\x91" Ntilde
+Ctrl<T> <N> <minus> : "\xc3\x91" Ntilde
+Ctrl<T> <minus> <N> : "\xc3\x91" Ntilde
+Ctrl<T> <n> <asciitilde> : "\xc3\xb1" ntilde
+Ctrl<T> <asciitilde> <n> : "\xc3\xb1" ntilde
+Ctrl<T> <n> <minus> : "\xc3\xb1" ntilde
+Ctrl<T> <minus> <n> : "\xc3\xb1" ntilde
+Ctrl<T> <O> <grave> : "\xc3\x92" Ograve
+Ctrl<T> <grave> <O> : "\xc3\x92" Ograve
+Ctrl<T> <O> <acute> : "\xc3\x93" Oacute
+Ctrl<T> <acute> <O> : "\xc3\x93" Oacute
+Ctrl<T> <O> <apostrophe> : "\xc3\x93" Oacute
+Ctrl<T> <apostrophe> <O> : "\xc3\x93" Oacute
+Ctrl<T> <O> <asciicircum> : "\xc3\x94" Ocircumflex
+Ctrl<T> <asciicircum> <O> : "\xc3\x94" Ocircumflex
+Ctrl<T> <O> <greater> : "\xc3\x94" Ocircumflex
+Ctrl<T> <greater> <O> : "\xc3\x94" Ocircumflex
+Ctrl<T> <O> <asciitilde> : "\xc3\x95" Otilde
+Ctrl<T> <asciitilde> <O> : "\xc3\x95" Otilde
+Ctrl<T> <O> <minus> : "\xc3\x95" Otilde
+Ctrl<T> <minus> <O> : "\xc3\x95" Otilde
+Ctrl<T> <O> <quotedbl> : "\xc3\x96" Odiaeresis
+Ctrl<T> <quotedbl> <O> : "\xc3\x96" Odiaeresis
+Ctrl<T> <O> <slash> : "\xc3\x98" Ooblique
+Ctrl<T> <slash> <O> : "\xc3\x98" Ooblique
+Ctrl<T> <o> <grave> : "\xc3\xb2" ograve
+Ctrl<T> <grave> <o> : "\xc3\xb2" ograve
+Ctrl<T> <o> <acute> : "\xc3\xb3" oacute
+Ctrl<T> <acute> <o> : "\xc3\xb3" oacute
+Ctrl<T> <o> <apostrophe> : "\xc3\xb3" oacute
+Ctrl<T> <apostrophe> <o> : "\xc3\xb3" oacute
+Ctrl<T> <o> <asciicircum> : "\xc3\xb4" ocircumflex
+Ctrl<T> <asciicircum> <o> : "\xc3\xb4" ocircumflex
+Ctrl<T> <o> <greater> : "\xc3\xb4" ocircumflex
+Ctrl<T> <greater> <o> : "\xc3\xb4" ocircumflex
+Ctrl<T> <o> <asciitilde> : "\xc3\xb5" otilde
+Ctrl<T> <asciitilde> <o> : "\xc3\xb5" otilde
+Ctrl<T> <o> <minus> : "\xc3\xb5" otilde
+Ctrl<T> <minus> <o> : "\xc3\xb5" otilde
+Ctrl<T> <o> <quotedbl> : "\xc3\xb6" odiaeresis
+Ctrl<T> <quotedbl> <o> : "\xc3\xb6" odiaeresis
+Ctrl<T> <o> <slash> : "\xc3\xb8" oslash
+Ctrl<T> <slash> <o> : "\xc3\xb8" oslash
+Ctrl<T> <U> <grave> : "\xc3\x99" Ugrave
+Ctrl<T> <grave> <U> : "\xc3\x99" Ugrave
+Ctrl<T> <U> <acute> : "\xc3\x9a" Uacute
+Ctrl<T> <acute> <U> : "\xc3\x9a" Uacute
+Ctrl<T> <U> <apostrophe> : "\xc3\x9a" Uacute
+Ctrl<T> <apostrophe> <U> : "\xc3\x9a" Uacute
+Ctrl<T> <U> <asciicircum> : "\xc3\x9b" Ucircumflex
+Ctrl<T> <asciicircum> <U> : "\xc3\x9b" Ucircumflex
+Ctrl<T> <U> <greater> : "\xc3\x9b" Ucircumflex
+Ctrl<T> <greater> <U> : "\xc3\x9b" Ucircumflex
+Ctrl<T> <U> <quotedbl> : "\xc3\x9c" Udiaeresis
+Ctrl<T> <quotedbl> <U> : "\xc3\x9c" Udiaeresis
+Ctrl<T> <u> <grave> : "\xc3\xb9" ugrave
+Ctrl<T> <grave> <u> : "\xc3\xb9" ugrave
+Ctrl<T> <u> <acute> : "\xc3\xba" uacute
+Ctrl<T> <acute> <u> : "\xc3\xba" uacute
+Ctrl<T> <u> <apostrophe> : "\xc3\xba" uacute
+Ctrl<T> <apostrophe> <u> : "\xc3\xba" uacute
+Ctrl<T> <u> <asciicircum> : "\xc3\xbb" ucircumflex
+Ctrl<T> <asciicircum> <u> : "\xc3\xbb" ucircumflex
+Ctrl<T> <u> <greater> : "\xc3\xbb" ucircumflex
+Ctrl<T> <greater> <u> : "\xc3\xbb" ucircumflex
+Ctrl<T> <u> <quotedbl> : "\xc3\xbc" udiaeresis
+Ctrl<T> <quotedbl> <u> : "\xc3\xbc" udiaeresis
+Ctrl<T> <s> <s> : "\xc3\x9f" ssharp
+Ctrl<T> <T> <H> : "\xc3\x9e" THORN
+Ctrl<T> <t> <h> : "\xc3\xbe" thorn
+Ctrl<T> <Y> <acute> : "\xc3\x9d" Yacute
+Ctrl<T> <acute> <Y> : "\xc3\x9d" Yacute
+Ctrl<T> <Y> <apostrophe> : "\xc3\x9d" Yacute
+Ctrl<T> <apostrophe> <Y> : "\xc3\x9d" Yacute
+Ctrl<T> <y> <acute> : "\xc3\xbd" yacute
+Ctrl<T> <acute> <y> : "\xc3\xbd" yacute
+Ctrl<T> <y> <apostrophe> : "\xc3\xbd" yacute
+Ctrl<T> <apostrophe> <y> : "\xc3\xbd" yacute
+Ctrl<T> <y> <quotedbl> : "\xc3\xbf" ydiaeresis
+Ctrl<T> <quotedbl> <y> : "\xc3\xbf" ydiaeresis
+# turkish
+<Multi_key> <G> <u> : "\xc4\x9e" Gbreve
+<Multi_key> <u> <G> : "\xc4\x9e" Gbreve
+<Multi_key> <g> <u> : "\xc4\x9f" gbreve
+<Multi_key> <u> <g> : "\xc4\x9f" gbreve
+<Multi_key> <I> <period> : "\xc4\xb0" Iabovedot
+<Multi_key> <period> <I> : "\xc4\xb0" Iabovedot
+<Multi_key> <i> <period> : "\xc4\xb1" idotless
+<Multi_key> <period> <i> : "\xc4\xb1" idotless
+# polish
+<Multi_key> <space> <breve> : "\xcb\x98" breve
+<Multi_key> <space> <degree> : "\xc2\xb0" degree
+<Multi_key> <space> <ogonek> : "\xcb\x9b" ogonek
+<Multi_key> <space> <caron> : "\xcb\x87" caron
+<Multi_key> <space> <v> : "\xcb\x87" caron
+<Multi_key> <space> <doubleacute> : "\xcb\x9d" doubleacute
+<Multi_key> <diaeresis> <A> : "\xc3\x84" Adiaeresis
+<Multi_key> <A> <diaeresis> : "\xc3\x84" Adiaeresis
+<Multi_key> <diaeresis> <E> : "\xc3\x8b" Ediaeresis
+<Multi_key> <E> <diaeresis> : "\xc3\x8b" Ediaeresis
+<Multi_key> <diaeresis> <O> : "\xc3\x96" Odiaeresis
+<Multi_key> <O> <diaeresis> : "\xc3\x96" Odiaeresis
+<Multi_key> <diaeresis> <U> : "\xc3\x9c" Udiaeresis
+<Multi_key> <U> <diaeresis> : "\xc3\x9c" Udiaeresis
+<Multi_key> <diaeresis> <a> : "\xc3\xa4" adiaeresis
+<Multi_key> <a> <diaeresis> : "\xc3\xa4" adiaeresis
+<Multi_key> <diaeresis> <e> : "\xc3\xab" ediaeresis
+<Multi_key> <e> <diaeresis> : "\xc3\xab" ediaeresis
+<Multi_key> <diaeresis> <o> : "\xc3\xb6" odiaeresis
+<Multi_key> <o> <diaeresis> : "\xc3\xb6" odiaeresis
+<Multi_key> <diaeresis> <u> : "\xc3\xbc" udiaeresis
+<Multi_key> <u> <diaeresis> : "\xc3\xbc" udiaeresis
+<Multi_key> <acute> <R> : "\xc5\x94" Racute
+<Multi_key> <R> <acute> : "\xc5\x94" Racute
+<Multi_key> <acute> <S> : "\xc5\x9a" Sacute
+<Multi_key> <S> <acute> : "\xc5\x9a" Sacute
+<Multi_key> <acute> <Z> : "\xc4\xbe" Zacute
+<Multi_key> <Z> <acute> : "\xc4\xbe" Zacute
+<Multi_key> <acute> <n> : "\xc5\x84" nacute
+<Multi_key> <n> <acute> : "\xc5\x84" nacute
+<Multi_key> <acute> <r> : "\xc5\x95" racute
+<Multi_key> <r> <acute> : "\xc5\x95" racute
+<Multi_key> <acute> <s> : "\xc5\x9b" sacute
+<Multi_key> <s> <acute> : "\xc5\x9b" sacute
+<Multi_key> <acute> <z> : "\xc5\xba" zacute
+<Multi_key> <z> <acute> : "\xc5\xba" zacute
+<Multi_key> <0> <O> : "\xc2\xb0" degree
+<Multi_key> <o> <o> : "\xc2\xb0" degree
+<Multi_key> <comma> <S> : "\xc5\x9e" Scedilla
+<Multi_key> <S> <comma> : "\xc5\x9e" Scedilla
+<Multi_key> <comma> <T> : "\xc5\xa2" Tcedilla
+<Multi_key> <T> <comma> : "\xc5\xa2" Tcedilla
+<Multi_key> <comma> <s> : "\xc5\x9f" scedilla
+<Multi_key> <s> <comma> : "\xc5\x9f" scedilla
+<Multi_key> <comma> <t> : "\xc5\xa3" tcedilla
+<Multi_key> <t> <comma> : "\xc5\xa3" tcedilla
+<Multi_key> <caron> <C> : "\xc4\x8c" Ccaron
+<Multi_key> <C> <caron> : "\xc4\x8c" Ccaron
+<Multi_key> <caron> <D> : "\xc4\x8e" Dcaron
+<Multi_key> <D> <caron> : "\xc4\x8e" Dcaron
+<Multi_key> <caron> <E> : "\xc4\x9a" Ecaron
+<Multi_key> <E> <caron> : "\xc4\x9a" Ecaron
+<Multi_key> <caron> <L> : "\xc4\xbd" Lcaron
+<Multi_key> <L> <caron> : "\xc4\xbd" Lcaron
+<Multi_key> <caron> <N> : "\xc5\x87" Ncaron
+<Multi_key> <N> <caron> : "\xc5\x87" Ncaron
+<Multi_key> <caron> <R> : "\xc5\x98" Rcaron
+<Multi_key> <R> <caron> : "\xc5\x98" Rcaron
+<Multi_key> <caron> <S> : "\xc5\xa0" Scaron
+<Multi_key> <S> <caron> : "\xc5\xa0" Scaron
+<Multi_key> <caron> <T> : "\xc5\xa4" Tcaron
+<Multi_key> <T> <caron> : "\xc5\xa4" Tcaron
+<Multi_key> <caron> <U> : "\xc5\xae" Uring
+<Multi_key> <U> <caron> : "\xc5\xae" Uring
+<Multi_key> <caron> <c> : "\xc4\x8d" ccaron
+<Multi_key> <c> <caron> : "\xc4\x8d" ccaron
+<Multi_key> <caron> <d> : "\xc4\x8f" dcaron
+<Multi_key> <d> <caron> : "\xc4\x8f" dcaron
+<Multi_key> <caron> <e> : "\xc4\x9b" ecaron
+<Multi_key> <e> <caron> : "\xc4\x9b" ecaron
+<Multi_key> <caron> <l> : "\xc4\xbe" lcaron
+<Multi_key> <l> <caron> : "\xc4\xbe" lcaron
+<Multi_key> <caron> <n> : "\xc5\x88" ncaron
+<Multi_key> <n> <caron> : "\xc5\x88" ncaron
+<Multi_key> <caron> <r> : "\xc5\x99" rcaron
+<Multi_key> <r> <caron> : "\xc5\x99" rcaron
+<Multi_key> <caron> <s> : "\xc5\xa1" scaron
+<Multi_key> <s> <caron> : "\xc5\xa1" scaron
+<Multi_key> <caron> <t> : "\xc5\xa5" tcaron
+<Multi_key> <t> <caron> : "\xc5\xa5" tcaron
+<Multi_key> <caron> <u> : "\xc5\xaf" uring
+<Multi_key> <u> <caron> : "\xc5\xaf" uring
+<Multi_key> <v> <C> : "\xc4\x8c" Ccaron
+<Multi_key> <C> <v> : "\xc4\x8c" Ccaron
+<Multi_key> <v> <D> : "\xc4\x8e" Dcaron
+<Multi_key> <D> <v> : "\xc4\x8e" Dcaron
+<Multi_key> <v> <E> : "\xc4\x9a" Ecaron
+<Multi_key> <E> <v> : "\xc4\x9a" Ecaron
+<Multi_key> <v> <N> : "\xc5\x87" Ncaron
+<Multi_key> <N> <v> : "\xc5\x87" Ncaron
+<Multi_key> <v> <R> : "\xc5\x98" Rcaron
+<Multi_key> <R> <v> : "\xc5\x98" Rcaron
+<Multi_key> <v> <T> : "\xc5\xa4" Tcaron
+<Multi_key> <T> <v> : "\xc5\xa4" Tcaron
+<Multi_key> <v> <U> : "\xc5\xae" Uring
+<Multi_key> <U> <v> : "\xc5\xae" Uring
+<Multi_key> <v> <c> : "\xc4\x8d" ccaron
+<Multi_key> <c> <v> : "\xc4\x8d" ccaron
+<Multi_key> <v> <d> : "\xc4\x8f" dcaron
+<Multi_key> <d> <v> : "\xc4\x8f" dcaron
+<Multi_key> <v> <e> : "\xc4\x9b" ecaron
+<Multi_key> <e> <v> : "\xc4\x9b" ecaron
+<Multi_key> <v> <n> : "\xc5\x88" ncaron
+<Multi_key> <n> <v> : "\xc5\x88" ncaron
+<Multi_key> <v> <r> : "\xc5\x99" rcaron
+<Multi_key> <r> <v> : "\xc5\x99" rcaron
+<Multi_key> <v> <t> : "\xc5\xa5" tcaron
+<Multi_key> <t> <v> : "\xc5\xa5" tcaron
+<Multi_key> <v> <u> : "\xc5\xaf" uring
+<Multi_key> <u> <v> : "\xc5\xaf" uring
+<Multi_key> <breve> <A> : "\xc4\x82" Abreve
+<Multi_key> <A> <breve> : "\xc4\x82" Abreve
+<Multi_key> <breve> <a> : "\xc4\x83" abreve
+<Multi_key> <a> <breve> : "\xc4\x83" abreve
+<Multi_key> <ogonek> <A> : "\xc4\x84" Aogonek
+<Multi_key> <A> <ogonek> : "\xc4\x84" Aogonek
+<Multi_key> <ogonek> <E> : "\xc4\x98" Eogonek
+<Multi_key> <E> <ogonek> : "\xc4\x98" Eogonek
+<Multi_key> <ogonek> <a> : "\xc4\x85" aogonek
+<Multi_key> <a> <ogonek> : "\xc4\x85" aogonek
+<Multi_key> <ogonek> <e> : "\xc4\x99" eogonek
+<Multi_key> <e> <ogonek> : "\xc4\x99" eogonek
+<Multi_key> <E> <a> : "\xc4\x98" Eogonek
+<Multi_key> <e> <a> : "\xc4\x99" eogonek
+<Multi_key> <doubleacute> <O> : "\xc5\x90" Odoubleacute
+<Multi_key> <O> <doubleacute> : "\xc5\x90" Odoubleacute
+<Multi_key> <doubleacute> <U> : "\xc5\xb0" Udoubleacute
+<Multi_key> <U> <doubleacute> : "\xc5\xb0" Udoubleacute
+<Multi_key> <doubleacute> <o> : "\xc5\x91" odoubleacute
+<Multi_key> <o> <doubleacute> : "\xc5\x91" odoubleacute
+<Multi_key> <doubleacute> <u> : "\xc5\xb1" udoubleacute
+<Multi_key> <u> <doubleacute> : "\xc5\xb1" udoubleacute
+<Multi_key> <period> <U> : "\xc5\xae" Uring
+<Multi_key> <U> <period> : "\xc5\xae" Uring
+<Multi_key> <period> <u> : "\xc5\xaf" uring
+<Multi_key> <u> <period> : "\xc5\xaf" uring
+<Multi_key> <period> <z> : "\xc5\xbc" zabovedot
+<Multi_key> <z> <period> : "\xc5\xbc" zabovedot
+<Multi_key> <period> <Z> : "\xc5\xbb" Zabovedot
+<Multi_key> <Z> <period> : "\xc5\xbb" Zabovedot
+<acute> <A> : "\xc3\x81" Aacute
+<acute> <C> : "\xc4\x86" Cacute
+<acute> <E> : "\xc3\x89" Eacute
+<acute> <I> : "\xc3\x8d" Iacute
+<acute> <L> : "\xc4\xb9" Lacute
+<acute> <N> : "\xc5\x83" Nacute
+<acute> <O> : "\xc3\x93" Oacute
+<acute> <R> : "\xc5\x94" Racute
+<acute> <S> : "\xc5\x9a" Sacute
+<acute> <U> : "\xc3\x9a" Uacute
+<acute> <Y> : "\xc3\x9d" Yacute
+<acute> <Z> : "\xc4\xbe" Zacute
+<acute> <a> : "\xc3\xa1" aacute
+<acute> <c> : "\xc4\x87" cacute
+<acute> <e> : "\xc3\xa9" eacute
+<acute> <i> : "\xc3\xad" iacute
+<acute> <l> : "\xc4\xba" lacute
+<acute> <n> : "\xc5\x84" nacute
+<acute> <o> : "\xc3\xb3" oacute
+<acute> <r> : "\xc5\x95" racute
+<acute> <s> : "\xc5\x9b" sacute
+<acute> <u> : "\xc3\xba" uacute
+<acute> <y> : "\xc3\xbd" yacute
+<acute> <z> : "\xc5\xba" zacute
+<diaeresis> <A> : "\xc3\x84" Adiaeresis
+<diaeresis> <E> : "\xc3\x8b" Ediaeresis
+<diaeresis> <O> : "\xc3\x96" Odiaeresis
+<diaeresis> <U> : "\xc3\x9c" Udiaeresis
+<diaeresis> <a> : "\xc3\xa4" adiaeresis
+<diaeresis> <e> : "\xc3\xab" ediaeresis
+<diaeresis> <o> : "\xc3\xb6" odiaeresis
+<diaeresis> <u> : "\xc3\xbc" udiaeresis
+#
+# Additional latin-2 sequences
+<Multi_key> <a> <space> : "\xcb\x9b" ogonek
+<Multi_key> <u> <space> : "\xcb\x98" breve
+<Multi_key> <v> <space> : "\xcb\x87" caron
+<Multi_key> <quotedbl> <space> : "\xcb\x9d" doubleacute
+<Multi_key> <A> <u> : "\xc4\x82" Abreve
+<Multi_key> <C> <apostrophe> : "\xc4\x86" Cacute
+<Multi_key> <L> <apostrophe> : "\xc4\xb9" Lacute
+<Multi_key> <L> <slash> : "\xc5\x81" Lstroke
+<Multi_key> <L> <greater> : "\xc4\xbd" Lcaron
+<Multi_key> <N> <apostrophe> : "\xc5\x83" Nacute
+<Multi_key> <S> <apostrophe> : "\xc5\x9a" Sacute
+<Multi_key> <R> <apostrophe> : "\xc5\x94" Racute
+<Multi_key> <U> <asterisk> : "\xc5\xae" Uring
+<Multi_key> <Z> <apostrophe> : "\xc5\xb9" Zacute
+<Multi_key> <a> <u> : "\xc4\x83" abreve
+<Multi_key> <c> <apostrophe> : "\xc4\x87" cacute
+<Multi_key> <l> <apostrophe> : "\xc4\xba" lacute
+<Multi_key> <l> <slash> : "\xc5\x82" lstroke
+<Multi_key> <l> <greater> : "\xc4\xbe" lcaron
+<Multi_key> <n> <apostrophe> : "\xc5\x84" nacute
+<Multi_key> <s> <apostrophe> : "\xc5\x9b" sacute
+<Multi_key> <r> <apostrophe> : "\xc5\x95" racute
+<Multi_key> <u> <asterisk> : "\xc5\xaf" uring
+<Multi_key> <z> <apostrophe> : "\xc5\xba" zacute
+#
+# Latin-4 sequences
+<Multi_key> <N> <N> : "\xc5\x8a" ENG
+<Multi_key> <U> <a> : "\xc5\xb2" Uogonek
+<Multi_key> <u> <a> : "\xc5\xb3" uogonek
+<Multi_key> <k> <k> : "\xc4\xb8" kra
+<Multi_key> <R> <comma> : "\xc5\x96" Rcedilla
+<Multi_key> <comma> <R> : "\xc5\x96" Rcedilla
+<Multi_key> <r> <comma> : "\xc5\x97" rcedilla
+<Multi_key> <comma> <r> : "\xc5\x97" rcedilla
+<Multi_key> <I> <asciitilde> : "\xc4\xa8" Itilde
+<Multi_key> <asciitilde> <I> : "\xc4\xa8" Itilde
+<Multi_key> <i> <asciitilde> : "\xc4\xa9" itilde
+<Multi_key> <asciitilde> <i> : "\xc4\xa9" itilde
+<Multi_key> <L> <comma> : "\xc4\xbb" Lcedilla
+<Multi_key> <comma> <L> : "\xc4\xbb" Lcedilla
+<Multi_key> <l> <comma> : "\xc4\xbc" lcedilla
+<Multi_key> <comma> <l> : "\xc4\xbc" lcedilla
+<diaeresis> : "\xc2\xa8" diaeresis
+<Multi_key> <S> <v> : "\xc5\xa0" Scaron
+<Multi_key> <S> <V> : "\xc5\xa0" Scaron
+<Multi_key> <v> <S> : "\xc5\xa0" Scaron
+<Multi_key> <V> <S> : "\xc5\xa0" Scaron
+<Multi_key> <s> <v> : "\xc5\xa1" scaron
+<Multi_key> <s> <V> : "\xc5\xa1" scaron
+<Multi_key> <v> <s> : "\xc5\xa1" scaron
+<Multi_key> <V> <s> : "\xc5\xa1" scaron
+<Multi_key> <E> <underscore> : "\xc4\x92" Emacron
+<Multi_key> <underscore> <E> : "\xc4\x92" Emacron
+<Multi_key> <e> <underscore> : "\xc4\x93" emacron
+<Multi_key> <underscore> <e> : "\xc4\x93" emacron
+<Multi_key> <G> <comma> : "\xc4\xa2" Gcedilla
+<Multi_key> <comma> <G> : "\xc4\xa2" Gcedilla
+<Multi_key> <g> <comma> : "\xc4\xa3" gcedilla
+<Multi_key> <comma> <g> : "\xc4\xa3" gcedilla
+<Multi_key> <T> <bar> : "\xc5\xa6" Tslash
+<Multi_key> <bar> <T> : "\xc5\xa6" Tslash
+<Multi_key> <t> <bar> : "\xc5\xa7" tslash
+<Multi_key> <bar> <t> : "\xc5\xa7" tslash
+<Multi_key> <n> <n> : "\xc5\x8b" eng
+<Multi_key> <A> <underscore> : "\xc4\x80" Amacron
+<Multi_key> <underscore> <A> : "\xc4\x80" Amacron
+<Multi_key> <a> <underscore> : "\xc4\x81" amacron
+<Multi_key> <underscore> <a> : "\xc4\x81" amacron
+<Multi_key> <d> <underscore> : "\xc4\x91"
+<Multi_key> <underscore> <d> : "\xc4\x91"
+<Multi_key> <N> <comma> : "\xc5\x85" Ncedilla
+<Multi_key> <comma> <N> : "\xc5\x85" Ncedilla
+<Multi_key> <n> <comma> : "\xc5\x86" ncedilla
+<Multi_key> <comma> <n> : "\xc5\x86" ncedilla
+<Multi_key> <O> <underscore> : "\xc5\x8c" Omacron
+<Multi_key> <underscore> <O> : "\xc5\x8c" Omacron
+<Multi_key> <o> <underscore> : "\xc5\x8d" omacron
+<Multi_key> <underscore> <o> : "\xc5\x8d" omacron
+<Multi_key> <K> <comma> : "\xc4\xb6" Kcedilla
+<Multi_key> <comma> <K> : "\xc4\xb6" Kcedilla
+<Multi_key> <k> <comma> : "\xc4\xb7" kcedilla
+<Multi_key> <comma> <k> : "\xc4\xb7" kcedilla
+<Multi_key> <I> <a> : "\xc4\xae" Iogonek
+<Multi_key> <a> <I> : "\xc4\xae" Iogonek
+<Multi_key> <i> <a> : "\xc4\xaf" iogonek
+<Multi_key> <a> <i> : "\xc4\xaf" iogonek
+<Multi_key> <E> <period> : "\xc4\x96" Eabovedot
+<Multi_key> <e> <period> : "\xc4\x97" eabovedot
+<Multi_key> <U> <asciitilde> : "\xc5\xa8" Utilde
+<Multi_key> <asciitilde> <U> : "\xc5\xa8" Utilde
+<Multi_key> <u> <asciitilde> : "\xc5\xa9" utilde
+<Multi_key> <asciitilde> <u> : "\xc5\xa9" utilde
+<Multi_key> <U> <underscore> : "\xc5\xaa" Umacron
+<Multi_key> <underscore> <U> : "\xc5\xaa" Umacron
+<Multi_key> <u> <underscore> : "\xc5\xab" umacron
+<Multi_key> <underscore> <u> : "\xc5\xab" umacron
+<Multi_key> <I> <underscore> : "\xc4\xaa" Imacron
+<Multi_key> <underscore> <I> : "\xc4\xaa" Imacron
+<Multi_key> <i> <underscore> : "\xc4\xab" imacron
+<Multi_key> <underscore> <i> : "\xc4\xab" imacron
+
+# Ctrl<T> combo
+Ctrl<T> <a> <A> : "\xc4\x84" Aogonek
+Ctrl<T> <A> <a> : "\xc4\x84" Aogonek
+Ctrl<T> <a> <a> : "\xc4\x85" aogonek
+Ctrl<T> <C> <acute> : "\xc4\x86" Cacute
+Ctrl<T> <c> <acute> : "\xc4\x87" cacute
+Ctrl<T> <acute> <C> : "\xc4\x86" Cacute
+Ctrl<T> <acute> <c> : "\xc4\x87" cacute
+Ctrl<T> <acute> <N> : "\xc5\x83" Nacute
+Ctrl<T> <N> <acute> : "\xc5\x83" Nacute
+#Ctrl<T> <minus> <D> : "\xc3\x90" ETH
+#Ctrl<T> <minus> <d> : "\xc3\xb0" eth
+Ctrl<T> <slash> <D> : "\xc4\x90" Dstroke
+Ctrl<T> <slash> <d> : "\xc4\x91" dstroke
+Ctrl<T> <caron> <Z> : "\xc5\xbd" Zcaron
+Ctrl<T> <Z> <caron> : "\xc5\xbd" Zcaron
+Ctrl<T> <v> <Z> : "\xc5\xbd" Zcaron
+Ctrl<T> <Z> <v> : "\xc5\xbd" Zcaron
+Ctrl<T> <caron> <z> : "\xc5\xbe" zcaron
+Ctrl<T> <z> <caron> : "\xc5\xbe" zcaron
+Ctrl<T> <z> <v> : "\xc5\xbe" zcaron
+Ctrl<T> <v> <z> : "\xc5\xbe" zcaron
+Ctrl<T> <G> <u> : "\xc4\x9e" Gbreve
+Ctrl<T> <u> <G> : "\xc4\x9e" Gbreve
+Ctrl<T> <g> <u> : "\xc4\x9f" gbreve
+Ctrl<T> <u> <g> : "\xc4\x9f" gbreve
+Ctrl<T> <I> <period> : "\xc4\xb0" Iabovedot
+Ctrl<T> <period> <I> : "\xc4\xb0" Iabovedot
+Ctrl<T> <i> <period> : "\xc4\xb1" idotless
+Ctrl<T> <period> <i> : "\xc4\xb1" idotless
+Ctrl<T> <space> <breve> : "\xcb\x98" breve
+Ctrl<T> <space> <degree> : "\xc2\xb0" degree
+Ctrl<T> <space> <ogonek> : "\xcb\x9b" ogonek
+Ctrl<T> <space> <caron> : "\xcb\x87" caron
+Ctrl<T> <space> <v> : "\xcb\x87" caron
+Ctrl<T> <space> <doubleacute> : "\xcb\x9d" doubleacute
+Ctrl<T> <diaeresis> <A> : "\xc3\x84" Adiaeresis
+Ctrl<T> <A> <diaeresis> : "\xc3\x84" Adiaeresis
+Ctrl<T> <diaeresis> <E> : "\xc3\x8b" Ediaeresis
+Ctrl<T> <E> <diaeresis> : "\xc3\x8b" Ediaeresis
+Ctrl<T> <diaeresis> <O> : "\xc3\x96" Odiaeresis
+Ctrl<T> <O> <diaeresis> : "\xc3\x96" Odiaeresis
+Ctrl<T> <diaeresis> <U> : "\xc3\x9c" Udiaeresis
+Ctrl<T> <U> <diaeresis> : "\xc3\x9c" Udiaeresis
+Ctrl<T> <diaeresis> <a> : "\xc3\xa4" adiaeresis
+Ctrl<T> <a> <diaeresis> : "\xc3\xa4" adiaeresis
+Ctrl<T> <diaeresis> <e> : "\xc3\xab" ediaeresis
+Ctrl<T> <e> <diaeresis> : "\xc3\xab" ediaeresis
+Ctrl<T> <diaeresis> <o> : "\xc3\xb6" odiaeresis
+Ctrl<T> <o> <diaeresis> : "\xc3\xb6" odiaeresis
+Ctrl<T> <diaeresis> <u> : "\xc3\xbc" udiaeresis
+Ctrl<T> <u> <diaeresis> : "\xc3\xbc" udiaeresis
+Ctrl<T> <acute> <R> : "\xc5\x94" Racute
+Ctrl<T> <R> <acute> : "\xc5\x94" Racute
+Ctrl<T> <acute> <S> : "\xc5\x9a" Sacute
+Ctrl<T> <S> <acute> : "\xc5\x9a" Sacute
+Ctrl<T> <acute> <Z> : "\xc4\xbe" Zacute
+Ctrl<T> <Z> <acute> : "\xc4\xbe" Zacute
+Ctrl<T> <acute> <n> : "\xc5\x84" nacute
+Ctrl<T> <n> <acute> : "\xc5\x84" nacute
+Ctrl<T> <acute> <r> : "\xc5\x95" racute
+Ctrl<T> <r> <acute> : "\xc5\x95" racute
+Ctrl<T> <acute> <s> : "\xc5\x9b" sacute
+Ctrl<T> <s> <acute> : "\xc5\x9b" sacute
+Ctrl<T> <acute> <z> : "\xc5\xba" zacute
+Ctrl<T> <z> <acute> : "\xc5\xba" zacute
+Ctrl<T> <0> <O> : "\xc2\xb0" degree
+Ctrl<T> <o> <o> : "\xc2\xb0" degree
+Ctrl<T> <comma> <S> : "\xc5\x9e" Scedilla
+Ctrl<T> <S> <comma> : "\xc5\x9e" Scedilla
+Ctrl<T> <comma> <T> : "\xc5\xa2" Tcedilla
+Ctrl<T> <T> <comma> : "\xc5\xa2" Tcedilla
+Ctrl<T> <comma> <s> : "\xc5\x9f" scedilla
+Ctrl<T> <s> <comma> : "\xc5\x9f" scedilla
+Ctrl<T> <comma> <t> : "\xc5\xa3" tcedilla
+Ctrl<T> <t> <comma> : "\xc5\xa3" tcedilla
+Ctrl<T> <caron> <C> : "\xc4\x8c" Ccaron
+Ctrl<T> <C> <caron> : "\xc4\x8c" Ccaron
+Ctrl<T> <caron> <D> : "\xc4\x8e" Dcaron
+Ctrl<T> <D> <caron> : "\xc4\x8e" Dcaron
+Ctrl<T> <caron> <E> : "\xc4\x9a" Ecaron
+Ctrl<T> <E> <caron> : "\xc4\x9a" Ecaron
+Ctrl<T> <caron> <L> : "\xc4\xbd" Lcaron
+Ctrl<T> <L> <caron> : "\xc4\xbd" Lcaron
+Ctrl<T> <caron> <N> : "\xc5\x87" Ncaron
+Ctrl<T> <N> <caron> : "\xc5\x87" Ncaron
+Ctrl<T> <caron> <R> : "\xc5\x98" Rcaron
+Ctrl<T> <R> <caron> : "\xc5\x98" Rcaron
+Ctrl<T> <caron> <S> : "\xc5\xa0" Scaron
+Ctrl<T> <S> <caron> : "\xc5\xa0" Scaron
+Ctrl<T> <caron> <T> : "\xc5\xa4" Tcaron
+Ctrl<T> <T> <caron> : "\xc5\xa4" Tcaron
+Ctrl<T> <caron> <U> : "\xc5\xae" Uring
+Ctrl<T> <U> <caron> : "\xc5\xae" Uring
+Ctrl<T> <caron> <c> : "\xc4\x8d" ccaron
+Ctrl<T> <c> <caron> : "\xc4\x8d" ccaron
+Ctrl<T> <caron> <d> : "\xc4\x8f" dcaron
+Ctrl<T> <d> <caron> : "\xc4\x8f" dcaron
+Ctrl<T> <caron> <e> : "\xc4\x9b" ecaron
+Ctrl<T> <e> <caron> : "\xc4\x9b" ecaron
+Ctrl<T> <caron> <l> : "\xc4\xbe" lcaron
+Ctrl<T> <l> <caron> : "\xc4\xbe" lcaron
+Ctrl<T> <caron> <n> : "\xc5\x88" ncaron
+Ctrl<T> <n> <caron> : "\xc5\x88" ncaron
+Ctrl<T> <caron> <r> : "\xc5\x99" rcaron
+Ctrl<T> <r> <caron> : "\xc5\x99" rcaron
+Ctrl<T> <caron> <s> : "\xc5\xa1" scaron
+Ctrl<T> <s> <caron> : "\xc5\xa1" scaron
+Ctrl<T> <caron> <t> : "\xc5\xa5" tcaron
+Ctrl<T> <t> <caron> : "\xc5\xa5" tcaron
+Ctrl<T> <caron> <u> : "\xc5\xaf" uring
+Ctrl<T> <u> <caron> : "\xc5\xaf" uring
+Ctrl<T> <v> <C> : "\xc4\x8c" Ccaron
+Ctrl<T> <C> <v> : "\xc4\x8c" Ccaron
+Ctrl<T> <v> <D> : "\xc4\x8e" Dcaron
+Ctrl<T> <D> <v> : "\xc4\x8e" Dcaron
+Ctrl<T> <v> <E> : "\xc4\x9a" Ecaron
+Ctrl<T> <E> <v> : "\xc4\x9a" Ecaron
+Ctrl<T> <v> <N> : "\xc5\x87" Ncaron
+Ctrl<T> <N> <v> : "\xc5\x87" Ncaron
+Ctrl<T> <v> <R> : "\xc5\x98" Rcaron
+Ctrl<T> <R> <v> : "\xc5\x98" Rcaron
+Ctrl<T> <v> <T> : "\xc5\xa4" Tcaron
+Ctrl<T> <T> <v> : "\xc5\xa4" Tcaron
+Ctrl<T> <v> <U> : "\xc5\xae" Uring
+Ctrl<T> <U> <v> : "\xc5\xae" Uring
+Ctrl<T> <v> <c> : "\xc4\x8d" ccaron
+Ctrl<T> <c> <v> : "\xc4\x8d" ccaron
+Ctrl<T> <v> <d> : "\xc4\x8f" dcaron
+Ctrl<T> <d> <v> : "\xc4\x8f" dcaron
+Ctrl<T> <v> <e> : "\xc4\x9b" ecaron
+Ctrl<T> <e> <v> : "\xc4\x9b" ecaron
+Ctrl<T> <v> <n> : "\xc5\x88" ncaron
+Ctrl<T> <n> <v> : "\xc5\x88" ncaron
+Ctrl<T> <v> <r> : "\xc5\x99" rcaron
+Ctrl<T> <r> <v> : "\xc5\x99" rcaron
+Ctrl<T> <v> <t> : "\xc5\xa5" tcaron
+Ctrl<T> <t> <v> : "\xc5\xa5" tcaron
+Ctrl<T> <v> <u> : "\xc5\xaf" uring
+Ctrl<T> <u> <v> : "\xc5\xaf" uring
+Ctrl<T> <breve> <A> : "\xc4\x82" Abreve
+Ctrl<T> <A> <breve> : "\xc4\x82" Abreve
+Ctrl<T> <breve> <a> : "\xc4\x83" abreve
+Ctrl<T> <a> <breve> : "\xc4\x83" abreve
+Ctrl<T> <ogonek> <A> : "\xc4\x84" Aogonek
+Ctrl<T> <A> <ogonek> : "\xc4\x84" Aogonek
+Ctrl<T> <ogonek> <E> : "\xc4\x98" Eogonek
+Ctrl<T> <E> <ogonek> : "\xc4\x98" Eogonek
+Ctrl<T> <ogonek> <a> : "\xc4\x85" aogonek
+Ctrl<T> <a> <ogonek> : "\xc4\x85" aogonek
+Ctrl<T> <ogonek> <e> : "\xc4\x99" eogonek
+Ctrl<T> <e> <ogonek> : "\xc4\x99" eogonek
+Ctrl<T> <E> <a> : "\xc4\x98" Eogonek
+Ctrl<T> <e> <a> : "\xc4\x99" eogonek
+Ctrl<T> <doubleacute> <O> : "\xc5\x90" Odoubleacute
+Ctrl<T> <O> <doubleacute> : "\xc5\x90" Odoubleacute
+Ctrl<T> <doubleacute> <U> : "\xc5\xb0" Udoubleacute
+Ctrl<T> <U> <doubleacute> : "\xc5\xb0" Udoubleacute
+Ctrl<T> <doubleacute> <o> : "\xc5\x91" odoubleacute
+Ctrl<T> <o> <doubleacute> : "\xc5\x91" odoubleacute
+Ctrl<T> <doubleacute> <u> : "\xc5\xb1" udoubleacute
+Ctrl<T> <u> <doubleacute> : "\xc5\xb1" udoubleacute
+Ctrl<T> <period> <U> : "\xc5\xae" Uring
+Ctrl<T> <U> <period> : "\xc5\xae" Uring
+Ctrl<T> <period> <u> : "\xc5\xaf" uring
+Ctrl<T> <u> <period> : "\xc5\xaf" uring
+Ctrl<T> <period> <z> : "\xc5\xbc" zabovedot
+Ctrl<T> <z> <period> : "\xc5\xbc" zabovedot
+Ctrl<T> <period> <Z> : "\xc5\xbb" Zabovedot
+Ctrl<T> <Z> <period> : "\xc5\xbb" Zabovedot
+Ctrl<T> <a> <space> : "\xcb\x9b" ogonek
+Ctrl<T> <u> <space> : "\xcb\x98" breve
+Ctrl<T> <v> <space> : "\xcb\x87" caron
+Ctrl<T> <quotedbl> <space> : "\xcb\x9d" doubleacute
+Ctrl<T> <A> <u> : "\xc4\x82" Abreve
+Ctrl<T> <C> <apostrophe> : "\xc4\x86" Cacute
+Ctrl<T> <L> <apostrophe> : "\xc4\xb9" Lacute
+Ctrl<T> <L> <slash> : "\xc5\x81" Lstroke
+Ctrl<T> <L> <greater> : "\xc4\xbd" Lcaron
+Ctrl<T> <N> <apostrophe> : "\xc5\x83" Nacute
+Ctrl<T> <S> <apostrophe> : "\xc5\x9a" Sacute
+Ctrl<T> <R> <apostrophe> : "\xc5\x94" Racute
+Ctrl<T> <U> <asterisk> : "\xc5\xae" Uring
+Ctrl<T> <Z> <apostrophe> : "\xc5\xb9" Zacute
+Ctrl<T> <a> <u> : "\xc4\x83" abreve
+Ctrl<T> <c> <apostrophe> : "\xc4\x87" cacute
+Ctrl<T> <l> <apostrophe> : "\xc4\xba" lacute
+Ctrl<T> <l> <slash> : "\xc5\x82" lstroke
+Ctrl<T> <l> <greater> : "\xc4\xbe" lcaron
+Ctrl<T> <n> <apostrophe> : "\xc5\x84" nacute
+Ctrl<T> <s> <apostrophe> : "\xc5\x9b" sacute
+Ctrl<T> <r> <apostrophe> : "\xc5\x95" racute
+Ctrl<T> <u> <asterisk> : "\xc5\xaf" uring
+Ctrl<T> <z> <apostrophe> : "\xc5\xba" zacute
+#
+# Latin-4 sequences
+Ctrl<T> <N> <N> : "\xc5\x8a" ENG
+Ctrl<T> <U> <a> : "\xc5\xb2" Uogonek
+Ctrl<T> <u> <a> : "\xc5\xb3" uogonek
+Ctrl<T> <k> <k> : "\xc4\xb8" kra
+Ctrl<T> <R> <comma> : "\xc5\x96" Rcedilla
+Ctrl<T> <comma> <R> : "\xc5\x96" Rcedilla
+Ctrl<T> <r> <comma> : "\xc5\x97" rcedilla
+Ctrl<T> <comma> <r> : "\xc5\x97" rcedilla
+Ctrl<T> <I> <asciitilde> : "\xc4\xa8" Itilde
+Ctrl<T> <asciitilde> <I> : "\xc4\xa8" Itilde
+Ctrl<T> <i> <asciitilde> : "\xc4\xa9" itilde
+Ctrl<T> <asciitilde> <i> : "\xc4\xa9" itilde
+Ctrl<T> <L> <comma> : "\xc4\xbb" Lcedilla
+Ctrl<T> <comma> <L> : "\xc4\xbb" Lcedilla
+Ctrl<T> <l> <comma> : "\xc4\xbc" lcedilla
+Ctrl<T> <comma> <l> : "\xc4\xbc" lcedilla
+Ctrl<T> <S> <v> : "\xc5\xa0" Scaron
+Ctrl<T> <S> <V> : "\xc5\xa0" Scaron
+Ctrl<T> <v> <S> : "\xc5\xa0" Scaron
+Ctrl<T> <V> <S> : "\xc5\xa0" Scaron
+Ctrl<T> <s> <v> : "\xc5\xa1" scaron
+Ctrl<T> <s> <V> : "\xc5\xa1" scaron
+Ctrl<T> <v> <s> : "\xc5\xa1" scaron
+Ctrl<T> <V> <s> : "\xc5\xa1" scaron
+Ctrl<T> <E> <underscore> : "\xc4\x92" Emacron
+Ctrl<T> <underscore> <E> : "\xc4\x92" Emacron
+Ctrl<T> <e> <underscore> : "\xc4\x93" emacron
+Ctrl<T> <underscore> <e> : "\xc4\x93" emacron
+Ctrl<T> <G> <comma> : "\xc4\xa2" Gcedilla
+Ctrl<T> <comma> <G> : "\xc4\xa2" Gcedilla
+Ctrl<T> <g> <comma> : "\xc4\xa3" gcedilla
+Ctrl<T> <comma> <g> : "\xc4\xa3" gcedilla
+Ctrl<T> <T> <bar> : "\xc5\xa6" Tslash
+Ctrl<T> <bar> <T> : "\xc5\xa6" Tslash
+Ctrl<T> <t> <bar> : "\xc5\xa7" tslash
+Ctrl<T> <bar> <t> : "\xc5\xa7" tslash
+Ctrl<T> <n> <n> : "\xc5\x8b" eng
+Ctrl<T> <d> <underscore> : "\xc4\x91"
+Ctrl<T> <underscore> <d> : "\xc4\x91"
+Ctrl<T> <N> <comma> : "\xc5\x85" Ncedilla
+Ctrl<T> <comma> <N> : "\xc5\x85" Ncedilla
+Ctrl<T> <n> <comma> : "\xc5\x86" ncedilla
+Ctrl<T> <comma> <n> : "\xc5\x86" ncedilla
+Ctrl<T> <K> <comma> : "\xc4\xb6" Kcedilla
+Ctrl<T> <comma> <K> : "\xc4\xb6" Kcedilla
+Ctrl<T> <k> <comma> : "\xc4\xb7" kcedilla
+Ctrl<T> <comma> <k> : "\xc4\xb7" kcedilla
+Ctrl<T> <I> <a> : "\xc4\xae" Iogonek
+Ctrl<T> <a> <I> : "\xc4\xae" Iogonek
+Ctrl<T> <i> <a> : "\xc4\xaf" iogonek
+Ctrl<T> <a> <i> : "\xc4\xaf" iogonek
+Ctrl<T> <E> <period> : "\xc4\x96" Eabovedot
+Ctrl<T> <e> <period> : "\xc4\x97" eabovedot
+Ctrl<T> <U> <asciitilde> : "\xc5\xa8" Utilde
+Ctrl<T> <asciitilde> <U> : "\xc5\xa8" Utilde
+Ctrl<T> <u> <asciitilde> : "\xc5\xa9" utilde
+Ctrl<T> <asciitilde> <u> : "\xc5\xa9" utilde
+Ctrl<T> <U> <underscore> : "\xc5\xaa" Umacron
+Ctrl<T> <underscore> <U> : "\xc5\xaa" Umacron
+Ctrl<T> <u> <underscore> : "\xc5\xab" umacron
+Ctrl<T> <underscore> <u> : "\xc5\xab" umacron
+Ctrl<T> <I> <underscore> : "\xc4\xaa" Imacron
+Ctrl<T> <underscore> <I> : "\xc4\xaa" Imacron
+Ctrl<T> <i> <underscore> : "\xc4\xab" imacron
+Ctrl<T> <underscore> <i> : "\xc4\xab" imacron
+#
+# Latin-9 input sequences:
+<Multi_key> <o> <e> : "\xc5\x93"
+<Multi_key> <O> <E> : "\xc5\x92"
+<Multi_key> <Y> <quotedbl> : "\xc5\xb8"
+<Multi_key> <quotedbl> <Y> : "\xc5\xb8"
+Ctrl<T> <o> <e> : "\xc5\x93"
+Ctrl<T> <O> <E> : "\xc5\x92"
+Ctrl<T> <Y> <quotedbl> : "\xc5\xb8"
+Ctrl<T> <quotedbl> <Y> : "\xc5\xb8"
+END_STATE
+
+STATE "[ Cyrillic ]"
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+<at> : "\x22" quotedbl
+<numbersign> : "\xe2\x84\x96" numerosign
+<dollar> : "\x25" percent
+<percent> : "\x3a" colon
+<asciicircum> : "\x2c" comma
+<ampersand> : "\x2e" period
+<asterisk> : "\x3b" semicolon
+<numerosign> : "\xe2\x84\x96" numerosign
+<q> : "\xd0\xb9" Cyrillic_shorti
+<w> : "\xd1\x86" Cyrillic_tse
+<e> : "\xd1\x83" Cyrillic_u
+<r> : "\xd0\xba" Cyrillic_ka
+<t> : "\xd0\xb5" Cyrillic_ie
+<y> : "\xd0\xbd" Cyrillic_en
+<u> : "\xd0\xb3" Cyrillic_ghe
+<i> : "\xd1\x88" Cyrillic_sha
+<o> : "\xd1\x89" Cyrillic_shcha
+<p> : "\xd0\xb7" Cyrillic_ze
+<bracketleft> : "\xd1\x85" Cyrillic_ha
+<bracketright> : "\xd1\x8a" Cyrillic_hardsign
+<Q> : "\xd0\x99" Cyrillic_SHORTI
+<W> : "\xd0\xa6" Cyrillic_TSE
+<E> : "\xd0\xa3" Cyrillic_U
+<R> : "\xd0\x9a" Cyrillic_KA
+<T> : "\xd0\x95" Cyrillic_IE
+<Y> : "\xd0\x9d" Cyrillic_EN
+<U> : "\xd0\x93" Cyrillic_GHE
+<I> : "\xd0\xa8" Cyrillic_SHA
+<O> : "\xd0\xa9" Cyrillic_SHCHA
+<P> : "\xd0\x97" Cyrillic_ZE
+Lock<bracketleft> : "\xd0\xa5" Cyrillic_HA
+Lock<bracketright> : "\xd0\xaa" Cyrillic_HARDSIGN
+<braceleft> : "\xd0\xa5" Cyrillic_HA
+<braceright> : "\xd0\xaa" Cyrillic_HARDSIGN
+<a> : "\xd1\x84" Cyrillic_ef
+<s> : "\xd1\x8b" Cyrillic_yeru
+<d> : "\xd0\xb2" Cyrillic_ve
+<f> : "\xd0\xb0" Cyrillic_a
+<g> : "\xd0\xbf" Cyrillic_pe
+<h> : "\xd1\x80" Cyrillic_er
+<j> : "\xd0\xbe" Cyrillic_o
+<k> : "\xd0\xbb" Cyrillic_el
+<l> : "\xd0\xb4" Cyrillic_de
+<semicolon> : "\xd0\xb6" Cyrillic_ghe
+<quoteright> : "\xd1\x8d" Cyrillic_e
+<A> : "\xd0\xa4" Cyrillic_EF
+<S> : "\xd0\xab" Cyrillic_YERU
+<D> : "\xd0\x92" Cyrillic_VE
+<F> : "\xd0\x90" Cyrillic_A
+<G> : "\xd0\x9f" Cyrillic_PE
+<H> : "\xd0\xa0" Cyrillic_ER
+<J> : "\xd0\x9e" Cyrillic_O
+<K> : "\xd0\x9b" Cyrillic_EL
+<L> : "\xd0\x94" Cyrillic_DE
+<colon> : "\xd0\x96" Cyrillic_GHE
+<quotedbl> : "\xd0\xad" Cyrillic_E
+<z> : "\xd1\x8f" Cyrillic_ya
+<x> : "\xd1\x87" Cyrillic_che
+<c> : "\xd1\x81" Cyrillic_es
+<v> : "\xd0\xbc" Cyrillic_em
+<b> : "\xd0\xb8" Cyrillic_i
+<n> : "\xd1\x82" Cyrillic_te
+<m> : "\xd1\x8c" Cyrillic_softsign
+<comma> : "\xd0\xb1" Cyrillic_be
+<period> : "\xd1\x8e" Cyrillic_yu
+<slash> : "\xd1\x91" Cyrillic_io
+<Z> : "\xd0\xaf" Cyrillic_YA
+<X> : "\xd0\xa7" Cyrillic_CHE
+<C> : "\xd0\xa1" Cyrillic_ES
+<V> : "\xd0\x9c" Cyrillic_EM
+<B> : "\xd0\x98" Cyrillic_I
+<N> : "\xd0\xa2" Cyrillic_TE
+<M> : "\xd0\xac" Cyrillic_SOFTSIGN
+<less> : "\xd0\x91" Cyrillic_BE
+<greater> : "\xd0\xae" Cyrillic_YU
+<question> : "\xd0\x81" Cyrillic_IO
+
+END_STATE
+
+STATE "[ Greek ]"
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+<at> : "\x22" quotedbl
+<numbersign> : "\xcf\x80" numerosign
+<dollar> : "\x25" percent
+<percent> : "\x3a" colon
+<asciicircum> : "\x2c" comma
+<ampersand> : "\x2e" period
+<asterisk> : "\x3b" semicolon
+<q> : "\x3b" semicolon
+<w> : "\xcf\x82" Greek_sigma
+<e> : "\xce\xb5" Greek_epsilon
+<r> : "\xcf\x81" Greek_rho
+<t> : "\xcf\x84" Greek_tau
+<y> : "\xcf\x85" Greek_upsilon
+<u> : "\xce\xb8" Greek_theta
+<i> : "\xce\xb9" Greek_iota
+<o> : "\xce\xbf" Greek_omicron
+<p> : "\xcf\x80" Greek_pi
+<Greek_sigma> : "\xcf\x82" Greek_sigma
+<Greek_epsilon> : "\xce\xb5" Greek_epsilon
+<Greek_rho> : "\xcf\x81" Greek_rho
+<Greek_tau> : "\xcf\x84" Greek_tau
+<Greek_upsilon> : "\xcf\x85" Greek_upsilon
+<Greek_theta> : "\xce\xb8" Greek_theta
+<Greek_iota> : "\xce\xb9" Greek_iota
+<Greek_omicron> : "\xce\xbf" Greek_omicron
+<Greek_pi> : "\xcf\x80" Greek_pi
+<Q> : "\x3a" colon
+<W> : "\xce\xa3" Greek_SIGMA
+<E> : "\xce\x95" Greek_EPSILON
+<R> : "\xce\xa1" Greek_RHO
+<T> : "\xce\xa4" Greek_TAU
+<Y> : "\xce\xa5" Greek_UPSILON
+<U> : "\xce\x98" Greek_THETA
+<I> : "\xce\x99" Greek_IOTA
+<O> : "\xce\x9f" Greek_OMICRON
+<P> : "\xce\xa0" Greek_PI
+<Greek_SIGMA> : "\xce\xa3" Greek_SIGMA
+<Greek_EPSILON> : "\xce\x95" Greek_EPSILON
+<Greek_RHO> : "\xce\xa1" Greek_RHO
+<Greek_TAU> : "\xce\xa4" Greek_TAU
+<Greek_UPSILON> : "\xce\xa5" Greek_UPSILON
+<Greek_THETA> : "\xce\x98" Greek_THETA
+<Greek_IOTA> : "\xce\x99" Greek_IOTA
+<Greek_OMICRON> : "\xce\x9f" Greek_OMICRON
+<Greek_PI> : "\xce\xa0" Greek_PI
+<a> : "\xce\xb1" Greek_alpha
+<s> : "\xcf\x83" Greek_finalsmallsigma
+<d> : "\xce\xb4" Greek_delta
+<f> : "\xcf\x86" Greek_phi
+<g> : "\xce\xb3" Greek_gamma
+<h> : "\xce\xb7" Greek_eta
+<j> : "\xce\xbe" Greek_xi
+<k> : "\xce\xba" Greek_kappa
+<l> : "\xce\xbb" Greek_lamda
+<Greek_alpha> : "\xce\xb1" Greek_alpha
+<Greek_finalsmallsigma> : "\xcf\x83" Greek_finalsmallsigma
+<Greek_delta> : "\xce\xb4" Greek_delta
+<Greek_phi> : "\xcf\x86" Greek_phi
+<Greek_gamma> : "\xce\xb3" Greek_gamma
+<Greek_eta> : "\xce\xb7" Greek_eta
+<Greek_xi> : "\xce\xbe" Greek_xi
+<Greek_kappa> : "\xce\xba" Greek_kappa
+<Greek_lamda> : "\xce\xbb" Greek_lamda
+<A> : "\xce\x91" Greek_ALPHA
+<S> : "\xce\xa3" Greek_SIGMA
+<D> : "\xce\x94" Greek_DELTA
+<F> : "\xce\xa6" Greek_PHI
+<G> : "\xce\x93" Greek_GAMMA
+<H> : "\xce\x97" Greek_ETA
+<J> : "\xce\x9e" Greek_XI
+<K> : "\xce\x9a" Greek_KAPPA
+<L> : "\xce\x9b" Greek_LAMDA
+<Greek_ALPHA> : "\xce\x91" Greek_ALPHA
+<Greek_DELTA> : "\xce\x94" Greek_DELTA
+<Greek_PHI> : "\xce\xa6" Greek_PHI
+<Greek_GAMMA> : "\xce\x93" Greek_GAMMA
+<Greek_ETA> : "\xce\x97" Greek_ETA
+<Greek_XI> : "\xce\x9e" Greek_XI
+<Greek_KAPPA> : "\xce\x9a" Greek_KAPPA
+<Greek_LAMDA> : "\xce\x9b" Greek_LAMDA
+<z> : "\xce\xb6" Greek_zeta
+<x> : "\xcf\x87" Greek_chi
+<c> : "\xcf\x88" Greek_psi
+<v> : "\xcf\x89" Greek_omega
+<b> : "\xce\xb2" Greek_beta
+<n> : "\xce\xbd" Greek_nu
+<m> : "\xce\xbc" Greek_mu
+<Greek_zeta> : "\xc2\x98" Greek_zeta
+<Greek_chi> : "\xcf\x87" Greek_chi
+<Greek_psi> : "\xcf\x88" Greek_psi
+<Greek_omega> : "\xcf\x89" Greek_omega
+<Greek_beta> : "\xce\xb2" Greek_beta
+<Greek_nu> : "\xce\xbd" Greek_nu
+<Greek_mu> : "\xce\xbc" Greek_mu
+<Z> : "\xce\x96" Greek_ZETA
+<X> : "\xce\xa7" Greek_CHI
+<C> : "\xce\xa8" Greek_PSI
+<V> : "\xce\xa9" Greek_OMEGA
+<B> : "\xce\x92" Greek_BETA
+<N> : "\xce\x9d" Greek_NU
+<M> : "\xce\x9c" Greek_MU
+<less> : "\x3b" semicolon
+<greater> : "\x3a" colon
+<question> : "\xc2\xb7" periodcentered
+<Greek_ZETA> : "\xce\x96" Greek_ZETA
+<Greek_CHI> : "\xce\xa7" Greek_CHI
+<Greek_PSI> : "\xce\xa8" Greek_PSI
+<Greek_OMEGA> : "\xce\xa9" Greek_OMEGA
+<Greek_BETA> : "\xce\x92" Greek_BETA
+<Greek_NU> : "\xce\x9d" Greek_NU
+<Greek_MU> : "\xce\x9c" Greek_MU
+<periodcentered> : "\xc2\xb7" periodcentered
+<dead_acute> <Greek_alpha> :"\xce\xac" Greek_alphaaccent
+<dead_acute> <Greek_epsilon> :"\xce\xad" Greek_epsilonaccent
+<dead_acute> <Greek_eta> :"\xce\xae" Greek_etaaccent
+<dead_acute> <Greek_iota> :"\xce\xaf" Greek_iotaaccent
+<dead_acute> <Greek_omicron> :"\xcf\x8c" Greek_omicronaccent
+<dead_acute> <Greek_upsilon> :"\xcf\x8d" Greek_upsilonaccent
+<dead_acute> <Greek_omega> :"\xcf\x8e" Greek_omegaaccent
+<dead_acute> <Greek_ALPHA> :"\xce\x86" Greek_ALPHAaccent
+<dead_acute> <Greek_EPSILON> :"\xce\x88" Greek_EPSILONaccent
+<dead_acute> <Greek_ETA> :"\xce\x89" Greek_ETAaccent
+<dead_acute> <Greek_IOTA> :"\xce\x8a" Greek_IOTAaccent
+<dead_acute> <Greek_OMICRON> :"\xce\x8c" Greek_OMICRONaccent
+<dead_acute> <Greek_UPSILON> :"\xce\x8e" Greek_UPSILONaccent
+<dead_acute> <Greek_OMEGA> :"\xce\x8f" Greek_OMEGAaccent
+<dead_diaeresis> <Greek_iota> :"\xcf\x8a" Greek_iotadieresis
+<dead_diaeresis> <Greek_upsilon> :"\xcf\x8b" Greek_upsilondieresis
+<diaeresis> <Greek_IOTA> :"\xce\xaa" Greek_IOTAdiaeresis
+<diaeresis> <Greek_UPSILON> :"\xce\xab" Greek_UPSILONdieresis
+<dead_acute> <dead_diaeresis> <Greek_upsilon> :"\xce\xb0"
+<dead_diaeresis> <dead_acute> <Greek_upsilon> :"\xce\xb0"
+<dead_acute> <dead_diaeresis> <Greek_iota> :"\xce\x90"
+<dead_diaeresis> <dead_acute> <Greek_iota> :"\xce\x90"
+<ordfeminine> <0> :"\xc2\xb1" plusminus
+<ordfeminine> <1> :"\xc2\xa7" section
+<ordfeminine> <2> :"\xc2\xb2" twosuperior
+<ordfeminine> <3> :"\xc2\xb3" threesuperior
+<ordfeminine> <4> :""
+<ordfeminine> <5> :"\xc2\xa6" brokenbar
+<ordfeminine> <6> :"\xc2\xa9" copyright
+<ordfeminine> <7> :"\xc2\xac" notequal
+<ordfeminine> <8> :"\xc2\xad" hyphen
+<ordfeminine> <9> :"\xc2\xb0" degree
+<ordfeminine> <hyphen> :"\xc2\xbd" onehalf
+<ordfeminine> <equal> :""
+<ordfeminine> <backslash> :"\xc2\xa3" sterling
+<ordfeminine> <braceleft> :"\xca\xbd"
+<ordfeminine> <braceright> :"\xca\xbc"
+<ordfeminine> <bracketleft> :"\xc2\xab" guillemotleft
+<ordfeminine> <bracketright> :"\xc2\xbb" guillemotright
+
+END_STATE
+
+STATE "[ Thai ]"
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+<exclam> : "\x2b"
+<2> : "\x2f"
+<3> : "\x2d"
+<W> : "\x22"
+<braceright> : "\x2c"
+<quotedbl> : "\x2e"
+<backslash> : "\x5f"
+<bar> : "\x25"
+<Z> : "\x28"
+<X> : "\x29"
+<M> : "\x3f"
+<d> : "\xe0\xb8\x81"
+<minus> : "\xe0\xb8\x82"
+<grave> : "\xe0\xb8\x83"
+<8> : "\xe0\xb8\x84"
+<asciitilde> : "\xe0\xb8\x85"
+<S> : "\xe0\xb8\x86"
+<apostrophe> : "\xe0\xb8\x87"
+<0> : "\xe0\xb8\x88"
+<C> : "\xe0\xb8\x89"
+<equal> : "\xe0\xb8\x8a"
+<colon> : "\xe0\xb8\x8b"
+<G> : "\xe0\xb8\x8c"
+<P> : "\xe0\xb8\x8d"
+<E> : "\xe0\xb8\x8e"
+<D> : "\xe0\xb8\x8f"
+<braceleft> : "\xe0\xb8\x90"
+<R> : "\xe0\xb8\x91"
+<less> : "\xe0\xb8\x92"
+<I> : "\xe0\xb8\x93"
+<f> : "\xe0\xb8\x94"
+<9> : "\xe0\xb8\x95"
+<5> : "\xe0\xb8\x96"
+<m> : "\xe0\xb8\x97"
+<T> : "\xe0\xb8\x98"
+<o> : "\xe0\xb8\x99"
+<bracketleft> : "\xe0\xb8\x9a"
+<x> : "\xe0\xb8\x9b"
+<z> : "\xe0\xb8\x9c"
+<slash> : "\xe0\xb8\x9d"
+<r> : "\xe0\xb8\x9e"
+<a> : "\xe0\xb8\x9f"
+<4> : "\xe0\xb8\xa0"
+<comma> : "\xe0\xb8\xa1"
+<p> : "\xe0\xb8\xa2"
+<i> : "\xe0\xb8\xa3"
+<A> : "\xe0\xb8\xa4"
+<bracketright> : "\xe0\xb8\xa5"
+<question> : "\xe0\xb8\xa6"
+<semicolon> : "\xe0\xb8\xa7"
+<L> : "\xe0\xb8\xa8"
+<K> : "\xe0\xb8\xa9"
+<l> : "\xe0\xb8\xaa"
+<s> : "\xe0\xb8\xab"
+<greater> : "\xe0\xb8\xac"
+<v> : "\xe0\xb8\xad"
+<V> : "\xe0\xb8\xae"
+<O> : "\xe0\xb8\xaf"
+<t> : "\xe0\xb8\xb0"
+<y> : "\xe0\xb8\xb1"
+<k> : "\xe0\xb8\xb2"
+<e> : "\xe0\xb8\xb3"
+<b> : "\xe0\xb8\xb4"
+<u> : "\xe0\xb8\xb5"
+<7> : "\xe0\xb8\xb6"
+<n> : "\xe0\xb8\xb7"
+<6> : "\xe0\xb8\xb8"
+<asciicircum> : "\xe0\xb8\xb9"
+<B> : "\xe0\xb8\xba"
+<ampersand> : "\xe0\xb8\xbf"
+<g> : "\xe0\xb9\x80"
+<c> : "\xe0\xb9\x81"
+<F> : "\xe0\xb9\x82"
+<period> : "\xe0\xb9\x83"
+<w> : "\xe0\xb9\x84"
+<1> : "\xe0\xb9\x85"
+<q> : "\xe0\xb9\x86"
+<H> : "\xe0\xb9\x87"
+<j> : "\xe0\xb9\x88"
+<h> : "\xe0\xb9\x89"
+<U> : "\xe0\xb9\x8a"
+<J> : "\xe0\xb9\x8b"
+<N> : "\xe0\xb9\x8c"
+<Y> : "\xe0\xb9\x8d"
+<Q> : "\xe0\xb9\x90"
+<at> : "\xe0\xb9\x91"
+<numbersign> : "\xe0\xb9\x92"
+<dollar> : "\xe0\xb9\x93"
+<percent> : "\xe0\xb9\x94"
+<asterisk> : "\xe0\xb9\x95"
+<parenleft> : "\xe0\xb9\x96"
+<parenright> : "\xe0\xb9\x97"
+<underscore> : "\xe0\xb9\x98"
+<plus> : "\xe0\xb9\x99"
+END_STATE
+
+STATE "[ Arabic ]"
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+# <0> Arabic-Indic Digit Zero
+<0> : "\xd9\xa0"
+# <1> Arabic-Indic Digit One
+<1> : "\xd9\xa1"
+# <2> Arabic-Indic Digit Two
+<2> : "\xd9\xa2"
+# <3> Arabic-Indic Digit Three
+<3> : "\xd9\xa3"
+# <4> Arabic-Indic Digit Four
+<4> : "\xd9\xa4"
+# <5> Arabic-Indic Digit Five
+<5> : "\xd9\xa5"
+# <6> Arabic-Indic Digit Six
+<6> : "\xd9\xa6"
+# <7> Arabic-Indic Digit Seven
+<7> : "\xd9\xa7"
+# <8> Arabic-Indic Digit Eight
+<8> : "\xd9\xa8"
+# <9> Arabic-Indic Digit Nine
+<9> : "\xd9\xa9"
+
+<a> : "\xd8\xb4"
+<A> : "\x5c"
+<apostrophe> : "\xd8\xb7"
+<asciitilde> : "\xd9\x91"
+<b> : "\xd9\x84\xd8\xa7"
+<B> : "\xd9\x84\xd8\xa2"
+<backslash> : "\xd9\x80"
+<bracketleft> : "\xd8\xac"
+<bracketright> : "\xd8\xaf"
+<c> : "\xd8\xa4"
+<C> : "\xd9\x8d"
+<comma> : "\xd9\x88"
+<d> : "\xd9\x8a"
+<D> : "\x5d"
+<e> : "\xd8\xab"
+<E> : "\xd9\x8f"
+<f> : "\xd8\xa8"
+<F> : "\x5b"
+<g> : "\xd9\x84"
+<G> : "\xd9\x84\xd8\xa3"
+<grave> : "\xd8\xb0"
+<greater> : "\x2e"
+<h> : "\xd8\xa7"
+<H> : "\xd8\xa3"
+<i> : "\xd9\x87"
+<j> : "\xd8\xaa"
+<k> : "\xd9\x86"
+<K> : "\xd8\x8c"
+<l> : "\xd9\x85"
+<L> : "\x2f"
+<m> : "\xd8\xa9"
+# previously <M> : "\xd9\x8f"
+<M> : "\xd9\xac"
+<n> : "\xd9\x89"
+<N> : "\xd8\xa2"
+<o> : "\xd8\xae"
+<p> : "\xd8\xad"
+<P> : "\xd8\x9b"
+<period> : "\xd8\xb2"
+<q> : "\xd8\xb6"
+<Q> : "\xd9\x8e"
+<question> : "\xd8\x9f"
+<r> : "\xd9\x82"
+<R> : "\xd9\x8c"
+<s> : "\xd8\xb3"
+<semicolon> : "\xd9\x83"
+<slash> : "\xd8\xb8"
+<smaller> : "\x2c"
+<t> : "\xd9\x81"
+<u> : "\xd8\xb9"
+<v> : "\xd8\xb1"
+<V> : "\xd9\x90"
+<w> : "\xd8\xb5"
+<W> : "\xd9\x8b"
+<x> : "\xd8\xa1"
+<y> : "\xd8\xba"
+<Y> : "\xd8\xa5"
+<z> : "\xd8\xa6"
+
+END_STATE
+
+STATE "[ Hebrew ]"
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+<q> : "\x2f"
+<w> : "\x27"
+<e> : "\xd7\xa7"
+<r> : "\xd7\xa8"
+<t> : "\xd7\x90"
+<y> : "\xd7\x98"
+<u> : "\xd7\x95"
+<i> : "\xd7\x9f"
+<o> : "\xd7\x9d"
+<p> : "\xd7\xa4"
+<a> : "\xd7\xa9"
+<s> : "\xd7\x93"
+<d> : "\xd7\x92"
+<f> : "\xd7\x9b"
+<g> : "\xd7\xa2"
+<h> : "\xd7\x99"
+<j> : "\xd7\x97"
+<k> : "\xd7\x9c"
+<l> : "\xd7\x9a"
+<semicolon> : "\xd7\xa3"
+<z> : "\xd7\x96"
+<x> : "\xd7\xa1"
+<c> : "\xd7\x91"
+<v> : "\xd7\x94"
+<b> : "\xd7\xa0"
+<n> : "\xd7\x9e"
+<m> : "\xd7\xa6"
+<comma> : "\xd7\xaa"
+<period> : "\xd7\xa5"
+<slash> : "\x2f"
+<grave> : "\x3b"
+<apostrophe> : "\x2c"
+END_STATE
+
+STATE "[ Unicode Hex ]"
+STATE_TYPE: CODE_INPUT
+#attributes
+MAX_INPUT_LENGTH: 4 # 1|2|3|4|5|,...
+ # when the number of input sequence
+ # reaches to the given number,
+ # conversion occurs automatically.
+
+TYPE_OF_INPUT: HEX # HEX or OCTET. The default is HEX.
+ # If it's HEX, valid input is: 0-9,
+ # a-f, A-F.
+ # If it's OCTET, valid input is: 0-7
+#end of attributes
+#actions
+Ctrl<w> : DO_LOOKUP
+<space> : DO_CONV
+ # force to convert input sequence into
+ # a character before MAX_INPUT_LENGTH
+ # of characters are input.
+Ctrl<n> : NEXT_PAGE
+Ctrl<p> : PREV_PAGE
+Ctrl<a> : TOP_PAGE
+Ctrl<e> : LAST_PAGE
+<Right> : NEXT_CAND
+<Left> : PREV_CAND
+<Up> : UP_CAND
+<Down> : DOWN_CAND
+Ctrl<k> : SELECT_CAND
+#end of actions
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+END_STATE
+
+STATE "[ Unicode Octal ]"
+STATE_TYPE: CODE_INPUT
+#attributes
+MAX_INPUT_LENGTH: 6 # 1|2|3|4|5|,...
+ # when the number of input sequence
+ # reaches to the given number,
+ # conversion occurs automatically.
+
+TYPE_OF_INPUT: OCTET # HEX or OCTET. The default is HEX.
+ # If it's HEX, valid input is: 0-9,
+ # a-f, A-F.
+ # If it's OCTET, valid input is: 0-7
+#end of attributes
+#actions
+Ctrl<w> : DO_LOOKUP
+<space> : DO_CONV
+ # force to convert input sequence into
+ # a character before MAX_INPUT_LENGTH
+ # of characters are input.
+Ctrl<n> : NEXT_PAGE
+Ctrl<p> : PREV_PAGE
+Ctrl<a> : TOP_PAGE
+Ctrl<e> : LAST_PAGE
+<Right> : NEXT_CAND
+<Left> : PREV_CAND
+<Up> : UP_CAND
+<Down> : DOWN_CAND
+Ctrl<k> : SELECT_CAND
+#end of actions
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <l> <l> : SWITCH_STATE_TO "[ Lookup ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+END_STATE
+
+STATE "[ Lookup ]"
+STATE_TYPE: LOOKUP
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+<Multi_key> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+<Multi_key> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+<Multi_key> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+<Multi_key> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+<Multi_key> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+<Multi_key> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+<Multi_key> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+<Multi_key> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+<Multi_key> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+<Multi_key> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+<Multi_key> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+Ctrl<T> <c> <c> : SWITCH_STATE_TO "[ Cyrillic ]"
+Ctrl<T> <g> <g> : SWITCH_STATE_TO "[ Greek ]"
+Ctrl<T> <t> <t> : SWITCH_STATE_TO "[ Thai ]"
+Ctrl<T> <a> <r> : SWITCH_STATE_TO "[ Arabic ]"
+Ctrl<T> <h> <h> : SWITCH_STATE_TO "[ Hebrew ]"
+Ctrl<T> <u> <h> : SWITCH_STATE_TO "[ Unicode Hex ]"
+Ctrl<T> <u> <o> : SWITCH_STATE_TO "[ Unicode Octal ]"
+Ctrl<T> <j> <a> : SWITCH_STATE_TO "[ Japanese ]"
+Ctrl<T> <k> <o> : SWITCH_STATE_TO "[ Korean ]"
+Ctrl<T> <s> <c> : SWITCH_STATE_TO "[ S-Chinese ]"
+Ctrl<T> <t> <c> : SWITCH_STATE_TO "[ T-Chinese ]"
+
+#attributes
+MAX_NUMBER_OF_ROWS : 6
+MAX_NUMBER_OF_COLUMNS : 16
+MAX_NUMBER_OF_CANDIDATES : 80 # <= 94 best if it's multiple of 16
+TITLE_STRING: "Lookup Selection Window"
+FONTSET: "-dt-interface user-medium-r-normal-s*utf*-*-*-*-*-*-*-*-*"
+POSITION: CURSOR # CURSOR/CLIENT
+PLACEMENT: BOTTOM # TOP/BOTTOM/LEFT/RIGHT
+"a - Basic Latin" : 0x0000 0x007f
+"b - Latin 1" : 0x0080 0x00ff
+"c - Latin Extended A" : 0x0100 0x017f
+"d - Latin Extended B" : 0x0180 0x024f
+# N/A IPA Extension : 0x0250 0x02af
+"e - Spacing Modifier Letters" : 0x02b0 0x02ff
+# N/A Combining Diaetrical Marks : 0x0300 0x036f
+"f - Greek" : 0x0370 0x03ff
+"g - Cyrillic" : 0x0400 0x04ff
+# N/A Armenian : 0x0530 0x058f
+"h - Hebrew" : 0x0590 0x05ff
+"i - Arabic" : 0x0600 0x06ff
+# N/A Davangari : 0x0900 0x097f
+# N/A Bengali : 0x0980 0x09ff
+# N/A Gurmukhi : 0x0a00 0x0a7f
+# N/A Gujarati : 0x0a80 0x0aff
+# N/A Oriya : 0x0b00 0x0b7f
+# N/A Tamil : 0x0b80 0x0bff
+# N/A Telugu : 0x0c00 0x0c7f
+# N/A Kannada : 0x0c80 0x0cff
+# N/A Malayalam : 0x0d00 0x0d7f
+"j - Thai" : 0x0e00 0x0e7f
+# N/A Lao : 0x0e80 0x0eff
+# N/A Tibetan : 0x0f00 0x0fbf
+# N/A Georgian : 0x10a0 0x10ff
+# N/A Hangul Jamo : 0x1100 0x11ff
+# N/A Latin Extended Additional : 0x1e00 0x1eff
+# N/A Greek Extended : 0x1f00 0x1fff
+"k - General Punctuation" : 0x2000 0x206f
+"l - Superscripts Subscripts" : 0x2070 0x209f
+"m - Currency Symbols" : 0x20a0 0x20cf
+# N/A Combining Diacritical Marks for Symbols : 0x20d0 0x20ff
+"n - Letterlike Symbols" : 0x2100 0x214f
+"o - Number Forms" : 0x2150 0x218f
+"p - Arrows" : 0x2190 0x21ff
+"q - Mathematical Operators" : 0x2200 0x22ff
+"r - Miscellaneous Techical" : 0x2300 0x23ff
+# N/A Control Pictures : 0x2400 0x243f
+# N/A Optical Character Recognition : 0x2440 0x245f
+"s - Enclosed Alphanumerics" : 0x2460 0x24ff
+"t - Box Drawing" : 0x2500 0x257f
+"u - Block Elements" : 0x2580 0x259f
+"v - Geometric Shapes" : 0x25a0 0x25ff
+"w - Miscellaneous Symbols" : 0x2600 0x26ff
+# N/A Dingbats : 0x2700 0x27bf
+"x - CJK Symbols and Punctuation" : 0x3000 0x303f
+"y - Hiragana" : 0x3040 0x309f
+"z - Katakana" : 0x30a0 0x30ff
+"0 - Bopomofo" : 0x3100 0x312f
+"1 - Hangul Compatibility Jamo" : 0x3130 0x318f
+# N/A Kanbun : 0x3190 0x319f
+"2 - Enclosed CJK Letters and Months" : 0x3200 0x32ff
+"3 - CJK Compatibility" : 0x3300 0x33ff
+"4 - CJK Unified Ideographs" : 0x4e00 0x9fa5
+"5 - Hangul Syllables" : 0xac00 0xd7a3
+# N/A High Surrogates : 0xd800 0xdb7f
+# N/A Private Use High Surrogates : 0xdb80 0xdbff
+# N/A Low Surrogates : 0xdc00 0xdfff
+# N/A Private Use Area : 0xe000 0xf8ff
+"6 - CJK Compatibility Ideographs" : 0xf900 0xfaff
+# N/A Alphabetic Presentation Forms : 0xfb00 0xfb4f
+# N/A Arabic Presentation Forms-A : 0xfb50 0xfdff
+# N/A Combining Half Marks : 0xfe20 0xfe2f
+"7 - CJK Compatibility Forms" : 0xfe30 0xfe4f
+"8 - Small Form Variants" : 0xfe50 0xfe6f
+# N/A Arabic Presentation Forms-B : 0xfe70 0xfeff
+"9 - Halfwidth and Fullwidth Forms" : 0xff00 0xffef
+"/ - Specials" : 0xfff0 0xffff
+#end of attributes
+
+#actions
+Ctrl<n> : NEXT_PAGE
+Ctrl<p> : PREV_PAGE
+Ctrl<a> : TOP_PAGE
+Ctrl<e> : LAST_PAGE
+<Right> : NEXT_CAND
+<Left> : PREV_CAND
+<Up> : UP_CAND
+<Down> : DOWN_CAND
+Ctrl<k> : SELECT_CAND
+#end of actions
+END_STATE
+
+STATE "[ Japanese ]"
+STATE_TYPE: REMOTE_IM
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+LANGUAGE : ja
+END_STATE
+
+STATE "[ Korean ]"
+STATE_TYPE: REMOTE_IM
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+
+LANGUAGE : ko
+END_STATE
+
+STATE "[ S-Chinese ]"
+STATE_TYPE: REMOTE_IM
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+
+LANGUAGE : zh_CN
+END_STATE
+
+STATE "[ T-Chinese ]"
+STATE_TYPE: REMOTE_IM
+Ctrl<space> : SWITCH_STATE_TO "[ English/European ]"
+
+LANGUAGE : zh_TW
+END_STATE
diff --git a/nls/en_US.UTF-8/XI18N_OBJS b/nls/en_US.UTF-8/XI18N_OBJS
new file mode 100644
index 00000000..da1a9587
--- /dev/null
+++ b/nls/en_US.UTF-8/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlcUTF-8 _XlcUnicodeLoader # XLC_open
+XOM common/xomLTRTTB _XomGenericOpenOM # XOM_open
+XIM common/xiiimp _SwitchOpenIM # XIM_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
diff --git a/nls/en_US.UTF-8/XLC_LOCALE.pre b/nls/en_US.UTF-8/XLC_LOCALE.pre
new file mode 100644
index 00000000..d1e7e2c2
--- /dev/null
+++ b/nls/en_US.UTF-8/XLC_LOCALE.pre
@@ -0,0 +1,365 @@
+XCOMM
+XCOMM Copyright (c) 1996-1998 by Sun Microsystems, Inc.
+XCOMM All rights reserved.
+XCOMM
+#ident "@(#)en_US.UTF-8 1.26 98/11/17 SMI"
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+
+XCOMM fs0 class
+fs0 {
+ charset ISO8859-1:GL
+ font {
+ primary ISO8859-1:GL
+ }
+}
+
+XCOMM fs1 class
+fs1 {
+ charset ISO8859-1:GR
+ font {
+ primary ISO8859-1:GR
+ }
+}
+
+XCOMM fs2 class
+fs2 {
+ charset ISO8859-5:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-5:GR
+ }
+}
+XCOMM fs3 class
+fs3 {
+ charset ISO8859-7:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-7:GR
+ }
+}
+
+XCOMM fs4 class
+fs4 {
+ charset ISO8859-2:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-2:GR
+ }
+}
+
+XCOMM fs5 class
+fs5 {
+ charset ISO8859-4:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-4:GR
+ }
+}
+
+XCOMM fs6 class
+fs6 {
+ charset ISO8859-9:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-9:GR
+ }
+}
+
+XCOMM fs7 class
+fs7 {
+ charset ISO8859-15:GR
+ font {
+ load_option delay_nocheck
+ primary ISO8859-15:GR
+ }
+}
+
+XCOMM fs8 class for JISX0208
+fs8 {
+ charset JISX0208.1983-0:GR
+ font {
+ load_option delay_nocheck
+ primary JISX0208.1983-0:GL
+ }
+}
+
+XCOMM fs9 class for JISX0201 kana
+fs9 {
+ charset JISX0201.1976-0:GR
+ font {
+ load_option delay_nocheck
+ primary JISX0201.1976-0:GR
+ }
+}
+
+XCOMM fs10 calss for KS C 5601-1992 Supplementary Codes 3
+fs10 {
+ charset KSC5601.1992-3:GLGR
+ font {
+ primary KSC5601.1992-3:GLGR
+ }
+}
+
+XCOMM fs11 class
+fs11 {
+ charset GB2312.1980-0:GR
+ font {
+ load_option delay_nocheck
+ primary GB2312.1980-0:GL
+ }
+}
+
+XCOMM fs12 class
+fs12 {
+ charset BIG5-1:GLGR
+ font {
+ load_option delay_nocheck
+ primary BIG5-1:GLGR
+ }
+}
+
+XCOMM fs13 class (Thai)
+fs13 {
+ charset TIS620.2533-0:GR
+ font {
+ primary TIS620.2533-0:GR
+ }
+}
+
+XCOMM fs14 class (ISO8859-6) (Arabic)
+fs14 {
+ charset ISO8859-6:GLGR
+ font {
+ primary ISO8859-6:GLGR
+ }
+}
+
+XCOMM fs15 class (ISO8859-8) (Hebrew)
+fs15 {
+ charset ISO8859-8:GR
+ font {
+ primary ISO8859-8:GR
+ }
+}
+
+XCOMM fs16 (Last, fallback) class (unicode-fontspecific)
+fs16 {
+ charset UNICODE-FONTSPECIFIC:GLGR
+ font {
+ load_option delay_nocheck
+ primary UNICODE-FONTSPECIFIC:GLGR
+ }
+}
+
+END XLC_FONTSET
+
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name en_US.UTF-8
+mb_cur_max 8
+state_depend_encoding False
+
+mb_encoding_name UTF-8
+wc_encoding_name UCS-4
+wc_valid_length 2
+wc_conversion_table conv_tables/UCS_TO_CS
+
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ ct_encoding ISO8859-1:GL
+ byte1 \x00,\x7f
+ cs_range \x00,\x7f
+ cs_conversion [\x00,\x7f]->\x00
+ cs_conversion_table conv_tables/ISO8859-1.GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-1:GR
+ byte1 \x80,\xff
+ cs_range \x80,\xff
+ cs_conversion [\x80,\xff]->\x80
+ cs_conversion_table conv_tables/ISO8859-1.GR
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-5:GR
+ byte1 \xa0,\xff
+ cs_range \xa0,\xff
+ cs_conversion_file conv_tables/ISO8859-5.GR.txt
+ cs_conversion_table conv_tables/ISO8859-5.GR
+}
+
+XCOMM cs3 class
+cs3 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-7:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-7.GR.txt
+ cs_conversion_table conv_tables/ISO8859-7.GR
+}
+
+XCOMM cs4 class
+cs4 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-2:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-2.GR.txt
+ cs_conversion_table conv_tables/ISO8859-2.GR
+}
+
+XCOMM cs5 class
+cs5 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-4:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-4.GR.txt
+ cs_conversion_table conv_tables/ISO8859-4.GR
+}
+
+XCOMM cs6 class
+cs6 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-9:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-9.GR.txt
+ cs_conversion_table conv_tables/ISO8859-9.GR
+}
+
+XCOMM cs7 class
+cs7 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-15:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-15.GR.txt
+ cs_conversion_table conv_tables/ISO8859-15.GR
+}
+
+XCOMM cs8 class
+cs8 {
+ side GR:Default
+ length 2
+ ct_encoding JISX0208.1983-0:GR;
+ byte1 \xa1,\xfe
+ byte2 \xa1,\xfe
+ cs_conversion_file conv_tables/JISX0208-0.GR.txt
+ cs_conversion_table conv_tables/JISX0208-0.GR
+}
+
+XCOMM cs9 class
+cs9 {
+ side GR:Default
+ length 1
+ ct_encoding JISX0201.1976-0:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/JISX0201-0.GR.txt
+ cs_conversion_table conv_tables/JISX0201-0.GR
+}
+
+XCOMM cs10 class
+cs10 {
+ side GR:Default
+ length 2
+ ct_encoding KSC5601.1992-3:GLGR
+ byte1 \x88,\xf9
+ byte2 \x31,\xfe
+ cs_conversion_file conv_tables/KSC-JOHAP.GLGR.txt
+ cs_conversion_table conv_tables/KSC-JOHAP.GLGR
+
+}
+
+XCOMM cs11 class
+cs11 {
+ side GR:Default
+ length 2
+ ct_encoding GB2312.1980-0:GR
+ byte1 \xa1,\xfe
+ byte2 \xa1,\xfe
+ cs_conversion_file conv_tables/GB2312-0.GR.txt
+ cs_conversion_table conv_tables/GB2312-0.GR
+}
+
+XCOMM cs12 class
+cs12 {
+ side GR:Default
+ length 2
+ ct_encoding BIG5-1:GLGR
+ byte1 \xa1,\xf9
+ byte2 \x31,\xfe
+ cs_conversion_file conv_tables/BIG5-1.GLGR.txt
+ cs_conversion_table conv_tables/BIG5-1.GLGR
+
+}
+
+XCOMM cs13 class
+cs13 {
+ side GR:Default
+ length 1
+ ct_encoding TIS620.2533-0:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/TIS620.2533-0.GR.txt
+ cs_conversion_table conv_tables/TIS620.2533-0.GR
+}
+
+XCOMM cs14 class
+cs14 {
+ side GR:Default
+ length 2
+ ct_encoding ISO8859-6:GLGR
+ byte1 \x00,\xff
+ byte2 \x00,\xff
+ cs_conversion_file conv_tables/ISO8859-6.GLGR.txt
+ cs_conversion_table conv_tables/ISO8859-6.GLGR
+}
+
+XCOMM cs15 class
+cs15 {
+ side GR:Default
+ length 1
+ ct_encoding ISO8859-8:GR
+ byte1 \xa0,\xfe
+ cs_range \xa0,\xfe
+ cs_conversion_file conv_tables/ISO8859-8.GR.txt
+ cs_conversion_table conv_tables/ISO8859-8.GR
+}
+
+XCOMM Last, fallback class
+cs16 {
+ side GR:Default
+ length 2
+ ct_encoding UNICODE-FONTSPECIFIC:GLGR
+ byte1 \x00,\xff
+ byte2 \x00,\xff
+ cs_conversion [\x0000,\xffff]->\x0000
+ cs_conversion_table conv_tables/UNICODE-FONTSPECIFIC.GLGR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-1/Compose.pre b/nls/iso8859-1/Compose.pre
new file mode 100644
index 00000000..63038ca0
--- /dev/null
+++ b/nls/iso8859-1/Compose.pre
@@ -0,0 +1,810 @@
+# $Xorg: iso8859-1,v 1.3 2000/08/17 19:46:59 cpqbld Exp $
+#
+# ISO 8859-1 (Latin1) Compose Sequence
+#
+# Sequence Definition
+#
+# <Multi_key> Means <Compose>
+# Special Character
+<Multi_key> <plus> <plus> : "#" numbersign
+<Multi_key> <apostrophe> <space> : "'" apostrophe
+<Multi_key> <space> <apostrophe> : "'" apostrophe
+<Multi_key> <A> <A> : "@" at
+<Multi_key> <parenleft> <parenleft> : "[" bracketleft
+<Multi_key> <slash> <slash> : "\\" backslash
+<Multi_key> <slash> <less> : "\\" backslash
+<Multi_key> <less> <slash> : "\\" backslash
+<Multi_key> <parenright> <parenright> : "]" bracketright
+<Multi_key> <asciicircum> <space> : "^" asciicircum
+<Multi_key> <space> <asciicircum> : "^" asciicircum
+<Multi_key> <greater> <space> : "^" asciicirum
+<Multi_key> <space> <greater> : "^" asciicirum
+<Multi_key> <grave> <space> : "`" grave
+<Multi_key> <space> <grave> : "`" grave
+<Multi_key> <parenleft> <minus> : "{" braceleft
+<Multi_key> <minus> <parenleft> : "{" braceleft
+<Multi_key> <slash> <asciicircum> : "|" bar
+<Multi_key> <asciicircum> <slash> : "|" bar
+<Multi_key> <V> <L> : "|" bar
+<Multi_key> <L> <V> : "|" bar
+<Multi_key> <v> <l> : "|" bar
+<Multi_key> <l> <v> : "|" bar
+<Multi_key> <parenright> <minus> : "}" braceright
+<Multi_key> <minus> <parenright> : "}" braceright
+<Multi_key> <asciitilde> <space> : "~" asciitilde
+<Multi_key> <space> <asciitilde> : "~" asciitilde
+<Multi_key> <minus> <space> : "~" asciitilde
+<Multi_key> <space> <minus> : "~" asciitilde
+<Multi_key> <exclam> <exclam> : "\241" exclamdown
+<Multi_key> <c> <slash> : "\242" cent
+<Multi_key> <slash> <c> : "\242" cent
+<Multi_key> <C> <slash> : "\242" cent
+<Multi_key> <slash> <C> : "\242" cent
+<Multi_key> <C> <bar> : "\242" cent
+<Multi_key> <bar> <C> : "\242" cent
+<Multi_key> <c> <bar> : "\242" cent
+<Multi_key> <bar> <c> : "\242" cent
+<Multi_key> <l> <minus> : "\243" sterling
+<Multi_key> <minus> <l> : "\243" sterling
+<Multi_key> <L> <minus> : "\243" sterling
+<Multi_key> <minus> <L> : "\243" sterling
+<Multi_key> <l> <equal> : "\243" sterling
+<Multi_key> <equal> <l> : "\243" sterling
+<Multi_key> <L> <equal> : "\243" sterling
+<Multi_key> <equal> <L> : "\243" sterling
+<Multi_key> <y> <minus> : "\245" yen
+<Multi_key> <minus> <y> : "\245" yen
+<Multi_key> <Y> <minus> : "\245" yen
+<Multi_key> <minus> <Y> : "\245" yen
+<Multi_key> <y> <equal> : "\245" yen
+<Multi_key> <equal> <y> : "\245" yen
+<Multi_key> <Y> <equal> : "\245" yen
+<Multi_key> <equal> <Y> : "\245" yen
+<Multi_key> <s> <o> : "\247" section
+<Multi_key> <o> <s> : "\247" section
+<Multi_key> <S> <O> : "\247" section
+<Multi_key> <O> <S> : "\247" section
+<Multi_key> <S> <exclam> : "\247" section
+<Multi_key> <exclam> <S> : "\247" section
+<Multi_key> <s> <exclam> : "\247" section
+<Multi_key> <exclam> <s> : "\247" section
+<Multi_key> <S> <0> : "\247" section
+<Multi_key> <0> <S> : "\247" section
+<Multi_key> <s> <0> : "\247" section
+<Multi_key> <0> <s> : "\247" section
+<Multi_key> <x> <o> : "\244" currency
+<Multi_key> <o> <x> : "\244" currency
+<Multi_key> <X> <O> : "\244" currency
+<Multi_key> <O> <X> : "\244" currency
+<Multi_key> <x> <O> : "\244" currency
+<Multi_key> <O> <x> : "\244" currency
+<Multi_key> <X> <o> : "\244" currency
+<Multi_key> <o> <X> : "\244" currency
+<Multi_key> <x> <0> : "\244" currency
+<Multi_key> <0> <x> : "\244" currency
+<Multi_key> <X> <0> : "\244" currency
+<Multi_key> <0> <X> : "\244" currency
+<Multi_key> <c> <o> : "\251" copyright
+<Multi_key> <o> <c> : "\251" copyright
+<Multi_key> <C> <O> : "\251" copyright
+<Multi_key> <O> <C> : "\251" copyright
+<Multi_key> <c> <O> : "\251" copyright
+<Multi_key> <O> <c> : "\251" copyright
+<Multi_key> <C> <o> : "\251" copyright
+<Multi_key> <o> <C> : "\251" copyright
+<Multi_key> <c> <0> : "\251" copyright
+<Multi_key> <0> <c> : "\251" copyright
+<Multi_key> <C> <0> : "\251" copyright
+<Multi_key> <0> <C> : "\251" copyright
+<Multi_key> <a> <underscore> : "\252" ordfeminine
+<Multi_key> <underscore> <a> : "\252" ordfeminine
+<Multi_key> <A> <underscore> : "\252" ordfeminine
+<Multi_key> <underscore> <A> : "\252" ordfeminine
+<Multi_key> <o> <underscore> : "\272" masculine
+<Multi_key> <underscore> <o> : "\272" masculine
+<Multi_key> <O> <underscore> : "\272" masculine
+<Multi_key> <underscore> <O> : "\272" masculine
+<Multi_key> <less> <less> : "\253" guillemotleft
+<Multi_key> <greater> <greater> : "\273" guillemotright
+<Multi_key> <0> <asciicircum> : "\260" degree
+<Multi_key> <asciicircum> <0> : "\260" degree
+<Multi_key> <0> <asterisk> : "\260" degree
+<Multi_key> <asterisk> <0> : "\260" degree
+<Multi_key> <plus> <minus> : "\261" plusminus
+<Multi_key> <minus> <plus> : "\261" plusminus
+<Multi_key> <slash> <u> : "\265" mu
+<Multi_key> <u> <slash> : "\265" mu
+<Multi_key> <slash> <U> : "\265" mu
+<Multi_key> <U> <slash> : "\265" mu
+<Multi_key> <1> <asciicircum> : "\271" onesuperior
+<Multi_key> <asciicircum> <1> : "\271" onesuperior
+<Multi_key> <S> <1> : "\271" onesuperior
+<Multi_key> <1> <S> : "\271" onesuperior
+<Multi_key> <s> <1> : "\271" onesuperior
+<Multi_key> <1> <s> : "\271" onesuperior
+<Multi_key> <2> <asciicircum> : "\262" twosuperior
+<Multi_key> <asciicircum> <2> : "\262" twosuperior
+<Multi_key> <S> <2> : "\262" twosuperior
+<Multi_key> <2> <S> : "\262" twosuperior
+<Multi_key> <s> <2> : "\262" twosuperior
+<Multi_key> <2> <s> : "\262" twosuperior
+<Multi_key> <3> <asciicircum> : "\263" threesuperior
+<Multi_key> <asciicircum> <3> : "\263" threesuperior
+<Multi_key> <S> <3> : "\263" threesuperior
+<Multi_key> <3> <S> : "\263" threesuperior
+<Multi_key> <s> <3> : "\263" threesuperior
+<Multi_key> <3> <s> : "\263" threesuperior
+<Multi_key> <p> <exclam> : "\266" paragraph
+<Multi_key> <exclam> <p> : "\266" paragraph
+<Multi_key> <P> <exclam> : "\266" paragraph
+<Multi_key> <exclam> <P> : "\266" paragraph
+<Multi_key> <period> <asciicircum> : "\267" periodcentered
+<Multi_key> <asciicircum> <period> : "\267" periodcentered
+<Multi_key> <period> <period> : "\267" periodcentered
+<Multi_key> <1> <4> : "\274" onequarter
+<Multi_key> <1> <2> : "\275" onehalf
+<Multi_key> <3> <4> : "\276" threequarters
+<Multi_key> <question> <question> : "\277" questiondown
+<Multi_key> <space> <space> : "\240" nobreakspace
+<Multi_key> <bar> <bar> : "\246" brokenbar
+<Multi_key> <exclam> <asciicircum> : "\246" brokenbar
+<Multi_key> <asciicircum> <exclam> : "\246" brokenbar
+<Multi_key> <V> <B> : "\246" brokenbar
+<Multi_key> <B> <V> : "\246" brokenbar
+<Multi_key> <v> <b> : "\246" brokenbar
+<Multi_key> <b> <v> : "\246" brokenbar
+<Multi_key> <minus> <comma> : "\254" notsign
+<Multi_key> <comma> <minus> : "\254" notsign
+<Multi_key> <minus> <minus> : "\255" hyphen
+<Multi_key> <R> <O> : "\256" registered
+<Multi_key> <O> <R> : "\256" registered
+<Multi_key> <minus> <asciicircum> : "\257" macron
+<Multi_key> <asciicircum> <minus> : "\257" macron
+<Multi_key> <underscore> <asciicircum> : "\257" macron
+<Multi_key> <asciicircum> <underscore> : "\257" macron
+<Multi_key> <underscore> <underscore> : "\257" macron
+<Multi_key> <minus> <colon> : "\367" division
+<Multi_key> <colon> <minus> : "\367" division
+<Multi_key> <x> <x> : "\327" multiply
+<Multi_key> <apostrophe> <apostrophe> : "\264" acute
+<Multi_key> <comma> <comma> : "\270" cedilla
+<Multi_key> <quotedbl> <quotedbl> : "\250" diaeresis
+# Accented Alphabet
+<Multi_key> <A> <grave> : "\300" Agrave
+<Multi_key> <grave> <A> : "\300" Agrave
+<Multi_key> <A> <acute> : "\301" Aacute
+<Multi_key> <acute> <A> : "\301" Aacute
+<Multi_key> <A> <apostrophe> : "\301" Aacute
+<Multi_key> <apostrophe> <A> : "\301" Aacute
+<Multi_key> <A> <asciicircum> : "\302" Acircumflex
+<Multi_key> <asciicircum> <A> : "\302" Acircumflex
+<Multi_key> <A> <greater> : "\302" Acircumflex
+<Multi_key> <greater> <A> : "\302" Acircumflex
+<Multi_key> <A> <asciitilde> : "\303" Atilde
+<Multi_key> <asciitilde> <A> : "\303" Atilde
+<Multi_key> <A> <minus> : "\303" Atilde
+<Multi_key> <minus> <A> : "\303" Atilde
+<Multi_key> <A> <quotedbl> : "\304" Adiaeresis
+<Multi_key> <quotedbl> <A> : "\304" Adiaeresis
+<Multi_key> <A> <diaeresis> : "\304" Adiaeresis
+<Multi_key> <diaeresis> <A> : "\304" Adiaeresis
+<Multi_key> <A> <asterisk> : "\305" Aring
+<Multi_key> <asterisk> <A> : "\305" Aring
+<Multi_key> <A> <E> : "\306" AE
+<Multi_key> <a> <grave> : "\340" agrave
+<Multi_key> <grave> <a> : "\340" agrave
+<Multi_key> <a> <acute> : "\341" aacute
+<Multi_key> <acute> <a> : "\341" aacute
+<Multi_key> <a> <apostrophe> : "\341" aacute
+<Multi_key> <apostrophe> <a> : "\341" aacute
+<Multi_key> <a> <asciicircum> : "\342" acircumflex
+<Multi_key> <asciicircum> <a> : "\342" acircumflex
+<Multi_key> <a> <greater> : "\342" acircumflex
+<Multi_key> <greater> <a> : "\342" acircumflex
+<Multi_key> <a> <asciitilde> : "\343" atilde
+<Multi_key> <asciitilde> <a> : "\343" atilde
+<Multi_key> <a> <minus> : "\343" atilde
+<Multi_key> <minus> <a> : "\343" atilde
+<Multi_key> <a> <quotedbl> : "\344" adiaeresis
+<Multi_key> <quotedbl> <a> : "\344" adiaeresis
+<Multi_key> <a> <diaeresis> : "\344" adiaeresis
+<Multi_key> <diaeresis> <a> : "\344" adiaeresis
+<Multi_key> <a> <asterisk> : "\345" aring
+<Multi_key> <asterisk> <a> : "\345" aring
+<Multi_key> <a> <e> : "\346" ae
+<Multi_key> <C> <comma> : "\307" Ccedilla
+<Multi_key> <comma> <C> : "\307" Ccedilla
+<Multi_key> <c> <comma> : "\347" ccedilla
+<Multi_key> <comma> <c> : "\347" ccedilla
+<Multi_key> <minus> <D> : "\320" ETH
+<Multi_key> <D> <minus> : "\320" ETH
+<Multi_key> <minus> <d> : "\360" eth
+<Multi_key> <d> <minus> : "\360" eth
+<Multi_key> <E> <grave> : "\310" Egrave
+<Multi_key> <grave> <E> : "\310" Egrave
+<Multi_key> <E> <acute> : "\311" Eacute
+<Multi_key> <acute> <E> : "\311" Eacute
+<Multi_key> <E> <apostrophe> : "\311" Eacute
+<Multi_key> <apostrophe> <E> : "\311" Eacute
+<Multi_key> <E> <asciicircum> : "\312" Ecircumflex
+<Multi_key> <asciicircum> <E> : "\312" Ecircumflex
+<Multi_key> <E> <greater> : "\312" Ecircumflex
+<Multi_key> <greater> <E> : "\312" Ecircumflex
+<Multi_key> <E> <quotedbl> : "\313" Ediaeresis
+<Multi_key> <quotedbl> <E> : "\313" Ediaeresis
+<Multi_key> <E> <diaeresis> : "\313" Ediaeresis
+<Multi_key> <diaeresis> <E> : "\313" Ediaeresis
+<Multi_key> <e> <grave> : "\350" egrave
+<Multi_key> <grave> <e> : "\350" egrave
+<Multi_key> <e> <acute> : "\351" eacute
+<Multi_key> <acute> <e> : "\351" eacute
+<Multi_key> <e> <apostrophe> : "\351" eacute
+<Multi_key> <apostrophe> <e> : "\351" eacute
+<Multi_key> <e> <asciicircum> : "\352" ecircumflex
+<Multi_key> <asciicircum> <e> : "\352" ecircumflex
+<Multi_key> <e> <greater> : "\352" ecircumflex
+<Multi_key> <greater> <e> : "\352" ecircumflex
+<Multi_key> <e> <quotedbl> : "\353" ediaeresis
+<Multi_key> <quotedbl> <e> : "\353" ediaeresis
+<Multi_key> <e> <diaeresis> : "\353" ediaeresis
+<Multi_key> <diaeresis> <e> : "\353" ediaeresis
+<Multi_key> <I> <grave> : "\314" Igrave
+<Multi_key> <grave> <I> : "\314" Igrave
+<Multi_key> <I> <acute> : "\315" Iacute
+<Multi_key> <acute> <I> : "\315" Iacute
+<Multi_key> <I> <apostrophe> : "\315" Iacute
+<Multi_key> <apostrophe> <I> : "\315" Iacute
+<Multi_key> <I> <asciicircum> : "\316" Icircumflex
+<Multi_key> <asciicircum> <I> : "\316" Icircumflex
+<Multi_key> <I> <greater> : "\316" Icircumflex
+<Multi_key> <greater> <I> : "\316" Icircumflex
+<Multi_key> <I> <quotedbl> : "\317" Idiaeresis
+<Multi_key> <quotedbl> <I> : "\317" Idiaeresis
+<Multi_key> <I> <diaeresis> : "\317" Idiaeresis
+<Multi_key> <diaeresis> <I> : "\317" Idiaeresis
+<Multi_key> <i> <grave> : "\354" igrave
+<Multi_key> <grave> <i> : "\354" igrave
+<Multi_key> <i> <acute> : "\355" iacute
+<Multi_key> <acute> <i> : "\355" iacute
+<Multi_key> <i> <apostrophe> : "\355" iacute
+<Multi_key> <apostrophe> <i> : "\355" iacute
+<Multi_key> <i> <asciicircum> : "\356" icircumflex
+<Multi_key> <asciicircum> <i> : "\356" icircumflex
+<Multi_key> <i> <greater> : "\356" icircumflex
+<Multi_key> <greater> <i> : "\356" icircumflex
+<Multi_key> <i> <quotedbl> : "\357" idiaeresis
+<Multi_key> <quotedbl> <i> : "\357" idiaeresis
+<Multi_key> <i> <diaeresis> : "\357" idiaeresis
+<Multi_key> <diaeresis> <i> : "\357" idiaeresis
+<Multi_key> <N> <asciitilde> : "\321" Ntilde
+<Multi_key> <asciitilde> <N> : "\321" Ntilde
+<Multi_key> <N> <minus> : "\321" Ntilde
+<Multi_key> <minus> <N> : "\321" Ntilde
+<Multi_key> <n> <asciitilde> : "\361" ntilde
+<Multi_key> <asciitilde> <n> : "\361" ntilde
+<Multi_key> <n> <minus> : "\361" ntilde
+<Multi_key> <minus> <n> : "\361" ntilde
+<Multi_key> <O> <grave> : "\322" Ograve
+<Multi_key> <grave> <O> : "\322" Ograve
+<Multi_key> <O> <acute> : "\323" Oacute
+<Multi_key> <acute> <O> : "\323" Oacute
+<Multi_key> <O> <apostrophe> : "\323" Oacute
+<Multi_key> <apostrophe> <O> : "\323" Oacute
+<Multi_key> <O> <asciicircum> : "\324" Ocircumflex
+<Multi_key> <asciicircum> <O> : "\324" Ocircumflex
+<Multi_key> <O> <greater> : "\324" Ocircumflex
+<Multi_key> <greater> <O> : "\324" Ocircumflex
+<Multi_key> <O> <asciitilde> : "\325" Otilde
+<Multi_key> <asciitilde> <O> : "\325" Otilde
+<Multi_key> <O> <minus> : "\325" Otilde
+<Multi_key> <minus> <O> : "\325" Otilde
+<Multi_key> <O> <quotedbl> : "\326" Odiaeresis
+<Multi_key> <quotedbl> <O> : "\326" Odiaeresis
+<Multi_key> <O> <diaeresis> : "\326" Odiaeresis
+<Multi_key> <diaeresis> <O> : "\326" Odiaeresis
+<Multi_key> <O> <slash> : "\330" Ooblique
+<Multi_key> <slash> <O> : "\330" Ooblique
+<Multi_key> <o> <grave> : "\362" ograve
+<Multi_key> <grave> <o> : "\362" ograve
+<Multi_key> <o> <acute> : "\363" oacute
+<Multi_key> <acute> <o> : "\363" oacute
+<Multi_key> <o> <apostrophe> : "\363" oacute
+<Multi_key> <apostrophe> <o> : "\363" oacute
+<Multi_key> <o> <asciicircum> : "\364" ocircumflex
+<Multi_key> <asciicircum> <o> : "\364" ocircumflex
+<Multi_key> <o> <greater> : "\364" ocircumflex
+<Multi_key> <greater> <o> : "\364" ocircumflex
+<Multi_key> <o> <asciitilde> : "\365" otilde
+<Multi_key> <asciitilde> <o> : "\365" otilde
+<Multi_key> <o> <minus> : "\365" otilde
+<Multi_key> <minus> <o> : "\365" otilde
+<Multi_key> <o> <quotedbl> : "\366" odiaeresis
+<Multi_key> <quotedbl> <o> : "\366" odiaeresis
+<Multi_key> <o> <diaeresis> : "\366" odiaeresis
+<Multi_key> <diaeresis> <o> : "\366" odiaeresis
+<Multi_key> <o> <slash> : "\370" oslash
+<Multi_key> <slash> <o> : "\370" oslash
+<Multi_key> <U> <grave> : "\331" Ugrave
+<Multi_key> <grave> <U> : "\331" Ugrave
+<Multi_key> <U> <acute> : "\332" Uacute
+<Multi_key> <acute> <U> : "\332" Uacute
+<Multi_key> <U> <apostrophe> : "\332" Uacute
+<Multi_key> <apostrophe> <U> : "\332" Uacute
+<Multi_key> <U> <asciicircum> : "\333" Ucircumflex
+<Multi_key> <asciicircum> <U> : "\333" Ucircumflex
+<Multi_key> <U> <greater> : "\333" Ucircumflex
+<Multi_key> <greater> <U> : "\333" Ucircumflex
+<Multi_key> <U> <quotedbl> : "\334" Udiaeresis
+<Multi_key> <quotedbl> <U> : "\334" Udiaeresis
+<Multi_key> <U> <diaeresis> : "\334" Udiaeresis
+<Multi_key> <diaeresis> <U> : "\334" Udiaeresis
+<Multi_key> <u> <grave> : "\371" ugrave
+<Multi_key> <grave> <u> : "\371" ugrave
+<Multi_key> <u> <acute> : "\372" uacute
+<Multi_key> <acute> <u> : "\372" uacute
+<Multi_key> <u> <apostrophe> : "\372" uacute
+<Multi_key> <apostrophe> <u> : "\372" uacute
+<Multi_key> <u> <asciicircum> : "\373" ucircumflex
+<Multi_key> <asciicircum> <u> : "\373" ucircumflex
+<Multi_key> <u> <greater> : "\373" ucircumflex
+<Multi_key> <greater> <u> : "\373" ucircumflex
+<Multi_key> <u> <quotedbl> : "\374" udiaeresis
+<Multi_key> <quotedbl> <u> : "\374" udiaeresis
+<Multi_key> <u> <diaeresis> : "\374" udiaeresis
+<Multi_key> <diaeresis> <u> : "\374" udiaeresis
+<Multi_key> <s> <s> : "\337" ssharp
+<Multi_key> <T> <H> : "\336" THORN
+<Multi_key> <t> <h> : "\376" thorn
+<Multi_key> <Y> <acute> : "\335" Yacute
+<Multi_key> <acute> <Y> : "\335" Yacute
+<Multi_key> <Y> <apostrophe> : "\335" Yacute
+<Multi_key> <apostrophe> <Y> : "\335" Yacute
+<Multi_key> <y> <acute> : "\375" yacute
+<Multi_key> <acute> <y> : "\375" yacute
+<Multi_key> <y> <apostrophe> : "\375" yacute
+<Multi_key> <apostrophe> <y> : "\375" yacute
+<Multi_key> <y> <quotedbl> : "\377" ydiaeresis
+<Multi_key> <quotedbl> <y> : "\377" ydiaeresis
+<Multi_key> <y> <diaeresis> : "\377" ydiaeresis
+<Multi_key> <diaeresis> <y> : "\377" ydiaeresis
+#
+#
+# dead key accent keysyms
+# Special Character
+<dead_circumflex> <slash> : "|" bar
+<dead_grave> <space> : "`" grave
+<dead_acute> <space> : "'" apostrophe
+<dead_diaeresis> <space> : "\250" diaeresis
+<dead_circumflex> <space> : "^" asciicircum
+<dead_tilde> <space> : "~" asciitilde
+<dead_grave> <space> : "`" grave
+<dead_acute> <space> : "'" apostrophe
+<dead_circumflex> <0> : "\260" degree
+<dead_circumflex> <1> : "\271" onesuperior
+<dead_circumflex> <2> : "\262" twosuperior
+<dead_circumflex> <3> : "\263" threesuperior
+<dead_circumflex> <period> : "\267" periodcentered
+<dead_circumflex> <exclam> : "\246" brokenbar
+<dead_cedilla> <minus> : "\254" notsign
+<dead_circumflex> <minus> : "\257" macron
+<dead_circumflex> <underscore> : "\257" macron
+<dead_acute> <apostrophe> : "\264" acute
+<dead_cedilla> <comma> : "\270" cedilla
+<dead_diaeresis> <quotedbl> : "\250" diaeresis
+# Accented Alphabet
+<dead_grave> <A> : "\300" Agrave
+<dead_acute> <A> : "\301" Aacute
+<dead_circumflex> <A> : "\302" Acircumflex
+<dead_tilde> <A> : "\303" Atilde
+<dead_diaeresis> <A> : "\304" Adiaeresis
+<dead_grave> <a> : "\340" agrave
+<dead_acute> <a> : "\341" aacute
+<dead_circumflex> <a> : "\342" acircumflex
+<dead_tilde> <a> : "\343" atilde
+<dead_diaeresis> <a> : "\344" adiaeresis
+<dead_cedilla> <C> : "\307" Ccedilla
+<dead_cedilla> <c> : "\347" ccedilla
+<dead_grave> <E> : "\310" Egrave
+<dead_acute> <E> : "\311" Eacute
+<dead_circumflex> <E> : "\312" Ecircumflex
+<dead_diaeresis> <E> : "\313" Ediaeresis
+<dead_grave> <e> : "\350" egrave
+<dead_acute> <e> : "\351" eacute
+<dead_circumflex> <e> : "\352" ecircumflex
+<dead_diaeresis> <e> : "\353" ediaeresis
+<dead_grave> <I> : "\314" Igrave
+<dead_acute> <I> : "\315" Iacute
+<dead_circumflex> <I> : "\316" Icircumflex
+<dead_diaeresis> <I> : "\317" Idiaeresis
+<dead_grave> <i> : "\354" igrave
+<dead_acute> <i> : "\355" iacute
+<dead_circumflex> <i> : "\356" icircumflex
+<dead_diaeresis> <i> : "\357" idiaeresis
+<dead_tilde> <N> : "\321" Ntilde
+<dead_tilde> <n> : "\361" ntilde
+<dead_grave> <O> : "\322" Ograve
+<dead_acute> <O> : "\323" Oacute
+<dead_circumflex> <O> : "\324" Ocircumflex
+<dead_tilde> <O> : "\325" Otilde
+<dead_diaeresis> <O> : "\326" Odiaeresis
+<dead_grave> <o> : "\362" ograve
+<dead_acute> <o> : "\363" oacute
+<dead_circumflex> <o> : "\364" ocircumflex
+<dead_tilde> <o> : "\365" otilde
+<dead_diaeresis> <o> : "\366" odiaeresis
+<dead_grave> <U> : "\331" Ugrave
+<dead_acute> <U> : "\332" Uacute
+<dead_circumflex> <U> : "\333" Ucircumflex
+<dead_diaeresis> <U> : "\334" Udiaeresis
+<dead_grave> <u> : "\371" ugrave
+<dead_acute> <u> : "\372" uacute
+<dead_circumflex> <u> : "\373" ucircumflex
+<dead_diaeresis> <u> : "\374" udiaeresis
+<dead_acute> <Y> : "\335" Yacute
+<dead_acute> <y> : "\375" yacute
+<dead_diaeresis> <y> : "\377" ydiaeresis
+#
+# Ctrl<T> Means <Compose>
+# Special Character
+Ctrl<T> <plus> <plus> : "#" numbersign
+Ctrl<T> <apostrophe> <space> : "'" apostrophe
+Ctrl<T> <space> <apostrophe> : "'" apostrophe
+Ctrl<T> <A> <A> : "@" at
+Ctrl<T> <parenleft> <parenleft> : "[" bracketleft
+Ctrl<T> <slash> <slash> : "\\" backslash
+Ctrl<T> <slash> <less> : "\\" backslash
+Ctrl<T> <less> <slash> : "\\" backslash
+Ctrl<T> <parenright> <parenright> : "]" bracketright
+Ctrl<T> <asciicircum> <space> : "^" asciicircum
+Ctrl<T> <space> <asciicircum> : "^" asciicircum
+Ctrl<T> <greater> <space> : "^" asciicirum
+Ctrl<T> <space> <greater> : "^" asciicirum
+Ctrl<T> <grave> <space> : "`" grave
+Ctrl<T> <space> <grave> : "`" grave
+Ctrl<T> <parenleft> <minus> : "{" braceleft
+Ctrl<T> <minus> <parenleft> : "{" braceleft
+Ctrl<T> <slash> <asciicircum> : "|" bar
+Ctrl<T> <asciicircum> <slash> : "|" bar
+Ctrl<T> <V> <L> : "|" bar
+Ctrl<T> <L> <V> : "|" bar
+Ctrl<T> <v> <l> : "|" bar
+Ctrl<T> <l> <v> : "|" bar
+Ctrl<T> <parenright> <minus> : "}" braceright
+Ctrl<T> <minus> <parenright> : "}" braceright
+Ctrl<T> <asciitilde> <space> : "~" asciitilde
+Ctrl<T> <space> <asciitilde> : "~" asciitilde
+Ctrl<T> <minus> <space> : "~" asciitilde
+Ctrl<T> <space> <minus> : "~" asciitilde
+Ctrl<T> <exclam> <exclam> : "\241" exclamdown
+Ctrl<T> <c> <slash> : "\242" cent
+Ctrl<T> <slash> <c> : "\242" cent
+Ctrl<T> <C> <slash> : "\242" cent
+Ctrl<T> <slash> <C> : "\242" cent
+Ctrl<T> <C> <bar> : "\242" cent
+Ctrl<T> <bar> <C> : "\242" cent
+Ctrl<T> <c> <bar> : "\242" cent
+Ctrl<T> <bar> <c> : "\242" cent
+Ctrl<T> <l> <minus> : "\243" sterling
+Ctrl<T> <minus> <l> : "\243" sterling
+Ctrl<T> <L> <minus> : "\243" sterling
+Ctrl<T> <minus> <L> : "\243" sterling
+Ctrl<T> <l> <equal> : "\243" sterling
+Ctrl<T> <equal> <l> : "\243" sterling
+Ctrl<T> <L> <equal> : "\243" sterling
+Ctrl<T> <equal> <L> : "\243" sterling
+Ctrl<T> <y> <minus> : "\245" yen
+Ctrl<T> <minus> <y> : "\245" yen
+Ctrl<T> <Y> <minus> : "\245" yen
+Ctrl<T> <minus> <Y> : "\245" yen
+Ctrl<T> <y> <equal> : "\245" yen
+Ctrl<T> <equal> <y> : "\245" yen
+Ctrl<T> <Y> <equal> : "\245" yen
+Ctrl<T> <equal> <Y> : "\245" yen
+Ctrl<T> <s> <o> : "\247" section
+Ctrl<T> <o> <s> : "\247" section
+Ctrl<T> <S> <O> : "\247" section
+Ctrl<T> <O> <S> : "\247" section
+Ctrl<T> <S> <exclam> : "\247" section
+Ctrl<T> <exclam> <S> : "\247" section
+Ctrl<T> <s> <exclam> : "\247" section
+Ctrl<T> <exclam> <s> : "\247" section
+Ctrl<T> <S> <0> : "\247" section
+Ctrl<T> <0> <S> : "\247" section
+Ctrl<T> <s> <0> : "\247" section
+Ctrl<T> <0> <s> : "\247" section
+Ctrl<T> <x> <o> : "\244" currency
+Ctrl<T> <o> <x> : "\244" currency
+Ctrl<T> <X> <O> : "\244" currency
+Ctrl<T> <O> <X> : "\244" currency
+Ctrl<T> <x> <O> : "\244" currency
+Ctrl<T> <O> <x> : "\244" currency
+Ctrl<T> <X> <o> : "\244" currency
+Ctrl<T> <o> <X> : "\244" currency
+Ctrl<T> <x> <0> : "\244" currency
+Ctrl<T> <0> <x> : "\244" currency
+Ctrl<T> <X> <0> : "\244" currency
+Ctrl<T> <0> <X> : "\244" currency
+Ctrl<T> <c> <o> : "\251" copyright
+Ctrl<T> <o> <c> : "\251" copyright
+Ctrl<T> <C> <O> : "\251" copyright
+Ctrl<T> <O> <C> : "\251" copyright
+Ctrl<T> <c> <O> : "\251" copyright
+Ctrl<T> <O> <c> : "\251" copyright
+Ctrl<T> <C> <o> : "\251" copyright
+Ctrl<T> <o> <C> : "\251" copyright
+Ctrl<T> <c> <0> : "\251" copyright
+Ctrl<T> <0> <c> : "\251" copyright
+Ctrl<T> <C> <0> : "\251" copyright
+Ctrl<T> <0> <C> : "\251" copyright
+Ctrl<T> <a> <underscore> : "\252" ordfeminine
+Ctrl<T> <underscore> <a> : "\252" ordfeminine
+Ctrl<T> <A> <underscore> : "\252" ordfeminine
+Ctrl<T> <underscore> <A> : "\252" ordfeminine
+Ctrl<T> <o> <underscore> : "\272" masculine
+Ctrl<T> <underscore> <o> : "\272" masculine
+Ctrl<T> <O> <underscore> : "\272" masculine
+Ctrl<T> <underscore> <O> : "\272" masculine
+Ctrl<T> <less> <less> : "\253" guillemotleft
+Ctrl<T> <greater> <greater> : "\273" guillemotright
+Ctrl<T> <0> <asciicircum> : "\260" degree
+Ctrl<T> <asciicircum> <0> : "\260" degree
+Ctrl<T> <0> <asterisk> : "\260" degree
+Ctrl<T> <asterisk> <0> : "\260" degree
+Ctrl<T> <plus> <minus> : "\261" plusminus
+Ctrl<T> <minus> <plus> : "\261" plusminus
+Ctrl<T> <slash> <u> : "\265" mu
+Ctrl<T> <u> <slash> : "\265" mu
+Ctrl<T> <slash> <U> : "\265" mu
+Ctrl<T> <U> <slash> : "\265" mu
+Ctrl<T> <1> <asciicircum> : "\271" onesuperior
+Ctrl<T> <asciicircum> <1> : "\271" onesuperior
+Ctrl<T> <S> <1> : "\271" onesuperior
+Ctrl<T> <1> <S> : "\271" onesuperior
+Ctrl<T> <s> <1> : "\271" onesuperior
+Ctrl<T> <1> <s> : "\271" onesuperior
+Ctrl<T> <2> <asciicircum> : "\262" twosuperior
+Ctrl<T> <asciicircum> <2> : "\262" twosuperior
+Ctrl<T> <S> <2> : "\262" twosuperior
+Ctrl<T> <2> <S> : "\262" twosuperior
+Ctrl<T> <s> <2> : "\262" twosuperior
+Ctrl<T> <2> <s> : "\262" twosuperior
+Ctrl<T> <3> <asciicircum> : "\263" threesuperior
+Ctrl<T> <asciicircum> <3> : "\263" threesuperior
+Ctrl<T> <S> <3> : "\263" threesuperior
+Ctrl<T> <3> <S> : "\263" threesuperior
+Ctrl<T> <s> <3> : "\263" threesuperior
+Ctrl<T> <3> <s> : "\263" threesuperior
+Ctrl<T> <p> <exclam> : "\266" paragraph
+Ctrl<T> <exclam> <p> : "\266" paragraph
+Ctrl<T> <P> <exclam> : "\266" paragraph
+Ctrl<T> <exclam> <P> : "\266" paragraph
+Ctrl<T> <period> <asciicircum> : "\267" periodcentered
+Ctrl<T> <asciicircum> <period> : "\267" periodcentered
+Ctrl<T> <period> <period> : "\267" periodcentered
+Ctrl<T> <1> <4> : "\274" onequarter
+Ctrl<T> <1> <2> : "\275" onehalf
+Ctrl<T> <3> <4> : "\276" threequarters
+Ctrl<T> <question> <question> : "\277" questiondown
+Ctrl<T> <space> <space> : "\240" nobreakspace
+Ctrl<T> <bar> <bar> : "\246" brokenbar
+Ctrl<T> <exclam> <asciicircum> : "\246" brokenbar
+Ctrl<T> <asciicircum> <exclam> : "\246" brokenbar
+Ctrl<T> <V> <B> : "\246" brokenbar
+Ctrl<T> <B> <V> : "\246" brokenbar
+Ctrl<T> <v> <b> : "\246" brokenbar
+Ctrl<T> <b> <v> : "\246" brokenbar
+Ctrl<T> <minus> <comma> : "\254" notsign
+Ctrl<T> <comma> <minus> : "\254" notsign
+Ctrl<T> <minus> <minus> : "\255" hyphen
+Ctrl<T> <R> <O> : "\256" registered
+Ctrl<T> <O> <R> : "\256" registered
+Ctrl<T> <minus> <asciicircum> : "\257" macron
+Ctrl<T> <asciicircum> <minus> : "\257" macron
+Ctrl<T> <underscore> <asciicircum> : "\257" macron
+Ctrl<T> <asciicircum> <underscore> : "\257" macron
+Ctrl<T> <underscore> <underscore> : "\257" macron
+Ctrl<T> <minus> <colon> : "\367" division
+Ctrl<T> <colon> <minus> : "\367" division
+Ctrl<T> <x> <x> : "\327" multiply
+Ctrl<T> <apostrophe> <apostrophe> : "\264" acute
+Ctrl<T> <comma> <comma> : "\270" cedilla
+Ctrl<T> <quotedbl> <quotedbl> : "\250" diaeresis
+# Accented Alphabet
+Ctrl<T> <A> <grave> : "\300" Agrave
+Ctrl<T> <grave> <A> : "\300" Agrave
+Ctrl<T> <A> <acute> : "\301" Aacute
+Ctrl<T> <acute> <A> : "\301" Aacute
+Ctrl<T> <A> <apostrophe> : "\301" Aacute
+Ctrl<T> <apostrophe> <A> : "\301" Aacute
+Ctrl<T> <A> <asciicircum> : "\302" Acircumflex
+Ctrl<T> <asciicircum> <A> : "\302" Acircumflex
+Ctrl<T> <A> <greater> : "\302" Acircumflex
+Ctrl<T> <greater> <A> : "\302" Acircumflex
+Ctrl<T> <A> <asciitilde> : "\303" Atilde
+Ctrl<T> <asciitilde> <A> : "\303" Atilde
+Ctrl<T> <A> <minus> : "\303" Atilde
+Ctrl<T> <minus> <A> : "\303" Atilde
+Ctrl<T> <A> <quotedbl> : "\304" Adiaeresis
+Ctrl<T> <quotedbl> <A> : "\304" Adiaeresis
+Ctrl<T> <A> <diaeresis> : "\304" Adiaeresis
+Ctrl<T> <diaeresis> <A> : "\304" Adiaeresis
+Ctrl<T> <A> <asterisk> : "\305" Aring
+Ctrl<T> <asterisk> <A> : "\305" Aring
+Ctrl<T> <A> <E> : "\306" AE
+Ctrl<T> <a> <grave> : "\340" agrave
+Ctrl<T> <grave> <a> : "\340" agrave
+Ctrl<T> <a> <acute> : "\341" aacute
+Ctrl<T> <acute> <a> : "\341" aacute
+Ctrl<T> <a> <apostrophe> : "\341" aacute
+Ctrl<T> <apostrophe> <a> : "\341" aacute
+Ctrl<T> <a> <asciicircum> : "\342" acircumflex
+Ctrl<T> <asciicircum> <a> : "\342" acircumflex
+Ctrl<T> <a> <greater> : "\342" acircumflex
+Ctrl<T> <greater> <a> : "\342" acircumflex
+Ctrl<T> <a> <asciitilde> : "\343" atilde
+Ctrl<T> <asciitilde> <a> : "\343" atilde
+Ctrl<T> <a> <minus> : "\343" atilde
+Ctrl<T> <minus> <a> : "\343" atilde
+Ctrl<T> <a> <quotedbl> : "\344" adiaeresis
+Ctrl<T> <quotedbl> <a> : "\344" adiaeresis
+Ctrl<T> <a> <diaeresis> : "\344" adiaeresis
+Ctrl<T> <diaeresis> <a> : "\344" adiaeresis
+Ctrl<T> <a> <asterisk> : "\345" aring
+Ctrl<T> <asterisk> <a> : "\345" aring
+Ctrl<T> <a> <e> : "\346" ae
+Ctrl<T> <C> <comma> : "\307" Ccedilla
+Ctrl<T> <comma> <C> : "\307" Ccedilla
+Ctrl<T> <c> <comma> : "\347" ccedilla
+Ctrl<T> <comma> <c> : "\347" ccedilla
+Ctrl<T> <minus> <D> : "\320" ETH
+Ctrl<T> <D> <minus> : "\320" ETH
+Ctrl<T> <minus> <d> : "\360" eth
+Ctrl<T> <d> <minus> : "\360" eth
+Ctrl<T> <E> <grave> : "\310" Egrave
+Ctrl<T> <grave> <E> : "\310" Egrave
+Ctrl<T> <E> <acute> : "\311" Eacute
+Ctrl<T> <acute> <E> : "\311" Eacute
+Ctrl<T> <E> <apostrophe> : "\311" Eacute
+Ctrl<T> <apostrophe> <E> : "\311" Eacute
+Ctrl<T> <E> <asciicircum> : "\312" Ecircumflex
+Ctrl<T> <asciicircum> <E> : "\312" Ecircumflex
+Ctrl<T> <E> <greater> : "\312" Ecircumflex
+Ctrl<T> <greater> <E> : "\312" Ecircumflex
+Ctrl<T> <E> <quotedbl> : "\313" Ediaeresis
+Ctrl<T> <quotedbl> <E> : "\313" Ediaeresis
+Ctrl<T> <E> <diaeresis> : "\313" Ediaeresis
+Ctrl<T> <diaeresis> <E> : "\313" Ediaeresis
+Ctrl<T> <e> <grave> : "\350" egrave
+Ctrl<T> <grave> <e> : "\350" egrave
+Ctrl<T> <e> <acute> : "\351" eacute
+Ctrl<T> <acute> <e> : "\351" eacute
+Ctrl<T> <e> <apostrophe> : "\351" eacute
+Ctrl<T> <apostrophe> <e> : "\351" eacute
+Ctrl<T> <e> <asciicircum> : "\352" ecircumflex
+Ctrl<T> <asciicircum> <e> : "\352" ecircumflex
+Ctrl<T> <e> <greater> : "\352" ecircumflex
+Ctrl<T> <greater> <e> : "\352" ecircumflex
+Ctrl<T> <e> <quotedbl> : "\353" ediaeresis
+Ctrl<T> <quotedbl> <e> : "\353" ediaeresis
+Ctrl<T> <e> <diaeresis> : "\353" ediaeresis
+Ctrl<T> <diaeresis> <e> : "\353" ediaeresis
+Ctrl<T> <I> <grave> : "\314" Igrave
+Ctrl<T> <grave> <I> : "\314" Igrave
+Ctrl<T> <I> <acute> : "\315" Iacute
+Ctrl<T> <acute> <I> : "\315" Iacute
+Ctrl<T> <I> <apostrophe> : "\315" Iacute
+Ctrl<T> <apostrophe> <I> : "\315" Iacute
+Ctrl<T> <I> <asciicircum> : "\316" Icircumflex
+Ctrl<T> <asciicircum> <I> : "\316" Icircumflex
+Ctrl<T> <I> <greater> : "\316" Icircumflex
+Ctrl<T> <greater> <I> : "\316" Icircumflex
+Ctrl<T> <I> <quotedbl> : "\317" Idiaeresis
+Ctrl<T> <quotedbl> <I> : "\317" Idiaeresis
+Ctrl<T> <I> <diaeresis> : "\317" Idiaeresis
+Ctrl<T> <diaeresis> <I> : "\317" Idiaeresis
+Ctrl<T> <i> <grave> : "\354" igrave
+Ctrl<T> <grave> <i> : "\354" igrave
+Ctrl<T> <i> <acute> : "\355" iacute
+Ctrl<T> <acute> <i> : "\355" iacute
+Ctrl<T> <i> <apostrophe> : "\355" iacute
+Ctrl<T> <apostrophe> <i> : "\355" iacute
+Ctrl<T> <i> <asciicircum> : "\356" icircumflex
+Ctrl<T> <asciicircum> <i> : "\356" icircumflex
+Ctrl<T> <i> <greater> : "\356" icircumflex
+Ctrl<T> <greater> <i> : "\356" icircumflex
+Ctrl<T> <i> <quotedbl> : "\357" idiaeresis
+Ctrl<T> <quotedbl> <i> : "\357" idiaeresis
+Ctrl<T> <i> <diaeresis> : "\357" idiaeresis
+Ctrl<T> <diaeresis> <i> : "\357" idiaeresis
+Ctrl<T> <N> <asciitilde> : "\321" Ntilde
+Ctrl<T> <asciitilde> <N> : "\321" Ntilde
+Ctrl<T> <N> <minus> : "\321" Ntilde
+Ctrl<T> <minus> <N> : "\321" Ntilde
+Ctrl<T> <n> <asciitilde> : "\361" ntilde
+Ctrl<T> <asciitilde> <n> : "\361" ntilde
+Ctrl<T> <n> <minus> : "\361" ntilde
+Ctrl<T> <minus> <n> : "\361" ntilde
+Ctrl<T> <O> <grave> : "\322" Ograve
+Ctrl<T> <grave> <O> : "\322" Ograve
+Ctrl<T> <O> <acute> : "\323" Oacute
+Ctrl<T> <acute> <O> : "\323" Oacute
+Ctrl<T> <O> <apostrophe> : "\323" Oacute
+Ctrl<T> <apostrophe> <O> : "\323" Oacute
+Ctrl<T> <O> <asciicircum> : "\324" Ocircumflex
+Ctrl<T> <asciicircum> <O> : "\324" Ocircumflex
+Ctrl<T> <O> <greater> : "\324" Ocircumflex
+Ctrl<T> <greater> <O> : "\324" Ocircumflex
+Ctrl<T> <O> <asciitilde> : "\325" Otilde
+Ctrl<T> <asciitilde> <O> : "\325" Otilde
+Ctrl<T> <O> <minus> : "\325" Otilde
+Ctrl<T> <minus> <O> : "\325" Otilde
+Ctrl<T> <O> <quotedbl> : "\326" Odiaeresis
+Ctrl<T> <quotedbl> <O> : "\326" Odiaeresis
+Ctrl<T> <O> <diaeresis> : "\326" Odiaeresis
+Ctrl<T> <diaeresis> <O> : "\326" Odiaeresis
+Ctrl<T> <O> <slash> : "\330" Ooblique
+Ctrl<T> <slash> <O> : "\330" Ooblique
+Ctrl<T> <o> <grave> : "\362" ograve
+Ctrl<T> <grave> <o> : "\362" ograve
+Ctrl<T> <o> <acute> : "\363" oacute
+Ctrl<T> <acute> <o> : "\363" oacute
+Ctrl<T> <o> <apostrophe> : "\363" oacute
+Ctrl<T> <apostrophe> <o> : "\363" oacute
+Ctrl<T> <o> <asciicircum> : "\364" ocircumflex
+Ctrl<T> <asciicircum> <o> : "\364" ocircumflex
+Ctrl<T> <o> <greater> : "\364" ocircumflex
+Ctrl<T> <greater> <o> : "\364" ocircumflex
+Ctrl<T> <o> <asciitilde> : "\365" otilde
+Ctrl<T> <asciitilde> <o> : "\365" otilde
+Ctrl<T> <o> <minus> : "\365" otilde
+Ctrl<T> <minus> <o> : "\365" otilde
+Ctrl<T> <o> <quotedbl> : "\366" odiaeresis
+Ctrl<T> <quotedbl> <o> : "\366" odiaeresis
+Ctrl<T> <o> <diaeresis> : "\366" odiaeresis
+Ctrl<T> <diaeresis> <o> : "\366" odiaeresis
+Ctrl<T> <o> <slash> : "\370" oslash
+Ctrl<T> <slash> <o> : "\370" oslash
+Ctrl<T> <U> <grave> : "\331" Ugrave
+Ctrl<T> <grave> <U> : "\331" Ugrave
+Ctrl<T> <U> <acute> : "\332" Uacute
+Ctrl<T> <acute> <U> : "\332" Uacute
+Ctrl<T> <U> <apostrophe> : "\332" Uacute
+Ctrl<T> <apostrophe> <U> : "\332" Uacute
+Ctrl<T> <U> <asciicircum> : "\333" Ucircumflex
+Ctrl<T> <asciicircum> <U> : "\333" Ucircumflex
+Ctrl<T> <U> <greater> : "\333" Ucircumflex
+Ctrl<T> <greater> <U> : "\333" Ucircumflex
+Ctrl<T> <U> <quotedbl> : "\334" Udiaeresis
+Ctrl<T> <quotedbl> <U> : "\334" Udiaeresis
+Ctrl<T> <U> <diaeresis> : "\334" Udiaeresis
+Ctrl<T> <diaeresis> <U> : "\334" Udiaeresis
+Ctrl<T> <u> <grave> : "\371" ugrave
+Ctrl<T> <grave> <u> : "\371" ugrave
+Ctrl<T> <u> <acute> : "\372" uacute
+Ctrl<T> <acute> <u> : "\372" uacute
+Ctrl<T> <u> <apostrophe> : "\372" uacute
+Ctrl<T> <apostrophe> <u> : "\372" uacute
+Ctrl<T> <u> <asciicircum> : "\373" ucircumflex
+Ctrl<T> <asciicircum> <u> : "\373" ucircumflex
+Ctrl<T> <u> <greater> : "\373" ucircumflex
+Ctrl<T> <greater> <u> : "\373" ucircumflex
+Ctrl<T> <u> <quotedbl> : "\374" udiaeresis
+Ctrl<T> <quotedbl> <u> : "\374" udiaeresis
+Ctrl<T> <u> <diaeresis> : "\374" udiaeresis
+Ctrl<T> <diaeresis> <u> : "\374" udiaeresis
+Ctrl<T> <s> <s> : "\337" ssharp
+Ctrl<T> <T> <H> : "\336" THORN
+Ctrl<T> <t> <h> : "\376" thorn
+Ctrl<T> <Y> <acute> : "\335" Yacute
+Ctrl<T> <acute> <Y> : "\335" Yacute
+Ctrl<T> <Y> <apostrophe> : "\335" Yacute
+Ctrl<T> <apostrophe> <Y> : "\335" Yacute
+Ctrl<T> <y> <acute> : "\375" yacute
+Ctrl<T> <acute> <y> : "\375" yacute
+Ctrl<T> <y> <apostrophe> : "\375" yacute
+Ctrl<T> <apostrophe> <y> : "\375" yacute
+Ctrl<T> <y> <quotedbl> : "\377" ydiaeresis
+Ctrl<T> <quotedbl> <y> : "\377" ydiaeresis
+Ctrl<T> <y> <diaeresis> : "\377" ydiaeresis
+Ctrl<T> <diaeresis> <y> : "\377" ydiaeresis
+# End of Sequence Definition
diff --git a/nls/iso8859-1/XI18N_OBJS b/nls/iso8859-1/XI18N_OBJS
new file mode 100644
index 00000000..32e4f358
--- /dev/null
+++ b/nls/iso8859-1/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/ximcp _XimOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-1/XLC_LOCALE.pre b/nls/iso8859-1/XLC_LOCALE.pre
new file mode 100644
index 00000000..256f50ee
--- /dev/null
+++ b/nls/iso8859-1/XLC_LOCALE.pre
@@ -0,0 +1,72 @@
+XCOMM $Xorg: iso8859-1,v 1.3 2000/08/17 19:46:59 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-1.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-1:GR
+ }
+ font {
+ primary ISO8859-1:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-1
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-1:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-10/XLC_LOCALE.pre b/nls/iso8859-10/XLC_LOCALE.pre
new file mode 100644
index 00000000..9d954d1e
--- /dev/null
+++ b/nls/iso8859-10/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-10,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-4.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-10:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-10:GR
+ }
+ font {
+ primary ISO8859-10:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-10
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-10:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-10:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-13/XI18N_OBJS b/nls/iso8859-13/XI18N_OBJS
new file mode 100644
index 00000000..f20902a6
--- /dev/null
+++ b/nls/iso8859-13/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-2/Compose.pre b/nls/iso8859-2/Compose.pre
new file mode 100644
index 00000000..3e7c0a4d
--- /dev/null
+++ b/nls/iso8859-2/Compose.pre
@@ -0,0 +1,450 @@
+# $Xorg: iso8859-2,v 1.3 2000/08/17 19:46:59 cpqbld Exp $
+#
+# ISO 8859-2 (Latin2) Compose Sequence
+#
+# Sequence Definition
+#
+# <Multi_key> Means <Compose>
+# Special Character
+<Multi_key> <plus> <plus> : "#" numbersign
+<Multi_key> <apostrophe> <space> : "'" apostrophe
+<Multi_key> <space> <apostrophe> : "'" apostrophe
+<Multi_key> <A> <A> : "@" at
+<Multi_key> <parenleft> <parenleft> : "[" bracketleft
+<Multi_key> <slash> <slash> : "\\" backslash
+<Multi_key> <slash> <less> : "\\" backslash
+<Multi_key> <less> <slash> : "\\" backslash
+<Multi_key> <parenright> <parenright> : "]" bracketright
+<Multi_key> <asciicircum> <space> : "^" asciicircum
+<Multi_key> <space> <asciicircum> : "^" asciicircum
+<Multi_key> <greater> <space> : "^" asciicirum
+<Multi_key> <space> <greater> : "^" asciicirum
+<Multi_key> <grave> <space> : "`" grave
+<Multi_key> <space> <grave> : "`" grave
+<Multi_key> <parenleft> <minus> : "{" braceleft
+<Multi_key> <minus> <parenleft> : "{" braceleft
+<Multi_key> <slash> <asciicircum> : "|" bar
+<Multi_key> <asciicircum> <slash> : "|" bar
+<Multi_key> <V> <L> : "|" bar
+<Multi_key> <L> <V> : "|" bar
+<Multi_key> <v> <l> : "|" bar
+<Multi_key> <l> <v> : "|" bar
+<Multi_key> <parenright> <minus> : "}" braceright
+<Multi_key> <minus> <parenright> : "}" braceright
+<Multi_key> <asciitilde> <space> : "~" asciitilde
+<Multi_key> <space> <asciitilde> : "~" asciitilde
+<Multi_key> <minus> <space> : "~" asciitilde
+<Multi_key> <space> <minus> : "~" asciitilde
+<Multi_key> <x> <o> : "\244" currency
+<Multi_key> <o> <x> : "\244" currency
+<Multi_key> <X> <O> : "\244" currency
+<Multi_key> <O> <X> : "\244" currency
+<Multi_key> <x> <O> : "\244" currency
+<Multi_key> <O> <x> : "\244" currency
+<Multi_key> <X> <o> : "\244" currency
+<Multi_key> <o> <X> : "\244" currency
+<Multi_key> <x> <0> : "\244" currency
+<Multi_key> <0> <x> : "\244" currency
+<Multi_key> <X> <0> : "\244" currency
+<Multi_key> <0> <X> : "\244" currency
+<Multi_key> <p> <exclam> : "\266" paragraph
+<Multi_key> <exclam> <p> : "\266" paragraph
+<Multi_key> <P> <exclam> : "\266" paragraph
+<Multi_key> <exclam> <P> : "\266" paragraph
+# Right-hand side (Accented Alphabet)
+# These compose sequences are pure supposition on my part.
+# It would be nice to know what the real cultural conventions
+# are for compose sequences.
+<Multi_key> <A> <comma> : "\241" Aogonek
+<Multi_key> <comma> <A> : "\241" Aogonek
+<Multi_key> <A> <ogonek> : "\241" Aogonek
+<Multi_key> <ogonek> <A> : "\241" Aogonek
+<Multi_key> <U> <space> : "\242" breve
+<Multi_key> <L> <minus> : "\243" Lstroke
+<Multi_key> <x> <o> : "\244" currency
+<Multi_key> <o> <x> : "\244" currency
+<Multi_key> <X> <O> : "\244" currency
+<Multi_key> <O> <X> : "\244" currency
+<Multi_key> <x> <O> : "\244" currency
+<Multi_key> <O> <x> : "\244" currency
+<Multi_key> <X> <o> : "\244" currency
+<Multi_key> <o> <X> : "\244" currency
+<Multi_key> <x> <0> : "\244" currency
+<Multi_key> <0> <x> : "\244" currency
+<Multi_key> <X> <0> : "\244" currency
+<Multi_key> <0> <X> : "\244" currency
+<Multi_key> <L> <less> : "\245" Lcaron
+<Multi_key> <less> <L> : "\245" Lcaron
+<Multi_key> <L> <caron> : "\245" Lcaron
+<Multi_key> <caron> <L> : "\245" Lcaron
+<Multi_key> <S> <apostrophe> : "\246" Sacute
+<Multi_key> <apostrophe> <S> : "\246" Sacute
+<Multi_key> <S> <acute> : "\246" Sacute
+<Multi_key> <acute> <S> : "\246" Sacute
+<Multi_key> <s> <o> : "\247" section
+<Multi_key> <o> <s> : "\247" section
+<Multi_key> <S> <O> : "\247" section
+<Multi_key> <O> <S> : "\247" section
+<Multi_key> <S> <exclam> : "\247" section
+<Multi_key> <exclam> <S> : "\247" section
+<Multi_key> <s> <exclam> : "\247" section
+<Multi_key> <exclam> <s> : "\247" section
+<Multi_key> <S> <0> : "\247" section
+<Multi_key> <0> <S> : "\247" section
+<Multi_key> <s> <0> : "\247" section
+<Multi_key> <0> <s> : "\247" section
+<Multi_key> <quotedbl> <quotedbl> : "\250" diaeresis
+<Multi_key> <S> <less> : "\251" Scaron
+<Multi_key> <less> <S> : "\251" Scaron
+<Multi_key> <S> <caron> : "\251" Scaron
+<Multi_key> <caron> <S> : "\251" Scaron
+<Multi_key> <S> <comma> : "\252" Scedilla
+<Multi_key> <comma> <S> : "\252" Scedilla
+<Multi_key> <S> <cedilla> : "\252" Scedilla
+<Multi_key> <cedilla> <S> : "\252" Scedilla
+<Multi_key> <T> <less> : "\253" Tcaron
+<Multi_key> <less> <T> : "\253" Tcaron
+<Multi_key> <T> <caron> : "\253" Tcaron
+<Multi_key> <caron> <T> : "\253" Tcaron
+<Multi_key> <Z> <apostrophe> : "\254" Zacute
+<Multi_key> <apostrophe> <Z> : "\254" Zacute
+<Multi_key> <Z> <acute> : "\254" Zacute
+<Multi_key> <acute> <Z> : "\254" Zacute
+<Multi_key> <minus> <minus> : "\255" hyphen
+<Multi_key> <Z> <less> : "\256" Zcaron
+<Multi_key> <less> <Z> : "\256" Zcaron
+<Multi_key> <Z> <caron> : "\256" Zcaron
+<Multi_key> <caron> <Z> : "\256" Zcaron
+<Multi_key> <Z> <period> : "\257" Zabovedot
+<Multi_key> <0> <asterisk> : "\260" degree
+<Multi_key> <asterisk> <0> : "\260" degree
+<Multi_key> <a> <comma> : "\261" aogonek
+<Multi_key> <comma> <a> : "\261" aogonek
+<Multi_key> <a> <ogonek> : "\261" aogonek
+<Multi_key> <ogonek> <a> : "\261" aogonek
+<Multi_key> <comma> <comma> : "\262" ogonek
+<Multi_key> <l> <minus> : "\263" lstroke
+<Multi_key> <apostrophe> <apostrophe> : "\264" acute
+<Multi_key> <l> <less> : "\265" lcaron
+<Multi_key> <less> <l> : "\265" lcaron
+<Multi_key> <l> <caron> : "\265" lcaron
+<Multi_key> <caron> <l> : "\265" lcaron
+<Multi_key> <s> <apostrophe> : "\266" sacute
+<Multi_key> <apostrophe> <s> : "\266" sacute
+<Multi_key> <s> <acute> : "\266" sacute
+<Multi_key> <acute> <s> : "\266" sacute
+<Multi_key> <less> <less> : "\267" caron
+<Multi_key> <comma> <comma> : "\270" cedilla
+<Multi_key> <s> <less> : "\271" scaron
+<Multi_key> <less> <s> : "\271" scaron
+<Multi_key> <s> <caron> : "\271" scaron
+<Multi_key> <caron> <s> : "\271" scaron
+<Multi_key> <s> <comma> : "\272" scedilla
+<Multi_key> <comma> <s> : "\272" scedilla
+<Multi_key> <s> <cedilla> : "\272" scedilla
+<Multi_key> <cedilla> <s> : "\272" scedilla
+<Multi_key> <t> <less> : "\273" tcaron
+<Multi_key> <less> <t> : "\273" tcaron
+<Multi_key> <t> <caron> : "\273" tcaron
+<Multi_key> <caron> <t> : "\273" tcaron
+<Multi_key> <z> <apostrophe> : "\274" zacute
+<Multi_key> <apostrophe> <z> : "\274" zacute
+<Multi_key> <z> <acute> : "\274" zacute
+<Multi_key> <acute> <z> : "\274" zacute
+<Multi_key> <apostrophe> <apostrophe> : "\275" doubleacute
+<Multi_key> <acute> <acute> : "\275" doubleacute
+<Multi_key> <z> <less> : "\276" zcaron
+<Multi_key> <less> <z> : "\276" zcaron
+<Multi_key> <z> <caron> : "\276" zcaron
+<Multi_key> <caron> <z> : "\276" zcaron
+<Multi_key> <z> <period> : "\277" zabovedot
+<Multi_key> <R> <acute> : "\300" Racute
+<Multi_key> <acute> <R> : "\300" Racute
+<Multi_key> <R> <apostrophe> : "\300" Racute
+<Multi_key> <apostrophe> <R> : "\300" Racute
+<Multi_key> <A> <acute> : "\301" Aacute
+<Multi_key> <acute> <A> : "\301" Aacute
+<Multi_key> <A> <apostrophe> : "\301" Aacute
+<Multi_key> <apostrophe> <A> : "\301" Aacute
+<Multi_key> <A> <asciicircum> : "\302" Acircumflex
+<Multi_key> <asciicircum> <A> : "\302" Acircumflex
+<Multi_key> <A> <greater> : "\302" Acircumflex
+<Multi_key> <greater> <A> : "\302" Acircumflex
+<Multi_key> <A> <U> : "\303" Abreve
+<Multi_key> <A> <breve> : "\303" Abreve
+<Multi_key> <breve> <A> : "\303" Abreve
+<Multi_key> <A> <quotedbl> : "\304" Adiaeresis
+<Multi_key> <quotedbl> <A> : "\304" Adiaeresis
+<Multi_key> <L> <acute> : "\305" Lacute
+<Multi_key> <acute> <L> : "\305" Lacute
+<Multi_key> <L> <apostrophe> : "\305" Lacute
+<Multi_key> <apostrophe> <L> : "\305" Lacute
+<Multi_key> <C> <acute> : "\306" Cacute
+<Multi_key> <acute> <C> : "\306" Cacute
+<Multi_key> <C> <apostrophe> : "\306" Cacute
+<Multi_key> <apostrophe> <C> : "\306" Cacute
+<Multi_key> <C> <comma> : "\307" Ccedilla
+<Multi_key> <comma> <C> : "\307" Ccedilla
+<Multi_key> <C> <cedilla> : "\307" Ccedilla
+<Multi_key> <cedilla> <C> : "\307" Ccedilla
+<Multi_key> <C> <less> : "\310" Ccaron
+<Multi_key> <less> <C> : "\310" Ccaron
+<Multi_key> <C> <caron> : "\310" Ccaron
+<Multi_key> <caron> <C> : "\310" Ccaron
+<Multi_key> <E> <acute> : "\311" Eacute
+<Multi_key> <acute> <E> : "\311" Eacute
+<Multi_key> <E> <apostrophe> : "\311" Eacute
+<Multi_key> <apostrophe> <E> : "\311" Eacute
+<Multi_key> <E> <comma> : "\312" Eogonek
+<Multi_key> <comma> <E> : "\312" Eogonek
+<Multi_key> <E> <ogonek> : "\312" Eogonek
+<Multi_key> <ogonek> <E> : "\312" Eogonek
+<Multi_key> <E> <quotedbl> : "\313" Ediaeresis
+<Multi_key> <quotedbl> <E> : "\313" Ediaeresis
+<Multi_key> <E> <less> : "\314" Ecaron
+<Multi_key> <less> <E> : "\314" Ecaron
+<Multi_key> <E> <caron> : "\314" Ecaron
+<Multi_key> <caron> <E> : "\314" Ecaron
+<Multi_key> <I> <acute> : "\315" Iacute
+<Multi_key> <acute> <I> : "\315" Iacute
+<Multi_key> <I> <apostrophe> : "\315" Iacute
+<Multi_key> <apostrophe> <I> : "\315" Iacute
+<Multi_key> <I> <asciicircum> : "\316" Icircumflex
+<Multi_key> <asciicircum> <I> : "\316" Icircumflex
+<Multi_key> <I> <greater> : "\316" Icircumflex
+<Multi_key> <greater> <I> : "\316" Icircumflex
+<Multi_key> <D> <less> : "\317" Dcaron
+<Multi_key> <less> <D> : "\317" Dcaron
+<Multi_key> <D> <caron> : "\317" Dcaron
+<Multi_key> <caron> <D> : "\317" Dcaron
+<Multi_key> <D> <minus> : "\320" Dstroke
+<Multi_key> <minus> <D> : "\320" Dstroke
+<Multi_key> <N> <acute> : "\321" Nacute
+<Multi_key> <acute> <N> : "\321" Nacute
+<Multi_key> <N> <apostrophe> : "\321" Nacute
+<Multi_key> <apostrophe> <N> : "\321" Nacute
+<Multi_key> <N> <less> : "\322" Ncaron
+<Multi_key> <less> <N> : "\322" Ncaron
+<Multi_key> <N> <caron> : "\322" Ncaron
+<Multi_key> <caron> <N> : "\322" Ncaron
+<Multi_key> <O> <acute> : "\323" Oacute
+<Multi_key> <acute> <O> : "\323" Oacute
+<Multi_key> <O> <apostrophe> : "\323" Oacute
+<Multi_key> <apostrophe> <O> : "\323" Oacute
+<Multi_key> <O> <asciicircum> : "\324" Ocircumflex
+<Multi_key> <asciicircum> <O> : "\324" Ocircumflex
+<Multi_key> <O> <greater> : "\324" Ocircumflex
+<Multi_key> <greater> <O> : "\324" Ocircumflex
+<Multi_key> <apostrophe> <apostrophe> <O> : "\325" Odoubleacute
+<Multi_key> <acute> <acute> <O> : "\325" Odoubleacute
+<Multi_key> <O> <quotedbl> : "\326" Odiaeresis
+<Multi_key> <quotedbl> <O> : "\326" Odiaeresis
+<Multi_key> <x> <x> : "\327" multiply
+<Multi_key> <R> <less> : "\330" Rcaron
+<Multi_key> <less> <R> : "\330" Rcaron
+<Multi_key> <R> <caron> : "\330" Rcaron
+<Multi_key> <caron> <R> : "\330" Rcaron
+<Multi_key> <U> <asterisk> : "\331" Uring
+<Multi_key> <asterisk> <U> : "\331" Uring
+<Multi_key> <U> <acute> : "\332" Uacute
+<Multi_key> <acute> <U> : "\332" Uacute
+<Multi_key> <U> <apostrophe> : "\332" Uacute
+<Multi_key> <apostrophe> <U> : "\332" Uacute
+<Multi_key> <apostrophe> <apostrophe> <U> : "\333" Udoubleacute
+<Multi_key> <acute> <acute> <U> : "\333" Udoubleacute
+<Multi_key> <U> <quotedbl> : "\334" Udiaeresis
+<Multi_key> <quotedbl> <U> : "\334" Udiaeresis
+<Multi_key> <Y> <acute> : "\335" Yacute
+<Multi_key> <acute> <Y> : "\335" Yacute
+<Multi_key> <Y> <apostrophe> : "\335" Yacute
+<Multi_key> <apostrophe> <Y> : "\335" Yacute
+<Multi_key> <T> <comma> : "\336" Tcedilla
+<Multi_key> <comma> <T> : "\336" Tcedilla
+<Multi_key> <T> <cedilla> : "\336" Tcedilla
+<Multi_key> <cedilla> <T> : "\336" Tcedilla
+<Multi_key> <s> <s> : "\337" ssharp
+<Multi_key> <r> <acute> : "\340" racute
+<Multi_key> <acute> <r> : "\340" racute
+<Multi_key> <r> <apostrophe> : "\340" racute
+<Multi_key> <apostrophe> <r> : "\340" racute
+<Multi_key> <a> <acute> : "\341" aacute
+<Multi_key> <acute> <a> : "\341" aacute
+<Multi_key> <a> <apostrophe> : "\341" aacute
+<Multi_key> <apostrophe> <a> : "\341" aacute
+<Multi_key> <a> <asciicircum> : "\342" acircumflex
+<Multi_key> <asciicircum> <a> : "\342" acircumflex
+<Multi_key> <a> <greater> : "\342" acircumflex
+<Multi_key> <greater> <a> : "\342" acircumflex
+<Multi_key> <a> <U> : "\343" abreve
+<Multi_key> <a> <breve> : "\343" abreve
+<Multi_key> <breve> <a> : "\343" abreve
+<Multi_key> <a> <quotedbl> : "\344" adiaeresis
+<Multi_key> <quotedbl> <a> : "\344" adiaeresis
+<Multi_key> <l> <acute> : "\345" lacute
+<Multi_key> <acute> <l> : "\345" lacute
+<Multi_key> <l> <apostrophe> : "\345" lacute
+<Multi_key> <apostrophe> <l> : "\345" lacute
+<Multi_key> <c> <acute> : "\346" cacute
+<Multi_key> <acute> <c> : "\346" cacute
+<Multi_key> <c> <apostrophe> : "\346" cacute
+<Multi_key> <apostrophe> <c> : "\346" cacute
+<Multi_key> <c> <comma> : "\347" ccedilla
+<Multi_key> <comma> <c> : "\347" ccedilla
+<Multi_key> <c> <cedilla> : "\347" ccedilla
+<Multi_key> <cedilla> <c> : "\347" ccedilla
+<Multi_key> <c> <less> : "\350" ccaron
+<Multi_key> <less> <c> : "\350" ccaron
+<Multi_key> <c> <caron> : "\350" ccaron
+<Multi_key> <caron> <c> : "\350" ccaron
+<Multi_key> <e> <acute> : "\351" eacute
+<Multi_key> <acute> <e> : "\351" eacute
+<Multi_key> <e> <apostrophe> : "\351" eacute
+<Multi_key> <apostrophe> <e> : "\351" eacute
+<Multi_key> <e> <comma> : "\352" eogonek
+<Multi_key> <comma> <e> : "\352" eogonek
+<Multi_key> <e> <ogonek> : "\352" eogonek
+<Multi_key> <ogonek> <e> : "\352" eogonek
+<Multi_key> <e> <quotedbl> : "\353" ediaeresis
+<Multi_key> <quotedbl> <e> : "\353" ediaeresis
+<Multi_key> <e> <less> : "\354" ecaron
+<Multi_key> <less> <e> : "\354" ecaron
+<Multi_key> <e> <caron> : "\354" ecaron
+<Multi_key> <caron> <e> : "\354" ecaron
+<Multi_key> <i> <acute> : "\355" iacute
+<Multi_key> <acute> <i> : "\355" iacute
+<Multi_key> <i> <apostrophe> : "\355" iacute
+<Multi_key> <apostrophe> <i> : "\355" iacute
+<Multi_key> <i> <asciicircum> : "\356" icircumflex
+<Multi_key> <asciicircum> <i> : "\356" icircumflex
+<Multi_key> <i> <greater> : "\356" icircumflex
+<Multi_key> <greater> <i> : "\356" icircumflex
+<Multi_key> <d> <less> : "\357" dcaron
+<Multi_key> <less> <d> : "\357" dcaron
+<Multi_key> <d> <caron> : "\357" dcaron
+<Multi_key> <caron> <d> : "\357" dcaron
+<Multi_key> <d> <minus> : "\360" dstroke
+<Multi_key> <minus> <d> : "\360" dstroke
+<Multi_key> <n> <acute> : "\361" nacute
+<Multi_key> <acute> <n> : "\361" nacute
+<Multi_key> <n> <apostrophe> : "\361" nacute
+<Multi_key> <apostrophe> <n> : "\361" nacute
+<Multi_key> <n> <less> : "\362" ncaron
+<Multi_key> <less> <n> : "\362" ncaron
+<Multi_key> <n> <caron> : "\362" ncaron
+<Multi_key> <caron> <n> : "\362" ncaron
+<Multi_key> <o> <acute> : "\363" nacute
+<Multi_key> <acute> <o> : "\363" nacute
+<Multi_key> <o> <apostrophe> : "\363" nacute
+<Multi_key> <apostrophe> <o> : "\363" nacute
+<Multi_key> <o> <asciicircum> : "\364" ocircumflex
+<Multi_key> <asciicircum> <o> : "\364" ocircumflex
+<Multi_key> <o> <greater> : "\364" ocircumflex
+<Multi_key> <greater> <o> : "\364" ocircumflex
+<Multi_key> <apostrophe> <apostrophe> <o> : "\365" odoubleacute
+<Multi_key> <acute> <acute> <o> : "\365" odoubleacute
+<Multi_key> <o> <quotedbl> : "\366" odiaeresis
+<Multi_key> <quotedbl> <o> : "\366" odiaeresis
+<Multi_key> <minus> <colon> : "\367" division
+<Multi_key> <colon> <minus> : "\367" division
+<Multi_key> <r> <less> : "\370" rcaron
+<Multi_key> <less> <r> : "\370" rcaron
+<Multi_key> <r> <caron> : "\370" rcaron
+<Multi_key> <caron> <r> : "\370" rcaron
+<Multi_key> <u> <asterisk> : "\371" uring
+<Multi_key> <asterisk> <u> : "\371" uring
+<Multi_key> <u> <acute> : "\372" uacute
+<Multi_key> <acute> <u> : "\372" uacute
+<Multi_key> <u> <apostrophe> : "\372" uacute
+<Multi_key> <apostrophe> <u> : "\372" uacute
+<Multi_key> <apostrophe> <apostrophe> <u> : "\373" udoubleacute
+<Multi_key> <acute> <acute> <u> : "\373" udoubleacute
+<Multi_key> <u> <quotedbl> : "\374" udiaeresis
+<Multi_key> <quotedbl> <u> : "\374" udiaeresis
+<Multi_key> <y> <acute> : "\375" yacute
+<Multi_key> <acute> <y> : "\375" yacute
+<Multi_key> <y> <apostrophe> : "\375" yacute
+<Multi_key> <apostrophe> <y> : "\375" yacute
+<Multi_key> <t> <comma> : "\376" tcedilla
+<Multi_key> <comma> <t> : "\376" tcedilla
+<Multi_key> <t> <cedilla> : "\376" tcedilla
+<Multi_key> <cedilla> <t> : "\376" tcedilla
+<Multi_key> <period> <period> : "\377" abovedot
+<dead_acute> <A> : "\301" Aacute
+<dead_acute> <C> : "\306" Cacute
+<dead_acute> <E> : "\311" Eacute
+<dead_acute> <I> : "\315" Iacute
+<dead_acute> <L> : "\305" Lacute
+<dead_acute> <N> : "\321" Nacute
+<dead_acute> <O> : "\323" Oacute
+<dead_acute> <R> : "\300" Racute
+<dead_acute> <S> : "\246" Sacute
+<dead_acute> <U> : "\332" Uacute
+<dead_acute> <Y> : "\335" Yacute
+<dead_acute> <Z> : "\254" Zacute
+<dead_acute> <a> : "\341" aacute
+<dead_acute> <c> : "\346" cacute
+<dead_acute> <e> : "\351" eacute
+<dead_acute> <i> : "\355" iacute
+<dead_acute> <l> : "\345" lacute
+<dead_acute> <n> : "\361" nacute
+<dead_acute> <o> : "\363" nacute
+<dead_acute> <r> : "\340" racute
+<dead_acute> <s> : "\266" sacute
+<dead_acute> <u> : "\372" uacute
+<dead_acute> <y> : "\375" yacute
+<dead_acute> <z> : "\274" zacute
+<dead_acute> <acute> : "\275" doubleacute
+<dead_acute> <dead_acute> : "\275" doubleacute
+<dead_circumflex> <A> : "\302" Acircumflex
+<dead_circumflex> <I> : "\316" Icircumflex
+<dead_circumflex> <O> : "\324" Ocircumflex
+<dead_circumflex> <a> : "\342" acircumflex
+<dead_circumflex> <i> : "\356" icircumflex
+<dead_circumflex> <o> : "\364" ocircumflex
+<dead_breve> <A> : "\303" Abreve
+<dead_breve> <a> : "\343" abreve
+<dead_abovedot> <Z> : "\257" Zabovedot
+<dead_abovedot> <z> : "\277" zabovedot
+<dead_diaeresis> <A> : "\304" Adiaeresis
+<dead_diaeresis> <E> : "\313" Ediaeresis
+<dead_diaeresis> <O> : "\326" Odiaeresis
+<dead_diaeresis> <U> : "\334" Udiaeresis
+<dead_diaeresis> <a> : "\344" adiaeresis
+<dead_diaeresis> <e> : "\353" ediaeresis
+<dead_diaeresis> <o> : "\366" odiaeresis
+<dead_diaeresis> <u> : "\374" udiaeresis
+<dead_abovering> <U> : "\331" Uring
+<dead_abovering> <u> : "\371" uring
+<dead_doubleacute> <O> : "\325" Odoubleacute
+<dead_doubleacute> <U> : "\333" Udoubleacute
+<dead_doubleacute> <o> : "\365" odoubleacute
+<dead_doubleacute> <u> : "\373" udoubleacute
+<dead_caron> <C> : "\310" Ccaron
+<dead_caron> <D> : "\317" Dcaron
+<dead_caron> <E> : "\314" Ecaron
+<dead_caron> <L> : "\245" Lcaron
+<dead_caron> <N> : "\322" Ncaron
+<dead_caron> <R> : "\330" Rcaron
+<dead_caron> <S> : "\251" Scaron
+<dead_caron> <T> : "\253" Tcaron
+<dead_caron> <Z> : "\256" Zcaron
+<dead_caron> <c> : "\350" ccaron
+<dead_caron> <d> : "\357" dcaron
+<dead_caron> <e> : "\354" ecaron
+<dead_caron> <l> : "\265" lcaron
+<dead_caron> <n> : "\362" ncaron
+<dead_caron> <r> : "\370" rcaron
+<dead_caron> <s> : "\271" scaron
+<dead_caron> <t> : "\273" tcaron
+<dead_caron> <z> : "\276" zcaron
+<dead_cedilla> <S> : "\252" Scedilla
+<dead_cedilla> <C> : "\307" Ccedilla
+<dead_cedilla> <T> : "\336" Tcedilla
+<dead_cedilla> <c> : "\347" ccedilla
+<dead_cedilla> <s> : "\272" scedilla
+<dead_cedilla> <t> : "\376" tcedilla
+<dead_ogonek> <A> : "\241" Aogonek
+<dead_ogonek> <E> : "\312" Eogonek
+<dead_ogonek> <a> : "\261" aogonek
+<dead_ogonek> <e> : "\352" eogonek
+# End of Sequence Definition
diff --git a/nls/iso8859-2/XI18N_OBJS b/nls/iso8859-2/XI18N_OBJS
new file mode 100644
index 00000000..f20902a6
--- /dev/null
+++ b/nls/iso8859-2/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-2/XLC_LOCALE.pre b/nls/iso8859-2/XLC_LOCALE.pre
new file mode 100644
index 00000000..715ff4ec
--- /dev/null
+++ b/nls/iso8859-2/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-2,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-2.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-2:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-2:GR
+ }
+ font {
+ primary ISO8859-2:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-2
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-2:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-2:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-3/XLC_LOCALE.pre b/nls/iso8859-3/XLC_LOCALE.pre
new file mode 100644
index 00000000..bf8f96d4
--- /dev/null
+++ b/nls/iso8859-3/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-3,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-3.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-3:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-3:GR
+ }
+ font {
+ primary ISO8859-3:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-3
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-3:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-3:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-4/XLC_LOCALE.pre b/nls/iso8859-4/XLC_LOCALE.pre
new file mode 100644
index 00000000..10b940a8
--- /dev/null
+++ b/nls/iso8859-4/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-4,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-4.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-4:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-4:GR
+ }
+ font {
+ primary ISO8859-4:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-4
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-4:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-4:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-5/XI18N_OBJS b/nls/iso8859-5/XI18N_OBJS
new file mode 100644
index 00000000..f20902a6
--- /dev/null
+++ b/nls/iso8859-5/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-5/XLC_LOCALE.pre b/nls/iso8859-5/XLC_LOCALE.pre
new file mode 100644
index 00000000..ecc19c32
--- /dev/null
+++ b/nls/iso8859-5/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-5,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-5.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-5:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-5:GR
+ }
+ font {
+ primary ISO8859-5:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-5
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-5:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-5:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-6/XLC_LOCALE.pre b/nls/iso8859-6/XLC_LOCALE.pre
new file mode 100644
index 00000000..7c2ffb82
--- /dev/null
+++ b/nls/iso8859-6/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-6,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-6.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-6:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-6:GR
+ }
+ font {
+ primary ISO8859-6:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-6
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-6:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-6:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-7/XI18N_OBJS b/nls/iso8859-7/XI18N_OBJS
new file mode 100644
index 00000000..f20902a6
--- /dev/null
+++ b/nls/iso8859-7/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-7/XLC_LOCALE.pre b/nls/iso8859-7/XLC_LOCALE.pre
new file mode 100644
index 00000000..1f66427b
--- /dev/null
+++ b/nls/iso8859-7/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-7,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-7.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-7:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-7:GR
+ }
+ font {
+ primary ISO8859-7:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-7
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-7:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-7:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-8/XLC_LOCALE.pre b/nls/iso8859-8/XLC_LOCALE.pre
new file mode 100644
index 00000000..74523d88
--- /dev/null
+++ b/nls/iso8859-8/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-8,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-8.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-8:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-8:GR
+ }
+ font {
+ primary ISO8859-8:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-8
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-8:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-8:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/iso8859-9/XI18N_OBJS b/nls/iso8859-9/XI18N_OBJS
new file mode 100644
index 00000000..f20902a6
--- /dev/null
+++ b/nls/iso8859-9/XI18N_OBJS
@@ -0,0 +1,8 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for euro locales
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/xiiimp _XimpLocalOpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
+
diff --git a/nls/iso8859-9/XLC_LOCALE.pre b/nls/iso8859-9/XLC_LOCALE.pre
new file mode 100644
index 00000000..6f06cb19
--- /dev/null
+++ b/nls/iso8859-9/XLC_LOCALE.pre
@@ -0,0 +1,73 @@
+XCOMM $Xorg: iso8859-9,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for iso8859-9.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-9:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name ISO8859-9:GR
+ }
+ font {
+ primary ISO8859-9:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ISO8859-9
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-9:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding ISO8859-9:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/ja.JIS/XLC_LOCALE.pre b/nls/ja.JIS/XLC_LOCALE.pre
new file mode 100644
index 00000000..6a8e2bbb
--- /dev/null
+++ b/nls/ja.JIS/XLC_LOCALE.pre
@@ -0,0 +1,123 @@
+XCOMM $Xorg: ja.JIS,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for ja_JP.jis
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ substitute JISX0201.1976-0:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ }
+ font {
+ primary JISX0208.1983-0:GL
+ substitute JISX0208.1990-0:GL
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (Supplementary Kanji)
+XCOMM fs3 {
+XCOMM charset {
+XCOMM name JISX0212.1990-0:GL
+XCOMM }
+XCOMM font {
+XCOMM primary JISX0212.1990-0:GL
+XCOMM }
+XCOMM }
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ja.jis
+mb_cur_max 5
+state_depend_encoding True
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ mb_encoding <LSL> \x1b \x28 \x4a;\
+ <LSL> \x1b \x28 \x42
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GL
+ length 2
+ mb_encoding <LSL> \x1b \x24 \x42;\
+ <LSL> \x1b \x24 \x40
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+}
+
+XCOMM cs2 class
+cs2 {
+ side GL
+ length 1
+ mb_encoding <LSL> \x1b \x28 \x49
+#if WCHAR32
+ wc_encoding \x10000000
+#else
+ wc_encoding \x00000080
+#endif
+ ct_encoding JISX0201.1976-0:GR
+}
+
+XCOMM cs3 class
+XCOMM cs3 {
+XCOMM side GL
+XCOMM length 2
+XCOMM mb_encoding <LSL> \x1b \x24 \x28 \x44
+XCOMM #if WCHAR32
+XCOMM wc_encoding \x20000000
+XCOMM #else
+XCOMM wc_encoding \x00008000
+XCOMM #endif
+XCOMM ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR
+XCOMM }
+
+END XLC_XLOCALE
diff --git a/nls/ja.S90/XLC_LOCALE.pre b/nls/ja.S90/XLC_LOCALE.pre
new file mode 100644
index 00000000..bff4a734
--- /dev/null
+++ b/nls/ja.S90/XLC_LOCALE.pre
@@ -0,0 +1,151 @@
+XCOMM $Xorg: ja.S90,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM Copyright 1995 by FUJITSU LIMITED
+XCOMM This is source code modified by FUJITSU LIMITED under the Joint
+XCOMM Development Agreement for the CDEnext PST.
+XCOMM This is unpublished proprietary source code of FUJITSU LIMITED
+XCOMM
+XCOMM NLS-DB for ja_JP.S90
+
+XCOMM
+XCOMM XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0 {
+ charset_name u90x03.1991-0
+ side GL
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x28\x32
+ encoding_name fujitsu.U90X03
+}
+
+csd1 {
+ charset_name u90x03.1991-0
+ side GR
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x2f\x32
+ encoding_name fujitsu.U90X03
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name JISX0201.1976-0:GL
+ }
+ font {
+ primary JISX0201.1976-0:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ udc_area \x7521,\x7e7e
+ }
+ font {
+ primary fujitsu.u90x01.1991-0:GL,[\x2121,\x747e];\
+ fujitsu.u90x03.1991-0:GL,[\x7521,\x7e7e]->\x6521
+ substitute u90x01.1991-0:GL;\
+ JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR
+ vertical_map u90x01.1991-0.2:GL,\
+ [\x2122,\x2125]->\x7d21,[\x2131,\x2132]->\x7d25,\
+ [\x213c,\x213e]->\x7d27,[\x2141,\x215b]->\x7d2a,\
+ [\x2421,\x2421]->\x7d45,[\x2423,\x2423]->\x7d46,\
+ [\x2425,\x2425]->\x7d47,[\x2427,\x2427]->\x7d48,\
+ [\x2429,\x2429]->\x7d49,[\x2443,\x2443]->\x7d4a,\
+ [\x2463,\x2463]->\x7d4b,[\x2465,\x2465]->\x7d4c,\
+ [\x2467,\x2467]->\x7d4d,[\x246e,\x246e]->\x7d4e,\
+ [\x2521,\x2521]->\x7d4f,[\x2523,\x2523]->\x7d50,\
+ [\x2525,\x2525]->\x7d51,[\x2527,\x2527]->\x7d52,\
+ [\x2529,\x2529]->\x7d53,[\x2543,\x2543]->\x7d54,\
+ [\x2563,\x2563]->\x7d55,[\x2565,\x2565]->\x7d56,\
+ [\x2567,\x2567]->\x7d57,[\x256e,\x256e]->\x7d58,\
+ [\x2575,\x2576]->\x7d59,[\x2475,\x2476]->\x7d5b
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (JEF Kanji + User Defined Character)
+fs3 {
+ charset {
+ name u90x03.1991-0:GR; u90x03.1991-0:GL
+ udc_area \x6521,\x787e
+ }
+ font {
+ primary fujitsu.u90x03.1991-0:GL
+ substitute u90x03.1991-0:GL;\
+ JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+XCOMM encoding_name ja.euc
+encoding_name ja_JP.S90
+mb_cur_max 3
+state_depend_encoding False
+
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding JISX0201.1976-0:GL; ISO8859-1:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 2
+ wc_encoding \x30000000
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR
+ length 1
+ mb_encoding <SS> \x8e
+ wc_encoding \x10000000
+ ct_encoding JISX0201.1976-0:GR
+}
+XCOMM cs3 class
+cs3 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8f
+ wc_encoding \x20000000
+ ct_encoding u90x03.1991-0:GR; u90x03.1991-0:GL
+}
+END XLC_XLOCALE
diff --git a/nls/ja.SJIS/XI18N_OBJS b/nls/ja.SJIS/XI18N_OBJS
new file mode 100644
index 00000000..29dffff7
--- /dev/null
+++ b/nls/ja.SJIS/XI18N_OBJS
@@ -0,0 +1,10 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for ja locale
+#
+XLC ja_JP.PCK/xlibi18n_PCK _XlcGenericLoader # XLC_open
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/ximp40 _Ximp_OpenIM # XIM_open
+XIM common/ximlocal _XimpLocalOpenIM # XIM_open
+XIM common/ximcp _XimOpenIM _XimRegisterIMInstantiateCallback _XimUnRegisterIMInstantiateCallback # XIM_open XIM_regiser XIM_unregister
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
diff --git a/nls/ja.SJIS/XLC_LOCALE.pre b/nls/ja.SJIS/XLC_LOCALE.pre
new file mode 100644
index 00000000..d5b65e1a
--- /dev/null
+++ b/nls/ja.SJIS/XLC_LOCALE.pre
@@ -0,0 +1,383 @@
+XCOMM $Xorg: ja.SJIS,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for ja_JP.sjis
+XCOMM
+
+#ifndef __uxp__
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ substitute JISX0201.1976-0:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ }
+ font {
+ primary JISX0208.1983-0:GL
+ substitute JISX0208.1990-0:GL
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (Supplementary Kanji)
+XCOMM fs3 {
+XCOMM charset {
+XCOMM name JISX0212.1990-0:GL
+XCOMM }
+XCOMM font {
+XCOMM primary JISX0212.1990-0:GL
+XCOMM }
+XCOMM }
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ja.sjis
+mb_cur_max 2
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side none
+ length 2
+ byte1 \x81,\x9f;\xe0,\xef
+ byte2 \x40,\x7e;\x80,\xfc
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+ mb_conversion \
+ [\x8140,\x817e]->\x2121,[\x8180,\x819e]->\x2160,[\x819f,\x81fc]->\x2221,\
+ [\x8240,\x827e]->\x2321,[\x8280,\x829e]->\x2360,[\x829f,\x82fc]->\x2421,\
+ [\x8340,\x837e]->\x2521,[\x8380,\x839e]->\x2560,[\x839f,\x83fc]->\x2621,\
+ [\x8440,\x847e]->\x2721,[\x8480,\x849e]->\x2760,[\x849f,\x84fc]->\x2821,\
+ [\x8540,\x857e]->\x2921,[\x8580,\x859e]->\x2960,[\x859f,\x85fc]->\x2a21,\
+ [\x8640,\x867e]->\x2b21,[\x8680,\x869e]->\x2b60,[\x869f,\x86fc]->\x2c21,\
+ [\x8740,\x877e]->\x2d21,[\x8780,\x879e]->\x2d60,[\x879f,\x87fc]->\x2e21,\
+ [\x8840,\x887e]->\x2f21,[\x8880,\x889e]->\x2f60,[\x889f,\x88fc]->\x3021,\
+ [\x8940,\x897e]->\x3121,[\x8980,\x899e]->\x3160,[\x899f,\x89fc]->\x3221,\
+ [\x8a40,\x8a7e]->\x3321,[\x8a80,\x8a9e]->\x3360,[\x8a9f,\x8afc]->\x3421,\
+ [\x8b40,\x8b7e]->\x3521,[\x8b80,\x8b9e]->\x3560,[\x8b9f,\x8bfc]->\x3621,\
+ [\x8c40,\x8c7e]->\x3721,[\x8c80,\x8c9e]->\x3760,[\x8c9f,\x8cfc]->\x3821,\
+ [\x8d40,\x8d7e]->\x3921,[\x8d80,\x8d9e]->\x3960,[\x8d9f,\x8dfc]->\x3a21,\
+ [\x8e40,\x8e7e]->\x3b21,[\x8e80,\x8e9e]->\x3b60,[\x8e9f,\x8efc]->\x3c21,\
+ [\x8f40,\x8f7e]->\x3d21,[\x8f80,\x8f9e]->\x3d60,[\x8f9f,\x8ffc]->\x3e21,\
+ [\x9040,\x907e]->\x3f21,[\x9080,\x909e]->\x3f60,[\x909f,\x90fc]->\x4021,\
+ [\x9140,\x917e]->\x4121,[\x9180,\x919e]->\x4160,[\x919f,\x91fc]->\x4221,\
+ [\x9240,\x927e]->\x4321,[\x9280,\x929e]->\x4360,[\x929f,\x92fc]->\x4421,\
+ [\x9340,\x937e]->\x4521,[\x9380,\x939e]->\x4560,[\x939f,\x93fc]->\x4621,\
+ [\x9440,\x947e]->\x4721,[\x9480,\x949e]->\x4760,[\x949f,\x94fc]->\x4821,\
+ [\x9540,\x957e]->\x4921,[\x9580,\x959e]->\x4960,[\x959f,\x95fc]->\x4a21,\
+ [\x9640,\x967e]->\x4b21,[\x9680,\x969e]->\x4b60,[\x969f,\x96fc]->\x4c21,\
+ [\x9740,\x977e]->\x4d21,[\x9780,\x979e]->\x4d60,[\x979f,\x97fc]->\x4e21,\
+ [\x9840,\x987e]->\x4f21,[\x9880,\x989e]->\x4f60,[\x989f,\x98fc]->\x5021,\
+ [\x9940,\x997e]->\x5121,[\x9980,\x999e]->\x5160,[\x999f,\x99fc]->\x5221,\
+ [\x9a40,\x9a7e]->\x5321,[\x9a80,\x9a9e]->\x5360,[\x9a9f,\x9afc]->\x5421,\
+ [\x9b40,\x9b7e]->\x5521,[\x9b80,\x9b9e]->\x5560,[\x9b9f,\x9bfc]->\x5621,\
+ [\x9c40,\x9c7e]->\x5721,[\x9c80,\x9c9e]->\x5760,[\x9c9f,\x9cfc]->\x5821,\
+ [\x9d40,\x9d7e]->\x5921,[\x9d80,\x9d9e]->\x5960,[\x9d9f,\x9dfc]->\x5a21,\
+ [\x9e40,\x9e7e]->\x5b21,[\x9e80,\x9e9e]->\x5b60,[\x9e9f,\x9efc]->\x5c21,\
+ [\x9f40,\x9f7e]->\x5d21,[\x9f80,\x9f9e]->\x5d60,[\x9f9f,\x9ffc]->\x5e21,\
+ [\xe040,\xe07e]->\x5f21,[\xe080,\xe09e]->\x5f60,[\xe09f,\xe0fc]->\x6021,\
+ [\xe140,\xe17e]->\x6121,[\xe180,\xe19e]->\x6160,[\xe19f,\xe1fc]->\x6221,\
+ [\xe240,\xe27e]->\x6321,[\xe280,\xe29e]->\x6360,[\xe29f,\xe2fc]->\x6421,\
+ [\xe340,\xe37e]->\x6521,[\xe380,\xe39e]->\x6560,[\xe39f,\xe3fc]->\x6621,\
+ [\xe440,\xe47e]->\x6721,[\xe480,\xe49e]->\x6760,[\xe49f,\xe4fc]->\x6821,\
+ [\xe540,\xe57e]->\x6921,[\xe580,\xe59e]->\x6960,[\xe59f,\xe5fc]->\x6a21,\
+ [\xe640,\xe67e]->\x6b21,[\xe680,\xe69e]->\x6b60,[\xe69f,\xe6fc]->\x6c21,\
+ [\xe740,\xe77e]->\x6d21,[\xe780,\xe79e]->\x6d60,[\xe79f,\xe7fc]->\x6e21,\
+ [\xe840,\xe87e]->\x6f21,[\xe880,\xe89e]->\x6f60,[\xe89f,\xe8fc]->\x7021,\
+ [\xe940,\xe97e]->\x7121,[\xe980,\xe99e]->\x7160,[\xe99f,\xe9fc]->\x7221,\
+ [\xea40,\xea7e]->\x7321,[\xea80,\xea9e]->\x7360,[\xea9f,\xeafc]->\x7421,\
+ [\xeb40,\xeb7e]->\x7521,[\xeb80,\xeb9e]->\x7560,[\xeb9f,\xebfc]->\x7621,\
+ [\xec40,\xec7e]->\x7721,[\xec80,\xec9e]->\x7760,[\xec9f,\xecfc]->\x7821,\
+ [\xed40,\xed7e]->\x7921,[\xed80,\xed9e]->\x7960,[\xed9f,\xedfc]->\x7a21,\
+ [\xee40,\xee7e]->\x7b21,[\xee80,\xee9e]->\x7b60,[\xee9f,\xeefc]->\x7c21,\
+ [\xef40,\xef7e]->\x7d21,[\xef80,\xef9e]->\x7d60,[\xef9f,\xeffc]->\x7e21
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR
+ length 1
+#if WCHAR32
+ wc_encoding \x10000000
+#else
+ wc_encoding \x00000080
+#endif
+ ct_encoding JISX0201.1976-0:GR
+}
+
+XCOMM cs3 class
+XCOMM cs3 {
+XCOMM side GR
+XCOMM length 2
+XCOMM #if WCHAR32
+XCOMM wc_encoding \x20000000
+XCOMM #else
+XCOMM wc_encoding \x00008000
+XCOMM #endif
+XCOMM ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR
+XCOMM }
+
+END XLC_XLOCALE
+
+#else /* __uxp__ */
+
+XCOMM For UXP/DS plat form
+XCOMM
+XCOMM XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0 {
+ charset_name u90x03.1991-0
+ side GL
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x28\x32
+ encoding_name fujitsu.U90X03
+}
+
+csd1 {
+ charset_name u90x03.1991-0
+ side GR
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x2f\x32
+ encoding_name fujitsu.U90X03
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name JISX0201.1976-0:GL
+ }
+ font {
+ primary JISX0201.1976-0:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ }
+ font {
+ primary fujitsu.u90x01.1991-0:GL
+ substitute u90x01.1991-0:GL;\
+ JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR
+ vertical_map u90x01.1991-0.2:GL,\
+ [\x2122,\x2125]->\x7d21,[\x2131,\x2132]->\x7d25,\
+ [\x213c,\x213e]->\x7d27,[\x2141,\x215b]->\x7d2a,\
+ [\x2421,\x2421]->\x7d45,[\x2423,\x2423]->\x7d46,\
+ [\x2425,\x2425]->\x7d47,[\x2427,\x2427]->\x7d48,\
+ [\x2429,\x2429]->\x7d49,[\x2443,\x2443]->\x7d4a,\
+ [\x2463,\x2463]->\x7d4b,[\x2465,\x2465]->\x7d4c,\
+ [\x2467,\x2467]->\x7d4d,[\x246e,\x246e]->\x7d4e,\
+ [\x2521,\x2521]->\x7d4f,[\x2523,\x2523]->\x7d50,\
+ [\x2525,\x2525]->\x7d51,[\x2527,\x2527]->\x7d52,\
+ [\x2529,\x2529]->\x7d53,[\x2543,\x2543]->\x7d54,\
+ [\x2563,\x2563]->\x7d55,[\x2565,\x2565]->\x7d56,\
+ [\x2567,\x2567]->\x7d57,[\x256e,\x256e]->\x7d58,\
+ [\x2575,\x2576]->\x7d59,[\x2475,\x2476]->\x7d5b
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (Supplementary Kanji)
+fs3 {
+ charset {
+ name u90x03.1991-0:GL; u90x03.1991-0:GR
+ udc_area \x6521,\x787e
+ }
+ font {
+ primary fujitsu.u90x03.1991-0:GL
+ substitute u90x03.1991-0:GL;\
+ JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ja.sjis
+mb_cur_max 2
+state_depend_encoding False
+
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding JISX0201.1976-0:GL; ISO8859-1:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side none
+ length 2
+ byte1 \x81,\x9f;\xe0,\xef
+ byte2 \x40,\x7e;\x80,\xfc
+
+ wc_encoding \x30000000
+
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+ mb_conversion \
+ [\x8140,\x817e]->\x2121,[\x8180,\x819e]->\x2160,[\x819f,\x81fc]->\x2221,\
+ [\x8240,\x827e]->\x2321,[\x8280,\x829e]->\x2360,[\x829f,\x82fc]->\x2421,\
+ [\x8340,\x837e]->\x2521,[\x8380,\x839e]->\x2560,[\x839f,\x83fc]->\x2621,\
+ [\x8440,\x847e]->\x2721,[\x8480,\x849e]->\x2760,[\x849f,\x84fc]->\x2821,\
+ [\x8540,\x857e]->\x2921,[\x8580,\x859e]->\x2960,[\x859f,\x85fc]->\x2a21,\
+ [\x8640,\x867e]->\x2b21,[\x8680,\x869e]->\x2b60,[\x869f,\x86fc]->\x2c21,\
+ [\x8740,\x877e]->\x2d21,[\x8780,\x879e]->\x2d60,[\x879f,\x87fc]->\x2e21,\
+ [\x8840,\x887e]->\x2f21,[\x8880,\x889e]->\x2f60,[\x889f,\x88fc]->\x3021,\
+ [\x8940,\x897e]->\x3121,[\x8980,\x899e]->\x3160,[\x899f,\x89fc]->\x3221,\
+ [\x8a40,\x8a7e]->\x3321,[\x8a80,\x8a9e]->\x3360,[\x8a9f,\x8afc]->\x3421,\
+ [\x8b40,\x8b7e]->\x3521,[\x8b80,\x8b9e]->\x3560,[\x8b9f,\x8bfc]->\x3621,\
+ [\x8c40,\x8c7e]->\x3721,[\x8c80,\x8c9e]->\x3760,[\x8c9f,\x8cfc]->\x3821,\
+ [\x8d40,\x8d7e]->\x3921,[\x8d80,\x8d9e]->\x3960,[\x8d9f,\x8dfc]->\x3a21,\
+ [\x8e40,\x8e7e]->\x3b21,[\x8e80,\x8e9e]->\x3b60,[\x8e9f,\x8efc]->\x3c21,\
+ [\x8f40,\x8f7e]->\x3d21,[\x8f80,\x8f9e]->\x3d60,[\x8f9f,\x8ffc]->\x3e21,\
+ [\x9040,\x907e]->\x3f21,[\x9080,\x909e]->\x3f60,[\x909f,\x90fc]->\x4021,\
+ [\x9140,\x917e]->\x4121,[\x9180,\x919e]->\x4160,[\x919f,\x91fc]->\x4221,\
+ [\x9240,\x927e]->\x4321,[\x9280,\x929e]->\x4360,[\x929f,\x92fc]->\x4421,\
+ [\x9340,\x937e]->\x4521,[\x9380,\x939e]->\x4560,[\x939f,\x93fc]->\x4621,\
+ [\x9440,\x947e]->\x4721,[\x9480,\x949e]->\x4760,[\x949f,\x94fc]->\x4821,\
+ [\x9540,\x957e]->\x4921,[\x9580,\x959e]->\x4960,[\x959f,\x95fc]->\x4a21,\
+ [\x9640,\x967e]->\x4b21,[\x9680,\x969e]->\x4b60,[\x969f,\x96fc]->\x4c21,\
+ [\x9740,\x977e]->\x4d21,[\x9780,\x979e]->\x4d60,[\x979f,\x97fc]->\x4e21,\
+ [\x9840,\x987e]->\x4f21,[\x9880,\x989e]->\x4f60,[\x989f,\x98fc]->\x5021,\
+ [\x9940,\x997e]->\x5121,[\x9980,\x999e]->\x5160,[\x999f,\x99fc]->\x5221,\
+ [\x9a40,\x9a7e]->\x5321,[\x9a80,\x9a9e]->\x5360,[\x9a9f,\x9afc]->\x5421,\
+ [\x9b40,\x9b7e]->\x5521,[\x9b80,\x9b9e]->\x5560,[\x9b9f,\x9bfc]->\x5621,\
+ [\x9c40,\x9c7e]->\x5721,[\x9c80,\x9c9e]->\x5760,[\x9c9f,\x9cfc]->\x5821,\
+ [\x9d40,\x9d7e]->\x5921,[\x9d80,\x9d9e]->\x5960,[\x9d9f,\x9dfc]->\x5a21,\
+ [\x9e40,\x9e7e]->\x5b21,[\x9e80,\x9e9e]->\x5b60,[\x9e9f,\x9efc]->\x5c21,\
+ [\x9f40,\x9f7e]->\x5d21,[\x9f80,\x9f9e]->\x5d60,[\x9f9f,\x9ffc]->\x5e21,\
+ [\xe040,\xe07e]->\x5f21,[\xe080,\xe09e]->\x5f60,[\xe09f,\xe0fc]->\x6021,\
+ [\xe140,\xe17e]->\x6121,[\xe180,\xe19e]->\x6160,[\xe19f,\xe1fc]->\x6221,\
+ [\xe240,\xe27e]->\x6321,[\xe280,\xe29e]->\x6360,[\xe29f,\xe2fc]->\x6421,\
+ [\xe340,\xe37e]->\x6521,[\xe380,\xe39e]->\x6560,[\xe39f,\xe3fc]->\x6621,\
+ [\xe440,\xe47e]->\x6721,[\xe480,\xe49e]->\x6760,[\xe49f,\xe4fc]->\x6821,\
+ [\xe540,\xe57e]->\x6921,[\xe580,\xe59e]->\x6960,[\xe59f,\xe5fc]->\x6a21,\
+ [\xe640,\xe67e]->\x6b21,[\xe680,\xe69e]->\x6b60,[\xe69f,\xe6fc]->\x6c21,\
+ [\xe740,\xe77e]->\x6d21,[\xe780,\xe79e]->\x6d60,[\xe79f,\xe7fc]->\x6e21,\
+ [\xe840,\xe87e]->\x6f21,[\xe880,\xe89e]->\x6f60,[\xe89f,\xe8fc]->\x7021,\
+ [\xe940,\xe97e]->\x7121,[\xe980,\xe99e]->\x7160,[\xe99f,\xe9fc]->\x7221,\
+ [\xea40,\xea7e]->\x7321,[\xea80,\xea9e]->\x7360,[\xea9f,\xeafc]->\x7421,\
+ [\xeb40,\xeb7e]->\x7521,[\xeb80,\xeb9e]->\x7560,[\xeb9f,\xebfc]->\x7621,\
+ [\xec40,\xec7e]->\x7721,[\xec80,\xec9e]->\x7760,[\xec9f,\xecfc]->\x7821,\
+ [\xed40,\xed7e]->\x7921,[\xed80,\xed9e]->\x7960,[\xed9f,\xedfc]->\x7a21,\
+ [\xee40,\xee7e]->\x7b21,[\xee80,\xee9e]->\x7b60,[\xee9f,\xeefc]->\x7c21,\
+ [\xef40,\xef7e]->\x7d21,[\xef80,\xef9e]->\x7d60,[\xef9f,\xeffc]->\x7e21
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR
+ length 1
+ wc_encoding \x10000000
+ ct_encoding JISX0201.1976-0:GR
+}
+
+XCOMM cs3 class
+cs3 {
+ side none
+ length 2
+ byte1 \xf0,\xfc
+ byte2 \x40,\x7e;\x80,\xfc
+ wc_encoding \x20000000
+ ct_encoding u90x03.1991-0:GL; u90x03.1991-0:GR
+ mb_conversion \
+ [\xf040,\xf07e]->\x6521,[\xf080,\xf09e]->\x6560,[\xf09f,\xf0fc]->\x6621,\
+ [\xf140,\xf17e]->\x6721,[\xf180,\xf19e]->\x6760,[\xf19f,\xf1fc]->\x6821,\
+ [\xf240,\xf27e]->\x6921,[\xf280,\xf29e]->\x6960,[\xf29f,\xf2fc]->\x6a21,\
+ [\xf340,\xf37e]->\x6b21,[\xf380,\xf39e]->\x6b60,[\xf39f,\xf3fc]->\x6c21,\
+ [\xf440,\xf47e]->\x6d21,[\xf480,\xf49e]->\x6d60,[\xf49f,\xf4fc]->\x6e21,\
+ [\xf540,\xf57e]->\x6f21,[\xf580,\xf59e]->\x6f60,[\xf59f,\xf5fc]->\x7021,\
+ [\xf640,\xf67e]->\x7121,[\xf680,\xf69e]->\x7160,[\xf69f,\xf6fc]->\x7221,\
+ [\xf740,\xf77e]->\x7321,[\xf780,\xf79e]->\x7360,[\xf79f,\xf7fc]->\x7421,\
+ [\xf840,\xf87e]->\x7521,[\xf880,\xf89e]->\x7560,[\xf89f,\xf8fc]->\x7621,\
+ [\xf940,\xf97e]->\x7721,[\xf980,\xf99e]->\x7760,[\xf99f,\xf9fc]->\x7821,\
+ [\xfa40,\xfa7e]->\x7921,[\xfa80,\xfa9e]->\x7960,[\xfa9f,\xfafc]->\x7a21,\
+ [\xfb40,\xfb7e]->\x7b21,[\xfb80,\xfb9e]->\x7b60,[\xfb9f,\xfbfc]->\x7c21,\
+ [\xfc40,\xfc7e]->\x7d21,[\xfc80,\xfc9e]->\x7d60,[\xfc9f,\xfcfc]->\x7e21
+}
+
+END XLC_XLOCALE
+
+#endif /* __uxp__ */
diff --git a/nls/ja.U90/XLC_LOCALE.pre b/nls/ja.U90/XLC_LOCALE.pre
new file mode 100644
index 00000000..2ba1a48f
--- /dev/null
+++ b/nls/ja.U90/XLC_LOCALE.pre
@@ -0,0 +1,152 @@
+XCOMM $Xorg: ja.U90,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM Copyright 1995 by FUJITSU LIMITED
+XCOMM This is source code modified by FUJITSU LIMITED under the Joint
+XCOMM Development Agreement for the CDEnext PST.
+XCOMM This is unpublished proprietary source code of FUJITSU LIMITED
+XCOMM
+XCOMM NLS-DB for ja_JP.U90
+
+XCOMM
+XCOMM XLC_CHARSET_DEFINE category
+XCOMM
+XLC_CHARSET_DEFINE
+csd0 {
+ charset_name u90x03.1991-0
+ side GL
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x28\x32
+ encoding_name fujitsu.U90X03
+}
+
+csd1 {
+ charset_name u90x03.1991-0
+ side GR
+ length 2
+ gc_number 94
+ string_encoding False
+ sequence \x1b\x25\x2f\x32
+ encoding_name fujitsu.U90X03
+}
+END XLC_CHARSET_DEFINE
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name JISX0201.1976-0:GL
+ }
+ font {
+ primary JISX0201.1976-0:GL
+ substitute ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ }
+ font {
+ primary fujitsu.u90x01.1991-0:GL
+XCOMM primary JISX0208.1983-0:GL
+ substitute JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR;\
+ u90x01.1991-0:GL
+ vertical_map u90x01.1991-0.2:GL,\
+ [\x2122,\x2125]->\x7d21,[\x2131,\x2132]->\x7d25,\
+ [\x213c,\x213e]->\x7d27,[\x2141,\x215b]->\x7d2a,\
+ [\x2421,\x2421]->\x7d45,[\x2423,\x2423]->\x7d46,\
+ [\x2425,\x2425]->\x7d47,[\x2427,\x2427]->\x7d48,\
+ [\x2429,\x2429]->\x7d49,[\x2443,\x2443]->\x7d4a,\
+ [\x2463,\x2463]->\x7d4b,[\x2465,\x2465]->\x7d4c,\
+ [\x2467,\x2467]->\x7d4d,[\x246e,\x246e]->\x7d4e,\
+ [\x2521,\x2521]->\x7d4f,[\x2523,\x2523]->\x7d50,\
+ [\x2525,\x2525]->\x7d51,[\x2527,\x2527]->\x7d52,\
+ [\x2529,\x2529]->\x7d53,[\x2543,\x2543]->\x7d54,\
+ [\x2563,\x2563]->\x7d55,[\x2565,\x2565]->\x7d56,\
+ [\x2567,\x2567]->\x7d57,[\x256e,\x256e]->\x7d58,\
+ [\x2575,\x2576]->\x7d59,[\x2475,\x2476]->\x7d5b
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (JEF Kanji + User Defined Character)
+fs3 {
+ charset {
+ name u90x03.1991-0:GR; u90x03.1991-0:GL
+ udc_area \x6521,\x787e
+ }
+ font {
+ primary fujitsu.u90x03.1991-0:GL
+ substitute u90x03.1991-0:GL;\
+ JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR;\
+ JISX0208.1990-0:GL; JISX0208.1990-0:GR
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+XCOMM encoding_name ja.euc
+encoding_name ja_JP.U90
+mb_cur_max 3
+state_depend_encoding False
+
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding JISX0201.1976-0:GL; ISO8859-1:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 2
+ wc_encoding \x30000000
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR
+ length 1
+ mb_encoding <SS> \x8e
+ wc_encoding \x10000000
+ ct_encoding JISX0201.1976-0:GR
+}
+
+XCOMM cs3 class
+cs3 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8f
+ wc_encoding \x20000000
+ ct_encoding u90x03.1991-0:GR; u90x03.1991-0:GL
+}
+
+END XLC_XLOCALE
diff --git a/nls/ja/XI18N_OBJS b/nls/ja/XI18N_OBJS
new file mode 100644
index 00000000..50b51fec
--- /dev/null
+++ b/nls/ja/XI18N_OBJS
@@ -0,0 +1,11 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for ja locale
+#
+XLC ja/xlibi18n_ja _XlcGenericLoader # XLC_open
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+#XIM common/ximcp _XimOpenIM _XimRegisterIMInstantiateCallback _XimUnRegisterIMInstantiateCallback # XIM_open XIM_regiser XIM_unregister
+XIM common/ximp40 _Ximp_OpenIM # XIM_open
+XIM common/ximlocal _XimpLocalOpenIM # XIM_open
+XIM common/ximcp _XimOpenIM _XimRegisterIMInstantiateCallback _XimUnRegisterIMInstantiateCallback # XIM_open XIM_regiser XIM_unregister
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
diff --git a/nls/ja/XLC_LOCALE.pre b/nls/ja/XLC_LOCALE.pre
new file mode 100644
index 00000000..60c71fee
--- /dev/null
+++ b/nls/ja/XLC_LOCALE.pre
@@ -0,0 +1,123 @@
+XCOMM $Xorg: ja,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for ja_JP.euc
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ substitute JISX0201.1976-0:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class (Kanji)
+fs1 {
+ charset {
+ name JISX0208.1983-0:GL
+ udc_area \x7521,\x7e7e
+ }
+ font {
+ primary JISX0208.1983-0:GL
+ substitute JISX0208.1990-0:GL
+ }
+}
+XCOMM fs2 class (Half Kana)
+fs2 {
+ charset {
+ name JISX0201.1976-0:GR
+ }
+ font {
+ primary JISX0201.1976-0:GR
+ vertical_rotate all
+ }
+}
+XCOMM fs3 class (Supplementary Kanji)
+XCOMM fs3 {
+XCOMM charset {
+XCOMM name JISX0212.1990-0:GL
+XCOMM udc_area \x7521,\x7e7e
+XCOMM }
+XCOMM font {
+XCOMM primary JISX0212.1990-0:GL
+XCOMM }
+XCOMM }
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ja.euc
+mb_cur_max 3
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL; JISX0201.1976-0:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 2
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding JISX0208.1983-0:GL; JISX0208.1983-0:GR;\
+ JISX0208.1983-1:GL; JISX0208.1983-1:GR
+}
+
+XCOMM cs2 class
+cs2 {
+ side GR
+ length 1
+ mb_encoding <SS> \x8e
+#if WCHAR32
+ wc_encoding \x10000000
+#else
+ wc_encoding \x00000080
+#endif
+ ct_encoding JISX0201.1976-0:GR
+}
+
+XCOMM cs3 class
+XCOMM cs3 {
+XCOMM side GL
+XCOMM length 2
+XCOMM mb_encoding <SS> \x8f
+XCOMM #if WCHAR32
+XCOMM wc_encoding \x20000000
+XCOMM #else
+XCOMM wc_encoding \x00008000
+XCOMM #endif
+XCOMM ct_encoding JISX0212.1990-0:GL; JISX0212.1990-0:GR
+XCOMM }
+
+
+END XLC_XLOCALE
+
diff --git a/nls/ko/XI18N_OBJS b/nls/ko/XI18N_OBJS
new file mode 100644
index 00000000..5ee52379
--- /dev/null
+++ b/nls/ko/XI18N_OBJS
@@ -0,0 +1,7 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for ko locale
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/ximp40 _Ximp_OpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
diff --git a/nls/ko/XLC_LOCALE.pre b/nls/ko/XLC_LOCALE.pre
new file mode 100644
index 00000000..8f19ea90
--- /dev/null
+++ b/nls/ko/XLC_LOCALE.pre
@@ -0,0 +1,71 @@
+XCOMM $Xorg: ko,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for ko.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name KSC5601.1987-0:GL
+ }
+ font {
+ primary KSC5601.1987-0:GL
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name ko.euc
+mb_cur_max 2
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 2
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding KSC5601.1987-0:GL; KSC5601.1987-0:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/koi8-r/XLC_LOCALE.pre b/nls/koi8-r/XLC_LOCALE.pre
new file mode 100644
index 00000000..8f7f06a2
--- /dev/null
+++ b/nls/koi8-r/XLC_LOCALE.pre
@@ -0,0 +1,58 @@
+XCOMM $Xorg: koi8-r,v 1.3 2000/08/17 19:47:00 cpqbld Exp $
+XCOMM XLocale Database Sample for koi8-r.
+XCOMM
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset ISO8859-1:GL
+ font KOI8-R:GL; ISO8859-1:GL
+}
+XCOMM fs1 class
+fs1 {
+ charset KOI8-R:GR
+ font KOI8-R:GR
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name KOI8-R
+mb_cur_max 1
+state_depend_encoding False
+#if WCHAR32
+wc_encoding_mask \x30000000
+wc_shift_bits 7
+#else
+wc_encoding_mask \x00008080
+wc_shift_bits 8
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding KOI8-R:GL; ISO8859-1:GL
+}
+
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 1
+#if WCHAR32
+ wc_encoding \x30000000
+#else
+ wc_encoding \x00008080
+#endif
+ ct_encoding KOI8-R:GR
+}
+
+END XLC_XLOCALE
diff --git a/nls/locale.alias.pre b/nls/locale.alias.pre
new file mode 100644
index 00000000..ed5009a1
--- /dev/null
+++ b/nls/locale.alias.pre
@@ -0,0 +1,417 @@
+XCOMM $Xorg: locale.alias,v 1.4 2000/12/12 13:00:42 coskrey Exp $
+XCOMM
+XCOMM This file contains alias name of locale.
+XCOMM Each alias name is described within one line.
+XCOMM The first word is the alias name (simplified locale name)
+XCOMM the second word is full locale name.
+XCOMM
+POSIX: C
+POSIX-UTF2: C
+C_C.C: C
+C.en: C
+C.iso88591: en_US.ISO8859-1
+Cextend: en_US.ISO8859-1
+Cextend.en: en_US.ISO8859-1
+English_United-States.437: C
+XCOMM
+ar: ar_AA.ISO8859-6
+ar_AA: ar_AA.ISO8859-6
+ar_SA.iso88596: ar_SA.ISO8859-6
+bg: bg_BG.ISO8859-5
+bg_BG: bg_BG.ISO8859-5
+bg_BG.iso88595: bg_BG.ISO8859-5
+cs: cs_CZ.ISO8859-2
+cs_CS: cs_CZ.ISO8859-2
+cs_CS.ISO8859-2: cs_CZ.ISO8859-2
+cs_CZ: cs_CZ.ISO8859-2
+cs_CZ.iso88592: cs_CZ.ISO8859-2
+cz: cz_CZ.ISO8859-2
+cz_CZ: cz_CZ.ISO8859-2
+da: da_DK.ISO8859-1
+da_DK: da_DK.ISO8859-1
+da_DK.88591: da_DK.ISO8859-1
+da_DK.88591.en: da_DK.ISO8859-1
+da_DK.iso88591: da_DK.ISO8859-1
+da_DK.ISO_8859-1: da_DK.ISO8859-1
+de: de_DE.ISO8859-1
+de_AT: de_AT.ISO8859-1
+de_AT.ISO_8859-1: de_AT.ISO8859-1
+de_CH: de_CH.ISO8859-1
+de_CH.ISO_8859-1: de_CH.ISO8859-1
+de_DE: de_DE.ISO8859-1
+de_DE.88591: de_DE.ISO8859-1
+de_DE.88591.en: de_DE.ISO8859-1
+de_DE.iso88591: de_DE.ISO8859-1
+de_DE.ISO_8859-1: de_DE.ISO8859-1
+GER_DE.8859: de_DE.ISO8859-1
+GER_DE.8859.in: de_DE.ISO8859-1
+ee: ee_EE.ISO8859-4
+el: el_GR.ISO8859-7
+el_GR: el_GR.ISO8859-7
+el_GR.iso88597: el_GR.ISO8859-7
+en: en_US.ISO8859-1
+en_AU: en_AU.ISO8859-1
+en_AU.ISO_8859-1: en_AU.ISO8859-1
+en_CA: en_CA.ISO8859-1
+en_CA.ISO_8859-1: en_CA.ISO8859-1
+en_GB: en_GB.ISO8859-1
+en_GB.88591: en_GB.ISO8859-1
+en_GB.88591.en: en_GB.ISO8859-1
+en_GB.iso88591: en_GB.ISO8859-1
+en_GB.ISO_8859-1: en_GB.ISO8859-1
+en_UK: en_GB.ISO8859-1
+ENG_GB.8859: en_GB.ISO8859-1
+ENG_GB.8859.in: en_GB.ISO8859-1
+en_IE: en_IE.ISO8859-1
+en_NZ: en_NZ.ISO8859-1
+en_US: en_US.ISO8859-1
+en_US.88591: en_US.ISO8859-1
+en_US.88591.en: en_US.ISO8859-1
+en_US.iso88591: en_US.ISO8859-1
+en_US.ISO_8859-1: en_US.ISO8859-1
+en_US.UTF-8: en_US.UTF-8
+es: es_ES.ISO8859-1
+es_AR: es_AR.ISO8859-1
+es_BO: es_BO.ISO8859-1
+es_CL: es_CL.ISO8859-1
+es_CO: es_CO.ISO8859-1
+es_CR: es_CR.ISO8859-1
+es_EC: es_EC.ISO8859-1
+es_ES: es_ES.ISO8859-1
+es_ES.88591: es_ES.ISO8859-1
+es_ES.88591.en: es_ES.ISO8859-1
+es_ES.iso88591: es_ES.ISO8859-1
+es_ES.ISO_8859-1: es_ES.ISO8859-1
+es_GT: es_GT.ISO8859-1
+es_MX: es_MX.ISO8859-1
+es_NI: es_NI.ISO8859-1
+es_PA: es_PA.ISO8859-1
+es_PE: es_PE.ISO8859-1
+es_PY: es_PY.ISO8859-1
+es_SV: es_SV.ISO8859-1
+es_UY: es_UY.ISO8859-1
+es_VE: es_VE.ISO8859-1
+#if defined(SVR4) && defined(sun)
+XCOMM Sun Solaris 2.6 has erroneously specified Estonian as a Latin-1
+XCOMM language; however this is clearly incorrect according to ISO8859.
+#endif
+et: et_EE.ISO8859-4
+et_EE: et_EE.ISO8859-4
+fi: fi_FI.ISO8859-1
+fi_FI: fi_FI.ISO8859-1
+fi_FI.88591: fi_FI.ISO8859-1
+fi_FI.88591.en: fi_FI.ISO8859-1
+fi_FI.iso88591: fi_FI.ISO8859-1
+fi_FI.ISO_8859-1: fi_FI.ISO8859-1
+fr: fr_FR.ISO8859-1
+fr_BE: fr_BE.ISO8859-1
+fr_BE.88591: fr_BE.ISO8859-1
+fr_BE.88591.en: fr_BE.ISO8859-1
+fr_BE.ISO_8859-1: fr_BE.ISO8859-1
+fr_CA: fr_CA.ISO8859-1
+fr_CA.88591: fr_CA.ISO8859-1
+fr_CA.88591.en: fr_CA.ISO8859-1
+fr_CA.iso88591: fr_CA.ISO8859-1
+fr_CA.ISO_8859-1: fr_CA.ISO8859-1
+fr_CH: fr_CH.ISO8859-1
+fr_CH.88591: fr_CH.ISO8859-1
+fr_CH.88591.en: fr_CH.ISO8859-1
+fr_CH.ISO_8859-1: fr_CH.ISO8859-1
+fr_FR: fr_FR.ISO8859-1
+fr_FR.88591: fr_FR.ISO8859-1
+fr_FR.88591.en: fr_FR.ISO8859-1
+fr_FR.iso88591: fr_FR.ISO8859-1
+fr_FR.ISO_8859-1: fr_FR.ISO8859-1
+FRE_FR.8859: fr_FR.ISO8859-1
+FRE_FR.8859.in: fr_FR.ISO8859-1
+hr: hr_HR.ISO8859-2
+hr_HR: hr_HR.ISO8859-2
+hr_HR.iso88592: hr_HR.ISO8859-2
+hr_HR.ISO_8859-2: hr_HR.ISO8859-2
+hu: hu_HU.ISO8859-2
+hu_HU: hu_HU.ISO8859-2
+hu_HU.iso88592: hu_HU.ISO8859-2
+is: is_IS.ISO8859-1
+is_IS: is_IS.ISO8859-1
+is_IS.iso88591: is_IS.ISO8859-1
+is_IS.ISO_8859-1: is_IS.ISO8859-1
+it: it_IT.ISO8859-1
+it_CH: it_CH.ISO8859-1
+it_CH.ISO_8859-1: it_CH.ISO8859-1
+it_IT: it_IT.ISO8859-1
+it_IT.88591: it_IT.ISO8859-1
+it_IT.88591.en: it_IT.ISO8859-1
+it_IT.iso88591: it_IT.ISO8859-1
+it_IT.ISO_8859-1: it_IT.ISO8859-1
+iw: iw_IL.ISO8859-8
+iw_IL: iw_IL.ISO8859-8
+iw_IL.iso88598: iw_IL.ISO8859-8
+ja: ja_JP.eucJP
+ja.JIS: ja_JP.JIS7
+ja.SJIS: ja_JP.SJIS
+#ifndef __uxp__
+ja_JP: ja_JP.eucJP
+#else /* __uxp__ */
+ja_JP: ja_JP.U90
+ja_JP.U90: ja_JP.U90
+ja_JP.S90: ja_JP.S90
+#endif /* __uxp__ */
+ja_JP.ujis: ja_JP.eucJP
+ja_JP.eucJP: ja_JP.eucJP
+Jp_JP: ja_JP.eucJP
+ja_JP.AJEC: ja_JP.eucJP
+ja_JP.EUC: ja_JP.eucJP
+ja_JP.ISO-2022-JP: ja_JP.JIS7
+ja_JP.JIS: ja_JP.JIS7
+ja_JP.jis7: ja_JP.JIS7
+ja_JP.mscode: ja_JP.SJIS
+ja_JP.SJIS: ja_JP.SJIS
+ko: ko_KR.eucKR
+ko_KR: ko_KR.eucKR
+ko_KR.EUC: ko_KR.eucKR
+ko_KR.euc: ko_KR.eucKR
+#if defined(__FreeBSD__)
+XCOMM most locales in FreeBSD 2.1.[56] do not work, allow use of FreeBSD's
+XCOMM generic latin-1 locale name. N.B. "lt" is a bad code to use for a
+XCOMM generic Latin-1 locale anyway because it is the country code for
+XCOMM Lithuania, which by default uses Latin-4.
+lt_LN.ISO_8859-1: lt_LN.ISO8859-1
+#endif
+lt: lt_LT.ISO8859-4
+lv: lv_LV.ISO8859-4
+mk: mk_MK.ISO8859-5
+mk_MK: mk_MK.ISO8859-5
+nl: nl_NL.ISO8859-1
+nl_BE: nl_BE.ISO8859-1
+nl_BE.88591: nl_BE.ISO8859-1
+nl_BE.88591.en: nl_BE.ISO8859-1
+nl_BE.ISO_8859-1: nl_BE.ISO8859-1
+nl_NL: nl_NL.ISO8859-1
+nl_NL.88591: nl_NL.ISO8859-1
+nl_NL.88591.en: nl_NL.ISO8859-1
+nl_NL.iso88591: nl_NL.ISO8859-1
+nl_NL.ISO_8859-1: nl_NL.ISO8859-1
+no: no_NO.ISO8859-1
+no_NO: no_NO.ISO8859-1
+no_NO.88591: no_NO.ISO8859-1
+no_NO.88591.en: no_NO.ISO8859-1
+no_NO.iso88591: no_NO.ISO8859-1
+no_NO.ISO_8859-1: no_NO.ISO8859-1
+pl: pl_PL.ISO8859-2
+pl_PL: pl_PL.ISO8859-2
+pl_PL.iso88592: pl_PL.ISO8859-2
+pt: pt_PT.ISO8859-1
+pt_BR: pt_BR.ISO8859-1
+pt_PT: pt_PT.ISO8859-1
+pt_PT.88591: pt_PT.ISO8859-1
+pt_PT.88591.en: pt_PT.ISO8859-1
+pt_PT.iso88591: pt_PT.ISO8859-1
+pt_PT.ISO_8859-1: pt_PT.ISO8859-1
+ro: ro_RO.ISO8859-2
+ro_RO: ro_RO.ISO8859-2
+ro_RO.iso88592: ro_RO.ISO8859-2
+ru: ru_RU.ISO8859-5
+ru_RU: ru_RU.ISO8859-5
+ru_RU.iso88595: ru_RU.ISO8859-5
+ru_SU: ru_RU.ISO8859-5
+ru_SU.ISO8859-5: ru_RU.ISO8859-5
+ru_SU.KOI8-R: ru_RU.KOI8-R
+sh: sh_YU.ISO8859-2
+sh_HR.iso88592: sh_HR.ISO8859-2
+sh_YU: sh_YU.ISO8859-2
+sh_SP: sh_YU.ISO8859-2
+sk: sk_SK.ISO8859-2
+sk_SK: sk_SK.ISO8859-2
+sk_sK.iso88592: sk_SK.ISO8859-2
+sl: sl_CS.ISO8859-2
+sl_CS: sl_CS.ISO8859-2
+sl_SI: sl_SI.ISO8859-2
+sl_SI.iso88592: sl_SI.ISO8859-2
+sp: sp_YU.ISO8859-5
+sp_YU: sp_YU.ISO8859-5
+sr_SP: sr_SP.ISO8859-2
+sv: sv_SE.ISO8859-1
+sv_SE: sv_SE.ISO8859-1
+sv_SE.88591: sv_SE.ISO8859-1
+sv_SE.88591.en: sv_SE.ISO8859-1
+sv_SE.iso88591: sv_SE.ISO8859-1
+sv_SE.ISO_8859-1: sv_SE.ISO8859-1
+th_TH: th_TH.TACTIS
+th_TH.tis620: th_TH.TACTIS
+tr: tr_TR.ISO8859-9
+tr_TR: tr_TR.ISO8859-9
+tr_TR.iso88599: tr_TR.ISO8859-9
+zh: zh_CN.eucCN
+zh_CN: zh_CN.eucCN
+zh_CN.EUC: zh_CN.eucCN
+zh_TW: zh_TW.eucTW
+zh_TW.EUC: zh_TW.eucTW
+zh_CN.big5: zh_TW.eucTW
+XCOMM The following locale names are used in SCO 3.0
+english_uk.8859: en_GB.ISO8859-1
+english_us.8859: en_US.ISO8859-1
+english_us.ascii: en_US.ISO8859-1
+french_france.8859: fr_FR.ISO8859-1
+german_germany.8859: de_DE.ISO8859-1
+portuguese_brazil.8859: pt_BR.ISO8859-1
+spanish_spain.8859: es_ES.ISO8859-1
+XCOMM The following locale names are used in HPUX 9.x
+american.iso88591: en_US.ISO8859-1
+arabic.iso88596: ar_AA.ISO8859-6
+bulgarian: bg_BG.ISO8859-5
+c-french.iso88591: fr_CA.ISO8859-1
+chinese-s: zh_CN.eucCN
+chinese-t: zh_TW.eucTW
+croatian: hr_HR.ISO8859-2
+czech: cs_CS.ISO8859-2
+danish.iso88591: da_DK.ISO8859-1
+dutch.iso88591: nl_BE.ISO8859-1
+english.iso88591: en_EN.ISO8859-1
+finnish.iso88591: fi_FI.ISO8859-1
+french.iso88591: fr_CH.ISO8859-1
+german.iso88591: de_CH.ISO8859-1
+greek.iso88597: el_GR.ISO8859-7
+hebrew.iso88598: iw_IL.ISO8859-8
+hungarian: hu_HU.ISO8859-2
+icelandic.iso88591: is_IS.ISO8859-1
+italian.iso88591: it_IT.ISO8859-1
+#if ! (defined(SVR4) && defined(sun))
+japanese: ja_JP.SJIS
+#else
+japanese: ja_JP.eucJP
+#endif
+japanese.euc: ja_JP.eucJP
+korean: ko_KR.eucKR
+norwegian.iso88591: no_NO.ISO8859-1
+polish: pl_PL.ISO8859-2
+portuguese.iso88591: pt_PT.ISO8859-1
+rumanian: ro_RO.ISO8859-2
+russian: ru_SU.ISO8859-5
+serbocroatian: sh_YU.ISO8859-2
+slovak: sk_SK.ISO8859-2
+slovene: sl_CS.ISO8859-2
+spanish.iso88591: es_ES.ISO8859-1
+swedish.iso88591: sv_SE.ISO8859-1
+turkish.iso88599: tr_TR.ISO8859-9
+univ.utf8: en_US.utf
+XCOMM Digital Unix utf
+universal.utf8@ucs4: en_US.utf
+XCOMM Solaris 2.6
+XCOMM Solaris and SunOS have iso_8859_1 LC_CTYPES to augment LANG=C
+iso_8859_1: en_US.ISO8859-1
+#ifdef WIN32
+XCOMM Microsoft Windows/NT 4.0 SP3
+XCOMM parser doesn't grok embedded spaces in locale name
+Afrikaans_South Africa.1252: af_ZA.iso8859-1
+Arabic_Bahrain.1256: ar_BH.iso8859-6
+Arabic_Algeria.1256: ar_DZ.iso8859-6
+Arabic_Egypt.1256: ar_EG.iso8859-6
+Arabic_Iraq.1256: ar_IQ.iso8859-6
+Arabic_Jordan.1256: ar_JO.iso8859-6
+Arabic_Kuwait.1256: ar_KW.iso8859-6
+Arabic_Lebanon.1256: ar_LB.iso8859-6
+Arabic_Libya.1256: ar_LY.iso8859-6
+Arabic_Morocco.1256: ar_MA.iso8859-6
+Arabic_Oman.1256: ar_OM.iso8859-6
+Arabic_Qatar.1256: ar_QA.iso8859-6
+Arabic_Saudi Arabia.1256: ar_SA.iso8859-6
+Arabic_Tunisia.1256: ar_TN.iso8859-6
+Arabic_Yemen.1256: ar_YE.iso8859-6
+Belarusian_Belarus.1251: be_BY.iso8859-5
+Bulgarian_Bulgaria.1251: bg_BG.iso8859-5
+Catalan_Spain.1252: ca_ES.iso8859-1
+Czech_Czech Republic.1250: cs_CZ.iso8859-2
+Danish_Denmark.1252: da_DK.iso8859-1
+German_Austria.1252: de_AT.iso8859-1
+German_Switzerland.1252: de_CH.iso8859-1
+German_Germany.1252: de_DE.iso8859-1
+German_Liechtenstein.1252: de_LI.iso8859-1
+German_Luxembourg.1252: de_LU.iso8859-1
+Greek_Greece.1253: el_GR.iso8859-7
+English_Australia.1252: en_AU.iso8859-1
+English_Belize.1252: en_BZ.iso8859-1
+English_Canada.1252: en_CA.iso8859-1
+English_Ireland.1252: en_IE.iso8859-1
+English_Jamaica.1252: en_JM.iso8859-1
+English_New Zealand.1252: en_NZ.iso8859-1
+English_Trinidad y Tobago.1252: en_TT.iso8859-1
+English_United Kingdom.1252: en_UK.iso8859-1
+English_United States.1252: en_US.iso8859-1
+English_South Africa.1252: en_ZA.iso8859-1
+Spanish_Argentina.1252: es_AR.iso8859-1
+Spanish_Bolivia.1252: es_BO.iso8859-1
+Spanish_Chile.1252: es_CL.iso8859-1
+Spanish_Colombia.1252: es_CO.iso8859-1
+Spanish_Costa Rica.1252: es_CR.iso8859-1
+Spanish_Dominican Republic.1252: es_DO.iso8859-1
+Spanish_Ecuador.1252: es_EC.iso8859-1
+Spanish - Modern Sort_Spain.1252: es_ES.iso8859-1
+Spanish - Traditional Sort_Spain.1252: es_ES.iso8859-1
+Spanish_Guatemala.1252: es_GT.iso8859-1
+Spanish_Honduras.1252: es_HN.iso8859-1
+Spanish_Mexican.1252: es_MX.iso8859-1
+Spanish_Nicaragua.1252: es_NI.iso8859-1
+Spanish_Panama.1252: es_PA.iso8859-1
+Spanish_Paraguay.1252: es_PY.iso8859-1
+Spanish_Peru.1252: es_PE.iso8859-1
+Spanish_Puerto Rico.1252: es_PR.iso8859-1
+Spanish_El Salvador.1252: es_SV.iso8859-1
+Spanish_Uruguay.1252: es_UY.iso8859-1
+Spanish_Venezuela.1252: es_VE.iso8859-1
+Estonian_Estonia.1257 et_EE.iso8859-4
+Basque_Spain.1252: eu_ES.iso8859-1
+Finnish_Finland.1252: fi_FI.iso8859-1
+French_Belgium.1252: fr_BE.iso8859-1
+French_Canada.1252: fr_CA.iso8859-1
+French_Switzerland.1252: fr_CH.iso8859-1
+French_France.1252: fr_FR.iso8859-1
+French_Luxembourg.1252: fr_LU.iso8859-1
+Faeroese_Faeroe Islands.1252: fo_FO.iso8859-1
+Hebrew_Israel.1255: he_IL.iso8859-8
+Croatian_Croatia.1250: hr_HR.iso8859-2
+Hungarian_Hungary.1250: hu_HU.iso8859-2
+Indonesian_Indonesia.1252: id_ID.iso8859-1
+Icelandic_Iceland.1252: is_IS.iso8859-1
+Italian_Switzerland.1252: it_CH.iso8859-1
+Italian_Italy.1252: it_IT.iso8859-1
+Japanese_Japan.932: ja_JP.SJIS
+Korean_Korea.949: ko_KR.EUC
+Lithuanian_Lithuania.1257 lt_LT.iso8859-4
+Latvian_Latvia.1257: lv_LV.iso8859-4
+Dutch_Belgium.1252: nl_BE.iso8859-1
+Dutch_Netherlands.1252: nl_NL.iso8859-1
+Norwegian (Nynorsk)_Norway.1252: no_NO.iso8859-1
+Norwegian (Bokmål)_Norway.1252: no_NO.iso8859-1
+Polish_Poland.1250: pl_PL.iso8859-2
+Portuguese_Brazil.1252: pt_BR.iso8859-1
+Portuguese_Portugal.1252: pt_PT.iso8859-1
+Romanian_Romania.1250: ro_RO.iso8859-2
+Russian_Russia.1251: ru_RU.iso8859-5
+Slovak_Slovakia.1250: sk_SK.iso8859-2
+Slovene_Slovenia.1250: sl_SI.iso8859-2
+Albanian_Albania.1250: sq_AL.iso8859-2
+Serbian (Latin)_Serbia.1250: sr_YU.iso8859-2
+Swedish_Finland.1252: sv_FI.iso8859-1
+Swedish_Sweden.1252: sv_SE.iso8859-1
+Turkish_Turkey.1254: tr_TR.iso8859-9
+Ukrainian_Ukraine.1251: uk_UA.iso8859-5
+Chinese(PRC)_People's Republic of China.936: zh_CN.EUC
+Chinese(PRC)_Hong Kong.950: zh_HK.EUC
+Chinese(Singapore)_Signapore.936: zh_SG.EUC
+Chinese(Taiwan)_Taiwan.950: zh_TW.EUC
+#endif
+XCOMM Other miscellaneous locale names
+ISO8859-1: en_US.ISO8859-1
+ISO-8859-1: en_US.ISO8859-1
+#ifndef __uxp__
+japan: ja_JP.eucJP
+#else
+japan: ja_JP.U90
+#endif
+Japanese-EUC: ja_JP.eucJP
+
+XCOMM Added by Sun
+ja_JP.PCK: ja_JP.SJIS
+zh_CN.GBK: zh.GBK
+zh.GBK: zh.GBK
+zh_TW.BIG5: zh_TW.BIG5
diff --git a/nls/locale.dir.pre b/nls/locale.dir.pre
new file mode 100644
index 00000000..692efc02
--- /dev/null
+++ b/nls/locale.dir.pre
@@ -0,0 +1,123 @@
+XCOMM $Xorg: locale.dir,v 1.4 2000/12/12 13:00:42 coskrey Exp $
+XCOMM
+XCOMM This file contains locALE: database file name
+XCOMM The first word is the locALE: database file name and
+XCOMM the second word is full locALE: name.
+XCOMM
+C/XLC_LOCALE: C
+iso8859-1/XLC_LOCALE: af_ZA.ISO8859-1
+iso8859-6/XLC_LOCALE: ar_AA.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_BH.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_DZ.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_EG.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_IQ.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_JO.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_KW.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_LB.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_LY.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_MA.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_OM.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_QA.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_SA.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_TN.ISO8859-6
+iso8859-6/XLC_LOCALE: ar_YE.ISO8859-6
+iso8859-5/XLC_LOCALE: bg_BG.ISO8859-5
+iso8859-1/XLC_LOCALE: ca_ES.ISO8859-1
+iso8859-2/XLC_LOCALE: cs_CZ.ISO8859-2
+iso8859-2/XLC_LOCALE: cz_CZ.ISO8859-2
+iso8859-1/XLC_LOCALE: da_DK.ISO8859-1
+iso8859-1/XLC_LOCALE: de_AT.ISO8859-1
+iso8859-1/XLC_LOCALE: de_CH.ISO8859-1
+iso8859-1/XLC_LOCALE: de_DE.ISO8859-1
+iso8859-1/XLC_LOCALE: de_LI.ISO8859-1
+iso8859-1/XLC_LOCALE: de_LU.ISO8859-1
+iso8859-7/XLC_LOCALE: el_GR.ISO8859-7
+iso8859-1/XLC_LOCALE: en_AU.ISO8859-1
+iso8859-1/XLC_LOCALE: en_BZ.ISO8859-1
+iso8859-1/XLC_LOCALE: en_CA.ISO8859-1
+iso8859-1/XLC_LOCALE: en_GB.ISO8859-1
+iso8859-1/XLC_LOCALE: en_IE.ISO8859-1
+iso8859-1/XLC_LOCALE: en_JM.ISO8859-1
+iso8859-1/XLC_LOCALE: en_NZ.ISO8859-1
+iso8859-1/XLC_LOCALE: en_TT.ISO8859-1
+iso8859-1/XLC_LOCALE: en_UK.ISO8859-1
+iso8859-1/XLC_LOCALE: en_US.ISO8859-1
+iso8859-1/XLC_LOCALE: en_ZA.ISO8859-1
+iso8859-1/XLC_LOCALE: es_AR.ISO8859-1
+iso8859-1/XLC_LOCALE: es_BO.ISO8859-1
+iso8859-1/XLC_LOCALE: es_CL.ISO8859-1
+iso8859-1/XLC_LOCALE: es_CO.ISO8859-1
+iso8859-1/XLC_LOCALE: es_CR.ISO8859-1
+iso8859-1/XLC_LOCALE: es_DO.ISO8859-1
+iso8859-1/XLC_LOCALE: es_EC.ISO8859-1
+iso8859-1/XLC_LOCALE: es_ES.ISO8859-1
+iso8859-1/XLC_LOCALE: es_GT.ISO8859-1
+iso8859-1/XLC_LOCALE: es_HN.ISO8859-1
+iso8859-1/XLC_LOCALE: es_MX.ISO8859-1
+iso8859-1/XLC_LOCALE: es_NI.ISO8859-1
+iso8859-1/XLC_LOCALE: es_PA.ISO8859-1
+iso8859-1/XLC_LOCALE: es_PE.ISO8859-1
+iso8859-1/XLC_LOCALE: es_PR.ISO8859-1
+iso8859-1/XLC_LOCALE: es_PY.ISO8859-1
+iso8859-1/XLC_LOCALE: es_SV.ISO8859-1
+iso8859-1/XLC_LOCALE: es_UY.ISO8859-1
+iso8859-1/XLC_LOCALE: es_VE.ISO8859-1
+iso8859-4/XLC_LOCALE: et_EE.ISO8859-4
+iso8859-1/XLC_LOCALE: eu_ES.ISO8859-1
+iso8859-1/XLC_LOCALE: fi_FI.ISO8859-1
+iso8859-1/XLC_LOCALE: fo_FO.ISO8859-1
+iso8859-1/XLC_LOCALE: fr_BE.ISO8859-1
+iso8859-1/XLC_LOCALE: fr_CA.ISO8859-1
+iso8859-1/XLC_LOCALE: fr_CH.ISO8859-1
+iso8859-1/XLC_LOCALE: fr_FR.ISO8859-1
+iso8859-1/XLC_LOCALE: fr_LU.ISO8859-1
+iso8859-8/XLC_LOCALE: he_IL.ISO8859-8
+iso8859-2/XLC_LOCALE: hr_HR.ISO8859-2
+iso8859-2/XLC_LOCALE: hu_HU.ISO8859-2
+iso8859-1/XLC_LOCALE: id_ID.ISO8859-1
+iso8859-1/XLC_LOCALE: is_IS.ISO8859-1
+iso8859-1/XLC_LOCALE: it_CH.ISO8859-1
+iso8859-1/XLC_LOCALE: it_IT.ISO8859-1
+iso8859-8/XLC_LOCALE: iw_IL.ISO8859-8
+ja/XLC_LOCALE: ja_JP.eucJP
+ja.SJIS/XLC_LOCALE: ja_JP.SJIS
+ja.JIS/XLC_LOCALE: ja_JP.JIS7
+ko/XLC_LOCALE: ko_KR.eucKR
+iso8859-1/XLC_LOCALE: lt_LN.ISO8859-1
+iso8859-1/XLC_LOCALE: lt_LT.ISO8859-4
+iso8859-1/XLC_LOCALE: lv_LV.ISO8859-4
+iso8859-5/XLC_LOCALE: mk_MK.ISO8859-5
+iso8859-1/XLC_LOCALE: nl_BE.ISO8859-1
+iso8859-1/XLC_LOCALE: nl_NL.ISO8859-1
+iso8859-1/XLC_LOCALE: no_NO.ISO8859-1
+iso8859-2/XLC_LOCALE: pl_PL.ISO8859-2
+iso8859-1/XLC_LOCALE: pt_BR.ISO8859-1
+iso8859-1/XLC_LOCALE: pt_PT.ISO8859-1
+iso8859-2/XLC_LOCALE: ro_RO.ISO8859-2
+iso8859-5/XLC_LOCALE: ru_RU.ISO8859-5
+koi8-r/XLC_LOCALE: ru_RU.KOI8-R
+iso8859-2/XLC_LOCALE: sh_YU.ISO8859-2
+iso8859-2/XLC_LOCALE: sk_SK.ISO8859-2
+iso8859-2/XLC_LOCALE: sl_CS.ISO8859-2
+iso8859-2/XLC_LOCALE: sl_SI.ISO8859-2
+iso8859-5/XLC_LOCALE: sp_YU.ISO8859-5
+iso8859-2/XLC_LOCALE: sq_AL.ISO8859-2
+iso8859-2/XLC_LOCALE: sr_SP.ISO8859-2
+iso8859-2/XLC_LOCALE: sr_YU.ISO8859-2
+iso8859-1/XLC_LOCALE: sv_FI.ISO8859-1
+iso8859-1/XLC_LOCALE: sv_SE.ISO8859-1
+th_TH/XLC_LOCALE: th_TH.TACTIS
+iso8859-9/XLC_LOCALE: tr_TR.ISO8859-9
+iso8859-5/XLC_LOCALE: uk_UA.ISO8859-5
+zh/XLC_LOCALE: zh_CN.eucCN
+zh_TW/XLC_LOCALE: zh_TW.eucTW
+en_US.utf/XLC_LOCALE: en_US.utf
+#ifdef __uxp__
+ja.U90/XLC_LOCALE: ja_JP.U90
+ja.S90/XLC_LOCALE: ja_JP.S90
+#endif
+
+XCOMM Added by Sun
+en_US.UTF-8/XLC_LOCALE: en_US.UTF-8
+zh_TW.BIG5/XLC_LOCALE: zh_TW.BIG5
+zh.GBK/XLC_LOCALE: zh.GBK
diff --git a/nls/zh_TW/XI18N_OBJS b/nls/zh_TW/XI18N_OBJS
new file mode 100644
index 00000000..0f471dd0
--- /dev/null
+++ b/nls/zh_TW/XI18N_OBJS
@@ -0,0 +1,7 @@
+# CATEGORY(XLC|XIM|OM) SHARED_LIBRARY_NAME FUNCTION_NAME
+#
+# XI18N objects table for zh_TW locale
+#
+XLC common/xlibi18n _XlcGenericLoader # XLC_open
+XIM common/ximp40 _Ximp_OpenIM # XIM_open
+XOM common/xomGeneric _XomGenericOpenOM # XOM_open
diff --git a/nls/zh_TW/XLC_LOCALE.pre b/nls/zh_TW/XLC_LOCALE.pre
new file mode 100644
index 00000000..93cecef0
--- /dev/null
+++ b/nls/zh_TW/XLC_LOCALE.pre
@@ -0,0 +1,143 @@
+XCOMM $Xorg: zh_TW,v 1.3 2000/08/17 19:47:01 cpqbld Exp $
+XCOMM XLocale Database Sample for zh_TW
+XCOMM
+XCOMM Note: In lib/X11/lcCT.c, charset names for CNS11643 coded character
+XCOMM sets are defined as CNS11643.1986-1 and -2. In the ECMA Registry,
+XCOMM CNS coded character sets 1-7 are registered as CNS 11643-1992.
+XCOMM CJK.INF Version 1.7 (August 15, 1995) written by Ken Lunde says
+XCOMM plane 14 of CNS 11643-1983 now became plane 3 of CNS 11643-1992.
+XCOMM I do not know how Taiwanese EUC is organized currently, so I left the
+XCOMM X11R6 organization of fsN/csN as it is and only changed "CNS11643-*"
+XCOMM to "CNS11643.1986-*".
+XCOMM 1995-10-24 T. Numata (numa@rp.open.cs.fujitsu.co.jp)
+
+XCOMM
+XCOMM XLC_FONTSET category
+XCOMM
+XLC_FONTSET
+XCOMM fs0 class (7 bit ASCII)
+fs0 {
+ charset {
+ name ISO8859-1:GL
+ }
+ font {
+ primary ISO8859-1:GL
+ vertical_rotate all
+ }
+}
+XCOMM fs1 class
+fs1 {
+ charset {
+ name CNS11643.1986-1:GL
+ }
+ font {
+ primary CNS11643.1986-1:GL
+ }
+}
+XCOMM fs2 class
+fs2 {
+ charset {
+ name CNS11643.1986-2:GL
+ }
+ font {
+ primary CNS11643.1986-2:GL
+ }
+}
+XCOMM fs3 class
+fs3 {
+ charset {
+ name CNS11643.1986-14:GL
+ }
+ font {
+ primary CNS11643.1986-14:GL
+ }
+}
+XCOMM fs4 class
+fs4 {
+ charset {
+ name CNS11643.1986-15:GL
+ }
+ font {
+ primary CNS11643.1986-15:GL
+ }
+}
+XCOMM fs5 class
+fs5 {
+ charset {
+ name CNS11643.1986-16:GL
+ }
+ font {
+ primary CNS11643.1986-16:GL
+ }
+}
+END XLC_FONTSET
+
+XCOMM
+XCOMM XLC_XLOCALE category
+XCOMM
+XLC_XLOCALE
+
+encoding_name zh_TW.euc
+mb_cur_max 4
+state_depend_encoding False
+wc_encoding_mask \x3fffc000
+wc_shift_bits 7
+
+#ifndef X_LOCALE
+use_stdc_env True
+force_convert_to_mb True
+#endif
+
+XCOMM cs0 class
+cs0 {
+ side GL:Default
+ length 1
+ wc_encoding \x00000000
+ ct_encoding ISO8859-1:GL; CNS11643.1986-0:GL
+}
+
+XCOMM cs1 class
+cs1 {
+ side GR:Default
+ length 2
+ wc_encoding \x30000000
+ ct_encoding CNS11643.1986-1:GR
+}
+
+XCOMM cs2 class # plane 2
+cs2 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8e\xa2
+ wc_encoding \x10088000
+ ct_encoding CNS11643.1986-2:GR
+}
+
+XCOMM cs3 class # plane 14
+cs3 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8e\xae
+ wc_encoding \x100b8000
+ ct_encoding CNS11643.1986-14:GR
+}
+
+XCOMM cs4 class # plane 15
+cs4 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8e\xaf
+ wc_encoding \x100bc000
+ ct_encoding CNS11643.1986-15:GR
+}
+
+XCOMM cs5 class # plane 16
+cs5 {
+ side GR
+ length 2
+ mb_encoding <SS> \x8e\xb0
+ wc_encoding \x100c0000
+ ct_encoding CNS11643.1986-16:GR
+}
+
+END XLC_XLOCALE
diff --git a/src/AllCells.c b/src/AllCells.c
new file mode 100644
index 00000000..495d9a36
--- /dev/null
+++ b/src/AllCells.c
@@ -0,0 +1,63 @@
+/* $Xorg: AllCells.c,v 1.4 2001/02/09 02:03:30 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+
+Status XAllocColorCells(dpy, cmap, contig, masks, nplanes, pixels, ncolors)
+register Display *dpy;
+Colormap cmap;
+Bool contig;
+unsigned int ncolors; /* CARD16 */
+unsigned int nplanes; /* CARD16 */
+unsigned long *masks; /* LISTofCARD32 */ /* RETURN */
+unsigned long *pixels; /* LISTofCARD32 */ /* RETURN */
+{
+
+ Status status;
+ xAllocColorCellsReply rep;
+ register xAllocColorCellsReq *req;
+ LockDisplay(dpy);
+ GetReq(AllocColorCells, req);
+
+ req->cmap = cmap;
+ req->colors = ncolors;
+ req->planes = nplanes;
+ req->contiguous = contig;
+
+ status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+ if (status) {
+ _XRead32 (dpy, (long *) pixels, 4L * (long) (rep.nPixels));
+ _XRead32 (dpy, (long *) masks, 4L * (long) (rep.nMasks));
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/AllPlanes.c b/src/AllPlanes.c
new file mode 100644
index 00000000..b636159e
--- /dev/null
+++ b/src/AllPlanes.c
@@ -0,0 +1,70 @@
+/* $Xorg: AllPlanes.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XAllocColorPlanes(dpy, cmap, contig, pixels, ncolors, nreds, ngreens,
+ nblues, rmask, gmask, bmask)
+register Display *dpy;
+Colormap cmap;
+Bool contig;
+unsigned long *pixels; /* LISTofCARD32 */ /* RETURN */
+int ncolors;
+int nreds, ngreens, nblues;
+unsigned long *rmask, *gmask, *bmask; /* CARD32 */ /* RETURN */
+{
+ xAllocColorPlanesReply rep;
+ Status status;
+ register xAllocColorPlanesReq *req;
+
+ LockDisplay(dpy);
+ GetReq(AllocColorPlanes,req);
+
+ req->cmap = cmap;
+ req->colors = ncolors;
+ req->red = nreds;
+ req->green = ngreens;
+ req->blue = nblues;
+ req->contiguous = contig;
+
+ status = _XReply(dpy, (xReply *)&rep, 0, xFalse);
+
+
+ if (status) {
+ *rmask = rep.redMask;
+ *gmask = rep.greenMask;
+ *bmask = rep.blueMask;
+
+ /* sizeof(CARD32) = 4 */
+ _XRead32 (dpy, (char *) pixels, (long)(ncolors * 4));
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/AllowEv.c b/src/AllowEv.c
new file mode 100644
index 00000000..b12e8f61
--- /dev/null
+++ b/src/AllowEv.c
@@ -0,0 +1,48 @@
+/* $Xorg: AllowEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XAllowEvents(dpy, mode, time)
+ register Display *dpy;
+ int mode;
+ Time time;
+
+{
+ register xAllowEventsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(AllowEvents,req);
+ req->mode = mode;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/src/AutoRep.c b/src/AutoRep.c
new file mode 100644
index 00000000..beb9a8f1
--- /dev/null
+++ b/src/AutoRep.c
@@ -0,0 +1,48 @@
+/* $Xorg: AutoRep.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XAutoRepeatOn (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOn;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+XAutoRepeatOff (dpy)
+register Display *dpy;
+{
+ XKeyboardControl values;
+ values.auto_repeat_mode = AutoRepeatModeOff;
+ XChangeKeyboardControl (dpy, KBAutoRepeatMode, &values);
+ return 1;
+}
+
+
diff --git a/src/Backgnd.c b/src/Backgnd.c
new file mode 100644
index 00000000..e5b67666
--- /dev/null
+++ b/src/Backgnd.c
@@ -0,0 +1,46 @@
+/* $Xorg: Backgnd.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBackground(dpy, w, pixel)
+ register Display *dpy;
+ Window w;
+ unsigned long pixel;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBackPixel;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixel);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/BdrWidth.c b/src/BdrWidth.c
new file mode 100644
index 00000000..2550fda3
--- /dev/null
+++ b/src/BdrWidth.c
@@ -0,0 +1,50 @@
+/* $Xorg: BdrWidth.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBorderWidth(dpy, w, width)
+Display *dpy;
+Window w;
+unsigned int width;
+{
+ unsigned long lwidth = width; /* must be CARD32 */
+
+ register xConfigureWindowReq *req;
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWBorderWidth;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), lwidth);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Bell.c b/src/Bell.c
new file mode 100644
index 00000000..7c620206
--- /dev/null
+++ b/src/Bell.c
@@ -0,0 +1,43 @@
+/* $Xorg: Bell.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XBell(dpy, percent)
+ register Display *dpy;
+ int percent;
+{
+ register xBellReq *req;
+
+ LockDisplay(dpy);
+ GetReq(Bell,req);
+ req->percent = percent;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Border.c b/src/Border.c
new file mode 100644
index 00000000..5e71ee90
--- /dev/null
+++ b/src/Border.c
@@ -0,0 +1,46 @@
+/* $Xorg: Border.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBorder(dpy, w, pixel)
+ register Display *dpy;
+ Window w;
+ unsigned long pixel;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBorderPixel;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixel);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChAccCon.c b/src/ChAccCon.c
new file mode 100644
index 00000000..4366f695
--- /dev/null
+++ b/src/ChAccCon.c
@@ -0,0 +1,58 @@
+/* $Xorg: ChAccCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XEnableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, EnableAccess);
+}
+
+XDisableAccessControl(dpy)
+ register Display *dpy;
+
+{
+ return XSetAccessControl(dpy, DisableAccess);
+}
+
+XSetAccessControl(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xSetAccessControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetAccessControl, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChActPGb.c b/src/ChActPGb.c
new file mode 100644
index 00000000..adc2036e
--- /dev/null
+++ b/src/ChActPGb.c
@@ -0,0 +1,46 @@
+/* $Xorg: ChActPGb.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeActivePointerGrab(dpy, event_mask, curs, time)
+register Display *dpy;
+unsigned int event_mask; /* CARD16 */
+Cursor curs;
+Time time;
+{
+ register xChangeActivePointerGrabReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeActivePointerGrab, req);
+ req->eventMask = event_mask;
+ req->cursor = curs;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ChClMode.c b/src/ChClMode.c
new file mode 100644
index 00000000..0b2657eb
--- /dev/null
+++ b/src/ChClMode.c
@@ -0,0 +1,44 @@
+/* $Xorg: ChClMode.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetCloseDownMode(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xSetCloseDownModeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetCloseDownMode, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChCmap.c b/src/ChCmap.c
new file mode 100644
index 00000000..d6aaa892
--- /dev/null
+++ b/src/ChCmap.c
@@ -0,0 +1,46 @@
+/* $Xorg: ChCmap.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowColormap(dpy, w, colormap)
+ register Display *dpy;
+ Window w;
+ Colormap colormap;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWColormap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), colormap);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChGC.c b/src/ChGC.c
new file mode 100644
index 00000000..d7d536a6
--- /dev/null
+++ b/src/ChGC.c
@@ -0,0 +1,48 @@
+/* $Xorg: ChGC.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeGC (dpy, gc, valuemask, values)
+ register Display *dpy;
+ GC gc;
+ unsigned long valuemask;
+ XGCValues *values;
+{
+ LockDisplay(dpy);
+
+ valuemask &= (1L << (GCLastBit + 1)) - 1;
+ if (valuemask) _XUpdateGCCache (gc, valuemask, values);
+
+ /* if any Resource ID changed, must flush */
+ if (gc->dirty & (GCFont | GCTile | GCStipple))
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChKeyCon.c b/src/ChKeyCon.c
new file mode 100644
index 00000000..c1b3fdce
--- /dev/null
+++ b/src/ChKeyCon.c
@@ -0,0 +1,80 @@
+/* $Xorg: ChKeyCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeKeyboardControl(dpy, mask, value_list)
+ register Display *dpy;
+ unsigned long mask;
+ XKeyboardControl *value_list;
+{
+ unsigned long values[8];
+ register unsigned long *value = values;
+ long nvalues;
+ register xChangeKeyboardControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeKeyboardControl, req);
+ req->mask = mask;
+
+ if (mask & KBKeyClickPercent)
+ *value++ = value_list->key_click_percent;
+
+ if (mask & KBBellPercent)
+ *value++ = value_list->bell_percent;
+
+ if (mask & KBBellPitch)
+ *value++ = value_list->bell_pitch;
+
+ if (mask & KBBellDuration)
+ *value++ = value_list->bell_duration;
+
+ if (mask & KBLed)
+ *value++ = value_list->led;
+
+ if (mask & KBLedMode)
+ *value++ = value_list->led_mode;
+
+ if (mask & KBKey)
+ *value++ = value_list->key;
+
+ if (mask & KBAutoRepeatMode)
+ *value++ = value_list->auto_repeat_mode;
+
+
+ req->length += (nvalues = value - values);
+
+ /* note: Data is a macro that uses its arguments multiple
+ times, so "nvalues" is changed in a separate assignment
+ statement */
+
+ nvalues <<= 2;
+ Data32 (dpy, (long *) values, nvalues);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/src/ChPntCon.c b/src/ChPntCon.c
new file mode 100644
index 00000000..ce0776d9
--- /dev/null
+++ b/src/ChPntCon.c
@@ -0,0 +1,50 @@
+/* $Xorg: ChPntCon.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangePointerControl(dpy, do_acc, do_thresh, acc_numerator,
+ acc_denominator, threshold)
+ register Display *dpy;
+ Bool do_acc, do_thresh;
+ int acc_numerator, acc_denominator, threshold;
+
+{
+ register xChangePointerControlReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangePointerControl, req);
+ req->doAccel = do_acc;
+ req->doThresh = do_thresh;
+ req->accelNum = acc_numerator;
+ req->accelDenum = acc_denominator;
+ req->threshold = threshold;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChProp.c b/src/ChProp.c
new file mode 100644
index 00000000..4cfbe96d
--- /dev/null
+++ b/src/ChProp.c
@@ -0,0 +1,107 @@
+/* $Xorg: ChProp.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XChangeProperty (
+ register Display *dpy,
+ Window w,
+ Atom property,
+ Atom type,
+ int format, /* 8, 16, or 32 */
+ int mode, /* PropModeReplace, PropModePrepend, PropModeAppend */
+ _Xconst unsigned char *data,
+ int nelements)
+#else
+XChangeProperty (dpy, w, property, type, format, mode, data, nelements)
+ register Display *dpy;
+ Window w;
+ Atom property, type;
+ int format; /* 8, 16, or 32 */
+ int mode; /* PropModeReplace, PropModePrepend, PropModeAppend */
+ unsigned char *data;
+ int nelements;
+#endif
+ {
+ register xChangePropertyReq *req;
+ register long len;
+
+ LockDisplay(dpy);
+ GetReq (ChangeProperty, req);
+ req->window = w;
+ req->property = property;
+ req->type = type;
+ req->mode = mode;
+ if (nelements < 0) {
+ req->nUnits = 0;
+ req->format = 0; /* ask for garbage, get garbage */
+ } else {
+ req->nUnits = nelements;
+ req->format = format;
+ }
+
+ switch (req->format) {
+ case 8:
+ len = ((long)nelements + 3)>>2;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ Data (dpy, (char *)data, nelements);
+ } /* else force BadLength */
+ break;
+
+ case 16:
+ len = ((long)nelements + 1)>>1;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ len = (long)nelements << 1;
+ Data16 (dpy, (short *) data, len);
+ } /* else force BadLength */
+ break;
+
+ case 32:
+ len = nelements;
+ if (dpy->bigreq_size || req->length + len <= (unsigned) 65535) {
+ SetReqLen(req, len, len);
+ len = (long)nelements << 2;
+ Data32 (dpy, (long *) data, len);
+ } /* else force BadLength */
+ break;
+
+ default:
+ /* BadValue will be generated */ ;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
+
diff --git a/src/ChSaveSet.c b/src/ChSaveSet.c
new file mode 100644
index 00000000..7adb08cf
--- /dev/null
+++ b/src/ChSaveSet.c
@@ -0,0 +1,58 @@
+/* $Xorg: ChSaveSet.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XChangeSaveSet(dpy, win, mode)
+register Display *dpy;
+Window win;
+int mode;
+{
+ register xChangeSaveSetReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ChangeSaveSet, req);
+ req->window = win;
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XAddToSaveSet(dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeInsert);
+}
+
+XRemoveFromSaveSet (dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ return XChangeSaveSet(dpy,win,SetModeDelete);
+}
diff --git a/src/ChWAttrs.c b/src/ChWAttrs.c
new file mode 100644
index 00000000..2c05cf55
--- /dev/null
+++ b/src/ChWAttrs.c
@@ -0,0 +1,55 @@
+/* $Xorg: ChWAttrs.c,v 1.5 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
+ CWBorderPixel|CWBitGravity|CWWinGravity|\
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|\
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|\
+ CWDontPropagate|CWColormap|CWCursor)
+
+XChangeWindowAttributes (dpy, w, valuemask, attributes)
+ register Display *dpy;
+ Window w;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ register xChangeWindowAttributesReq *req;
+ extern void _XProcessWindowAttributes();
+
+ LockDisplay(dpy);
+ GetReq(ChangeWindowAttributes,req);
+ req->window = w;
+ valuemask &= AllMaskBits;
+ if ((req->valueMask = valuemask))
+ _XProcessWindowAttributes (dpy, req, valuemask, attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ChWindow.c b/src/ChWindow.c
new file mode 100644
index 00000000..b0319aa6
--- /dev/null
+++ b/src/ChWindow.c
@@ -0,0 +1,59 @@
+/* $Xorg: ChWindow.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XResizeWindow(dpy, w, width, height)
+register Display *dpy;
+Window w;
+unsigned int width, height;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 8, req); /* 2 4-byte quantities */
+
+ req->window = w;
+ req->mask = CWWidth | CWHeight;
+#ifdef MUSTCOPY
+ {
+ unsigned long lwidth = width, lheight = height;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lwidth, 4); /* order dictated by values of */
+ Data32 (dpy, (long *) &lheight, 4); /* CWWidth and CWHeight */
+ }
+#else
+ {
+ CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = width;
+ *valuePtr = height;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ChkIfEv.c b/src/ChkIfEv.c
new file mode 100644
index 00000000..24539e82
--- /dev/null
+++ b/src/ChkIfEv.c
@@ -0,0 +1,83 @@
+/* $Xorg: ChkIfEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+#endif
+ ); /* function to call */
+ register XEvent *event; /* XEvent to be filled in. */
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial = 0;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if(qelt->qserial_num > qe_serial
+ && (*predicate)(dpy, &qelt->event, arg)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkMaskEv.c b/src/ChkMaskEv.c
new file mode 100644
index 00000000..cc511720
--- /dev/null
+++ b/src/ChkMaskEv.c
@@ -0,0 +1,90 @@
+/* $Xorg: ChkMaskEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckMaskEvent (dpy, mask, event)
+ register Display *dpy;
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkTypEv.c b/src/ChkTypEv.c
new file mode 100644
index 00000000..dd45be0b
--- /dev/null
+++ b/src/ChkTypEv.c
@@ -0,0 +1,75 @@
+/* $Xorg: ChkTypEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckTypedEvent (dpy, type, event)
+ register Display *dpy;
+ int type; /* Selected event type. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if (qelt->event.type == type) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkTypWEv.c b/src/ChkTypWEv.c
new file mode 100644
index 00000000..09b48b5d
--- /dev/null
+++ b/src/ChkTypWEv.c
@@ -0,0 +1,77 @@
+/* $Xorg: ChkTypWEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckTypedWindowEvent (dpy, w, type, event)
+ register Display *dpy;
+ Window w; /* Selected window. */
+ int type; /* Selected event type. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.xany.window == w) &&
+ (qelt->event.type == type)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/ChkWinEv.c b/src/ChkWinEv.c
new file mode 100644
index 00000000..27d4c05e
--- /dev/null
+++ b/src/ChkWinEv.c
@@ -0,0 +1,91 @@
+/* $Xorg: ChkWinEv.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Check existing events in queue to find if any match. If so, return.
+ * If not, flush buffer and see if any more events are readable. If one
+ * matches, return. If all else fails, tell the user no events found.
+ */
+
+Bool XCheckWindowEvent (dpy, w, mask, event)
+ register Display *dpy;
+ Window w; /* Selected window. */
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+ int n; /* time through count */
+
+ LockDisplay(dpy);
+ prev = NULL;
+ for (n = 3; --n >= 0;) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.xany.window == w) &&
+ (qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return True;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ switch (n) {
+ case 2:
+ _XEventsQueued(dpy, QueuedAfterReading);
+ break;
+ case 1:
+ _XFlush(dpy);
+ break;
+ }
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+ UnlockDisplay(dpy);
+ return False;
+}
diff --git a/src/CirWin.c b/src/CirWin.c
new file mode 100644
index 00000000..4099900f
--- /dev/null
+++ b/src/CirWin.c
@@ -0,0 +1,45 @@
+/* $Xorg: CirWin.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindows(dpy, w, direction)
+ register Display *dpy;
+ Window w;
+ int direction;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = direction;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CirWinDn.c b/src/CirWinDn.c
new file mode 100644
index 00000000..c3dce796
--- /dev/null
+++ b/src/CirWinDn.c
@@ -0,0 +1,44 @@
+/* $Xorg: CirWinDn.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindowsDown(dpy,w)
+ register Display *dpy;
+ Window w;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = LowerHighest;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CirWinUp.c b/src/CirWinUp.c
new file mode 100644
index 00000000..65ff8645
--- /dev/null
+++ b/src/CirWinUp.c
@@ -0,0 +1,44 @@
+/* $Xorg: CirWinUp.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCirculateSubwindowsUp(dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xCirculateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CirculateWindow, req);
+ req->window = w;
+ req->direction = RaiseLowest;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ClDisplay.c b/src/ClDisplay.c
new file mode 100644
index 00000000..0ea2fc54
--- /dev/null
+++ b/src/ClDisplay.c
@@ -0,0 +1,70 @@
+/* $Xorg: ClDisplay.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern void _XFreeDisplayStructure();
+
+/*
+ * XCloseDisplay - XSync the connection to the X Server, close the connection,
+ * and free all associated storage. Extension close procs should only free
+ * memory and must be careful about the types of requests they generate.
+ */
+
+XCloseDisplay (dpy)
+ register Display *dpy;
+{
+ register _XExtension *ext;
+ register int i;
+
+ if (!(dpy->flags & XlibDisplayClosing))
+ {
+ dpy->flags |= XlibDisplayClosing;
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XFreeGC (dpy, sp->default_gc);
+ }
+ if (dpy->cursor_font != None) {
+ XUnloadFont (dpy, dpy->cursor_font);
+ }
+ XSync(dpy, 1); /* throw away pending events, catch errors */
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->close_display)
+ (*ext->close_display)(dpy, &ext->codes);
+ }
+ /* if the closes generated more protocol, sync them up */
+ if (dpy->request != dpy->last_request_read)
+ XSync(dpy, 1);
+ }
+ _XDisconnectDisplay(dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ return 0;
+}
diff --git a/src/Clear.c b/src/Clear.c
new file mode 100644
index 00000000..54fde13e
--- /dev/null
+++ b/src/Clear.c
@@ -0,0 +1,46 @@
+/* $Xorg: Clear.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XClearWindow(dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xClearAreaReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ClearArea, req);
+ req->window = w;
+ req->x = req->y = req->width = req->height = 0;
+ /* these values mean "clear the entire window" */
+ req->exposures = xFalse;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ClearArea.c b/src/ClearArea.c
new file mode 100644
index 00000000..4028ae44
--- /dev/null
+++ b/src/ClearArea.c
@@ -0,0 +1,51 @@
+/* $Xorg: ClearArea.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XClearArea (dpy, w, x, y, width, height, exposures)
+ register Display *dpy;
+ Window w;
+ int x, y;
+ unsigned int width, height;
+ Bool exposures;
+{
+ register xClearAreaReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ClearArea, req);
+ req->window = w;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->exposures = exposures;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ConfWind.c b/src/ConfWind.c
new file mode 100644
index 00000000..f4bb4239
--- /dev/null
+++ b/src/ConfWind.c
@@ -0,0 +1,66 @@
+/* $Xorg: ConfWind.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMoveResizeWindow(dpy, w, x, y, width, height)
+register Display *dpy;
+Window w;
+int x, y;
+unsigned int width, height;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 16, req);
+ req->window = w;
+ req->mask = CWX | CWY | CWWidth | CWHeight;
+#ifdef MUSTCOPY
+ {
+ long lx = x, ly = y;
+ unsigned long lwidth = width, lheight = height;
+
+ dpy->bufptr -= 16;
+ Data32 (dpy, (long *) &lx, 4); /* order must match values of */
+ Data32 (dpy, (long *) &ly, 4); /* CWX, CWY, CWWidth, and CWHeight */
+ Data32 (dpy, (long *) &lwidth, 4);
+ Data32 (dpy, (long *) &lheight, 4);
+ }
+#else
+ {
+ register CARD32 *valuePtr =
+ (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = x;
+ *valuePtr++ = y;
+ *valuePtr++ = width;
+ *valuePtr = height;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/ConnDis.c b/src/ConnDis.c
new file mode 100644
index 00000000..9ee55118
--- /dev/null
+++ b/src/ConnDis.c
@@ -0,0 +1,1157 @@
+/* $Xorg: ConnDis.c,v 1.8 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * This file contains operating system dependencies.
+ */
+
+#define NEED_EVENTS
+
+#include <X11/Xlibint.h>
+#include <X11/Xtrans.h>
+#include <X11/Xauth.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#ifndef WIN32
+#include <sys/socket.h>
+#endif
+
+#ifndef X_CONNECTION_RETRIES /* number retries on ECONNREFUSED */
+#define X_CONNECTION_RETRIES 5
+#endif
+
+#ifdef LOCALCONN
+#include <sys/utsname.h>
+#endif
+
+static void GetAuthorization();
+
+static char *copystring (src, len)
+ char *src;
+ int len;
+{
+ char *dst = Xmalloc (len + 1);
+
+ if (dst) {
+ strncpy (dst, src, len);
+ dst[len] = '\0';
+ }
+
+ return dst;
+}
+
+
+/*
+ * Attempts to connect to server, given display name. Returns file descriptor
+ * (network socket) or -1 if connection fails. Display names may be of the
+ * following format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber [.screennumber]
+ *
+ * The second colon indicates a DECnet style name. No hostname is interpretted
+ * as the most efficient local connection to a server on the same machine.
+ * This is usually:
+ *
+ * o shared memory
+ * o local stream
+ * o UNIX domain socket
+ * o TCP to local host
+ *
+ * This function will eventually call the X Transport Interface functions
+ * which expects the hostname in the format:
+ *
+ * [protocol/] [hostname] : [:] displaynumber
+ *
+ */
+XtransConnInfo
+_X11TransConnectDisplay (display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ char *display_name;
+ char **fullnamep; /* RETURN */
+ int *dpynump; /* RETURN */
+ int *screenp; /* RETURN */
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+ int family;
+ int saddrlen;
+ Xtransaddr *saddr;
+ char *lastp, *lastc, *p; /* char pointers */
+ char *pprotocol = NULL; /* start of protocol name */
+ char *phostname = NULL; /* start of host of display */
+ char *pdpynum = NULL; /* start of dpynum of display */
+ char *pscrnum = NULL; /* start of screen of display */
+ Bool dnet = False; /* if true, then DECnet format */
+ int idisplay; /* required display number */
+ int iscreen = 0; /* optional screen number */
+ int (*connfunc)(); /* method to create connection */
+ int len, hostlen; /* length tmp variable */
+ int retry; /* retry counter */
+ char addrbuf[128]; /* final address passed to
+ X Transport Interface */
+ char* address = addrbuf;
+ XtransConnInfo trans_conn = NULL; /* transport connection object */
+ int connect_stat;
+#ifdef LOCALCONN
+ struct utsname sys;
+#ifdef TCPCONN
+ char *tcphostname = NULL; /* A place to save hostname pointer */
+#endif
+#endif
+
+ p = display_name;
+
+ saddrlen = 0; /* set so that we can clear later */
+ saddr = NULL;
+
+ /*
+ * Step 0, find the protocol. This is delimited by the optional
+ * slash ('/').
+ */
+ for (lastp = p; *p && *p != ':' && *p != '/'; p++) ;
+ if (!*p) return NULL; /* must have a colon */
+
+ if (p != lastp && *p != ':') { /* protocol given? */
+ pprotocol = copystring (lastp, p - lastp);
+ if (!pprotocol) goto bad; /* no memory */
+ p++; /* skip the '/' */
+ } else
+ p = display_name; /* reset the pointer in
+ case no protocol was given */
+
+ /*
+ * Step 1, find the hostname. This is delimited by either one colon,
+ * or two colons in the case of DECnet (DECnet Phase V allows a single
+ * colon in the hostname).
+ */
+
+ lastp = p;
+ lastc = NULL;
+ for (; *p; p++)
+ if (*p == ':')
+ lastc = p;
+
+ if (!lastc) return NULL; /* must have a colon */
+
+ if ((lastp != lastc) && (*(lastc - 1) == ':')) {
+ /* DECnet display specified */
+
+#ifndef DNETCONN
+ goto bad;
+#else
+ dnet = True;
+ /* override the protocol specified */
+ if (pprotocol)
+ Xfree (pprotocol);
+ pprotocol = copystring ("dnet", 4);
+ hostlen = lastc - 1 - lastp;
+#endif
+ }
+ else
+ hostlen = lastc - lastp;
+
+ if (hostlen > 0) { /* hostname given? */
+ phostname = copystring (lastp, hostlen);
+ if (!phostname) goto bad; /* no memory */
+ }
+
+ p = lastc;
+
+#ifdef LOCALCONN
+ /* check if phostname == localnodename AND protocol not specified */
+ if (!pprotocol && phostname && uname(&sys) >= 0 &&
+ !strncmp(phostname, sys.nodename,
+ (strlen(sys.nodename) < strlen(phostname) ?
+ strlen(phostname) : strlen(sys.nodename))))
+ {
+#ifdef TCPCONN
+ /*
+ * We'll first attempt to connect using the local transport. If
+ * this fails (which is the case if sshd X protocol forwarding is
+ * being used), retry using tcp and this hostname.
+ */
+ tcphostname = copystring(phostname, strlen(phostname));
+#endif
+ Xfree (phostname);
+ phostname = copystring ("unix", 4);
+ }
+#endif
+
+
+ /*
+ * Step 2, find the display number. This field is required and is
+ * delimited either by a nul or a period, depending on whether or not
+ * a screen number is present.
+ */
+
+ for (lastp = ++p; *p && isascii(*p) && isdigit(*p); p++) ;
+ if ((p == lastp) || /* required field */
+ (*p != '\0' && *p != '.') || /* invalid non-digit terminator */
+ !(pdpynum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ idisplay = atoi (pdpynum);
+
+
+ /*
+ * Step 3, find the screen number. This field is optional. It is
+ * present only if the display number was followed by a period (which
+ * we've already verified is the only non-nul character).
+ */
+
+ if (*p) {
+ for (lastp = ++p; *p && isascii(*p) && isdigit (*p); p++) ;
+ if (p != lastp) {
+ if (*p || /* non-digits */
+ !(pscrnum = copystring (lastp, p - lastp))) /* no memory */
+ goto bad;
+ iscreen = atoi (lastp);
+ }
+ }
+
+ /*
+ * At this point, we know the following information:
+ *
+ * pprotocol protocol string or NULL
+ * phostname hostname string or NULL
+ * idisplay display number
+ * iscreen screen number
+ * dnet DECnet boolean
+ *
+ * We can now decide which transport to use based on the ConnectionFlags
+ * build parameter the hostname string. If phostname is NULL or equals
+ * the string "local", then choose the best transport. If phostname
+ * is "unix", then choose BSD UNIX domain sockets (if configured).
+ */
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(LOCALCONN)
+ if (!pprotocol) {
+ if (!phostname)
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ pprotocol = copystring ("local", 5);
+ else
+#endif
+ pprotocol = copystring ("tcp", 3);
+ }
+#endif
+
+#if defined(UNIXCONN) || defined(LOCALCONN)
+ /*
+ * Now that the defaults have been established, see if we have any
+ * special names that we have to override:
+ *
+ * :N => if UNIXCONN then unix-domain-socket
+ * ::N => if UNIXCONN then unix-domain-socket
+ * unix:N => if UNIXCONN then unix-domain-socket
+ *
+ * Note that if UNIXCONN isn't defined, then we can use the default
+ * transport connection function set above.
+ */
+
+ if (!phostname) {
+#ifdef apollo
+ ; /* Unix domain sockets are *really* bad on apollos */
+#else
+ if( pprotocol ) Xfree(pprotocol);
+ pprotocol = copystring ("local", 5);
+#endif
+ }
+ else if (strcmp (phostname, "unix") == 0) {
+ if( pprotocol ) Xfree(pprotocol);
+ pprotocol = copystring ("local", 5);
+ }
+#endif
+
+ connect:
+ /*
+ * This seems kind of backwards, but we need to put the protocol,
+ * host, and port back together to pass to _X11TransOpenCOTSClient().
+ */
+
+ {
+ int olen = 3 + (pprotocol ? strlen(pprotocol) : 0) +
+ (phostname ? strlen(phostname) : 0) +
+ (pdpynum ? strlen(pdpynum) : 0);
+ if (olen > sizeof addrbuf) address = Xmalloc (olen);
+ }
+
+ sprintf(address,"%s/%s:%s",
+ pprotocol ? pprotocol : "",
+ phostname ? phostname : "",
+ pdpynum );
+
+ /*
+ * Make the connection, also need to get the auth address info for
+ * the connection. Do retries in case server host has hit its
+ * backlog (which, unfortunately, isn't distinguishable from there not
+ * being a server listening at all, which is why we have to not retry
+ * too many times).
+ */
+ for(retry=X_CONNECTION_RETRIES; retry>=0; retry-- )
+ {
+ if ( (trans_conn = _X11TransOpenCOTSClient(address)) == NULL )
+ {
+ break;
+ }
+ if ((connect_stat = _X11TransConnect(trans_conn,address)) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+
+ if (connect_stat == TRANS_TRY_CONNECT_AGAIN)
+ {
+ sleep(1);
+ continue;
+ }
+ else
+ break;
+ }
+
+ _X11TransGetPeerAddr(trans_conn, &family, &saddrlen, &saddr);
+
+ /*
+ * The family is given in a socket format (ie AF_INET). This
+ * will convert it to the format used by the authorization and
+ * X protocol (ie FamilyInternet).
+ */
+
+ if( _X11TransConvertAddress(&family, &saddrlen, &saddr) < 0 )
+ {
+ _X11TransClose(trans_conn);
+ trans_conn = NULL;
+ sleep(1);
+ if (saddr)
+ {
+ free ((char *) saddr);
+ saddr = NULL;
+ }
+ continue;
+ }
+
+ break;
+ }
+
+ if (address != addrbuf) Xfree (address);
+
+ if( trans_conn == NULL )
+ goto bad;
+
+ /*
+ * Set close-on-exec so that programs that fork() doesn't get confused.
+ */
+
+ _X11TransSetOption(trans_conn,TRANS_CLOSEONEXEC,1);
+
+ /*
+ * Build the expanded display name:
+ *
+ * [host] : [:] dpy . scr \0
+ */
+ len = ((phostname ? strlen(phostname) : 0) + 1 + (dnet ? 1 : 0) +
+ strlen(pdpynum) + 1 + (pscrnum ? strlen(pscrnum) : 1) + 1);
+ *fullnamep = (char *) Xmalloc (len);
+ if (!*fullnamep) goto bad;
+
+ sprintf (*fullnamep, "%s%s%d.%d",
+ (phostname ? phostname : ""),
+ (dnet ? "::" : ":"),
+ idisplay, iscreen);
+
+ *dpynump = idisplay;
+ *screenp = iscreen;
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+
+ GetAuthorization(trans_conn, family, (char *) saddr, saddrlen, idisplay,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+ return trans_conn;
+
+
+ /*
+ * error return; make sure everything is cleaned up.
+ */
+ bad:
+ if (trans_conn) (void)_X11TransClose(trans_conn);
+ if (saddr) free ((char *) saddr);
+ if (pprotocol) Xfree (pprotocol);
+ if (phostname) Xfree (phostname);
+
+#if defined(LOCALCONN) && defined(TCPCONN)
+ if (tcphostname) {
+ pprotocol = copystring("tcp", 3);
+ phostname = tcphostname;
+ tcphostname = NULL;
+ goto connect;
+ }
+#endif
+
+ if (pdpynum) Xfree (pdpynum);
+ if (pscrnum) Xfree (pscrnum);
+ return NULL;
+
+}
+
+/*
+ * This is gross, but we need it for compatiblity.
+ * The test suite relies on the following interface.
+ *
+ */
+
+int _XConnectDisplay (display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ char *display_name;
+ char **fullnamep; /* RETURN */
+ int *dpynump; /* RETURN */
+ int *screenp; /* RETURN */
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+ XtransConnInfo trans_conn;
+
+ trans_conn = _X11TransConnectDisplay (
+ display_name, fullnamep, dpynump, screenp,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp);
+
+ if (trans_conn)
+ {
+ int fd = _X11TransGetConnectionNumber (trans_conn);
+ _X11TransFreeConnInfo (trans_conn);
+ return (fd);
+ }
+ else
+ return (-1);
+}
+
+
+/*****************************************************************************
+ * *
+ * Connection Utility Routines *
+ * *
+ *****************************************************************************/
+
+/*
+ * Disconnect from server.
+ */
+
+int _XDisconnectDisplay (trans_conn)
+
+XtransConnInfo trans_conn;
+
+{
+ _X11TransDisconnect(trans_conn);
+ _X11TransClose(trans_conn);
+ return 0;
+}
+
+
+
+static int padlength[4] = {0, 3, 2, 1}; /* make sure auth is multiple of 4 */
+
+Bool
+_XSendClientPrefix (dpy, client, auth_proto, auth_string, prefix)
+ Display *dpy;
+ xConnClientPrefix *client; /* contains count for auth_* */
+ char *auth_proto, *auth_string; /* NOT null-terminated */
+ xConnSetupPrefix *prefix; /* prefix information */
+{
+ int auth_length = client->nbytesAuthProto;
+ int auth_strlen = client->nbytesAuthString;
+ char padbuf[3]; /* for padding to 4x bytes */
+ int pad;
+ struct iovec iovarray[5], *iov = iovarray;
+ int niov = 0;
+ int len = 0;
+
+#define add_to_iov(b,l) \
+ { iov->iov_base = (b); iov->iov_len = (l); iov++, niov++; len += (l); }
+
+ add_to_iov ((caddr_t) client, SIZEOF(xConnClientPrefix));
+
+ /*
+ * write authorization protocol name and data
+ */
+ if (auth_length > 0) {
+ add_to_iov (auth_proto, auth_length);
+ pad = padlength [auth_length & 3];
+ if (pad) add_to_iov (padbuf, pad);
+ }
+ if (auth_strlen > 0) {
+ add_to_iov (auth_string, auth_strlen);
+ pad = padlength [auth_strlen & 3];
+ if (pad) add_to_iov (padbuf, pad);
+ }
+
+#undef add_to_iov
+
+ len -= _X11TransWritev (dpy->trans_conn, iovarray, niov);
+
+ /*
+ * Set the connection non-blocking since we use select() to block.
+ */
+
+ _X11TransSetOption(dpy->trans_conn, TRANS_NONBLOCKING, 1);
+
+ if (len != 0)
+ return -1;
+
+#ifdef K5AUTH
+ if (auth_length == 14 &&
+ !strncmp(auth_proto, "MIT-KERBEROS-5", 14))
+ {
+ return k5_clientauth(dpy, prefix);
+ } else
+#endif
+ return 0;
+}
+
+
+#ifdef STREAMSCONN
+#ifdef SVR4
+#include <tiuser.h>
+#else
+#undef HASXDMAUTH
+#endif
+#endif
+
+#ifdef SECURE_RPC
+#include <rpc/rpc.h>
+#ifdef ultrix
+#include <time.h>
+#include <rpc/auth_des.h>
+#endif
+#endif
+
+#ifdef HASXDMAUTH
+#ifdef X_NOT_STDC_ENV
+#define Time_t long
+extern Time_t time ();
+#else
+#include <time.h>
+#define Time_t time_t
+#endif
+#endif
+
+/*
+ * First, a routine for setting authorization data
+ */
+static int xauth_namelen = 0;
+static char *xauth_name = NULL; /* NULL means use default mechanism */
+static int xauth_datalen = 0;
+static char *xauth_data = NULL; /* NULL means get default data */
+
+/*
+ * This is a list of the authorization names which Xlib currently supports.
+ * Xau will choose the file entry which matches the earliest entry in this
+ * array, allowing us to prioritize these in terms of the most secure first
+ */
+
+static char *default_xauth_names[] = {
+#ifdef K5AUTH
+ "MIT-KERBEROS-5",
+#endif
+#ifdef SECURE_RPC
+ "SUN-DES-1",
+#endif
+#ifdef HASXDMAUTH
+ "XDM-AUTHORIZATION-1",
+#endif
+ "MIT-MAGIC-COOKIE-1"
+};
+
+static int default_xauth_lengths[] = {
+#ifdef K5AUTH
+ 14, /* strlen ("MIT-KERBEROS-5") */
+#endif
+#ifdef SECURE_RPC
+ 9, /* strlen ("SUN-DES-1") */
+#endif
+#ifdef HASXDMAUTH
+ 19, /* strlen ("XDM-AUTHORIZATION-1") */
+#endif
+ 18 /* strlen ("MIT-MAGIC-COOKIE-1") */
+};
+
+#define NUM_DEFAULT_AUTH (sizeof (default_xauth_names) / sizeof (default_xauth_names[0]))
+
+static char **xauth_names = default_xauth_names;
+static int *xauth_lengths = default_xauth_lengths;
+
+static int xauth_names_length = NUM_DEFAULT_AUTH;
+
+void XSetAuthorization (name, namelen, data, datalen)
+ int namelen, datalen; /* lengths of name and data */
+ char *name, *data; /* NULL or arbitrary array of bytes */
+{
+ char *tmpname, *tmpdata;
+
+ _XLockMutex(_Xglobal_lock);
+ if (xauth_name) Xfree (xauth_name); /* free any existing data */
+ if (xauth_data) Xfree (xauth_data);
+
+ xauth_name = xauth_data = NULL; /* mark it no longer valid */
+ xauth_namelen = xauth_datalen = 0;
+ _XUnlockMutex(_Xglobal_lock);
+
+ if (namelen < 0) namelen = 0; /* check for bogus inputs */
+ if (datalen < 0) datalen = 0; /* maybe should return? */
+
+ if (namelen > 0) { /* try to allocate space */
+ tmpname = Xmalloc ((unsigned) namelen);
+ if (!tmpname) return;
+ memcpy (tmpname, name, namelen);
+ } else {
+ tmpname = NULL;
+ }
+
+ if (datalen > 0) {
+ tmpdata = Xmalloc ((unsigned) datalen);
+ if (!tmpdata) {
+ if (tmpname) (void) Xfree (tmpname);
+ return;
+ }
+ memcpy (tmpdata, data, datalen);
+ } else {
+ tmpdata = NULL;
+ }
+
+ _XLockMutex(_Xglobal_lock);
+ xauth_name = tmpname; /* and store the suckers */
+ xauth_namelen = namelen;
+ if (tmpname)
+ {
+ xauth_names = &xauth_name;
+ xauth_lengths = &xauth_namelen;
+ xauth_names_length = 1;
+ }
+ else
+ {
+ xauth_names = default_xauth_names;
+ xauth_lengths = default_xauth_lengths;
+ xauth_names_length = NUM_DEFAULT_AUTH;
+ }
+ xauth_data = tmpdata;
+ xauth_datalen = datalen;
+ _XUnlockMutex(_Xglobal_lock);
+ return;
+}
+
+#ifdef SECURE_RPC
+/*
+ * Create a credential that we can send to the X server.
+ */
+static int
+auth_ezencode(servername, window, cred_out, len)
+ char *servername;
+ int window;
+ char *cred_out;
+ int *len;
+{
+ AUTH *a;
+ XDR xdr;
+
+ a = (AUTH *)authdes_create(servername, window, NULL, NULL);
+ if (a == (AUTH *)NULL) {
+ perror("auth_create");
+ return 0;
+ }
+ xdrmem_create(&xdr, cred_out, *len, XDR_ENCODE);
+ if (AUTH_MARSHALL(a, &xdr) == FALSE) {
+ perror("auth_marshall");
+ AUTH_DESTROY(a);
+ return 0;
+ }
+ *len = xdr_getpos(&xdr);
+ AUTH_DESTROY(a);
+ return 1;
+}
+#endif
+
+#ifdef K5AUTH
+#include <com_err.h>
+
+extern krb5_flags krb5_kdc_default_options;
+
+/*
+ * k5_clientauth
+ *
+ * Returns non-zero if the setup prefix has been read,
+ * so we can tell XOpenDisplay to not bother looking for it by
+ * itself.
+ */
+static int k5_clientauth(dpy, sprefix)
+ Display *dpy;
+ xConnSetupPrefix *sprefix;
+{
+ krb5_error_code retval;
+ xReq prefix;
+ char *buf;
+ CARD16 plen, tlen;
+ krb5_data kbuf;
+ krb5_ccache cc;
+ krb5_creds creds;
+ krb5_principal cprinc, sprinc;
+ krb5_ap_rep_enc_part *repl;
+
+ krb5_init_ets();
+ /*
+ * stage 0: get encoded principal and tgt from server
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2 && prefix.reqType != 3)
+ /* not an auth packet... so deal */
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq); /* ewww... gross */
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 0: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 0)
+ {
+ fprintf(stderr, "Xlib: got out of sequence (%d) packet in Krb5 auth\n",
+ prefix.data);
+ return -1;
+ }
+ buf = (char *)malloc((prefix.length << 2) - sz_xReq);
+ if (buf == NULL) /* malloc failed. Run away! */
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ tlen = (prefix.length << 2) - sz_xReq;
+ _XRead(dpy, buf, tlen);
+ if (prefix.reqType == 2 && tlen < 6)
+ {
+ fprintf(stderr, "Xlib: Krb5 stage 0 reply from server too short\n");
+ free(buf);
+ return -1;
+ }
+ if (prefix.reqType == 2)
+ {
+ plen = *(CARD16 *)buf;
+ kbuf.data = buf + 2;
+ kbuf.length = (plen > tlen) ? tlen : plen;
+ }
+ else
+ {
+ kbuf.data = buf;
+ kbuf.length = tlen;
+ }
+ if (XauKrb5Decode(kbuf, &sprinc))
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: XauKrb5Decode bombed\n");
+ return -1;
+ }
+ if (prefix.reqType == 3) /* do some special stuff here */
+ {
+ char *sname, *hostname = NULL;
+
+ sname = (char *)malloc(krb5_princ_component(sprinc, 0)->length + 1);
+ if (sname == NULL)
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ memcpy(sname, krb5_princ_component(sprinc, 0)->data,
+ krb5_princ_component(sprinc, 0)->length);
+ sname[krb5_princ_component(sprinc, 0)->length] = '\0';
+ krb5_free_principal(sprinc);
+ if (dpy->display_name[0] != ':') /* hunt for a hostname */
+ {
+ char *t;
+
+ if ((hostname = (char *)malloc(strlen(dpy->display_name)))
+ == NULL)
+ {
+ free(buf);
+ free(sname);
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ strcpy(hostname, dpy->display_name);
+ t = strchr(hostname, ':');
+ if (t == NULL)
+ {
+ free(buf);
+ free(sname);
+ free(hostname);
+ fprintf(stderr,
+ "Xlib: shouldn't get here! malformed display name.");
+ return -1;
+ }
+ if ((t - hostname + 1 < strlen(hostname)) && t[1] == ':')
+ t++;
+ *t = '\0'; /* truncate the dpy number out */
+ }
+ retval = krb5_sname_to_principal(hostname, sname,
+ KRB5_NT_SRV_HST, &sprinc);
+ free(sname);
+ if (hostname)
+ free(hostname);
+ if (retval)
+ {
+ free(buf);
+ fprintf(stderr, "Xlib: krb5_sname_to_principal failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ }
+ if (retval = krb5_cc_default(&cc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: krb5_cc_default failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ if (retval = krb5_cc_get_principal(cc, &cprinc))
+ {
+ free(buf);
+ krb5_free_principal(sprinc);
+ fprintf(stderr, "Xlib: cannot get Kerberos principal from \"%s\": %s\n",
+ krb5_cc_default_name(), error_message(retval));
+ return -1;
+ }
+ bzero((char *)&creds, sizeof(creds));
+ creds.server = sprinc;
+ creds.client = cprinc;
+ if (prefix.reqType == 2)
+ {
+ creds.second_ticket.length = tlen - plen - 2;
+ creds.second_ticket.data = buf + 2 + plen;
+ retval = krb5_get_credentials(KRB5_GC_USER_USER |
+ krb5_kdc_default_options,
+ cc, &creds);
+ }
+ else
+ retval = krb5_get_credentials(krb5_kdc_default_options,
+ cc, &creds);
+ if (retval)
+ {
+ free(buf);
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: cannot get Kerberos credentials: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ /*
+ * now format the ap_req to send to the server
+ */
+ if (prefix.reqType == 2)
+ retval = krb5_mk_req_extended(AP_OPTS_USE_SESSION_KEY |
+ AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc,
+ &creds, NULL, &kbuf);
+ else
+ retval = krb5_mk_req_extended(AP_OPTS_MUTUAL_REQUIRED, NULL,
+ 0, 0, NULL, cc, &creds, NULL,
+ &kbuf);
+ free(buf);
+ if (retval) /* Some manner of Kerberos lossage */
+ {
+ krb5_free_cred_contents(&creds);
+ fprintf(stderr, "Xlib: krb5_mk_req_extended failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ prefix.reqType = 1;
+ prefix.data = 0;
+ prefix.length = (kbuf.length + sz_xReq + 3) >> 2;
+ /*
+ * stage 1: send ap_req to server
+ */
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ _XSend(dpy, (char *)kbuf.data, kbuf.length);
+ free(kbuf.data);
+ /*
+ * stage 2: get ap_rep from server to mutually authenticate
+ */
+ _XRead(dpy, (char *)&prefix, sz_xReq);
+ if (prefix.reqType != 2)
+ if (prefix.reqType == 0 || prefix.reqType == 1)
+ {
+ memcpy((char *)sprefix, (char *)&prefix, sz_xReq);
+ _XRead(dpy, (char *)sprefix + sz_xReq,
+ sz_xConnSetupPrefix - sz_xReq);
+ return 1;
+ }
+ else
+ {
+ fprintf(stderr,
+ "Xlib: Krb5 stage 2: got illegal connection setup success code %d\n",
+ prefix.reqType);
+ return -1;
+ }
+ if (prefix.data != 2)
+ return -1;
+ kbuf.length = (prefix.length << 2) - sz_xReq;
+ kbuf.data = (char *)malloc(kbuf.length);
+ if (kbuf.data == NULL)
+ {
+ fprintf(stderr, "Xlib: malloc bombed in Krb5 auth\n");
+ return -1;
+ }
+ _XRead(dpy, (char *)kbuf.data, kbuf.length);
+ retval = krb5_rd_rep(&kbuf, &creds.keyblock, &repl);
+ if (retval)
+ {
+ free(kbuf.data);
+ fprintf(stderr, "Xlib: krb5_rd_rep failed: %s\n",
+ error_message(retval));
+ return -1;
+ }
+ free(kbuf.data);
+ /*
+ * stage 3: send a short ack to the server and return
+ */
+ prefix.reqType = 3;
+ prefix.data = 0;
+ prefix.length = sz_xReq >> 2;
+ _XSend(dpy, (char *)&prefix, sz_xReq);
+ return 0;
+}
+#endif /* K5AUTH */
+
+static void
+GetAuthorization(trans_conn, family, saddr, saddrlen, idisplay,
+ auth_namep, auth_namelenp, auth_datap, auth_datalenp)
+ XtransConnInfo trans_conn;
+ int family;
+ int saddrlen;
+ int idisplay;
+ char *saddr;
+ char **auth_namep; /* RETURN */
+ int *auth_namelenp; /* RETURN */
+ char **auth_datap; /* RETURN */
+ int *auth_datalenp; /* RETURN */
+{
+#ifdef SECURE_RPC
+ char rpc_cred[MAX_AUTH_BYTES];
+#endif
+#ifdef HASXDMAUTH
+ char xdmcp_data[192/8];
+#endif
+ char *auth_name;
+ int auth_namelen;
+ char *auth_data;
+ int auth_datalen;
+ Xauth *authptr = NULL;
+
+/*
+ * Look up the authorization protocol name and data if necessary.
+ */
+ if (xauth_name && xauth_data) {
+ auth_namelen = xauth_namelen;
+ auth_name = xauth_name;
+ auth_datalen = xauth_datalen;
+ auth_data = xauth_data;
+ } else {
+ char dpynumbuf[40]; /* big enough to hold 2^64 and more */
+ (void) sprintf (dpynumbuf, "%d", idisplay);
+
+ authptr = XauGetBestAuthByAddr ((unsigned short) family,
+ (unsigned short) saddrlen,
+ saddr,
+ (unsigned short) strlen (dpynumbuf),
+ dpynumbuf,
+ xauth_names_length,
+ xauth_names,
+ xauth_lengths);
+ if (authptr) {
+ auth_namelen = authptr->name_length;
+ auth_name = (char *)authptr->name;
+ auth_datalen = authptr->data_length;
+ auth_data = (char *)authptr->data;
+ } else {
+ auth_namelen = 0;
+ auth_name = NULL;
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+#ifdef HASXDMAUTH
+ /*
+ * build XDM-AUTHORIZATION-1 data
+ */
+ if (auth_namelen == 19 && !strncmp (auth_name, "XDM-AUTHORIZATION-1", 19))
+ {
+ int i, j;
+ Time_t now;
+ int family, addrlen;
+ Xtransaddr *addr = NULL;
+
+ for (j = 0; j < 8; j++)
+ xdmcp_data[j] = auth_data[j];
+
+ _X11TransGetMyAddr(trans_conn, &family, &addrlen, &addr);
+
+ switch( family )
+ {
+#ifdef AF_INET
+ case AF_INET:
+ {
+ /*
+ * addr will contain a sockaddr_in with all
+ * of the members already in network byte order.
+ */
+
+ for(i=4; i<8; i++) /* do sin_addr */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ for(i=2; i<4; i++) /* do sin_port */
+ xdmcp_data[j++] = ((char *)addr)[i];
+ break;
+ }
+#endif /* AF_INET */
+#ifdef AF_UNIX
+ case AF_UNIX:
+ {
+ /*
+ * We don't use the sockaddr_un for this encoding.
+ * Instead, we create a sockaddr_in filled with
+ * a decreasing counter for the address, and the
+ * pid for the port.
+ */
+
+ static unsigned long unix_addr = 0xFFFFFFFF;
+ unsigned long the_addr;
+ unsigned short the_port;
+
+ _XLockMutex(_Xglobal_lock);
+ the_addr = unix_addr--;
+ _XUnlockMutex(_Xglobal_lock);
+ the_port = getpid ();
+
+ xdmcp_data[j++] = (the_addr >> 24) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 16) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 8) & 0xFF;
+ xdmcp_data[j++] = (the_addr >> 0) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 8) & 0xFF;
+ xdmcp_data[j++] = (the_port >> 0) & 0xFF;
+ break;
+ }
+#endif /* AF_UNIX */
+#ifdef AF_DECnet
+ case AF_DECnet:
+ /*
+ * What is the defined encoding for this?
+ */
+ break;
+#endif /* AF_DECnet */
+ default:
+ /*
+ * Need to return some kind of errro status here.
+ * maybe a NULL auth??
+ */
+ break;
+ } /* switch */
+
+ if (addr)
+ free ((char *) addr);
+
+ time (&now);
+ xdmcp_data[j++] = (now >> 24) & 0xFF;
+ xdmcp_data[j++] = (now >> 16) & 0xFF;
+ xdmcp_data[j++] = (now >> 8) & 0xFF;
+ xdmcp_data[j++] = (now >> 0) & 0xFF;
+ while (j < 192 / 8)
+ xdmcp_data[j++] = 0;
+ _XLockMutex(_Xglobal_lock);
+ /* this function might use static data, hence the lock around it */
+ XdmcpWrap (xdmcp_data, auth_data + 8,
+ xdmcp_data, j);
+ _XUnlockMutex(_Xglobal_lock);
+ auth_data = xdmcp_data;
+ auth_datalen = j;
+ }
+#endif /* HASXDMAUTH */
+#ifdef SECURE_RPC
+ /*
+ * The SUN-DES-1 authorization protocol uses the
+ * "secure RPC" mechanism in SunOS 4.0+.
+ */
+ if (auth_namelen == 9 && !strncmp(auth_name, "SUN-DES-1", 9)) {
+ char servernetname[MAXNETNAMELEN + 1];
+
+ /*
+ * Copy over the server's netname from the authorization
+ * data field filled in by XauGetAuthByAddr().
+ */
+ if (auth_datalen > MAXNETNAMELEN) {
+ auth_datalen = 0;
+ auth_data = NULL;
+ } else {
+ memcpy(servernetname, auth_data, auth_datalen);
+ servernetname[auth_datalen] = '\0';
+
+ auth_datalen = sizeof (rpc_cred);
+ if (auth_ezencode(servernetname, 100, rpc_cred,
+ &auth_datalen))
+ auth_data = rpc_cred;
+ else {
+ auth_datalen = 0;
+ auth_data = NULL;
+ }
+ }
+ }
+#endif
+ if (saddr) free ((char *) saddr);
+ if ((*auth_namelenp = auth_namelen))
+ {
+ if ((*auth_namep = Xmalloc(auth_namelen)))
+ memcpy(*auth_namep, auth_name, auth_namelen);
+ else
+ *auth_namelenp = 0;
+ }
+ else
+ *auth_namep = NULL;
+ if ((*auth_datalenp = auth_datalen))
+ {
+ if ((*auth_datap = Xmalloc(auth_datalen)))
+ memcpy(*auth_datap, auth_data, auth_datalen);
+ else
+ *auth_datalenp = 0;
+ }
+ else
+ *auth_datap = NULL;
+ if (authptr) XauDisposeAuth (authptr);
+}
diff --git a/src/Context.c b/src/Context.c
new file mode 100644
index 00000000..f924c258
--- /dev/null
+++ b/src/Context.c
@@ -0,0 +1,317 @@
+/* $Xorg: Context.c,v 1.5 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard,
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+/*
+
+Copyright 1987, 1988, 1990, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* This module implements a simple sparse array.
+
+ XSaveContext(a,b,c,d) will store d in position (a,b,c) of the array.
+ XFindContext(a,b,c,&d) will set d to be the value in position (a,b,c).
+ XDeleteContext(a,b,c) will delete the entry in (a,b,c).
+
+ a is a display id, b is a resource id, and c is a Context. d is just an
+ XPointer. This code will work with any range of parameters, but is geared
+ to be most efficient with very few (one or two) different a's.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+
+#define INITHASHMASK 63 /* Number of entries originally in the hash table. */
+
+typedef struct _TableEntryRec { /* Stores one entry. */
+ XID rid;
+ XContext context;
+ XPointer data;
+ struct _TableEntryRec *next;
+} TableEntryRec, *TableEntry;
+
+typedef struct _XContextDB { /* Stores hash table for one display. */
+ TableEntry *table; /* Pointer to array of hash entries. */
+ int mask; /* Current size of hash table minus 1. */
+ int numentries; /* Number of entries currently in table. */
+#ifdef XTHREADS
+ LockInfoRec linfo;
+#endif
+} DBRec, *DB;
+
+#ifdef MOTIFBC
+static DB NullDB = (DB)0;
+#endif
+
+/* Given an XID and a context, returns a value between 0 and HashSize-1.
+ Currently, this requires that HashSize be a power of 2.
+*/
+
+#define Hash(db,rid,context) \
+ (db)->table[(((rid) << 1) + context) & (db)->mask]
+
+/* Resize the given db */
+
+static void ResizeTable(db)
+ register DB db;
+{
+ TableEntry *otable;
+ register TableEntry entry, next, *pold, *head;
+ register int i, j;
+
+ otable = db->table;
+ for (i = INITHASHMASK+1; (i + i) < db->numentries; )
+ i += i;
+ db->table = (TableEntry *) Xcalloc((unsigned)i, sizeof(TableEntry));
+ if (!db->table) {
+ db->table = otable;
+ return;
+ }
+ j = db->mask + 1;
+ db->mask = i - 1;
+ for (pold = otable ; --j >= 0; pold++) {
+ for (entry = *pold; entry; entry = next) {
+ next = entry->next;
+ head = &Hash(db, entry->rid, entry->context);
+ entry->next = *head;
+ *head = entry;
+ }
+ }
+ Xfree((char *) otable);
+}
+
+static void _XFreeContextDB(display)
+ Display *display;
+{
+ register DB db;
+ register int i;
+ register TableEntry *pentry, entry, next;
+
+ db = display->context_db;
+ if (db) {
+ for (i = db->mask + 1, pentry = db->table ; --i >= 0; pentry++) {
+ for (entry = *pentry; entry; entry = next) {
+ next = entry->next;
+ Xfree((char *)entry);
+ }
+ }
+ Xfree((char *) db->table);
+ _XFreeMutex(&db->linfo);
+ Xfree((char *) db);
+ }
+}
+
+/* Public routines. */
+
+/* Save the given value of data to correspond with the keys XID and context.
+ Returns nonzero error code if an error has occured, 0 otherwise.
+ Possible errors are Out-of-memory.
+*/
+
+#if NeedFunctionPrototypes
+int XSaveContext(
+ Display *display,
+ register XID rid,
+ register XContext context,
+ _Xconst char* data)
+#else
+int XSaveContext(display, rid, context, data)
+ Display *display;
+ register XID rid;
+ register XContext context;
+ XPointer data;
+#endif
+{
+ DB *pdb;
+ register DB db;
+ TableEntry *head;
+ register TableEntry entry;
+
+#ifdef MOTIFBC
+ if (!display) {
+ pdb = &NullDB;
+ db = *pdb;
+ } else
+#endif
+ {
+ LockDisplay(display);
+ pdb = &display->context_db;
+ db = *pdb;
+ UnlockDisplay(display);
+ }
+ if (!db) {
+ db = (DB) Xmalloc(sizeof(DBRec));
+ if (!db)
+ return XCNOMEM;
+ db->mask = INITHASHMASK;
+ db->table = (TableEntry *)Xcalloc(db->mask + 1, sizeof(TableEntry));
+ if (!db->table) {
+ Xfree((char *)db);
+ return XCNOMEM;
+ }
+ db->numentries = 0;
+ _XCreateMutex(&db->linfo);
+#ifdef MOTIFBC
+ if (!display) *pdb = db; else
+#endif
+ {
+ LockDisplay(display);
+ *pdb = db;
+ display->free_funcs->context_db = _XFreeContextDB;
+ UnlockDisplay(display);
+ }
+ }
+ _XLockMutex(&db->linfo);
+ head = &Hash(db, rid, context);
+ _XUnlockMutex(&db->linfo);
+ for (entry = *head; entry; entry = entry->next) {
+ if (entry->rid == rid && entry->context == context) {
+ entry->data = (XPointer)data;
+ return 0;
+ }
+ }
+ entry = (TableEntry) Xmalloc(sizeof(TableEntryRec));
+ if (!entry)
+ return XCNOMEM;
+ entry->rid = rid;
+ entry->context = context;
+ entry->data = (XPointer)data;
+ entry->next = *head;
+ *head = entry;
+ _XLockMutex(&db->linfo);
+ db->numentries++;
+ if (db->numentries > (db->mask << 2))
+ ResizeTable(db);
+ _XUnlockMutex(&db->linfo);
+ return 0;
+}
+
+
+
+/* Given an XID and context, returns the associated data. Note that data
+ here is a pointer since it is a return value. Returns nonzero error code
+ if an error has occured, 0 otherwise. Possible errors are Entry-not-found.
+*/
+
+int XFindContext(display, rid, context, data)
+ Display *display;
+ register XID rid;
+ register XContext context;
+ XPointer *data; /* RETURN */
+{
+ register DB db;
+ register TableEntry entry;
+
+#ifdef MOTIFBC
+ if (!display) db = NullDB; else
+#endif
+ {
+ LockDisplay(display);
+ db = display->context_db;
+ UnlockDisplay(display);
+ }
+ if (!db)
+ return XCNOENT;
+ _XLockMutex(&db->linfo);
+ for (entry = Hash(db, rid, context); entry; entry = entry->next)
+ {
+ if (entry->rid == rid && entry->context == context) {
+ *data = (XPointer)entry->data;
+ _XUnlockMutex(&db->linfo);
+ return 0;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ return XCNOENT;
+}
+
+
+
+/* Deletes the entry for the given XID and context from the datastructure.
+ This returns the same thing that FindContext would have returned if called
+ with the same arguments.
+*/
+
+int XDeleteContext(display, rid, context)
+ Display *display;
+ register XID rid;
+ register XContext context;
+{
+ register DB db;
+ register TableEntry entry, *prev;
+
+#ifdef MOTIFBC
+ if (!display) db = NullDB; else
+#endif
+ {
+ LockDisplay(display);
+ db = display->context_db;
+ UnlockDisplay(display);
+ }
+ if (!db)
+ return XCNOENT;
+ _XLockMutex(&db->linfo);
+ for (prev = &Hash(db, rid, context);
+ (entry = *prev);
+ prev = &entry->next) {
+ if (entry->rid == rid && entry->context == context) {
+ *prev = entry->next;
+ Xfree((char *) entry);
+ db->numentries--;
+ if (db->numentries < db->mask && db->mask > INITHASHMASK)
+ ResizeTable(db);
+ _XUnlockMutex(&db->linfo);
+ return 0;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ return XCNOENT;
+}
diff --git a/src/ConvSel.c b/src/ConvSel.c
new file mode 100644
index 00000000..b7148a98
--- /dev/null
+++ b/src/ConvSel.c
@@ -0,0 +1,49 @@
+/* $Xorg: ConvSel.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+/*
+
+Copyright 1986,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XConvertSelection(dpy, selection, target, property, requestor, time)
+register Display *dpy;
+Atom selection, target;
+Atom property;
+Window requestor;
+Time time;
+{
+ register xConvertSelectionReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ConvertSelection, req);
+ req->selection = selection;
+ req->target = target;
+ req->property = property;
+ req->requestor = requestor;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/CopyArea.c b/src/CopyArea.c
new file mode 100644
index 00000000..5a4c42ba
--- /dev/null
+++ b/src/CopyArea.c
@@ -0,0 +1,59 @@
+/* $Xorg: CopyArea.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyArea(dpy, src_drawable, dst_drawable, gc,
+ src_x, src_y, width, height,
+ dst_x, dst_y)
+ register Display *dpy;
+ Drawable src_drawable, dst_drawable;
+ GC gc;
+ int src_x, src_y;
+ unsigned int width, height;
+ int dst_x, dst_y;
+
+{
+ register xCopyAreaReq *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(CopyArea, req);
+ req->srcDrawable = src_drawable;
+ req->dstDrawable = dst_drawable;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->width = width;
+ req->height = height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CopyCmap.c b/src/CopyCmap.c
new file mode 100644
index 00000000..a6873765
--- /dev/null
+++ b/src/CopyCmap.c
@@ -0,0 +1,49 @@
+/* $Xorg: CopyCmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Colormap XCopyColormapAndFree(dpy, src_cmap)
+register Display *dpy;
+Colormap src_cmap;
+{
+ Colormap mid;
+ register xCopyColormapAndFreeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CopyColormapAndFree, req);
+
+ mid = req->mid = XAllocID(dpy);
+ req->srcCmap = src_cmap;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsCopyCmapRecAndFree(dpy, src_cmap, mid);
+
+ return(mid);
+}
diff --git a/src/CopyGC.c b/src/CopyGC.c
new file mode 100644
index 00000000..ec228794
--- /dev/null
+++ b/src/CopyGC.c
@@ -0,0 +1,134 @@
+/* $Xorg: CopyGC.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyGC (dpy, srcGC, mask, destGC)
+ register Display *dpy;
+ unsigned long mask; /* which ones to set initially */
+ GC srcGC, destGC;
+{
+ register XGCValues *destgv = &destGC->values,
+ *srcgv = &srcGC->values;
+ register xCopyGCReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+
+ mask &= (1L << (GCLastBit + 1)) - 1;
+ /* if some of the source values to be copied are "dirty", flush them
+ out before sending the CopyGC request. */
+ if (srcGC->dirty & mask)
+ _XFlushGCCache(dpy, srcGC);
+
+ /* mark the copied values "not dirty" in the destination. */
+ destGC->dirty &= ~mask;
+
+ GetReq(CopyGC, req);
+ req->srcGC = srcGC->gid;
+ req->dstGC = destGC->gid;
+ req->mask = mask;
+
+ if (mask & GCFunction)
+ destgv->function = srcgv->function;
+
+ if (mask & GCPlaneMask)
+ destgv->plane_mask = srcgv->plane_mask;
+
+ if (mask & GCForeground)
+ destgv->foreground = srcgv->foreground;
+
+ if (mask & GCBackground)
+ destgv->background = srcgv->background;
+
+ if (mask & GCLineWidth)
+ destgv->line_width = srcgv->line_width;
+
+ if (mask & GCLineStyle)
+ destgv->line_style = srcgv->line_style;
+
+ if (mask & GCCapStyle)
+ destgv->cap_style = srcgv->cap_style;
+
+ if (mask & GCJoinStyle)
+ destgv->join_style = srcgv->join_style;
+
+ if (mask & GCFillStyle)
+ destgv->fill_style = srcgv->fill_style;
+
+ if (mask & GCFillRule)
+ destgv->fill_rule = srcgv->fill_rule;
+
+ if (mask & GCArcMode)
+ destgv->arc_mode = srcgv->arc_mode;
+
+ if (mask & GCTile)
+ destgv->tile = srcgv->tile;
+
+ if (mask & GCStipple)
+ destgv->stipple = srcgv->stipple;
+
+ if (mask & GCTileStipXOrigin)
+ destgv->ts_x_origin = srcgv->ts_x_origin;
+
+ if (mask & GCTileStipYOrigin)
+ destgv->ts_y_origin = srcgv->ts_y_origin;
+
+ if (mask & GCFont)
+ destgv->font = srcgv->font;
+
+ if (mask & GCSubwindowMode)
+ destgv->subwindow_mode = srcgv->subwindow_mode;
+
+ if (mask & GCGraphicsExposures)
+ destgv->graphics_exposures = srcgv->graphics_exposures;
+
+ if (mask & GCClipXOrigin)
+ destgv->clip_x_origin = srcgv->clip_x_origin;
+
+ if (mask & GCClipYOrigin)
+ destgv->clip_y_origin = srcgv->clip_y_origin;
+
+ if (mask & GCClipMask) {
+ destGC->rects = srcGC->rects;
+ destgv->clip_mask = srcgv->clip_mask;
+ }
+
+ if (mask & GCDashOffset)
+ destgv->dash_offset = srcgv->dash_offset;
+
+ if (mask & GCDashList) {
+ destGC->dashes = srcGC->dashes;
+ destgv->dashes = srcgv->dashes;
+ }
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->copy_GC) (*ext->copy_GC)(dpy, destGC, &ext->codes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/src/CopyPlane.c b/src/CopyPlane.c
new file mode 100644
index 00000000..1df2b14a
--- /dev/null
+++ b/src/CopyPlane.c
@@ -0,0 +1,61 @@
+/* $Xorg: CopyPlane.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XCopyPlane(dpy, src_drawable, dst_drawable, gc,
+ src_x, src_y, width, height,
+ dst_x, dst_y, bit_plane)
+ register Display *dpy;
+ Drawable src_drawable, dst_drawable;
+ GC gc;
+ int src_x, src_y;
+ unsigned int width, height;
+ int dst_x, dst_y;
+ unsigned long bit_plane;
+
+{
+ register xCopyPlaneReq *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(CopyPlane, req);
+ req->srcDrawable = src_drawable;
+ req->dstDrawable = dst_drawable;
+ req->gc = gc->gid;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->dstX = dst_x;
+ req->dstY = dst_y;
+ req->width = width;
+ req->height = height;
+ req->bitPlane = bit_plane;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/CrBFData.c b/src/CrBFData.c
new file mode 100644
index 00000000..70060a96
--- /dev/null
+++ b/src/CrBFData.c
@@ -0,0 +1,85 @@
+/* $Xorg: CrBFData.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlib.h"
+
+/*
+ * XCreateBitmapFromData: Routine to make a pixmap of depth 1 from user
+ * supplied data.
+ * D is any drawable on the same screen that the pixmap will be used in.
+ * Data is a pointer to the bit data, and
+ * width & height give the size in bits of the pixmap.
+ *
+ * The following format is assumed for data:
+ *
+ * format=XYPixmap
+ * bit_order=LSBFirst
+ * byte_order=LSBFirst
+ * padding=8
+ * bitmap_unit=8
+ * xoffset=0
+ * no extra bytes per line
+ */
+#if NeedFunctionPrototypes
+Pixmap XCreateBitmapFromData(
+ Display *display,
+ Drawable d,
+ _Xconst char *data,
+ unsigned int width,
+ unsigned int height)
+#else
+Pixmap XCreateBitmapFromData(display, d, data, width, height)
+ Display *display;
+ Drawable d;
+ char *data;
+ unsigned int width, height;
+#endif
+{
+ XImage ximage;
+ GC gc;
+ Pixmap pix;
+
+ pix = XCreatePixmap(display, d, width, height, 1);
+ if (! (gc = XCreateGC(display, pix, (unsigned long) 0, (XGCValues *) 0)))
+ return (Pixmap) None;
+ ximage.height = height;
+ ximage.width = width;
+ ximage.depth = 1;
+ ximage.bits_per_pixel = 1;
+ ximage.xoffset = 0;
+ ximage.format = XYPixmap;
+ ximage.data = (char *)data;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 8;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 8;
+ ximage.bytes_per_line = (width+7)/8;
+
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+}
diff --git a/src/CrCmap.c b/src/CrCmap.c
new file mode 100644
index 00000000..3c1878df
--- /dev/null
+++ b/src/CrCmap.c
@@ -0,0 +1,53 @@
+/* $Xorg: CrCmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Colormap XCreateColormap(dpy, w, visual, alloc)
+register Display *dpy;
+Window w;
+Visual *visual;
+int alloc;
+{
+ register xCreateColormapReq *req;
+ Colormap mid;
+
+ LockDisplay(dpy);
+ GetReq(CreateColormap, req);
+ req->window = w;
+ mid = req->mid = XAllocID(dpy);
+ req->alloc = alloc;
+ if (visual == CopyFromParent) req->visual = CopyFromParent;
+ else req->visual = visual->visualid;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsAddCmapRec(dpy, mid, w, visual);
+
+ return(mid);
+}
diff --git a/src/CrCursor.c b/src/CrCursor.c
new file mode 100644
index 00000000..93c7a006
--- /dev/null
+++ b/src/CrCursor.c
@@ -0,0 +1,57 @@
+/* $Xorg: CrCursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Cursor XCreatePixmapCursor(dpy, source, mask, foreground, background, x, y)
+ register Display *dpy;
+ Pixmap source, mask;
+ XColor *foreground, *background;
+ unsigned int x, y;
+
+{
+ register xCreateCursorReq *req;
+ Cursor cid;
+
+ LockDisplay(dpy);
+ GetReq(CreateCursor, req);
+ req->cid = cid = XAllocID(dpy);
+ req->source = source;
+ req->mask = mask;
+ req->foreRed = foreground->red;
+ req->foreGreen = foreground->green;
+ req->foreBlue = foreground->blue;
+ req->backRed = background->red;
+ req->backGreen = background->green;
+ req->backBlue = background->blue;
+ req->x = x;
+ req->y = y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (cid);
+}
+
diff --git a/src/CrGC.c b/src/CrGC.c
new file mode 100644
index 00000000..969f6d88
--- /dev/null
+++ b/src/CrGC.c
@@ -0,0 +1,342 @@
+/* $Xorg: CrGC.c,v 1.5 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+static XGCValues Const initial_GC = {
+ GXcopy, /* function */
+ AllPlanes, /* plane_mask */
+ 0L, /* foreground */
+ 1L, /* background */
+ 0, /* line_width */
+ LineSolid, /* line_style */
+ CapButt, /* cap_style */
+ JoinMiter, /* join_style */
+ FillSolid, /* fill_style */
+ EvenOddRule,/* fill_rule */
+ ArcPieSlice,/* arc_mode */
+ (Pixmap)~0L,/* tile, impossible (unknown) resource */
+ (Pixmap)~0L,/* stipple, impossible (unknown) resource */
+ 0, /* ts_x_origin */
+ 0, /* ts_y_origin */
+ (Font)~0L, /* font, impossible (unknown) resource */
+ ClipByChildren, /* subwindow_mode */
+ True, /* graphics_exposures */
+ 0, /* clip_x_origin */
+ 0, /* clip_y_origin */
+ None, /* clip_mask */
+ 0, /* dash_offset */
+ 4 /* dashes (list [4,4]) */
+};
+
+static void _XGenerateGCList();
+
+GC XCreateGC (dpy, d, valuemask, values)
+ register Display *dpy;
+ Drawable d; /* Window or Pixmap for which depth matches */
+ unsigned long valuemask; /* which ones to set initially */
+ XGCValues *values; /* the values themselves */
+{
+ register GC gc;
+ register xCreateGCReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+ if ((gc = (GC)Xmalloc (sizeof(struct _XGC))) == NULL) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ gc->rects = 0;
+ gc->dashes = 0;
+ gc->ext_data = NULL;
+ gc->values = initial_GC;
+ gc->dirty = 0L;
+
+ valuemask &= (1L << (GCLastBit + 1)) - 1;
+ if (valuemask) _XUpdateGCCache (gc, valuemask, values);
+
+ GetReq(CreateGC, req);
+ req->drawable = d;
+ req->gc = gc->gid = XAllocID(dpy);
+
+ if ((req->mask = gc->dirty))
+ _XGenerateGCList (dpy, gc, (xReq *) req);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->create_GC) (*ext->create_GC)(dpy, gc, &ext->codes);
+ gc->dirty = 0L; /* allow extensions to see dirty bits */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (gc);
+ }
+
+/*
+ * GenerateGCList looks at the GC dirty bits, and appends all the required
+ * long words to the request being generated.
+ */
+
+static void
+_XGenerateGCList (dpy, gc, req)
+ register Display *dpy;
+ xReq *req;
+ GC gc;
+ {
+ unsigned long values[32];
+ register unsigned long *value = values;
+ long nvalues;
+ register XGCValues *gv = &gc->values;
+ register unsigned long dirty = gc->dirty;
+
+ /*
+ * Note: The order of these tests are critical; the order must be the
+ * same as the GC mask bits in the word.
+ */
+ if (dirty & GCFunction) *value++ = gv->function;
+ if (dirty & GCPlaneMask) *value++ = gv->plane_mask;
+ if (dirty & GCForeground) *value++ = gv->foreground;
+ if (dirty & GCBackground) *value++ = gv->background;
+ if (dirty & GCLineWidth) *value++ = gv->line_width;
+ if (dirty & GCLineStyle) *value++ = gv->line_style;
+ if (dirty & GCCapStyle) *value++ = gv->cap_style;
+ if (dirty & GCJoinStyle) *value++ = gv->join_style;
+ if (dirty & GCFillStyle) *value++ = gv->fill_style;
+ if (dirty & GCFillRule) *value++ = gv->fill_rule;
+ if (dirty & GCTile) *value++ = gv->tile;
+ if (dirty & GCStipple) *value++ = gv->stipple;
+ if (dirty & GCTileStipXOrigin) *value++ = gv->ts_x_origin;
+ if (dirty & GCTileStipYOrigin) *value++ = gv->ts_y_origin;
+ if (dirty & GCFont) *value++ = gv->font;
+ if (dirty & GCSubwindowMode) *value++ = gv->subwindow_mode;
+ if (dirty & GCGraphicsExposures) *value++ = gv->graphics_exposures;
+ if (dirty & GCClipXOrigin) *value++ = gv->clip_x_origin;
+ if (dirty & GCClipYOrigin) *value++ = gv->clip_y_origin;
+ if (dirty & GCClipMask) *value++ = gv->clip_mask;
+ if (dirty & GCDashOffset) *value++ = gv->dash_offset;
+ if (dirty & GCDashList) *value++ = gv->dashes;
+ if (dirty & GCArcMode) *value++ = gv->arc_mode;
+
+ req->length += (nvalues = value - values);
+
+ /*
+ * note: Data is a macro that uses its arguments multiple
+ * times, so "nvalues" is changed in a separate assignment
+ * statement
+ */
+
+ nvalues <<= 2;
+ Data32 (dpy, (long *) values, nvalues);
+
+ }
+
+
+_XUpdateGCCache (gc, mask, attr)
+ register unsigned long mask;
+ register XGCValues *attr;
+ register GC gc;
+ {
+ register XGCValues *gv = &gc->values;
+
+ if (mask & GCFunction)
+ if (gv->function != attr->function) {
+ gv->function = attr->function;
+ gc->dirty |= GCFunction;
+ }
+
+ if (mask & GCPlaneMask)
+ if (gv->plane_mask != attr->plane_mask) {
+ gv->plane_mask = attr->plane_mask;
+ gc->dirty |= GCPlaneMask;
+ }
+
+ if (mask & GCForeground)
+ if (gv->foreground != attr->foreground) {
+ gv->foreground = attr->foreground;
+ gc->dirty |= GCForeground;
+ }
+
+ if (mask & GCBackground)
+ if (gv->background != attr->background) {
+ gv->background = attr->background;
+ gc->dirty |= GCBackground;
+ }
+
+ if (mask & GCLineWidth)
+ if (gv->line_width != attr->line_width) {
+ gv->line_width = attr->line_width;
+ gc->dirty |= GCLineWidth;
+ }
+
+ if (mask & GCLineStyle)
+ if (gv->line_style != attr->line_style) {
+ gv->line_style = attr->line_style;
+ gc->dirty |= GCLineStyle;
+ }
+
+ if (mask & GCCapStyle)
+ if (gv->cap_style != attr->cap_style) {
+ gv->cap_style = attr->cap_style;
+ gc->dirty |= GCCapStyle;
+ }
+
+ if (mask & GCJoinStyle)
+ if (gv->join_style != attr->join_style) {
+ gv->join_style = attr->join_style;
+ gc->dirty |= GCJoinStyle;
+ }
+
+ if (mask & GCFillStyle)
+ if (gv->fill_style != attr->fill_style) {
+ gv->fill_style = attr->fill_style;
+ gc->dirty |= GCFillStyle;
+ }
+
+ if (mask & GCFillRule)
+ if (gv->fill_rule != attr->fill_rule) {
+ gv->fill_rule = attr->fill_rule;
+ gc->dirty |= GCFillRule;
+ }
+
+ if (mask & GCArcMode)
+ if (gv->arc_mode != attr->arc_mode) {
+ gv->arc_mode = attr->arc_mode;
+ gc->dirty |= GCArcMode;
+ }
+
+ /* always write through tile change, since client may have changed pixmap contents */
+ if (mask & GCTile) {
+ gv->tile = attr->tile;
+ gc->dirty |= GCTile;
+ }
+
+ /* always write through stipple change, since client may have changed pixmap contents */
+ if (mask & GCStipple) {
+ gv->stipple = attr->stipple;
+ gc->dirty |= GCStipple;
+ }
+
+ if (mask & GCTileStipXOrigin)
+ if (gv->ts_x_origin != attr->ts_x_origin) {
+ gv->ts_x_origin = attr->ts_x_origin;
+ gc->dirty |= GCTileStipXOrigin;
+ }
+
+ if (mask & GCTileStipYOrigin)
+ if (gv->ts_y_origin != attr->ts_y_origin) {
+ gv->ts_y_origin = attr->ts_y_origin;
+ gc->dirty |= GCTileStipYOrigin;
+ }
+
+ if (mask & GCFont)
+ if (gv->font != attr->font) {
+ gv->font = attr->font;
+ gc->dirty |= GCFont;
+ }
+
+ if (mask & GCSubwindowMode)
+ if (gv->subwindow_mode != attr->subwindow_mode) {
+ gv->subwindow_mode = attr->subwindow_mode;
+ gc->dirty |= GCSubwindowMode;
+ }
+
+ if (mask & GCGraphicsExposures)
+ if (gv->graphics_exposures != attr->graphics_exposures) {
+ gv->graphics_exposures = attr->graphics_exposures;
+ gc->dirty |= GCGraphicsExposures;
+ }
+
+ if (mask & GCClipXOrigin)
+ if (gv->clip_x_origin != attr->clip_x_origin) {
+ gv->clip_x_origin = attr->clip_x_origin;
+ gc->dirty |= GCClipXOrigin;
+ }
+
+ if (mask & GCClipYOrigin)
+ if (gv->clip_y_origin != attr->clip_y_origin) {
+ gv->clip_y_origin = attr->clip_y_origin;
+ gc->dirty |= GCClipYOrigin;
+ }
+
+ /* always write through mask change, since client may have changed pixmap contents */
+ if (mask & GCClipMask) {
+ gv->clip_mask = attr->clip_mask;
+ gc->dirty |= GCClipMask;
+ gc->rects = 0;
+ }
+
+ if (mask & GCDashOffset)
+ if (gv->dash_offset != attr->dash_offset) {
+ gv->dash_offset = attr->dash_offset;
+ gc->dirty |= GCDashOffset;
+ }
+
+ if (mask & GCDashList)
+ if ((gv->dashes != attr->dashes) || (gc->dashes == True)) {
+ gv->dashes = attr->dashes;
+ gc->dirty |= GCDashList;
+ gc->dashes = 0;
+ }
+ return 0;
+ }
+
+/* can only call when display is already locked. */
+
+void _XFlushGCCache(dpy, gc)
+ Display *dpy;
+ GC gc;
+{
+ register xChangeGCReq *req;
+ register _XExtension *ext;
+
+ if (gc->dirty) {
+ GetReq(ChangeGC, req);
+ req->gc = gc->gid;
+ req->mask = gc->dirty;
+ _XGenerateGCList (dpy, gc, (xReq *) req);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->flush_GC) (*ext->flush_GC)(dpy, gc, &ext->codes);
+ gc->dirty = 0L; /* allow extensions to see dirty bits */
+ }
+}
+
+void XFlushGC(dpy, gc)
+ Display *dpy;
+ GC gc;
+{
+ FlushGC(dpy, gc);
+}
+
+GContext XGContextFromGC(gc)
+ GC gc;
+ { return (gc->gid); }
diff --git a/src/CrGlCur.c b/src/CrGlCur.c
new file mode 100644
index 00000000..d6fc4039
--- /dev/null
+++ b/src/CrGlCur.c
@@ -0,0 +1,59 @@
+/* $Xorg: CrGlCur.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Cursor XCreateGlyphCursor(dpy, source_font, mask_font,
+ source_char, mask_char,
+ foreground, background)
+ register Display *dpy;
+ Font source_font, mask_font;
+ unsigned int source_char, mask_char;
+ XColor *foreground, *background;
+
+{
+ Cursor cid;
+ register xCreateGlyphCursorReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreateGlyphCursor, req);
+ cid = req->cid = XAllocID(dpy);
+ req->source = source_font;
+ req->mask = mask_font;
+ req->sourceChar = source_char;
+ req->maskChar = mask_char;
+ req->foreRed = foreground->red;
+ req->foreGreen = foreground->green;
+ req->foreBlue = foreground->blue;
+ req->backRed = background->red;
+ req->backGreen = background->green;
+ req->backBlue = background->blue;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (cid);
+}
+
diff --git a/src/CrPFBData.c b/src/CrPFBData.c
new file mode 100644
index 00000000..f28aabbb
--- /dev/null
+++ b/src/CrPFBData.c
@@ -0,0 +1,83 @@
+/* $Xorg: CrPFBData.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlib.h"
+#include <stdio.h>
+
+/*
+ * XCreatePixmapFromBitmapData: Routine to make a pixmap from user supplied bitmap data.
+ * D is any drawable on the same screen that the pixmap will be used in.
+ * Data is a pointer to the bit data, and
+ * width & height give the size in bits of the pixmap.
+ * Fg and Bg are the pixel values to use for the two colors.
+ * Depth is the depth of the pixmap to create.
+ *
+ * The following format is assumed for data:
+ *
+ * format=XYPixmap
+ * bit_order=LSBFirst
+ * byte_order=LSBFirst
+ * padding=8
+ * bitmap_unit=8
+ * xoffset=0
+ * no extra bytes per line
+ */
+Pixmap XCreatePixmapFromBitmapData(display,d,data,width,height,fg,bg,depth)
+ Display *display;
+ Drawable d;
+ char *data;
+ unsigned int width, height;
+ unsigned long fg, bg;
+ unsigned int depth;
+{
+ XImage ximage;
+ GC gc;
+ XGCValues gcv;
+ Pixmap pix;
+
+ pix = XCreatePixmap(display, d, width, height, depth);
+ gcv.foreground = fg;
+ gcv.background = bg;
+ if (! (gc = XCreateGC(display, pix, GCForeground|GCBackground, &gcv)))
+ return (Pixmap) NULL;
+ ximage.height = height;
+ ximage.width = width;
+ ximage.depth = 1;
+ ximage.bits_per_pixel = 1;
+ ximage.xoffset = 0;
+ ximage.format = XYBitmap;
+ ximage.data = data;
+ ximage.byte_order = LSBFirst;
+ ximage.bitmap_unit = 8;
+ ximage.bitmap_bit_order = LSBFirst;
+ ximage.bitmap_pad = 8;
+ ximage.bytes_per_line = (width+7)/8;
+
+ XPutImage(display, pix, gc, &ximage, 0, 0, 0, 0, width, height);
+ XFreeGC(display, gc);
+ return(pix);
+}
diff --git a/src/CrPixmap.c b/src/CrPixmap.c
new file mode 100644
index 00000000..2505f48a
--- /dev/null
+++ b/src/CrPixmap.c
@@ -0,0 +1,49 @@
+/* $Xorg: CrPixmap.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Pixmap XCreatePixmap (dpy, d, width, height, depth)
+ register Display *dpy;
+ Drawable d;
+ unsigned int width, height, depth;
+{
+ Pixmap pid;
+ register xCreatePixmapReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreatePixmap, req);
+ req->drawable = d;
+ req->width = width;
+ req->height = height;
+ req->depth = depth;
+ pid = req->pid = XAllocID(dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (pid);
+}
+
diff --git a/src/CrWindow.c b/src/CrWindow.c
new file mode 100644
index 00000000..418f9867
--- /dev/null
+++ b/src/CrWindow.c
@@ -0,0 +1,74 @@
+/* $Xorg: CrWindow.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Window XCreateSimpleWindow(dpy, parent, x, y, width, height,
+ borderWidth, border, background)
+ register Display *dpy;
+ Window parent;
+ int x, y;
+ unsigned int width, height, borderWidth;
+ unsigned long border;
+ unsigned long background;
+{
+ Window wid;
+ register xCreateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(CreateWindow, 8, req);
+ req->parent = parent;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = borderWidth;
+ req->depth = 0;
+ req->class = CopyFromParent;
+ req->visual = CopyFromParent;
+ wid = req->wid = XAllocID(dpy);
+ req->mask = CWBackPixel | CWBorderPixel;
+
+#ifdef MUSTCOPY
+ {
+ unsigned long lbackground = background, lborder = border;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lbackground, 4);
+ Data32 (dpy, (long *) &lborder, 4);
+ }
+#else
+ {
+ register CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xCreateWindowReq);
+ *valuePtr++ = background;
+ *valuePtr = border;
+ }
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (wid);
+ }
diff --git a/src/Cursor.c b/src/Cursor.c
new file mode 100644
index 00000000..55ff456c
--- /dev/null
+++ b/src/Cursor.c
@@ -0,0 +1,51 @@
+/* $Xorg: Cursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+static XColor foreground = { 0, 0, 0, 0 }; /* black */
+static XColor background = { 0, 65535, 65535, 65535 }; /* white */
+
+Cursor XCreateFontCursor(dpy, which)
+ Display *dpy;
+ unsigned int which;
+{
+ /*
+ * the cursor font contains the shape glyph followed by the mask
+ * glyph; so character position 0 contains a shape, 1 the mask for 0,
+ * 2 a shape, etc. <X11/cursorfont.h> contains hash define names
+ * for all of these.
+ */
+
+ if (dpy->cursor_font == None) {
+ dpy->cursor_font = XLoadFont (dpy, CURSORFONT);
+ if (dpy->cursor_font == None) return None;
+ }
+
+ return XCreateGlyphCursor (dpy, dpy->cursor_font, dpy->cursor_font,
+ which, which + 1, &foreground, &background);
+}
+
diff --git a/src/DefCursor.c b/src/DefCursor.c
new file mode 100644
index 00000000..d4eadea2
--- /dev/null
+++ b/src/DefCursor.c
@@ -0,0 +1,46 @@
+/* $Xorg: DefCursor.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDefineCursor (dpy, w, cursor)
+ register Display *dpy;
+ Window w;
+ Cursor cursor;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWCursor;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), cursor);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DelProp.c b/src/DelProp.c
new file mode 100644
index 00000000..11bf3a3d
--- /dev/null
+++ b/src/DelProp.c
@@ -0,0 +1,44 @@
+/* $Xorg: DelProp.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDeleteProperty(dpy, window, property)
+register Display *dpy;
+Window window;
+Atom property;
+{
+ register xDeletePropertyReq *req;
+
+ LockDisplay(dpy);
+ GetReq(DeleteProperty, req);
+ req->window = window;
+ req->property = property;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/Depths.c b/src/Depths.c
new file mode 100644
index 00000000..34756e71
--- /dev/null
+++ b/src/Depths.c
@@ -0,0 +1,60 @@
+/* $Xorg: Depths.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <stdio.h>
+
+/*
+ * XListDepths - return info from connection setup
+ */
+int *XListDepths (dpy, scrnum, countp)
+ Display *dpy;
+ int scrnum;
+ int *countp;
+{
+ Screen *scr;
+ int count;
+ int *depths;
+
+ if (scrnum < 0 || scrnum >= dpy->nscreens) return NULL;
+
+ scr = &dpy->screens[scrnum];
+ if ((count = scr->ndepths) > 0) {
+ register Depth *dp;
+ register int i;
+
+ depths = (int *) Xmalloc (count * sizeof(int));
+ if (!depths) return NULL;
+ for (i = 0, dp = scr->depths; i < count; i++, dp++)
+ depths[i] = dp->depth;
+ } else {
+ /* a screen must have a depth */
+ return NULL;
+ }
+ *countp = count;
+ return depths;
+}
diff --git a/src/DestSubs.c b/src/DestSubs.c
new file mode 100644
index 00000000..98aadd6b
--- /dev/null
+++ b/src/DestSubs.c
@@ -0,0 +1,42 @@
+/* $Xorg: DestSubs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDestroySubwindows(dpy, win)
+register Display *dpy;
+Window win;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq (DestroySubwindows,win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DestWind.c b/src/DestWind.c
new file mode 100644
index 00000000..319e4ec3
--- /dev/null
+++ b/src/DestWind.c
@@ -0,0 +1,42 @@
+/* $Xorg: DestWind.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDestroyWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(DestroyWindow, w, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DisName.c b/src/DisName.c
new file mode 100644
index 00000000..17ebf356
--- /dev/null
+++ b/src/DisName.c
@@ -0,0 +1,62 @@
+/* $Xorg: DisName.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* XDisplayName.c */
+/*
+ * Returns the name of the display XOpenDisplay would use. This is better
+ * than just printing the "display" variable in a program because that
+ * could be NULL and/or there could be an environment variable set.
+ * This makes it easier for programmers to provide meaningful error
+ * messages.
+ *
+ *
+ * For example, this is used in XOpenDisplay() as
+ * strncpy( displaybuf, XDisplayName( display ), sizeof(displaybuf) );
+ * if ( *displaybuf == '\0' ) return( NULL );
+ * This check is actually unnecessary because the next thing is an index()
+ * call looking for a ':' which will fail and we'll return(NULL).
+ */
+/* Written at Waterloo - JMSellens */
+
+#include <stdio.h>
+
+extern char *getenv();
+
+char *
+XDisplayName( display )
+ char *display;
+{
+ char *d;
+ if ( display != (char *)NULL && *display != '\0' )
+ return( display );
+ if ( (d = getenv( "DISPLAY" )) != (char *)NULL )
+ return( d );
+ return( "" );
+}
diff --git a/src/DrArc.c b/src/DrArc.c
new file mode 100644
index 00000000..466e7e15
--- /dev/null
+++ b/src/DrArc.c
@@ -0,0 +1,79 @@
+/* $Xorg: DrArc.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* Note to future maintainers: XDrawArc does NOT batch successive PolyArc
+ requests into a single request like XDrawLine, XDrawPoint, etc.
+ We don't do this because X_PolyArc applies the GC's join-style if
+ the last point in one arc coincides with the first point in another.
+ The client wouldn't expect this and would have no easy way to defeat it. */
+
+#include "Xlibint.h"
+
+XDrawArc(dpy, d, gc, x, y, width, height, angle1, angle2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+ int angle1, angle2; /* INT16 */
+{
+ register xPolyArcReq *req;
+ register xArc *arc;
+#ifdef MUSTCOPY
+ xArc arcdata;
+ long len = SIZEOF(xArc);
+
+ arc = &arcdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReqExtra (PolyArc, SIZEOF(xArc), req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+
+#ifndef MUSTCOPY
+ arc = (xArc *) NEXTPTR(req,xPolyArcReq);
+#endif /* MUSTCOPY */
+
+ arc->x = x;
+ arc->y = y;
+ arc->width = width;
+ arc->height = height;
+ arc->angle1 = angle1;
+ arc->angle2 = angle2;
+
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xArc);
+ Data (dpy, (char *) arc, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrArcs.c b/src/DrArcs.c
new file mode 100644
index 00000000..9f8ef96a
--- /dev/null
+++ b/src/DrArcs.c
@@ -0,0 +1,54 @@
+/* $Xorg: DrArcs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+XDrawArcs(dpy, d, gc, arcs, n_arcs)
+register Display *dpy;
+Drawable d;
+GC gc;
+XArc *arcs;
+int n_arcs;
+{
+ register xPolyArcReq *req;
+ register long len;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(PolyArc,req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ len = ((long)n_arcs) * arc_scale;
+ SetReqLen(req, len, 1);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) arcs, len);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrLine.c b/src/DrLine.c
new file mode 100644
index 00000000..6b17fbe5
--- /dev/null
+++ b/src/DrLine.c
@@ -0,0 +1,95 @@
+/* $Xorg: DrLine.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define wsize (SIZEOF(xPolySegmentReq) + WLNSPERBATCH * SIZEOF(xSegment))
+#define zsize (SIZEOF(xPolySegmentReq) + ZLNSPERBATCH * SIZEOF(xSegment))
+
+XDrawLine (dpy, d, gc, x1, y1, x2, y2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x1, y1, x2, y2;
+{
+ register xSegment *segment;
+#ifdef MUSTCOPY
+ xSegment segmentdata;
+ long len = SIZEOF(xSegment);
+
+ segment = &segmentdata;
+#endif /* not MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolySegmentReq *req = (xPolySegmentReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolySegment)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xSegment)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
+ wsize : zsize)) ) {
+ req->length += SIZEOF(xSegment) >> 2;
+#ifndef MUSTCOPY
+ segment = (xSegment *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xSegment);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra (PolySegment, SIZEOF(xSegment), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xSegment);
+#else
+ segment = (xSegment *) NEXTPTR(req,xPolySegmentReq);
+#endif /* MUSTCOPY */
+ }
+
+ segment->x1 = x1;
+ segment->y1 = y1;
+ segment->x2 = x2;
+ segment->y2 = y2;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) &segmentdata, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ }
+ return 1;
+}
+
diff --git a/src/DrLines.c b/src/DrLines.c
new file mode 100644
index 00000000..05b0d5d7
--- /dev/null
+++ b/src/DrLines.c
@@ -0,0 +1,54 @@
+/* $Xorg: DrLines.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawLines (dpy, d, gc, points, npoints, mode)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XPoint *points;
+ int npoints;
+ int mode;
+{
+ register xPolyLineReq *req;
+ register long length;
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyLine, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = mode;
+ SetReqLen(req, npoints, 65535 - req->length);
+ /* each point is 2 16-bit integers */
+ length = npoints << 2; /* watch out for macros... */
+ Data16 (dpy, (short *) points, length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DrPoint.c b/src/DrPoint.c
new file mode 100644
index 00000000..390e9dad
--- /dev/null
+++ b/src/DrPoint.c
@@ -0,0 +1,93 @@
+/* $Xorg: DrPoint.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyPointReq) + PTSPERBATCH * SIZEOF(xPoint))
+
+XDrawPoint(dpy, d, gc, x, y)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+{
+ xPoint *point;
+#ifdef MUSTCOPY
+ xPoint pointdata;
+ long len = SIZEOF(xPoint);
+
+ point = &pointdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyPointReq *req = (xPolyPointReq *) dpy->last_req;
+
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyPoint)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && (req->coordMode == CoordModeOrigin)
+ && ((dpy->bufptr + SIZEOF(xPoint)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xPoint) >> 2;
+#ifndef MUSTCOPY
+ point = (xPoint *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xPoint);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyPoint, 4, req); /* 1 point = 4 bytes */
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = CoordModeOrigin;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xPoint);
+#else
+ point = (xPoint *) NEXTPTR(req,xPolyPointReq);
+#endif /* MUSTCOPY */
+ }
+
+ point->x = x;
+ point->y = y;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) point, len);
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/DrPoints.c b/src/DrPoints.c
new file mode 100644
index 00000000..c261be0d
--- /dev/null
+++ b/src/DrPoints.c
@@ -0,0 +1,82 @@
+/* $Xorg: DrPoints.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawPoints(dpy, d, gc, points, n_points, mode)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XPoint *points;
+ int n_points;
+ int mode; /* CoordMode */
+{
+ register xPolyPointReq *req;
+ register long nbytes;
+ int n;
+ int xoff, yoff;
+ XPoint pt;
+
+ xoff = yoff = 0;
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_points) {
+ GetReq(PolyPoint, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->coordMode = mode;
+ n = n_points;
+ if (!dpy->bigreq_size && n > (dpy->max_request_size - req->length))
+ n = dpy->max_request_size - req->length;
+ SetReqLen(req, n, n);
+ nbytes = ((long)n) << 2; /* watch out for macros... */
+ if (xoff || yoff) {
+ pt.x = xoff + points->x;
+ pt.y = yoff + points->y;
+ Data16 (dpy, (short *) &pt, 4);
+ if (nbytes > 4) {
+ Data16 (dpy, (short *) (points + 1), nbytes - 4);
+ }
+ } else {
+ Data16 (dpy, (short *) points, nbytes);
+ }
+ n_points -= n;
+ if (n_points && (mode == CoordModePrevious)) {
+ register XPoint *pptr = points;
+ points += n;
+ while (pptr != points) {
+ xoff += pptr->x;
+ yoff += pptr->y;
+ pptr++;
+ }
+ } else
+ points += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrRect.c b/src/DrRect.c
new file mode 100644
index 00000000..0c3c48e4
--- /dev/null
+++ b/src/DrRect.c
@@ -0,0 +1,95 @@
+/* $Xorg: DrRect.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define wsize (SIZEOF(xPolyRectangleReq) + WRCTSPERBATCH * SIZEOF(xRectangle))
+#define zsize (SIZEOF(xPolyRectangleReq) + ZRCTSPERBATCH * SIZEOF(xRectangle))
+
+XDrawRectangle(dpy, d, gc, x, y, width, height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+{
+ xRectangle *rect;
+#ifdef MUSTCOPY
+ xRectangle rectdata;
+ long len = SIZEOF(xRectangle);
+
+ rect = &rectdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyRectangleReq *req = (xPolyRectangleReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyRectangle)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xRectangle)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < (gc->values.line_width ?
+ wsize : zsize)) ) {
+ req->length += SIZEOF(xRectangle) >> 2;
+#ifndef MUSTCOPY
+ rect = (xRectangle *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xRectangle);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyRectangle, SIZEOF(xRectangle), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xRectangle);
+#else
+ rect = (xRectangle *) NEXTPTR(req,xPolyRectangleReq);
+#endif /* MUSTCOPY */
+ }
+
+ rect->x = x;
+ rect->y = y;
+ rect->width = width;
+ rect->height = height;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) rect, len); /* subtracted bufptr up above */
+#endif /* MUSTCOPY */
+
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrRects.c b/src/DrRects.c
new file mode 100644
index 00000000..ac87bd9b
--- /dev/null
+++ b/src/DrRects.c
@@ -0,0 +1,62 @@
+/* $Xorg: DrRects.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawRectangles(dpy, d, gc, rects, n_rects)
+register Display *dpy;
+Drawable d;
+GC gc;
+XRectangle *rects;
+int n_rects;
+{
+ register xPolyRectangleReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_rects) {
+ GetReq(PolyRectangle, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_rects;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) rects, len);
+ n_rects -= n;
+ rects += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/DrSegs.c b/src/DrSegs.c
new file mode 100644
index 00000000..41c4ea4a
--- /dev/null
+++ b/src/DrSegs.c
@@ -0,0 +1,63 @@
+/* $Xorg: DrSegs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawSegments (dpy, d, gc, segments, nsegments)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ XSegment *segments;
+ int nsegments;
+{
+ register xPolySegmentReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (nsegments) {
+ GetReq (PolySegment, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = nsegments;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) segments, len);
+ nsegments -= n;
+ segments += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ErrDes.c b/src/ErrDes.c
new file mode 100644
index 00000000..a7f82cc7
--- /dev/null
+++ b/src/ErrDes.c
@@ -0,0 +1,196 @@
+/*
+ * $Xorg: ErrDes.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $
+ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xresource.h"
+#include <stdio.h>
+
+#ifndef ERRORDB
+#define ERRORDB "/usr/lib/X11/XErrorDB"
+#endif
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * descriptions of errors in Section 4 of Protocol doc (pp. 350-351); more
+ * verbose descriptions are given in the error database
+ */
+static Const char * Const _XErrorList[] = {
+ /* No error */ "no error",
+ /* BadRequest */ "BadRequest",
+ /* BadValue */ "BadValue",
+ /* BadWindow */ "BadWindow",
+ /* BadPixmap */ "BadPixmap",
+ /* BadAtom */ "BadAtom",
+ /* BadCursor */ "BadCursor",
+ /* BadFont */ "BadFont",
+ /* BadMatch */ "BadMatch",
+ /* BadDrawable */ "BadDrawable",
+ /* BadAccess */ "BadAccess",
+ /* BadAlloc */ "BadAlloc",
+ /* BadColor */ "BadColor",
+ /* BadGC */ "BadGC",
+ /* BadIDChoice */ "BadIDChoice",
+ /* BadName */ "BadName",
+ /* BadLength */ "BadLength",
+ /* BadImplementation */ "BadImplementation",
+};
+
+
+XGetErrorText(dpy, code, buffer, nbytes)
+ register int code;
+ register Display *dpy;
+ char *buffer;
+ int nbytes;
+{
+ char buf[150];
+ register _XExtension *ext;
+ _XExtension *bext = (_XExtension *)NULL;
+
+ if (nbytes == 0) return 0;
+ if (code <= BadImplementation && code > 0) {
+ sprintf(buf, "%d", code);
+ (void) XGetErrorDatabaseText(dpy, "XProtoError", buf, _XErrorList[code],
+ buffer, nbytes);
+ } else
+ buffer[0] = '\0';
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, code, &ext->codes, buffer, nbytes);
+ if (ext->codes.first_error &&
+ ext->codes.first_error < code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (!buffer[0] && bext) {
+ sprintf(buf, "%s.%d", bext->name, code - bext->codes.first_error);
+ (void) XGetErrorDatabaseText(dpy, "XProtoError", buf, "", buffer, nbytes);
+ }
+ if (!buffer[0])
+ sprintf(buffer, "%d", code);
+ return 0;
+}
+
+#if NeedFunctionPrototypes
+/*ARGSUSED*/
+XGetErrorDatabaseText(
+ Display *dpy,
+ register _Xconst char *name,
+ register _Xconst char *type,
+ _Xconst char *defaultp,
+ char *buffer,
+ int nbytes)
+#else
+/*ARGSUSED*/
+XGetErrorDatabaseText(dpy, name, type, defaultp, buffer, nbytes)
+ Display *dpy;
+ register char *name, *type;
+ char *defaultp;
+ char *buffer;
+ int nbytes;
+#endif
+{
+
+ static XrmDatabase db = NULL;
+ XrmString type_str;
+ XrmValue result;
+ char temp[BUFSIZ];
+ char* tptr;
+ unsigned long tlen;
+
+ if (nbytes == 0) return 0;
+
+ if (!db) {
+ /* the Xrm routines expect to be called with the global
+ mutex unlocked. */
+ XrmDatabase temp_db;
+ int do_destroy;
+
+ XrmInitialize();
+ temp_db = XrmGetFileDatabase(ERRORDB);
+
+ _XLockMutex(_Xglobal_lock);
+ if (!db) {
+ db = temp_db;
+ do_destroy = 0;
+ } else
+ do_destroy = 1; /* we didn't need to get it after all */
+ _XUnlockMutex(_Xglobal_lock);
+
+ if (do_destroy)
+ XrmDestroyDatabase(temp_db);
+ }
+
+ if (db)
+ {
+ tlen = strlen (name) + strlen (type) + 2;
+ if (tlen <= BUFSIZE) tptr = temp;
+ else tptr = Xmalloc (tlen);
+ sprintf(tptr, "%s.%s", name, type);
+ XrmGetResource(db, tptr, "ErrorType.ErrorNumber", &type_str, &result);
+ if (tptr != temp) Xfree (tptr);
+ }
+ else
+ result.addr = (XPointer)NULL;
+ if (!result.addr) {
+ result.addr = (XPointer) defaultp;
+ result.size = strlen(defaultp) + 1;
+ }
+ (void) strncpy (buffer, (char *) result.addr, nbytes);
+ if (result.size > nbytes) buffer[nbytes-1] = '\0';
+ return 0;
+}
diff --git a/src/ErrHndlr.c b/src/ErrHndlr.c
new file mode 100644
index 00000000..b7f6418b
--- /dev/null
+++ b/src/ErrHndlr.c
@@ -0,0 +1,95 @@
+/* $Xorg: ErrHndlr.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern int _XDefaultError();
+extern int _XDefaultIOError();
+/*
+ * XErrorHandler - This procedure sets the X non-fatal error handler
+ * (_XErrorFunction) to be the specified routine. If NULL is passed in
+ * the original error handler is restored.
+ */
+
+#if NeedFunctionPrototypes
+XErrorHandler XSetErrorHandler(XErrorHandler handler)
+#else
+XErrorHandler XSetErrorHandler(handler)
+ register XErrorHandler handler;
+#endif
+{
+ int (*oldhandler)();
+
+ _XLockMutex(_Xglobal_lock);
+ oldhandler = _XErrorFunction;
+
+ if (!oldhandler)
+ oldhandler = _XDefaultError;
+
+ if (handler != NULL) {
+ _XErrorFunction = handler;
+ }
+ else {
+ _XErrorFunction = _XDefaultError;
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return (XErrorHandler) oldhandler;
+}
+
+/*
+ * XIOErrorHandler - This procedure sets the X fatal I/O error handler
+ * (_XIOErrorFunction) to be the specified routine. If NULL is passed in
+ * the original error handler is restored.
+ */
+
+extern int _XIOError();
+#if NeedFunctionPrototypes
+XIOErrorHandler XSetIOErrorHandler(XIOErrorHandler handler)
+#else
+XIOErrorHandler XSetIOErrorHandler(handler)
+ register XIOErrorHandler handler;
+#endif
+{
+ int (*oldhandler)();
+
+ _XLockMutex(_Xglobal_lock);
+ oldhandler = _XIOErrorFunction;
+
+ if (!oldhandler)
+ oldhandler = _XDefaultIOError;
+
+ if (handler != NULL) {
+ _XIOErrorFunction = handler;
+ }
+ else {
+ _XIOErrorFunction = _XDefaultIOError;
+ }
+ _XUnlockMutex(_Xglobal_lock);
+
+ return (XIOErrorHandler) oldhandler;
+}
diff --git a/src/EvToWire.c b/src/EvToWire.c
new file mode 100644
index 00000000..361c4e2c
--- /dev/null
+++ b/src/EvToWire.c
@@ -0,0 +1,404 @@
+/* $Xorg: EvToWire.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1986, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * XEvToWire.c - Internal support routines for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol V11.0.
+ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Status
+_XEventToWire(dpy, re, event)
+register Display *dpy; /* pointer to display structure */
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+{
+ switch (event->u.u.type = re->type) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX = ev->x ;
+ event->u.keyButtonPointer.eventY = ev->y ;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->keycode;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX = ev->x;
+ event->u.keyButtonPointer.eventY = ev->y;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen = ev->same_screen;
+ event->u.u.detail = ev->button;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ event->u.keyButtonPointer.root = ev->root;
+ event->u.keyButtonPointer.event = ev->window;
+ event->u.keyButtonPointer.child = ev->subwindow;
+ event->u.keyButtonPointer.time = ev->time;
+ event->u.keyButtonPointer.eventX= ev->x;
+ event->u.keyButtonPointer.eventY= ev->y;
+ event->u.keyButtonPointer.rootX = ev->x_root;
+ event->u.keyButtonPointer.rootY = ev->y_root;
+ event->u.keyButtonPointer.state = ev->state;
+ event->u.keyButtonPointer.sameScreen= ev->same_screen;
+ event->u.u.detail = ev->is_hint;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ event->u.enterLeave.root = ev->root;
+ event->u.enterLeave.event = ev->window;
+ event->u.enterLeave.child = ev->subwindow;
+ event->u.enterLeave.time = ev->time;
+ event->u.enterLeave.eventX = ev->x;
+ event->u.enterLeave.eventY = ev->y;
+ event->u.enterLeave.rootX = ev->x_root;
+ event->u.enterLeave.rootY = ev->y_root;
+ event->u.enterLeave.state = ev->state;
+ event->u.enterLeave.mode = ev->mode;
+ event->u.enterLeave.flags = 0;
+ if (ev->same_screen) {
+ event->u.enterLeave.flags |= ELFlagSameScreen;
+ }
+ if (ev->focus) {
+ event->u.enterLeave.flags |= ELFlagFocus;
+ }
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ event->u.focus.window = ev->window;
+ event->u.focus.mode = ev->mode;
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ memcpy ((char *)(((xKeymapEvent *) event)->map),
+ &ev->key_vector[1],
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ event->u.expose.window = ev->window;
+ event->u.expose.x = ev->x;
+ event->u.expose.y = ev->y;
+ event->u.expose.width = ev->width;
+ event->u.expose.height = ev->height;
+ event->u.expose.count = ev->count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ event->u.graphicsExposure.drawable = ev->drawable;
+ event->u.graphicsExposure.x = ev->x;
+ event->u.graphicsExposure.y = ev->y;
+ event->u.graphicsExposure.width = ev->width;
+ event->u.graphicsExposure.height = ev->height;
+ event->u.graphicsExposure.count = ev->count;
+ event->u.graphicsExposure.majorEvent= ev->major_code;
+ event->u.graphicsExposure.minorEvent= ev->minor_code;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ event->u.noExposure.drawable = ev->drawable;
+ event->u.noExposure.majorEvent = ev->major_code;
+ event->u.noExposure.minorEvent = ev->minor_code;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ event->u.visibility.window = ev->window;
+ event->u.visibility.state = ev->state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ event->u.createNotify.window = ev->window;
+ event->u.createNotify.parent = ev->parent;
+ event->u.createNotify.x = ev->x;
+ event->u.createNotify.y = ev->y;
+ event->u.createNotify.width = ev->width;
+ event->u.createNotify.height = ev->height;
+ event->u.createNotify.borderWidth = ev->border_width;
+ event->u.createNotify.override = ev->override_redirect;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ event->u.destroyNotify.window = ev->window;
+ event->u.destroyNotify.event = ev->event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ event->u.unmapNotify.window = ev->window;
+ event->u.unmapNotify.event = ev->event;
+ event->u.unmapNotify.fromConfigure = ev->from_configure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ event->u.mapNotify.window = ev->window;
+ event->u.mapNotify.event = ev->event;
+ event->u.mapNotify.override = ev->override_redirect;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ event->u.mapRequest.window = ev->window;
+ event->u.mapRequest.parent = ev->parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ event->u.reparent.window = ev->window;
+ event->u.reparent.event = ev->event;
+ event->u.reparent.parent = ev->parent;
+ event->u.reparent.x = ev->x;
+ event->u.reparent.y = ev->y;
+ event->u.reparent.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ event->u.configureNotify.window = ev->window;
+ event->u.configureNotify.event = ev->event;
+ event->u.configureNotify.aboveSibling = ev->above;
+ event->u.configureNotify.x = ev->x;
+ event->u.configureNotify.y = ev->y;
+ event->u.configureNotify.width = ev->width;
+ event->u.configureNotify.height = ev->height;
+ event->u.configureNotify.borderWidth= ev->border_width;
+ event->u.configureNotify.override = ev->override_redirect;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ event->u.configureRequest.window = ev->window;
+ event->u.configureRequest.parent = ev->parent;
+ event->u.configureRequest.sibling = ev->above;
+ event->u.configureRequest.x = ev->x;
+ event->u.configureRequest.y = ev->y;
+ event->u.configureRequest.width = ev->width;
+ event->u.configureRequest.height = ev->height;
+ event->u.configureRequest.borderWidth= ev->border_width;
+ event->u.configureRequest.valueMask= ev->value_mask;
+ event->u.u.detail = ev->detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ event->u.gravity.window = ev->window;
+ event->u.gravity.event = ev->event;
+ event->u.gravity.x = ev->x;
+ event->u.gravity.y = ev->y;
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ event->u.resizeRequest.window = ev->window;
+ event->u.resizeRequest.width = ev->width;
+ event->u.resizeRequest.height = ev->height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ event->u.circulate.window = ev->window;
+ event->u.circulate.event = ev->event;
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ event->u.circulate.window = ev->window;
+ event->u.circulate.event = ev->parent;
+ event->u.circulate.place = ev->place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ event->u.property.window = ev->window;
+ event->u.property.atom = ev->atom;
+ event->u.property.time = ev->time;
+ event->u.property.state = ev->state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ event->u.selectionClear.window = ev->window;
+ event->u.selectionClear.atom = ev->selection;
+ event->u.selectionClear.time = ev->time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ event->u.selectionRequest.owner = ev->owner;
+ event->u.selectionRequest.requestor = ev->requestor;
+ event->u.selectionRequest.selection = ev->selection;
+ event->u.selectionRequest.target = ev->target;
+ event->u.selectionRequest.property = ev->property;
+ event->u.selectionRequest.time = ev->time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ event->u.selectionNotify.requestor = ev->requestor;
+ event->u.selectionNotify.selection = ev->selection;
+ event->u.selectionNotify.target = ev->target;
+ event->u.selectionNotify.property = ev->property;
+ event->u.selectionNotify.time = ev->time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ event->u.colormap.window = ev->window;
+ event->u.colormap.colormap = ev->colormap;
+ event->u.colormap.new = ev->new;
+ event->u.colormap.state = ev->state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ event->u.clientMessage.window = ev->window;
+ event->u.u.detail = ev->format;
+ switch (ev->format) {
+ case 8:
+ event->u.clientMessage.u.b.type = ev->message_type;
+ for (i = 0; i < 20; i++)
+ event->u.clientMessage.u.b.bytes[i] = ev->data.b[i];
+ break;
+ case 16:
+ event->u.clientMessage.u.s.type = ev->message_type;
+ event->u.clientMessage.u.s.shorts0 = ev->data.s[0];
+ event->u.clientMessage.u.s.shorts1 = ev->data.s[1];
+ event->u.clientMessage.u.s.shorts2 = ev->data.s[2];
+ event->u.clientMessage.u.s.shorts3 = ev->data.s[3];
+ event->u.clientMessage.u.s.shorts4 = ev->data.s[4];
+ event->u.clientMessage.u.s.shorts5 = ev->data.s[5];
+ event->u.clientMessage.u.s.shorts6 = ev->data.s[6];
+ event->u.clientMessage.u.s.shorts7 = ev->data.s[7];
+ event->u.clientMessage.u.s.shorts8 = ev->data.s[8];
+ event->u.clientMessage.u.s.shorts9 = ev->data.s[9];
+ break;
+ case 32:
+ event->u.clientMessage.u.l.type = ev->message_type;
+ event->u.clientMessage.u.l.longs0 = ev->data.l[0];
+ event->u.clientMessage.u.l.longs1 = ev->data.l[1];
+ event->u.clientMessage.u.l.longs2 = ev->data.l[2];
+ event->u.clientMessage.u.l.longs3 = ev->data.l[3];
+ event->u.clientMessage.u.l.longs4 = ev->data.l[4];
+ break;
+ default:
+ /* client passing bogus data, let server complain */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *) re;
+ event->u.mappingNotify.firstKeyCode = ev->first_keycode;
+ event->u.mappingNotify.request = ev->request;
+ event->u.mappingNotify.count = ev->count;
+ }
+ break;
+
+ default:
+ return(_XUnknownNativeEvent(dpy, re, event));
+ }
+ return(1);
+}
diff --git a/src/FSSaver.c b/src/FSSaver.c
new file mode 100644
index 00000000..57cde1aa
--- /dev/null
+++ b/src/FSSaver.c
@@ -0,0 +1,60 @@
+/* $Xorg: FSSaver.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XActivateScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverActive);
+ return 1;
+}
+
+XResetScreenSaver(dpy)
+ register Display *dpy;
+
+{
+ XForceScreenSaver (dpy, ScreenSaverReset);
+ return 1;
+}
+
+XForceScreenSaver(dpy, mode)
+ register Display *dpy;
+ int mode;
+
+{
+ register xForceScreenSaverReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ForceScreenSaver, req);
+ req->mode = mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FSWrap.c b/src/FSWrap.c
new file mode 100644
index 00000000..14adca02
--- /dev/null
+++ b/src/FSWrap.c
@@ -0,0 +1,273 @@
+/* $Xorg: FSWrap.c,v 1.5 2001/02/09 02:03:32 xorgcvs Exp $ */
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 Open Software Foundation
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN 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.
+ *
+ * M. Collins OSF
+ *
+ * Katsuhisa Yano TOSHIBA Corp.
+ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <ctype.h>
+#include <X11/Xos.h>
+
+
+#define XMAXLIST 256
+
+char **
+_XParseBaseFontNameList(str, num)
+ char *str;
+ int *num;
+{
+ char *plist[XMAXLIST];
+ char **list;
+ char *ptr;
+
+ *num = 0;
+ if (!str || !*str) {
+ return (char **)NULL;
+ }
+ while (*str && isspace(*str))
+ str++;
+ if (!*str)
+ return (char **)NULL;
+
+ if (!(ptr = Xmalloc((unsigned)strlen(str) + 1))) {
+ return (char **)NULL;
+ }
+ strcpy(ptr, str);
+
+ /* somebody who specifies more than XMAXLIST basefontnames will lose */
+ while (*num < (sizeof plist / sizeof plist[0])) {
+ char *back;
+
+ plist[*num] = ptr;
+ if ((ptr = strchr(ptr, ','))) {
+ back = ptr;
+ } else {
+ back = plist[*num] + strlen(plist[*num]);
+ }
+ while (isspace(*(back - 1)))
+ back--;
+ *back = '\0';
+ (*num)++;
+ if (!ptr)
+ break;
+ ptr++;
+ while (*ptr && isspace(*ptr))
+ ptr++;
+ if (!*ptr)
+ break;
+ }
+ if (!(list = (char **) Xmalloc((unsigned)sizeof(char *) * (*num + 1)))) {
+ Xfree(ptr);
+ return (char **)NULL;
+ }
+ memcpy((char *)list, (char *)plist, sizeof(char *) * (*num));
+ *(list + *num) = NULL;
+
+ return list;
+}
+
+static char **
+copy_string_list(string_list, list_count)
+ char **string_list;
+ int list_count;
+{
+ char **string_list_ret, **list_src, **list_dst, *dst;
+ int length, count;
+
+ if (string_list == NULL)
+ return (char **) NULL;
+
+ string_list_ret = (char **) Xmalloc(sizeof(char *) * list_count);
+ if (string_list_ret == NULL)
+ return (char **) NULL;
+
+ list_src = string_list;
+ count = list_count;
+ for (length = 0; count-- > 0; list_src++)
+ length += strlen(*list_src) + 1;
+
+ dst = (char *) Xmalloc(length);
+ if (dst == NULL) {
+ Xfree(string_list_ret);
+ return (char **) NULL;
+ }
+
+ list_src = string_list;
+ count = list_count;
+ list_dst = string_list_ret;
+ for ( ; count-- > 0; list_src++) {
+ strcpy(dst, *list_src);
+ *list_dst++ = dst;
+ dst += strlen(dst) + 1;
+ }
+
+ return string_list_ret;
+}
+
+#if NeedFunctionPrototypes
+XFontSet
+XCreateFontSet (
+ Display *dpy,
+ _Xconst char *base_font_name_list,
+ char ***missing_charset_list,
+ int *missing_charset_count,
+ char **def_string)
+#else
+XFontSet
+XCreateFontSet (dpy, base_font_name_list, missing_charset_list,
+ missing_charset_count, def_string)
+ Display *dpy;
+ char *base_font_name_list;
+ char ***missing_charset_list;
+ int *missing_charset_count;
+ char **def_string;
+#endif
+{
+ XOM om;
+ XOC oc;
+ XOMCharSetList *list;
+
+ *missing_charset_list = NULL;
+ *missing_charset_count = 0;
+
+ om = XOpenOM(dpy, NULL, NULL, NULL);
+ if (om == NULL)
+ return (XFontSet) NULL;
+
+ if ((oc = XCreateOC(om, XNBaseFontName, base_font_name_list, NULL))) {
+ list = &oc->core.missing_list;
+ oc->core.om_automatic = True;
+ } else
+ list = &om->core.required_charset;
+
+ *missing_charset_list = copy_string_list(list->charset_list,
+ list->charset_count);
+ *missing_charset_count = list->charset_count;
+
+ if (list->charset_list && *missing_charset_list == NULL)
+ oc = NULL;
+
+ if (oc && def_string) {
+ *def_string = oc->core.default_string;
+ if (!*def_string)
+ *def_string = "";
+ }
+
+ if (oc == NULL)
+ XCloseOM(om);
+
+ return (XFontSet) oc;
+}
+
+int
+XFontsOfFontSet(font_set, font_struct_list, font_name_list)
+ XFontSet font_set;
+ XFontStruct ***font_struct_list;
+ char ***font_name_list;
+{
+ *font_name_list = font_set->core.font_info.font_name_list;
+ *font_struct_list = font_set->core.font_info.font_struct_list;
+ return font_set->core.font_info.num_font;
+}
+
+char *
+XBaseFontNameListOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.base_name_list;
+}
+
+char *
+XLocaleOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.lcd->core->name;
+}
+
+extern Bool XContextDependentDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.context_dependent;
+}
+
+Bool
+XDirectionalDependentDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.directional_dependent;
+}
+
+Bool
+XContextualDrawing(font_set)
+ XFontSet font_set;
+{
+ return font_set->core.om->core.contextual_drawing;
+}
+
+XFontSetExtents *
+XExtentsOfFontSet(font_set)
+ XFontSet font_set;
+{
+ return &font_set->core.font_set_extents;
+}
+
+void
+XFreeFontSet(dpy, font_set)
+ Display *dpy;
+ XFontSet font_set;
+{
+ XCloseOM(font_set->core.om);
+}
diff --git a/src/FetchName.c b/src/FetchName.c
new file mode 100644
index 00000000..1317fa86
--- /dev/null
+++ b/src/FetchName.c
@@ -0,0 +1,93 @@
+/* $Xorg: FetchName.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+
+Status XFetchName (dpy, w, name)
+ register Display *dpy;
+ Window w;
+ char **name;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_NAME, 0L, (long)BUFSIZ, False, XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success) {
+ *name = NULL;
+ return (0);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+
+ /* The data returned by XGetWindowProperty is guarranteed to
+ contain one extra byte that is null terminated to make retrieveing
+ string properties easy. */
+
+ *name = (char *)data;
+ return(1);
+ }
+ if (data) Xfree ((char *)data);
+ *name = NULL;
+ return(0);
+}
+
+Status XGetIconName (dpy, w, icon_name)
+ register Display *dpy;
+ Window w;
+ char **icon_name;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_ICON_NAME, 0L, (long)BUFSIZ, False,
+ XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success) {
+ *icon_name = NULL;
+ return (0);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+
+ /* The data returned by XGetWindowProperty is guarranteed to
+ contain one extra byte that is null terminated to make retrieveing
+ string properties easy. */
+
+ *icon_name = (char*)data;
+ return(1);
+ }
+ if (data) Xfree ((char *)data);
+ *icon_name = NULL;
+ return(0);
+}
diff --git a/src/FillArc.c b/src/FillArc.c
new file mode 100644
index 00000000..22e41910
--- /dev/null
+++ b/src/FillArc.c
@@ -0,0 +1,96 @@
+/* $Xorg: FillArc.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillArcReq) + FARCSPERBATCH * SIZEOF(xArc))
+
+XFillArc(dpy, d, gc, x, y, width, height, angle1, angle2)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+ int angle1, angle2; /* INT16 */
+{
+ xArc *arc;
+#ifdef MUSTCOPY
+ xArc arcdata;
+ long len = SIZEOF(xArc);
+
+ arc = &arcdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyFillArcReq *req = (xPolyFillArcReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyFillArc)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xArc)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xArc) >> 2;
+#ifndef MUSTCOPY
+ arc = (xArc *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xArc);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyFillArc, SIZEOF(xArc), req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xArc);
+#else
+ arc = (xArc *) NEXTPTR(req,xPolyFillArcReq);
+#endif /* MUSTCOPY */
+ }
+ arc->x = x;
+ arc->y = y;
+ arc->width = width;
+ arc->height = height;
+ arc->angle1 = angle1;
+ arc->angle2 = angle2;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) arc, len);
+#endif /* MUSTCOPY */
+
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillArcs.c b/src/FillArcs.c
new file mode 100644
index 00000000..115f25cc
--- /dev/null
+++ b/src/FillArcs.c
@@ -0,0 +1,64 @@
+/* $Xorg: FillArcs.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define arc_scale (SIZEOF(xArc) / 4)
+
+XFillArcs(dpy, d, gc, arcs, n_arcs)
+register Display *dpy;
+Drawable d;
+GC gc;
+XArc *arcs;
+int n_arcs;
+{
+ register xPolyFillArcReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_arcs) {
+ GetReq(PolyFillArc, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_arcs;
+ len = ((long)n) * arc_scale;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) / arc_scale;
+ len = ((long)n) * arc_scale;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) arcs, len);
+ n_arcs -= n;
+ arcs += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillPoly.c b/src/FillPoly.c
new file mode 100644
index 00000000..c8f40c63
--- /dev/null
+++ b/src/FillPoly.c
@@ -0,0 +1,61 @@
+/* $Xorg: FillPoly.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFillPolygon(dpy, d, gc, points, n_points, shape, mode)
+register Display *dpy;
+Drawable d;
+GC gc;
+XPoint *points;
+int n_points;
+int shape;
+int mode;
+{
+ register xFillPolyReq *req;
+ register long nbytes;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq(FillPoly, req);
+
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->shape = shape;
+ req->coordMode = mode;
+
+ SetReqLen(req, n_points, 65535 - req->length);
+
+ /* shift (mult. by 4) before passing to the (possible) macro */
+
+ nbytes = n_points << 2;
+
+ Data16 (dpy, (short *) points, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillRct.c b/src/FillRct.c
new file mode 100644
index 00000000..d2537c7c
--- /dev/null
+++ b/src/FillRct.c
@@ -0,0 +1,92 @@
+/* $Xorg: FillRct.c,v 1.4 2001/02/09 02:03:32 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* precompute the maximum size of batching request allowed */
+
+#define size (SIZEOF(xPolyFillRectangleReq) + FRCTSPERBATCH * SIZEOF(xRectangle))
+
+XFillRectangle(dpy, d, gc, x, y, width, height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y; /* INT16 */
+ unsigned int width, height; /* CARD16 */
+{
+ xRectangle *rect;
+#ifdef MUSTCOPY
+ xRectangle rectdata;
+ long len = SIZEOF(xRectangle);
+
+ rect = &rectdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ {
+ register xPolyFillRectangleReq *req
+ = (xPolyFillRectangleReq *) dpy->last_req;
+
+ /* if same as previous request, with same drawable, batch requests */
+ if (
+ (req->reqType == X_PolyFillRectangle)
+ && (req->drawable == d)
+ && (req->gc == gc->gid)
+ && ((dpy->bufptr + SIZEOF(xRectangle)) <= dpy->bufmax)
+ && (((char *)dpy->bufptr - (char *)req) < size) ) {
+ req->length += SIZEOF(xRectangle) >> 2;
+#ifndef MUSTCOPY
+ rect = (xRectangle *) dpy->bufptr;
+ dpy->bufptr += SIZEOF(xRectangle);
+#endif /* not MUSTCOPY */
+ }
+
+ else {
+ GetReqExtra(PolyFillRectangle, SIZEOF(xRectangle), req);
+ req->drawable = d;
+ req->gc = gc->gid;
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xRectangle);
+#else
+ rect = (xRectangle *) NEXTPTR(req,xPolyFillRectangleReq);
+#endif /* MUSTCOPY */
+ }
+ rect->x = x;
+ rect->y = y;
+ rect->width = width;
+ rect->height = height;
+
+#ifdef MUSTCOPY
+ Data (dpy, (char *) rect, len);
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/FillRcts.c b/src/FillRcts.c
new file mode 100644
index 00000000..4e86fec3
--- /dev/null
+++ b/src/FillRcts.c
@@ -0,0 +1,63 @@
+/* $Xorg: FillRcts.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFillRectangles(dpy, d, gc, rectangles, n_rects)
+register Display *dpy;
+Drawable d;
+GC gc;
+XRectangle *rectangles;
+int n_rects;
+{
+ register xPolyFillRectangleReq *req;
+ long len;
+ int n;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ while (n_rects) {
+ GetReq(PolyFillRectangle, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ n = n_rects;
+ len = ((long)n) << 1;
+ if (!dpy->bigreq_size && len > (dpy->max_request_size - req->length)) {
+ n = (dpy->max_request_size - req->length) >> 1;
+ len = ((long)n) << 1;
+ }
+ SetReqLen(req, len, len);
+ len <<= 2; /* watch out for macros... */
+ Data16 (dpy, (short *) rectangles, len);
+ n_rects -= n;
+ rectangles += n;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FilterEv.c b/src/FilterEv.c
new file mode 100644
index 00000000..2b104839
--- /dev/null
+++ b/src/FilterEv.c
@@ -0,0 +1,104 @@
+/* $Xorg: FilterEv.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+ /*
+ * Copyright 1990, 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON 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
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+extern long Const _Xevent_to_mask[];
+
+/*
+ * Look up if there is a specified filter for the event.
+ */
+Bool
+XFilterEvent(ev, window)
+ XEvent *ev;
+ Window window;
+{
+ XFilterEventList p;
+ Window win;
+ long mask;
+ Bool ret;
+
+ if (window)
+ win = window;
+ else
+ win = ev->xany.window;
+ if (ev->type >= LASTEvent)
+ mask = 0;
+ else
+ mask = _Xevent_to_mask[ev->type];
+
+ LockDisplay(ev->xany.display);
+ for (p = ev->xany.display->im_filters; p != NULL; p = p->next) {
+ if (win == p->window) {
+ if ((mask & p->event_mask) ||
+ (ev->type >= p->start_type && ev->type <= p->end_type)) {
+ ret = (*(p->filter))(ev->xany.display, p->window, ev,
+ p->client_data);
+ UnlockDisplay(ev->xany.display);
+ return(ret);
+ }
+ }
+ }
+ UnlockDisplay(ev->xany.display);
+ return(False);
+}
diff --git a/src/Flush.c b/src/Flush.c
new file mode 100644
index 00000000..fd6b3935
--- /dev/null
+++ b/src/Flush.c
@@ -0,0 +1,40 @@
+/* $Xorg: Flush.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* Flush all buffered output requests. */
+/* NOTE: NOT necessary when calling any of the Xlib routines. */
+
+XFlush (dpy)
+ register Display *dpy;
+ {
+ LockDisplay(dpy);
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ return 1;
+ }
diff --git a/src/Font.c b/src/Font.c
new file mode 100644
index 00000000..2b1eae84
--- /dev/null
+++ b/src/Font.c
@@ -0,0 +1,241 @@
+/* $Xorg: Font.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+static XFontStruct *_XQueryFont();
+
+#if NeedFunctionPrototypes
+XFontStruct *XLoadQueryFont(
+ register Display *dpy,
+ _Xconst char *name)
+#else
+XFontStruct *XLoadQueryFont(dpy, name)
+ register Display *dpy;
+ char *name;
+#endif
+{
+ XFontStruct *font_result;
+ register long nbytes;
+ Font fid;
+ xOpenFontReq *req;
+ unsigned long seq;
+
+ LockDisplay(dpy);
+ GetReq(OpenFont, req);
+ seq = dpy->request;
+ nbytes = req->nbytes = name ? strlen(name) : 0;
+ req->fid = fid = XAllocID(dpy);
+ req->length += (nbytes+3)>>2;
+ Data (dpy, name, nbytes);
+ font_result = _XQueryFont(dpy, fid, seq);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+XFreeFont(dpy, fs)
+ register Display *dpy;
+ XFontStruct *fs;
+{
+ register xResourceReq *req;
+ register _XExtension *ext;
+
+ LockDisplay(dpy);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->free_Font) (*ext->free_Font)(dpy, fs, &ext->codes);
+ GetResReq (CloseFont, fs->fid, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _XFreeExtData(fs->ext_data);
+ if (fs->per_char)
+ Xfree ((char *) fs->per_char);
+ if (fs->properties)
+ Xfree ((char *) fs->properties);
+ Xfree ((char *) fs);
+ return 1;
+}
+
+static XFontStruct *
+_XQueryFont (dpy, fid, seq)
+ register Display *dpy;
+ Font fid;
+ unsigned long seq;
+{
+ register XFontStruct *fs;
+ register long nbytes;
+ xQueryFontReply reply;
+ register xResourceReq *req;
+ register _XExtension *ext;
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ if (seq) {
+ async_state.min_sequence_number = seq;
+ async_state.max_sequence_number = seq;
+ async_state.error_code = BadName;
+ async_state.major_opcode = X_OpenFont;
+ async_state.minor_opcode = 0;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ }
+ GetResReq(QueryFont, fid, req);
+ if (!_XReply (dpy, (xReply *) &reply,
+ ((SIZEOF(xQueryFontReply) - SIZEOF(xReply)) >> 2), xFalse)) {
+ if (seq)
+ DeqAsyncHandler(dpy, &async);
+ return (XFontStruct *)NULL;
+ }
+ if (seq)
+ DeqAsyncHandler(dpy, &async);
+ if (! (fs = (XFontStruct *) Xmalloc (sizeof (XFontStruct)))) {
+ _XEatData(dpy, (unsigned long)(reply.nFontProps * SIZEOF(xFontProp) +
+ reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+ fs->ext_data = NULL;
+ fs->fid = fid;
+ fs->direction = reply.drawDirection;
+ fs->min_char_or_byte2 = reply.minCharOrByte2;
+ fs->max_char_or_byte2 = reply.maxCharOrByte2;
+ fs->min_byte1 = reply.minByte1;
+ fs->max_byte1 = reply.maxByte1;
+ fs->default_char = reply.defaultChar;
+ fs->all_chars_exist = reply.allCharsExist;
+ fs->ascent = cvtINT16toInt (reply.fontAscent);
+ fs->descent = cvtINT16toInt (reply.fontDescent);
+
+#ifdef MUSTCOPY
+ {
+ xCharInfo *xcip;
+
+ xcip = (xCharInfo *) &reply.minBounds;
+ fs->min_bounds.lbearing = cvtINT16toShort(xcip->leftSideBearing);
+ fs->min_bounds.rbearing = cvtINT16toShort(xcip->rightSideBearing);
+ fs->min_bounds.width = cvtINT16toShort(xcip->characterWidth);
+ fs->min_bounds.ascent = cvtINT16toShort(xcip->ascent);
+ fs->min_bounds.descent = cvtINT16toShort(xcip->descent);
+ fs->min_bounds.attributes = xcip->attributes;
+
+ xcip = (xCharInfo *) &reply.maxBounds;
+ fs->max_bounds.lbearing = cvtINT16toShort(xcip->leftSideBearing);
+ fs->max_bounds.rbearing = cvtINT16toShort(xcip->rightSideBearing);
+ fs->max_bounds.width = cvtINT16toShort(xcip->characterWidth);
+ fs->max_bounds.ascent = cvtINT16toShort(xcip->ascent);
+ fs->max_bounds.descent = cvtINT16toShort(xcip->descent);
+ fs->max_bounds.attributes = xcip->attributes;
+ }
+#else
+ /* XXX the next two statements won't work if short isn't 16 bits */
+ fs->min_bounds = * (XCharStruct *) &reply.minBounds;
+ fs->max_bounds = * (XCharStruct *) &reply.maxBounds;
+#endif /* MUSTCOPY */
+
+ fs->n_properties = reply.nFontProps;
+ /*
+ * if no properties defined for the font, then it is bad
+ * font, but shouldn't try to read nothing.
+ */
+ fs->properties = NULL;
+ if (fs->n_properties > 0) {
+ nbytes = reply.nFontProps * sizeof(XFontProp);
+ fs->properties = (XFontProp *) Xmalloc ((unsigned) nbytes);
+ nbytes = reply.nFontProps * SIZEOF(xFontProp);
+ if (! fs->properties) {
+ Xfree((char *) fs);
+ _XEatData(dpy, (unsigned long)
+ (nbytes + reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+ _XRead32 (dpy, (char *)fs->properties, nbytes);
+ }
+ /*
+ * If no characters in font, then it is a bad font, but
+ * shouldn't try to read nothing.
+ */
+ /* have to unpack charinfos on some machines (CRAY) */
+ fs->per_char = NULL;
+ if (reply.nCharInfos > 0){
+ nbytes = reply.nCharInfos * sizeof(XCharStruct);
+ if (! (fs->per_char = (XCharStruct *) Xmalloc ((unsigned) nbytes))) {
+ if (fs->properties) Xfree((char *) fs->properties);
+ Xfree((char *) fs);
+ _XEatData(dpy, (unsigned long)
+ (reply.nCharInfos * SIZEOF(xCharInfo)));
+ return (XFontStruct *)NULL;
+ }
+
+#ifdef MUSTCOPY
+ {
+ register XCharStruct *cs = fs->per_char;
+ register int i;
+
+ for (i = 0; i < reply.nCharInfos; i++, cs++) {
+ xCharInfo xcip;
+
+ _XRead(dpy, (char *)&xcip, SIZEOF(xCharInfo));
+ cs->lbearing = cvtINT16toShort(xcip.leftSideBearing);
+ cs->rbearing = cvtINT16toShort(xcip.rightSideBearing);
+ cs->width = cvtINT16toShort(xcip.characterWidth);
+ cs->ascent = cvtINT16toShort(xcip.ascent);
+ cs->descent = cvtINT16toShort(xcip.descent);
+ cs->attributes = xcip.attributes;
+ }
+ }
+#else
+ nbytes = reply.nCharInfos * SIZEOF(xCharInfo);
+ _XRead16 (dpy, (char *)fs->per_char, nbytes);
+#endif
+ }
+
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->create_Font) (*ext->create_Font)(dpy, fs, &ext->codes);
+ return fs;
+}
+
+
+XFontStruct *XQueryFont (dpy, fid)
+ register Display *dpy;
+ Font fid;
+{
+ XFontStruct *font_result;
+
+ LockDisplay(dpy);
+ font_result = _XQueryFont(dpy, fid, 0L);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return font_result;
+}
+
+
+
diff --git a/src/FontInfo.c b/src/FontInfo.c
new file mode 100644
index 00000000..2dd4e793
--- /dev/null
+++ b/src/FontInfo.c
@@ -0,0 +1,248 @@
+/* $Xorg: FontInfo.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+char **XListFontsWithInfo(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount, /* RETURN */
+XFontStruct **info) /* RETURN */
+#else
+char **XListFontsWithInfo(dpy, pattern, maxNames, actualCount, info)
+register Display *dpy;
+char *pattern; /* null-terminated */
+int maxNames;
+int *actualCount; /* RETURN */
+XFontStruct **info; /* RETURN */
+#endif
+{
+ register long nbytes;
+ register int i;
+ register XFontStruct *fs;
+ register int size = 0;
+ XFontStruct *finfo = NULL;
+ char **flist = NULL;
+ xListFontsWithInfoReply reply;
+ register xListFontsReq *req;
+ int j;
+
+ LockDisplay(dpy);
+ GetReq(ListFontsWithInfo, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen (pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _XSend (dpy, pattern, nbytes);
+ /* use _XSend instead of Data, since subsequent _XReply will flush buffer */
+
+ for (i = 0; ; i++) {
+ if (!_XReply (dpy, (xReply *) &reply,
+ ((SIZEOF(xListFontsWithInfoReply) -
+ SIZEOF(xGenericReply)) >> 2), xFalse)) {
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties) Xfree((char *) finfo[j].properties);
+ }
+ if (flist) Xfree((char *) flist);
+ if (finfo) Xfree((char *) finfo);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((char **) NULL);
+ }
+ if (reply.nameLength == 0)
+ break;
+ if ((i + reply.nReplies) >= size) {
+ size = i + reply.nReplies + 1;
+
+ if (finfo) {
+ XFontStruct * tmp_finfo = (XFontStruct *)
+ Xrealloc ((char *) finfo,
+ (unsigned) (sizeof(XFontStruct) * size));
+ char ** tmp_flist = (char **)
+ Xrealloc ((char *) flist,
+ (unsigned) (sizeof(char *) * (size+1)));
+
+ if ((! tmp_finfo) || (! tmp_flist)) {
+ /* free all the memory that we allocated */
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties)
+ Xfree((char *) finfo[j].properties);
+ }
+ if (tmp_flist) Xfree((char *) tmp_flist);
+ else Xfree((char *) flist);
+ if (tmp_finfo) Xfree((char *) tmp_finfo);
+ else Xfree((char *) finfo);
+ goto clearwire;
+ }
+ finfo = tmp_finfo;
+ flist = tmp_flist;
+ }
+ else {
+ if (! (finfo = (XFontStruct *)
+ Xmalloc((unsigned) (sizeof(XFontStruct) * size))))
+ goto clearwire;
+ if (! (flist = (char **)
+ Xmalloc((unsigned) (sizeof(char *) * (size+1))))) {
+ Xfree((char *) finfo);
+ goto clearwire;
+ }
+ }
+ }
+ fs = &finfo[i];
+
+ fs->ext_data = NULL;
+ fs->per_char = NULL;
+ fs->fid = None;
+ fs->direction = reply.drawDirection;
+ fs->min_char_or_byte2 = reply.minCharOrByte2;
+ fs->max_char_or_byte2 = reply.maxCharOrByte2;
+ fs->min_byte1 = reply.minByte1;
+ fs->max_byte1 = reply.maxByte1;
+ fs->default_char = reply.defaultChar;
+ fs->all_chars_exist = reply.allCharsExist;
+ fs->ascent = cvtINT16toInt (reply.fontAscent);
+ fs->descent = cvtINT16toInt (reply.fontDescent);
+
+#ifdef MUSTCOPY
+ {
+ xCharInfo *xcip;
+
+ xcip = (xCharInfo *) &reply.minBounds;
+ fs->min_bounds.lbearing = xcip->leftSideBearing;
+ fs->min_bounds.rbearing = xcip->rightSideBearing;
+ fs->min_bounds.width = xcip->characterWidth;
+ fs->min_bounds.ascent = xcip->ascent;
+ fs->min_bounds.descent = xcip->descent;
+ fs->min_bounds.attributes = xcip->attributes;
+
+ xcip = (xCharInfo *) &reply.maxBounds;
+ fs->max_bounds.lbearing = xcip->leftSideBearing;
+ fs->max_bounds.rbearing = xcip->rightSideBearing;
+ fs->max_bounds.width = xcip->characterWidth;
+ fs->max_bounds.ascent = xcip->ascent;
+ fs->max_bounds.descent = xcip->descent;
+ fs->max_bounds.attributes = xcip->attributes;
+ }
+#else
+ /* XXX the next two statements won't work if short isn't 16 bits */
+ fs->min_bounds = * (XCharStruct *) &reply.minBounds;
+ fs->max_bounds = * (XCharStruct *) &reply.maxBounds;
+#endif /* MUSTCOPY */
+
+ fs->n_properties = reply.nFontProps;
+ if (fs->n_properties > 0) {
+ nbytes = reply.nFontProps * sizeof(XFontProp);
+ if (! (fs->properties = (XFontProp *) Xmalloc((unsigned) nbytes)))
+ goto badmem;
+ nbytes = reply.nFontProps * SIZEOF(xFontProp);
+ _XRead32 (dpy, (char *)fs->properties, nbytes);
+
+ } else
+ fs->properties = NULL;
+
+ j = reply.nameLength + 1;
+ if (!i)
+ j++; /* make first string 1 byte longer, to match XListFonts */
+ flist[i] = (char *) Xmalloc ((unsigned int) j);
+ if (! flist[i]) {
+ if (finfo[i].properties) Xfree((char *) finfo[i].properties);
+ nbytes = reply.nameLength + 3 & ~3;
+ _XEatData(dpy, (unsigned long) nbytes);
+ goto badmem;
+ }
+ if (!i) {
+ *flist[0] = 0; /* zero to distinguish from XListFonts */
+ flist[0]++;
+ }
+ flist[i][reply.nameLength] = '\0';
+ _XReadPad (dpy, flist[i], (long) reply.nameLength);
+ }
+ *info = finfo;
+ *actualCount = i;
+ if (flist)
+ flist[i] = NULL; /* required in case XFreeFontNames is called */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+
+
+ badmem:
+ /* Free all memory allocated by this function. */
+ for (j=(i-1); (j >= 0); j--) {
+ Xfree(flist[j]);
+ if (finfo[j].properties) Xfree((char *) finfo[j].properties);
+ }
+ if (flist) Xfree((char *) flist);
+ if (finfo) Xfree((char *) finfo);
+
+ clearwire:
+ /* Clear the wire. */
+ do {
+ if (reply.nFontProps)
+ _XEatData(dpy, (unsigned long)
+ (reply.nFontProps * SIZEOF(xFontProp)));
+ nbytes = (reply.nameLength + 3) & ~3;
+ _XEatData(dpy, (unsigned long) nbytes);
+ }
+ while (_XReply(dpy,(xReply *) &reply, ((SIZEOF(xListFontsWithInfoReply) -
+ SIZEOF(xGenericReply)) >> 2),
+ xFalse) && (reply.nameLength != 0));
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+}
+
+
+XFreeFontInfo (names, info, actualCount)
+char **names;
+XFontStruct *info;
+int actualCount;
+{
+ register int i;
+ if (names) {
+ Xfree (names[0]-1);
+ for (i = 1; i < actualCount; i++) {
+ Xfree (names[i]);
+ }
+ Xfree((char *) names);
+ }
+ if (info) {
+ for (i = 0; i < actualCount; i++) {
+ if (info[i].per_char)
+ Xfree ((char *) info[i].per_char);
+ if (info[i].properties)
+ Xfree ((char *) info[i].properties);
+ }
+ Xfree((char *) info);
+ }
+ return 1;
+}
diff --git a/src/FontNames.c b/src/FontNames.c
new file mode 100644
index 00000000..8432b2f9
--- /dev/null
+++ b/src/FontNames.c
@@ -0,0 +1,118 @@
+/* $Xorg: FontNames.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+char **XListFonts(
+register Display *dpy,
+_Xconst char *pattern, /* null-terminated */
+int maxNames,
+int *actualCount) /* RETURN */
+#else
+char **XListFonts(dpy, pattern, maxNames, actualCount)
+register Display *dpy;
+char *pattern; /* null-terminated */
+int maxNames;
+int *actualCount; /* RETURN */
+#endif
+{
+ register long nbytes;
+ register unsigned i;
+ register int length;
+ char **flist;
+ char *ch;
+ xListFontsReply rep;
+ register xListFontsReq *req;
+ register long rlen;
+
+ LockDisplay(dpy);
+ GetReq(ListFonts, req);
+ req->maxNames = maxNames;
+ nbytes = req->nbytes = pattern ? strlen (pattern) : 0;
+ req->length += (nbytes + 3) >> 2;
+ _XSend (dpy, pattern, nbytes);
+ /* use _XSend instead of Data, since following _XReply will flush buffer */
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ *actualCount = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ if (rep.nFonts) {
+ flist = (char **)Xmalloc ((unsigned)rep.nFonts * sizeof(char *));
+ rlen = rep.length << 2;
+ ch = (char *) Xmalloc((unsigned) (rlen + 1));
+ /* +1 to leave room for last null-terminator */
+
+ if ((! flist) || (! ch)) {
+ if (flist) Xfree((char *) flist);
+ if (ch) Xfree(ch);
+ _XEatData(dpy, (unsigned long) rlen);
+ *actualCount = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, rlen);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *(unsigned char *)ch;
+ *ch = 1; /* make sure it is non-zero for XFreeFontNames */
+ for (i = 0; i < rep.nFonts; i++) {
+ flist[i] = ch + 1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *(unsigned char *)ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else flist = (char **) NULL;
+ *actualCount = rep.nFonts;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+}
+
+XFreeFontNames(list)
+char **list;
+{
+ if (list) {
+ if (!*(list[0]-1)) { /* from ListFontsWithInfo */
+ register char **names;
+ for (names = list+1; *names; names++)
+ Xfree (*names);
+ }
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/FreeCmap.c b/src/FreeCmap.c
new file mode 100644
index 00000000..3a2d370c
--- /dev/null
+++ b/src/FreeCmap.c
@@ -0,0 +1,46 @@
+/* $Xorg: FreeCmap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+extern void _XcmsDeleteCmapRec();
+
+XFreeColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(FreeColormap, cmap, req);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XcmsDeleteCmapRec(dpy, cmap);
+ return 1;
+}
diff --git a/src/FreeCols.c b/src/FreeCols.c
new file mode 100644
index 00000000..03f74b90
--- /dev/null
+++ b/src/FreeCols.c
@@ -0,0 +1,54 @@
+/* $Xorg: FreeCols.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeColors(dpy, cmap, pixels, npixels, planes)
+register Display *dpy;
+Colormap cmap;
+unsigned long *pixels; /* LISTofCARD32 */
+int npixels;
+unsigned long planes; /* CARD32 */
+{
+ register xFreeColorsReq *req;
+ register long nbytes;
+
+ LockDisplay(dpy);
+ GetReq(FreeColors, req);
+ req->cmap = cmap;
+ req->planeMask = planes;
+
+ /* on the VAX, each pixel is a 32-bit (unsigned) integer */
+ req->length += npixels;
+
+ nbytes = npixels << 2; /* watch out for macros... */
+ Data32 (dpy, (long *) pixels, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FreeCurs.c b/src/FreeCurs.c
new file mode 100644
index 00000000..4fe214a9
--- /dev/null
+++ b/src/FreeCurs.c
@@ -0,0 +1,41 @@
+/* $Xorg: FreeCurs.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeCursor(dpy, cursor)
+ register Display *dpy;
+ Cursor cursor;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(FreeCursor, cursor, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/FreeEData.c b/src/FreeEData.c
new file mode 100644
index 00000000..14344fb8
--- /dev/null
+++ b/src/FreeEData.c
@@ -0,0 +1,43 @@
+/* $Xorg: FreeEData.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+_XFreeExtData (extension)
+ XExtData *extension;
+{
+ XExtData *temp;
+ while (extension) {
+ if (extension->free_private)
+ (*extension->free_private)(extension);
+ else Xfree ((char *)extension->private_data);
+ temp = extension->next;
+ Xfree ((char *)extension);
+ extension = temp;
+ }
+ return 0;
+}
diff --git a/src/FreeGC.c b/src/FreeGC.c
new file mode 100644
index 00000000..9912ff6f
--- /dev/null
+++ b/src/FreeGC.c
@@ -0,0 +1,47 @@
+/* $Xorg: FreeGC.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreeGC (dpy, gc)
+ register Display *dpy;
+ GC gc;
+ {
+ register xResourceReq *req;
+ register _XExtension *ext;
+ LockDisplay(dpy);
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->free_GC) (*ext->free_GC)(dpy, gc, &ext->codes);
+ GetResReq (FreeGC, gc->gid, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _XFreeExtData(gc->ext_data);
+ Xfree ((char *) gc);
+ return 1;
+ }
+
diff --git a/src/FreePix.c b/src/FreePix.c
new file mode 100644
index 00000000..d90ae131
--- /dev/null
+++ b/src/FreePix.c
@@ -0,0 +1,42 @@
+/* $Xorg: FreePix.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XFreePixmap(dpy, pixmap)
+ register Display *dpy;
+ Pixmap pixmap;
+
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(FreePixmap, pixmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GCMisc.c b/src/GCMisc.c
new file mode 100644
index 00000000..3735f692
--- /dev/null
+++ b/src/GCMisc.c
@@ -0,0 +1,103 @@
+/* $Xorg: GCMisc.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetArcMode (dpy, gc, arc_mode)
+register Display *dpy;
+register GC gc;
+int arc_mode;
+{
+ LockDisplay(dpy);
+ if (gc->values.arc_mode != arc_mode) {
+ gc->values.arc_mode = arc_mode;
+ gc->dirty |= GCArcMode;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetFillRule (dpy, gc, fill_rule)
+register Display *dpy;
+register GC gc;
+int fill_rule;
+{
+ LockDisplay(dpy);
+ if (gc->values.fill_rule != fill_rule) {
+ gc->values.fill_rule = fill_rule;
+ gc->dirty |= GCFillRule;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetFillStyle (dpy, gc, fill_style)
+register Display *dpy;
+register GC gc;
+int fill_style;
+{
+ LockDisplay(dpy);
+ if (gc->values.fill_style != fill_style) {
+ gc->values.fill_style = fill_style;
+ gc->dirty |= GCFillStyle;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetGraphicsExposures (dpy, gc, graphics_exposures)
+register Display *dpy;
+register GC gc;
+Bool graphics_exposures;
+{
+ LockDisplay(dpy);
+ if (gc->values.graphics_exposures != graphics_exposures) {
+ gc->values.graphics_exposures = graphics_exposures;
+ gc->dirty |= GCGraphicsExposures;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XSetSubwindowMode (dpy, gc, subwindow_mode)
+register Display *dpy;
+register GC gc;
+int subwindow_mode;
+{
+ LockDisplay(dpy);
+ if (gc->values.subwindow_mode != subwindow_mode) {
+ gc->values.subwindow_mode = subwindow_mode;
+ gc->dirty |= GCSubwindowMode;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/Geom.c b/src/Geom.c
new file mode 100644
index 00000000..2699231d
--- /dev/null
+++ b/src/Geom.c
@@ -0,0 +1,98 @@
+/* $Xorg: Geom.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+
+/*
+ * This routine given a user supplied positional argument and a default
+ * argument (fully qualified) will return the position the window should take
+ * returns 0 if there was some problem, else the position bitmask.
+ */
+
+#if NeedFunctionPrototypes
+int XGeometry (
+ Display *dpy, /* user's display connection */
+ int screen, /* screen on which to do computation */
+ _Xconst char *pos, /* user provided geometry spec */
+ _Xconst char *def, /* default geometry spec for window */
+ unsigned int bwidth, /* border width */
+ unsigned int fwidth, /* size of position units */
+ unsigned int fheight,
+ int xadd, /* any additional interior space */
+ int yadd,
+ register int *x, /* always set on successful RETURN */
+ register int *y, /* always set on successful RETURN */
+ register int *width, /* always set on successful RETURN */
+ register int *height) /* always set on successful RETURN */
+#else
+int XGeometry (dpy, screen, pos, def, bwidth, fwidth, fheight, xadd, yadd, x, y, width, height)
+ Display *dpy; /* user's display connection */
+ int screen; /* screen on which to do computation */
+ char *pos; /* user provided geometry spec */
+ char *def; /* default geometry spec for window */
+ unsigned int bwidth; /* border width */
+ unsigned int fwidth, fheight; /* size of position units */
+ int xadd, yadd; /* any additional interior space */
+ register int *x, *y, *width, *height;/* always set on successful RETURN */
+#endif
+{
+ int px, py; /* returned values from parse */
+ unsigned int pwidth, pheight; /* returned values from parse */
+ int dx, dy; /* default values from parse */
+ unsigned int dwidth, dheight; /* default values from parse */
+ int pmask, dmask; /* values back from parse */
+
+ pmask = XParseGeometry(pos, &px, &py, &pwidth, &pheight);
+ dmask = XParseGeometry(def, &dx, &dy, &dwidth, &dheight);
+
+ /* set default values */
+ *x = (dmask & XNegative) ?
+ DisplayWidth(dpy, screen) + dx - dwidth * fwidth -
+ 2 * bwidth - xadd : dx;
+ *y = (dmask & YNegative) ?
+ DisplayHeight(dpy, screen) + dy - dheight * fheight -
+ 2 * bwidth - yadd : dy;
+ *width = dwidth;
+ *height = dheight;
+
+ if (pmask & WidthValue) *width = pwidth;
+ if (pmask & HeightValue) *height = pheight;
+
+ if (pmask & XValue)
+ *x = (pmask & XNegative) ?
+ DisplayWidth(dpy, screen) + px - *width * fwidth -
+ 2 * bwidth - xadd : px;
+ if (pmask & YValue)
+ *y = (pmask & YNegative) ?
+ DisplayHeight(dpy, screen) + py - *height * fheight -
+ 2 * bwidth - yadd : py;
+ return (pmask);
+}
diff --git a/src/GetAtomNm.c b/src/GetAtomNm.c
new file mode 100644
index 00000000..1b11fd7a
--- /dev/null
+++ b/src/GetAtomNm.c
@@ -0,0 +1,204 @@
+/* $Xorg: GetAtomNm.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+extern void _XFreeAtomTable();
+
+/* XXX this table def is duplicated in IntAtom.c, keep them consistent! */
+
+#define TABLESIZE 64
+
+typedef struct _Entry {
+ unsigned long sig;
+ Atom atom;
+} EntryRec, *Entry;
+
+#define EntryName(e) ((char *)(e+1))
+
+typedef struct _XDisplayAtoms {
+ Entry table[TABLESIZE];
+} AtomTable;
+
+static
+char *_XGetAtomName(dpy, atom)
+ Display *dpy;
+ Atom atom;
+{
+ xResourceReq *req;
+ char *name;
+ register Entry *table;
+ register int idx;
+ register Entry e;
+
+ if (dpy->atoms) {
+ table = dpy->atoms->table;
+ for (idx = TABLESIZE; --idx >= 0; ) {
+ if ((e = *table++) && (e->atom == atom)) {
+ idx = strlen(EntryName(e)) + 1;
+ if ((name = (char *)Xmalloc(idx)))
+ strcpy(name, EntryName(e));
+ return name;
+ }
+ }
+ }
+ GetResReq(GetAtomName, atom, req);
+ return (char *)NULL;
+}
+
+char *XGetAtomName(dpy, atom)
+ register Display *dpy;
+ Atom atom;
+{
+ xGetAtomNameReply rep;
+ char *name;
+
+ LockDisplay(dpy);
+ if ((name = _XGetAtomName(dpy, atom))) {
+ UnlockDisplay(dpy);
+ return name;
+ }
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(NULL);
+ }
+ if ((name = (char *) Xmalloc(rep.nameLength+1))) {
+ _XReadPad(dpy, name, (long)rep.nameLength);
+ name[rep.nameLength] = '\0';
+ _XUpdateAtomCache(dpy, name, atom, 0, -1, 0);
+ } else {
+ _XEatData(dpy, (unsigned long) (rep.nameLength + 3) & ~3);
+ name = (char *) NULL;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(name);
+}
+
+typedef struct {
+ unsigned long start_seq;
+ unsigned long stop_seq;
+ Atom *atoms;
+ char **names;
+ int idx;
+ int count;
+ Status status;
+} _XGetAtomNameState;
+
+static
+Bool _XGetAtomNameHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XGetAtomNameState *state;
+ xGetAtomNameReply replbuf;
+ register xGetAtomNameReply *repl;
+
+ state = (_XGetAtomNameState *)data;
+ if (dpy->last_request_read < state->start_seq ||
+ dpy->last_request_read > state->stop_seq)
+ return False;
+ while (state->idx < state->count && state->names[state->idx])
+ state->idx++;
+ if (state->idx >= state->count)
+ return False;
+ if (rep->generic.type == X_Error) {
+ state->status = 0;
+ return False;
+ }
+ repl = (xGetAtomNameReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xGetAtomNameReply) - SIZEOF(xReply)) >> 2,
+ False);
+ state->names[state->idx] = (char *) Xmalloc(repl->nameLength+1);
+ _XGetAsyncData(dpy, state->names[state->idx], buf, len,
+ SIZEOF(xGetAtomNameReply), repl->nameLength,
+ repl->length << 2);
+ if (state->names[state->idx]) {
+ state->names[state->idx][repl->nameLength] = '\0';
+ _XUpdateAtomCache(dpy, state->names[state->idx],
+ state->atoms[state->idx], 0, -1, 0);
+ } else {
+ state->status = 0;
+ }
+ return True;
+}
+
+Status
+XGetAtomNames (dpy, atoms, count, names_return)
+ Display *dpy;
+ Atom *atoms;
+ int count;
+ char **names_return;
+{
+ _XAsyncHandler async;
+ _XGetAtomNameState async_state;
+ xGetAtomNameReply rep;
+ int i;
+ int missed = -1;
+
+ LockDisplay(dpy);
+ async_state.start_seq = dpy->request + 1;
+ async_state.atoms = atoms;
+ async_state.names = names_return;
+ async_state.idx = 0;
+ async_state.count = count - 1;
+ async_state.status = 1;
+ async.next = dpy->async_handlers;
+ async.handler = _XGetAtomNameHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ for (i = 0; i < count; i++) {
+ if (!(names_return[i] = _XGetAtomName(dpy, atoms[i]))) {
+ missed = i;
+ async_state.stop_seq = dpy->request;
+ }
+ }
+ if (missed >= 0) {
+ if (_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ if ((names_return[missed] = (char *) Xmalloc(rep.nameLength+1))) {
+ _XReadPad(dpy, names_return[missed], (long)rep.nameLength);
+ names_return[missed][rep.nameLength] = '\0';
+ _XUpdateAtomCache(dpy, names_return[missed], atoms[missed],
+ 0, -1, 0);
+ } else {
+ _XEatData(dpy, (unsigned long) (rep.nameLength + 3) & ~3);
+ async_state.status = 0;
+ }
+ }
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ if (missed >= 0)
+ SyncHandle();
+ return async_state.status;
+}
diff --git a/src/GetColor.c b/src/GetColor.c
new file mode 100644
index 00000000..b469b5d4
--- /dev/null
+++ b/src/GetColor.c
@@ -0,0 +1,111 @@
+/* $Xorg: GetColor.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+
+#if NeedFunctionPrototypes
+Status XAllocNamedColor(
+register Display *dpy,
+Colormap cmap,
+_Xconst char *colorname, /* STRING8 */
+XColor *hard_def, /* RETURN */
+XColor *exact_def) /* RETURN */
+#else
+Status XAllocNamedColor(dpy, cmap, colorname, hard_def, exact_def)
+register Display *dpy;
+Colormap cmap;
+char *colorname; /* STRING8 */
+XColor *hard_def; /* RETURN */
+XColor *exact_def; /* RETURN */
+#endif
+{
+
+ long nbytes;
+ xAllocNamedColorReply rep;
+ xAllocNamedColorReq *req;
+
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+ Status ret;
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ /* copy string to allow overwrite by _XcmsResolveColorString() */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &colorname, &cmsColor_exact,
+ XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, exact_def, 1);
+ memcpy((char *)hard_def, (char *)exact_def, sizeof(XColor));
+ ret = XAllocColor(dpy, cmap, hard_def);
+ exact_def->pixel = hard_def->pixel;
+ return(ret);
+ }
+ /*
+ * Otherwise we failed; or colorname was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+ /*
+ * Xcms and i18n approach failed.
+ */
+ LockDisplay(dpy);
+ GetReq(AllocNamedColor, req);
+
+ req->cmap = cmap;
+ nbytes = req->nbytes = strlen(colorname);
+ req->length += (nbytes + 3) >> 2; /* round up to mult of 4 */
+
+ _XSend(dpy, colorname, nbytes);
+ /* _XSend is more efficient that Data, since _XReply follows */
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ exact_def->red = rep.exactRed;
+ exact_def->green = rep.exactGreen;
+ exact_def->blue = rep.exactBlue;
+
+ hard_def->red = rep.screenRed;
+ hard_def->green = rep.screenGreen;
+ hard_def->blue = rep.screenBlue;
+
+ exact_def->pixel = hard_def->pixel = rep.pixel;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
diff --git a/src/GetDflt.c b/src/GetDflt.c
new file mode 100644
index 00000000..6e05abd4
--- /dev/null
+++ b/src/GetDflt.c
@@ -0,0 +1,247 @@
+/* $Xorg: GetDflt.c,v 1.6 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include <X11/Xresource.h>
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef PATH_MAX
+#ifdef WIN32
+#define PATH_MAX 512
+#else
+#include <sys/param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+#ifdef XTHREADS
+#include <X11/Xthreads.h>
+#endif
+#ifndef WIN32
+#define X_INCLUDE_PWD_H
+#define XOS_USE_XLIB_LOCKING
+#include <X11/Xos_r.h>
+#endif
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+/*ARGSUSED*/
+static char *GetHomeDir (dest, len)
+ char *dest;
+ int len;
+{
+#ifdef WIN32
+ register char *ptr1;
+ register char *ptr2;
+ int len1 = 0, len2 = 0;
+
+ if (ptr1 = getenv("HOME")) { /* old, deprecated */
+ len1 = strlen (ptr1);
+ } else if ((ptr1 = getenv("HOMEDRIVE")) && (ptr2 = getenv("HOMEDIR"))) {
+ len1 = strlen (ptr1);
+ len2 = strlen (ptr2);
+ } else if (ptr2 = getenv("USERNAME")) {
+ len1 = strlen (ptr1 = "/users/");
+ len2 = strlen (ptr2);
+ }
+ if ((len1 + len2 + 1) < len)
+ sprintf (dest, "%s%s", ptr1, (ptr2) ? ptr2 : "");
+ else
+ *dest = '\0';
+#else
+ _Xgetpwparams pwparams;
+ struct passwd *pw;
+ register char *ptr;
+
+ if (len <= 0 || dest == NULL)
+ return NULL;
+
+ if ((ptr = getenv("HOME"))) {
+ (void) strncpy(dest, ptr, len);
+ dest[len-1] = '\0';
+ } else {
+ if ((ptr = getenv("USER")))
+ pw = _XGetpwnam(ptr,pwparams);
+ else
+ pw = _XGetpwuid(getuid(),pwparams);
+ if (pw != NULL) {
+ (void) strncpy(dest, pw->pw_dir, len);
+ dest[len-1] = '\0';
+ } else
+ *dest = '\0';
+ }
+#endif
+ return dest;
+}
+
+
+static XrmDatabase InitDefaults (dpy)
+ Display *dpy; /* display for defaults.... */
+{
+ XrmDatabase userdb;
+ XrmDatabase xdb;
+ char fname[PATH_MAX]; /* longer than any conceivable size */
+ char *xenv;
+
+ XrmInitialize();
+
+ /*
+ * See lib/Xt/Initialize.c
+ *
+ * First, get the defaults from the server; if none, then load from
+ * ~/.Xdefaults. Next, if there is an XENVIRONMENT environment variable,
+ * then load that file.
+ */
+
+ if (dpy->xdefaults == NULL) {
+ char *slashDotXdefaults = "/.Xdefaults";
+
+ (void) GetHomeDir (fname, PATH_MAX - strlen (slashDotXdefaults) - 1);
+ (void) strcat (fname, slashDotXdefaults);
+ xdb = XrmGetFileDatabase (fname);
+ } else {
+ xdb = XrmGetStringDatabase(dpy->xdefaults);
+ }
+
+ if (!(xenv = getenv ("XENVIRONMENT"))) {
+ char *slashDotXdefaultsDash = "/.Xdefaults-";
+ int len;
+
+ (void) GetHomeDir (fname, PATH_MAX - strlen (slashDotXdefaultsDash) - 1);
+ (void) strcat (fname, slashDotXdefaultsDash);
+ len = strlen (fname);
+ (void) _XGetHostname (fname+len, PATH_MAX-len);
+ xenv = fname;
+ }
+ userdb = XrmGetFileDatabase (xenv);
+ XrmMergeDatabases (userdb, &xdb);
+ return (xdb);
+
+#ifdef old
+ if (fname[0] != '\0') userdb = XrmGetFileDatabase(fname);
+ xdb = XrmGetStringDatabase(dpy->xdefaults);
+ XrmMergeDatabases(userdb, &xdb);
+ return xdb;
+#endif
+}
+
+#if NeedFunctionPrototypes
+char *XGetDefault(
+ Display *dpy, /* display for defaults.... */
+ char _Xconst *prog, /* name of program for option */
+ register _Xconst char *name) /* name of option program wants */
+#else
+char *XGetDefault(dpy, prog, name)
+ Display *dpy; /* display for defaults.... */
+ char *prog; /* name of program for option */
+ register char *name; /* name of option program wants */
+#endif
+{ /* to get, for example, "font" */
+ XrmName names[3];
+ XrmClass classes[3];
+ XrmRepresentation fromType;
+ XrmValue result;
+ char *progname;
+#ifdef WIN32
+ char *progname2;
+#endif
+
+ /*
+ * strip path off of program name (XXX - this is OS specific)
+ */
+ progname = strrchr (prog, '/');
+#ifdef WIN32
+ progname2 = strrchr (prog, '\\');
+ if (progname2 && (!progname || progname < progname2))
+ progname = progname2;
+#endif
+ if (progname)
+ progname++;
+ else
+ progname = (char *)prog;
+
+ /*
+ * see if database has ever been initialized. Lookups can be done
+ * without locks held.
+ */
+ LockDisplay(dpy);
+ if (dpy->db == NULL) {
+ dpy->db = InitDefaults(dpy);
+ }
+ UnlockDisplay(dpy);
+
+ names[0] = XrmStringToName(progname);
+ names[1] = XrmStringToName(name);
+ names[2] = NULLQUARK;
+ classes[0] = XrmStringToClass("Program");
+ classes[1] = XrmStringToClass("Name");
+ classes[2] = NULLQUARK;
+ (void)XrmQGetResource(dpy->db, names, classes, &fromType, &result);
+ return (result.addr);
+}
+
diff --git a/src/GetFPath.c b/src/GetFPath.c
new file mode 100644
index 00000000..69dd809c
--- /dev/null
+++ b/src/GetFPath.c
@@ -0,0 +1,90 @@
+/* $Xorg: GetFPath.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+char **XGetFontPath(dpy, npaths)
+register Display *dpy;
+int *npaths; /* RETURN */
+{
+ xGetFontPathReply rep;
+ register long nbytes;
+ char **flist;
+ char *ch;
+ register unsigned i;
+ register int length;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq (GetFontPath, req);
+ (void) _XReply (dpy, (xReply *) &rep, 0, xFalse);
+
+ if (rep.nPaths) {
+ flist = (char **)
+ Xmalloc((unsigned) rep.nPaths * sizeof (char *));
+ nbytes = (long)rep.length << 2;
+ ch = (char *) Xmalloc ((unsigned) (nbytes + 1));
+ /* +1 to leave room for last null-terminator */
+
+ if ((! flist) || (! ch)) {
+ if (flist) Xfree((char *) flist);
+ if (ch) Xfree(ch);
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, nbytes);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *ch;
+ for (i = 0; i < rep.nPaths; i++) {
+ flist[i] = ch+1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else flist = NULL;
+ *npaths = rep.nPaths;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (flist);
+}
+
+XFreeFontPath (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/GetFProp.c b/src/GetFProp.c
new file mode 100644
index 00000000..f588c2f0
--- /dev/null
+++ b/src/GetFProp.c
@@ -0,0 +1,53 @@
+/* $Xorg: GetFProp.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+Bool XGetFontProperty (fs, name, valuePtr)
+ XFontStruct *fs;
+ register Atom name;
+ unsigned long *valuePtr;
+ {
+ /* XXX this is a simple linear search for now. If the
+ protocol is changed to sort the property list, this should
+ become a binary search. */
+ register XFontProp *prop = fs->properties;
+ register XFontProp *last = prop + fs->n_properties;
+ while (prop != last) {
+ if (prop->name == name) {
+ *valuePtr = prop->card32;
+ return (1);
+ }
+ prop++;
+ }
+ return (0);
+ }
+
+
+
+
+
diff --git a/src/GetGCVals.c b/src/GetGCVals.c
new file mode 100644
index 00000000..e8875869
--- /dev/null
+++ b/src/GetGCVals.c
@@ -0,0 +1,126 @@
+/* $Xorg: GetGCVals.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/*
+ * All gc fields except GCClipMask and GCDashList
+ */
+#define ValidGCValuesBits (GCFunction | GCPlaneMask | GCForeground | \
+ GCBackground | GCLineWidth | GCLineStyle | \
+ GCCapStyle | GCJoinStyle | GCFillStyle | \
+ GCFillRule | GCTile | GCStipple | \
+ GCTileStipXOrigin | GCTileStipYOrigin | \
+ GCFont | GCSubwindowMode | GCGraphicsExposures | \
+ GCClipXOrigin | GCClipYOrigin | GCDashOffset | \
+ GCArcMode)
+
+/*ARGSUSED*/
+Status XGetGCValues (dpy, gc, valuemask, values)
+ Display *dpy;
+ GC gc;
+ unsigned long valuemask;
+ XGCValues *values;
+{
+ if (valuemask == ValidGCValuesBits) {
+ char dashes = values->dashes;
+ Pixmap clip_mask = values->clip_mask;
+ *values = gc->values;
+ values->dashes = dashes;
+ values->clip_mask = clip_mask;
+ return True;
+ }
+
+ if (valuemask & ~ValidGCValuesBits) return False;
+
+ if (valuemask & GCFunction)
+ values->function = gc->values.function;
+
+ if (valuemask & GCPlaneMask)
+ values->plane_mask = gc->values.plane_mask;
+
+ if (valuemask & GCForeground)
+ values->foreground = gc->values.foreground;
+
+ if (valuemask & GCBackground)
+ values->background = gc->values.background;
+
+ if (valuemask & GCLineWidth)
+ values->line_width = gc->values.line_width;
+
+ if (valuemask & GCLineStyle)
+ values->line_style = gc->values.line_style;
+
+ if (valuemask & GCCapStyle)
+ values->cap_style = gc->values.cap_style;
+
+ if (valuemask & GCJoinStyle)
+ values->join_style = gc->values.join_style;
+
+ if (valuemask & GCFillStyle)
+ values->fill_style = gc->values.fill_style;
+
+ if (valuemask & GCFillRule)
+ values->fill_rule = gc->values.fill_rule;
+
+ if (valuemask & GCTile)
+ values->tile = gc->values.tile;
+
+ if (valuemask & GCStipple)
+ values->stipple = gc->values.stipple;
+
+ if (valuemask & GCTileStipXOrigin)
+ values->ts_x_origin = gc->values.ts_x_origin;
+
+ if (valuemask & GCTileStipYOrigin)
+ values->ts_y_origin = gc->values.ts_y_origin;
+
+ if (valuemask & GCFont)
+ values->font = gc->values.font;
+
+ if (valuemask & GCSubwindowMode)
+ values->subwindow_mode = gc->values.subwindow_mode;
+
+ if (valuemask & GCGraphicsExposures)
+ values->graphics_exposures = gc->values.graphics_exposures;
+
+ if (valuemask & GCClipXOrigin)
+ values->clip_x_origin = gc->values.clip_x_origin;
+
+ if (valuemask & GCClipYOrigin)
+ values->clip_y_origin = gc->values.clip_y_origin;
+
+ if (valuemask & GCDashOffset)
+
+ values->dash_offset = gc->values.dash_offset;
+
+ if (valuemask & GCArcMode)
+ values->arc_mode = gc->values.arc_mode;
+
+ return True;
+}
diff --git a/src/GetGeom.c b/src/GetGeom.c
new file mode 100644
index 00000000..367153f4
--- /dev/null
+++ b/src/GetGeom.c
@@ -0,0 +1,58 @@
+/* $Xorg: GetGeom.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XGetGeometry (dpy, d, root, x, y, width, height, borderWidth, depth)
+ register Display *dpy;
+ Drawable d;
+ Window *root; /* RETURN */
+ int *x, *y; /* RETURN */
+ unsigned int *width, *height, *borderWidth, *depth; /* RETURN */
+{
+ xGetGeometryReply rep;
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(GetGeometry, d, req);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ *root = rep.root;
+ *x = cvtINT16toInt (rep.x);
+ *y = cvtINT16toInt (rep.y);
+ *width = rep.width;
+ *height = rep.height;
+ *borderWidth = rep.borderWidth;
+ *depth = rep.depth;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
+
diff --git a/src/GetHColor.c b/src/GetHColor.c
new file mode 100644
index 00000000..33e6ad59
--- /dev/null
+++ b/src/GetHColor.c
@@ -0,0 +1,57 @@
+/* $Xorg: GetHColor.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XAllocColor(dpy, cmap, def)
+register Display *dpy;
+Colormap cmap;
+XColor *def;
+{
+ Status status;
+ xAllocColorReply rep;
+ register xAllocColorReq *req;
+ LockDisplay(dpy);
+ GetReq(AllocColor, req);
+
+ req->cmap = cmap;
+ req->red = def->red;
+ req->green = def->green;
+ req->blue = def->blue;
+
+ status = _XReply(dpy, (xReply *) &rep, 0, xTrue);
+ if (status) {
+ def->pixel = rep.pixel;
+ def->red = rep.red;
+ def->green = rep.green;
+ def->blue = rep.blue;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/GetHints.c b/src/GetHints.c
new file mode 100644
index 00000000..7958fd1f
--- /dev/null
+++ b/src/GetHints.c
@@ -0,0 +1,337 @@
+/* $Xorg: GetHints.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetSizeHints (dpy, w, hints, property)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom property;
+{
+ xPropSizeHints *prop = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ if (XGetWindowProperty(dpy, w, property, 0L,
+ (long) OldNumPropSizeElements,
+ False, XA_WM_SIZE_HINTS, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (0);
+
+ if ((actual_type != XA_WM_SIZE_HINTS) ||
+ (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(0);
+ }
+ hints->flags = (prop->flags & (USPosition|USSize|PAllHints));
+ hints->x = cvtINT32toInt (prop->x);
+ hints->y = cvtINT32toInt (prop->y);
+ hints->width = cvtINT32toInt (prop->width);
+ hints->height = cvtINT32toInt (prop->height);
+ hints->min_width = cvtINT32toInt (prop->minWidth);
+ hints->min_height = cvtINT32toInt (prop->minHeight);
+ hints->max_width = cvtINT32toInt (prop->maxWidth);
+ hints->max_height = cvtINT32toInt (prop->maxHeight);
+ hints->width_inc = cvtINT32toInt (prop->widthInc);
+ hints->height_inc = cvtINT32toInt (prop->heightInc);
+ hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
+ hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
+ hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
+ hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
+ Xfree((char *)prop);
+ return(1);
+}
+
+/*
+ * must return a pointer to the hint, in malloc'd memory, or routine is not
+ * extensible; any use of the caller's memory would cause things to be stepped
+ * on.
+ */
+
+XWMHints *XGetWMHints (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ xPropWMHints *prop = NULL;
+ register XWMHints *hints;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ if (XGetWindowProperty(dpy, w, XA_WM_HINTS,
+ 0L, (long)NumPropWMHintsElements,
+ False, XA_WM_HINTS, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (NULL);
+
+ /* If the property is undefined on the window, return null pointer. */
+ /* pre-R3 bogusly truncated window_group, don't fail on them */
+
+ if ((actual_type != XA_WM_HINTS) ||
+ (nitems < (NumPropWMHintsElements - 1)) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(NULL);
+ }
+ /* static copies not allowed in library, due to reentrancy constraint*/
+ if ((hints = (XWMHints *) Xcalloc (1, (unsigned) sizeof(XWMHints)))) {
+ hints->flags = prop->flags;
+ hints->input = (prop->input ? True : False);
+ hints->initial_state = cvtINT32toInt (prop->initialState);
+ hints->icon_pixmap = prop->iconPixmap;
+ hints->icon_window = prop->iconWindow;
+ hints->icon_x = cvtINT32toInt (prop->iconX);
+ hints->icon_y = cvtINT32toInt (prop->iconY);
+ hints->icon_mask = prop->iconMask;
+ if (nitems >= NumPropWMHintsElements)
+ hints->window_group = prop->windowGroup;
+ else
+ hints->window_group = 0;
+ }
+ Xfree ((char *)prop);
+ return(hints);
+}
+
+Status
+XGetZoomHints (dpy, w, zhints)
+ Display *dpy;
+ Window w;
+ XSizeHints *zhints;
+{
+ return (XGetSizeHints(dpy, w, zhints, XA_WM_ZOOM_HINTS));
+}
+
+Status
+XGetNormalHints (dpy, w, hints)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ return (XGetSizeHints(dpy, w, hints, XA_WM_NORMAL_HINTS));
+}
+
+
+/*
+ * XGetIconSizes reads the property
+ * ICONSIZE_ATOM type: ICONSIZE_ATOM format: 32
+ */
+
+Status XGetIconSizes (dpy, w, size_list, count)
+ Display *dpy;
+ Window w; /* typically, root */
+ XIconSize **size_list; /* RETURN */
+ int *count; /* RETURN number of items on the list */
+{
+ xPropIconSize *prop = NULL;
+ register xPropIconSize *pp;
+ register XIconSize *hp, *hints;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+ register int i;
+
+ if (XGetWindowProperty(dpy, w, XA_WM_ICON_SIZE, 0L, 60L,
+ False, XA_WM_ICON_SIZE, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&prop)
+ != Success) return (0);
+
+ pp = prop;
+
+ if ((actual_type != XA_WM_ICON_SIZE) ||
+ (nitems < NumPropIconSizeElements) ||
+ (nitems % NumPropIconSizeElements != 0) ||
+ (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return(0);
+ }
+
+ /* static copies not allowed in library, due to reentrancy constraint*/
+
+ nitems /= NumPropIconSizeElements;
+ if (! (hp = hints = (XIconSize *)
+ Xcalloc ((unsigned) nitems, (unsigned) sizeof(XIconSize)))) {
+ if (prop) Xfree ((char *) prop);
+ return 0;
+ }
+
+ /* march down array putting things into native form */
+ for (i = 0; i < nitems; i++) {
+ hp->min_width = cvtINT32toInt (pp->minWidth);
+ hp->min_height = cvtINT32toInt (pp->minHeight);
+ hp->max_width = cvtINT32toInt (pp->maxWidth);
+ hp->max_height = cvtINT32toInt (pp->maxHeight);
+ hp->width_inc = cvtINT32toInt (pp->widthInc);
+ hp->height_inc = cvtINT32toInt (pp->heightInc);
+ hp += 1;
+ pp += 1;
+ }
+ *count = nitems;
+ *size_list = hints;
+ Xfree ((char *)prop);
+ return(1);
+}
+
+
+Status XGetCommand (dpy, w, argvp, argcp)
+ Display *dpy;
+ Window w;
+ char ***argvp;
+ int *argcp;
+{
+ XTextProperty tp;
+ int argc;
+ char **argv;
+
+ if (!XGetTextProperty (dpy, w, &tp, XA_WM_COMMAND)) return 0;
+
+ if (tp.encoding != XA_STRING || tp.format != 8) {
+ if (tp.value) Xfree ((char *) tp.value);
+ return 0;
+ }
+
+
+ /*
+ * ignore final <NUL> if present since UNIX WM_COMMAND is nul-terminated
+ */
+ if (tp.nitems && (tp.value[tp.nitems - 1] == '\0')) tp.nitems--;
+
+
+ /*
+ * create a string list and return if successful
+ */
+ if (!XTextPropertyToStringList (&tp, &argv, &argc)) {
+ if (tp.value) Xfree ((char *) tp.value);
+ return (0);
+ }
+
+ if (tp.value) Xfree ((char *) tp.value);
+ *argvp = argv;
+ *argcp = argc;
+ return 1;
+}
+
+
+Status
+XGetTransientForHint(dpy, w, propWindow)
+ Display *dpy;
+ Window w;
+ Window *propWindow;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ Window *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_TRANSIENT_FOR, 0L, 1L, False,
+ XA_WINDOW,
+ &actual_type,
+ &actual_format, &nitems, &leftover, (unsigned char **) &data)
+ != Success) {
+ *propWindow = None;
+ return (0);
+ }
+ if ( (actual_type == XA_WINDOW) && (actual_format == 32) &&
+ (nitems != 0) ) {
+ *propWindow = *data;
+ Xfree( (char *) data);
+ return (1);
+ }
+ *propWindow = None;
+ if (data) Xfree( (char *) data);
+ return(0);
+}
+
+Status
+XGetClassHint(dpy, w, classhint)
+ Display *dpy;
+ Window w;
+ XClassHint *classhint; /* RETURN */
+{
+ int len_name, len_class;
+
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data = NULL;
+ if (XGetWindowProperty(dpy, w, XA_WM_CLASS, 0L, (long)BUFSIZ, False,
+ XA_STRING,
+ &actual_type,
+ &actual_format, &nitems, &leftover, &data) != Success)
+ return (0);
+
+ if ( (actual_type == XA_STRING) && (actual_format == 8) ) {
+ len_name = strlen((char *) data);
+ if (! (classhint->res_name = Xmalloc((unsigned) (len_name+1)))) {
+ Xfree((char *) data);
+ return (0);
+ }
+ strcpy(classhint->res_name, (char *) data);
+ if (len_name == nitems) len_name--;
+ len_class = strlen((char *) (data+len_name+1));
+ if (! (classhint->res_class = Xmalloc((unsigned) (len_class+1)))) {
+ Xfree(classhint->res_name);
+ classhint->res_name = (char *) NULL;
+ Xfree((char *) data);
+ return (0);
+ }
+ strcpy(classhint->res_class, (char *) (data+len_name+1));
+ Xfree( (char *) data);
+ return(1);
+ }
+ if (data) Xfree( (char *) data);
+ return(0);
+}
diff --git a/src/GetIFocus.c b/src/GetIFocus.c
new file mode 100644
index 00000000..7e2ca86c
--- /dev/null
+++ b/src/GetIFocus.c
@@ -0,0 +1,47 @@
+/* $Xorg: GetIFocus.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetInputFocus(dpy, focus, revert_to)
+ register Display *dpy;
+ Window *focus;
+ int *revert_to;
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *focus = rep.focus;
+ *revert_to = rep.revertTo;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetImage.c b/src/GetImage.c
new file mode 100644
index 00000000..ab665d81
--- /dev/null
+++ b/src/GetImage.c
@@ -0,0 +1,122 @@
+/* $Xorg: GetImage.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include <X11/Xutil.h> /* for XDestroyImage */
+
+#define ROUNDUP(nbytes, pad) (((((nbytes) - 1) + (pad)) / (pad)) * (pad))
+
+static unsigned int Ones(mask) /* HACKMEM 169 */
+ unsigned long mask;
+{
+ register unsigned long y;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ return ((unsigned int) (((y + (y >> 3)) & 030707070707) % 077));
+}
+
+XImage *XGetImage (dpy, d, x, y, width, height, plane_mask, format)
+ register Display *dpy;
+ Drawable d;
+ int x, y;
+ unsigned int width, height;
+ unsigned long plane_mask;
+ int format; /* either XYPixmap or ZPixmap */
+{
+ xGetImageReply rep;
+ register xGetImageReq *req;
+ char *data;
+ long nbytes;
+ XImage *image;
+ LockDisplay(dpy);
+ GetReq (GetImage, req);
+ /*
+ * first set up the standard stuff in the request
+ */
+ req->drawable = d;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->planeMask = plane_mask;
+ req->format = format;
+
+ if (_XReply (dpy, (xReply *) &rep, 0, xFalse) == 0 ||
+ rep.length == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XImage *)NULL;
+ }
+
+ nbytes = (long)rep.length << 2;
+ data = (char *) Xmalloc((unsigned) nbytes);
+ if (! data) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XImage *) NULL;
+ }
+ _XReadPad (dpy, data, nbytes);
+ if (format == XYPixmap)
+ image = XCreateImage(dpy, _XVIDtoVisual(dpy, rep.visual),
+ Ones (plane_mask &
+ (((unsigned long)0xFFFFFFFF) >> (32 - rep.depth))),
+ format, 0, data, width, height, dpy->bitmap_pad, 0);
+ else /* format == ZPixmap */
+ image = XCreateImage (dpy, _XVIDtoVisual(dpy, rep.visual),
+ rep.depth, ZPixmap, 0, data, width, height,
+ _XGetScanlinePad(dpy, (int) rep.depth), 0);
+
+ if (!image)
+ Xfree(data);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (image);
+}
+
+XImage *XGetSubImage(dpy, d, x, y, width, height, plane_mask, format,
+ dest_image, dest_x, dest_y)
+ register Display *dpy;
+ Drawable d;
+ int x, y;
+ unsigned int width, height;
+ unsigned long plane_mask;
+ int format; /* either XYPixmap or ZPixmap */
+ XImage *dest_image;
+ int dest_x, dest_y;
+{
+ XImage *temp_image;
+ temp_image = XGetImage(dpy, d, x, y, width, height,
+ plane_mask, format);
+ if (!temp_image)
+ return (XImage *)NULL;
+ _XSetImage(temp_image, dest_image, dest_x, dest_y);
+ XDestroyImage(temp_image);
+ return (dest_image);
+}
diff --git a/src/GetKCnt.c b/src/GetKCnt.c
new file mode 100644
index 00000000..d8fa69c9
--- /dev/null
+++ b/src/GetKCnt.c
@@ -0,0 +1,53 @@
+/* $Xorg: GetKCnt.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetKeyboardControl (dpy, state)
+ register Display *dpy;
+ register XKeyboardState *state;
+ {
+ xGetKeyboardControlReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq (GetKeyboardControl, req);
+ (void) _XReply (dpy, (xReply *) &rep,
+ (SIZEOF(xGetKeyboardControlReply) - SIZEOF(xReply)) >> 2, xTrue);
+
+ state->key_click_percent = rep.keyClickPercent;
+ state->bell_percent = rep.bellPercent;
+ state->bell_pitch = rep.bellPitch;
+ state->bell_duration = rep.bellDuration;
+ state->led_mask = rep.ledMask;
+ state->global_auto_repeat = rep.globalAutoRepeat;
+ memcpy (state->auto_repeats, rep.map, sizeof state->auto_repeats);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
diff --git a/src/GetMoEv.c b/src/GetMoEv.c
new file mode 100644
index 00000000..1bead38a
--- /dev/null
+++ b/src/GetMoEv.c
@@ -0,0 +1,83 @@
+/* $Xorg: GetMoEv.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XTimeCoord *XGetMotionEvents(dpy, w, start, stop, nEvents)
+ register Display *dpy;
+ Time start, stop;
+ Window w;
+ int *nEvents; /* RETURN */
+{
+ xGetMotionEventsReply rep;
+ register xGetMotionEventsReq *req;
+ XTimeCoord *tc = NULL;
+ long nbytes;
+ LockDisplay(dpy);
+ GetReq(GetMotionEvents, req);
+ req->window = w;
+/* XXX is this right for all machines? */
+ req->start = start;
+ req->stop = stop;
+ if (!_XReply (dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+
+ if (rep.nEvents) {
+ if (! (tc = (XTimeCoord *)
+ Xmalloc( (unsigned)
+ (nbytes = (long) rep.nEvents * sizeof(XTimeCoord))))) {
+ _XEatData (dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (NULL);
+ }
+ }
+
+ *nEvents = rep.nEvents;
+ nbytes = SIZEOF (xTimecoord);
+ {
+ register XTimeCoord *tcptr;
+ register int i;
+ xTimecoord xtc;
+
+ for (i = rep.nEvents, tcptr = tc; i > 0; i--, tcptr++) {
+ _XRead (dpy, (char *) &xtc, nbytes);
+ tcptr->time = xtc.time;
+ tcptr->x = cvtINT16toShort (xtc.x);
+ tcptr->y = cvtINT16toShort (xtc.y);
+ }
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (tc);
+}
+
diff --git a/src/GetNrmHint.c b/src/GetNrmHint.c
new file mode 100644
index 00000000..741d1531
--- /dev/null
+++ b/src/GetNrmHint.c
@@ -0,0 +1,125 @@
+/* $Xorg: GetNrmHint.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca,
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL DIGITAL OR WYSE 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.
+
+******************************************************************/
+
+/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include "Xatomtype.h"
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+Status XGetWMSizeHints (dpy, w, hints, supplied, property)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ long *supplied;
+ Atom property;
+{
+ xPropSizeHints *prop = NULL;
+ Atom actual_type;
+ int actual_format;
+ unsigned long leftover;
+ unsigned long nitems;
+
+ if (XGetWindowProperty (dpy, w, property, 0L,
+ (long)NumPropSizeElements,
+ False, XA_WM_SIZE_HINTS, &actual_type,
+ &actual_format, &nitems, &leftover,
+ (unsigned char **)&prop)
+ != Success)
+ return False;
+
+ if ((actual_type != XA_WM_SIZE_HINTS) ||
+ (nitems < OldNumPropSizeElements) || (actual_format != 32)) {
+ if (prop != NULL) Xfree ((char *)prop);
+ return False;
+ }
+
+ hints->flags = prop->flags;
+ /* XSizeHints misdeclares these as int instead of long */
+ hints->x = cvtINT32toInt (prop->x);
+ hints->y = cvtINT32toInt (prop->y);
+ hints->width = cvtINT32toInt (prop->width);
+ hints->height = cvtINT32toInt (prop->height);
+ hints->min_width = cvtINT32toInt (prop->minWidth);
+ hints->min_height = cvtINT32toInt (prop->minHeight);
+ hints->max_width = cvtINT32toInt (prop->maxWidth);
+ hints->max_height = cvtINT32toInt (prop->maxHeight);
+ hints->width_inc = cvtINT32toInt (prop->widthInc);
+ hints->height_inc = cvtINT32toInt (prop->heightInc);
+ hints->min_aspect.x = cvtINT32toInt (prop->minAspectX);
+ hints->min_aspect.y = cvtINT32toInt (prop->minAspectY);
+ hints->max_aspect.x = cvtINT32toInt (prop->maxAspectX);
+ hints->max_aspect.y = cvtINT32toInt (prop->maxAspectY);
+
+ *supplied = (USPosition | USSize | PAllHints);
+ if (nitems >= NumPropSizeElements) {
+ hints->base_width= cvtINT32toInt (prop->baseWidth);
+ hints->base_height= cvtINT32toInt (prop->baseHeight);
+ hints->win_gravity= cvtINT32toInt (prop->winGravity);
+ *supplied |= (PBaseSize | PWinGravity);
+ }
+ hints->flags &= (*supplied); /* get rid of unwanted bits */
+ Xfree((char *)prop);
+ return True;
+}
+
+
+Status XGetWMNormalHints (dpy, w, hints, supplied)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ long *supplied;
+{
+ return (XGetWMSizeHints (dpy, w, hints, supplied, XA_WM_NORMAL_HINTS));
+}
diff --git a/src/GetPCnt.c b/src/GetPCnt.c
new file mode 100644
index 00000000..54b84270
--- /dev/null
+++ b/src/GetPCnt.c
@@ -0,0 +1,49 @@
+/* $Xorg: GetPCnt.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetPointerControl(dpy, accel_numer, accel_denom, threshold)
+ register Display *dpy;
+ /* the following are return only vars */
+ int *accel_numer, *accel_denom;
+ int *threshold;
+{
+ xGetPointerControlReply rep;
+ xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetPointerControl, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *accel_numer = rep.accelNumerator;
+ *accel_denom = rep.accelDenominator;
+ *threshold = rep.threshold;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetPntMap.c b/src/GetPntMap.c
new file mode 100644
index 00000000..9af3a57c
--- /dev/null
+++ b/src/GetPntMap.c
@@ -0,0 +1,127 @@
+/* $Xorg: GetPntMap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#ifdef MIN /* some systems define this in <sys/param.h> */
+#undef MIN
+#endif
+#define MIN(a, b) ((a) < (b) ? (a) : (b))
+
+int XGetPointerMapping (dpy, map, nmaps)
+ register Display *dpy;
+ unsigned char *map; /* RETURN */
+ int nmaps;
+
+{
+ unsigned char mapping[256]; /* known fixed size */
+ long nbytes, remainder = 0;
+ xGetPointerMappingReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetPointerMapping, req);
+ if (! _XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
+ nbytes = (long)rep.length << 2;
+
+ if (nbytes > sizeof mapping) {
+ remainder = nbytes - sizeof mapping;
+ nbytes = sizeof mapping;
+ }
+ _XRead (dpy, (char *)mapping, nbytes);
+ /* don't return more data than the user asked for. */
+ if (rep.nElts) {
+ memcpy ((char *) map, (char *) mapping,
+ MIN((int)rep.nElts, nmaps) );
+ }
+
+ if (remainder)
+ _XEatData(dpy, (unsigned long)remainder);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.nElts);
+}
+
+#if NeedFunctionPrototypes
+KeySym *XGetKeyboardMapping (Display *dpy,
+#if NeedWidePrototypes
+ unsigned int first_keycode,
+#else
+ KeyCode first_keycode,
+#endif
+ int count,
+ int *keysyms_per_keycode)
+#else
+KeySym *XGetKeyboardMapping (dpy, first_keycode, count, keysyms_per_keycode)
+ register Display *dpy;
+ KeyCode first_keycode;
+ int count;
+ int *keysyms_per_keycode; /* RETURN */
+#endif
+{
+ long nbytes;
+ unsigned long nkeysyms;
+ register KeySym *mapping = NULL;
+ xGetKeyboardMappingReply rep;
+ register xGetKeyboardMappingReq *req;
+
+ LockDisplay(dpy);
+ GetReq(GetKeyboardMapping, req);
+ req->firstKeyCode = first_keycode;
+ req->count = count;
+ if (! _XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+
+ nkeysyms = (unsigned long) rep.length;
+ if (nkeysyms > 0) {
+ nbytes = nkeysyms * sizeof (KeySym);
+ mapping = (KeySym *) Xmalloc ((unsigned) nbytes);
+ nbytes = nkeysyms << 2;
+ if (! mapping) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (KeySym *) NULL;
+ }
+ _XRead32 (dpy, (char *) mapping, nbytes);
+ }
+ *keysyms_per_keycode = rep.keySymsPerKeyCode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (mapping);
+}
+
diff --git a/src/GetProp.c b/src/GetProp.c
new file mode 100644
index 00000000..ac8ef1c5
--- /dev/null
+++ b/src/GetProp.c
@@ -0,0 +1,129 @@
+/* $Xorg: GetProp.c,v 1.5 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+int
+XGetWindowProperty(dpy, w, property, offset, length, delete,
+ req_type, actual_type, actual_format, nitems, bytesafter, prop)
+ register Display *dpy;
+ Window w;
+ Atom property;
+ Bool delete;
+ Atom req_type;
+ Atom *actual_type; /* RETURN */
+ int *actual_format; /* RETURN 8, 16, or 32 */
+ long offset, length;
+ unsigned long *nitems; /* RETURN # of 8-, 16-, or 32-bit entities */
+ unsigned long *bytesafter; /* RETURN */
+ unsigned char **prop; /* RETURN */
+{
+ xGetPropertyReply reply;
+ register xGetPropertyReq *req;
+ xError error;
+
+ LockDisplay(dpy);
+ GetReq (GetProperty, req);
+ req->window = w;
+ req->property = property;
+ req->type = req_type;
+ req->delete = delete;
+ req->longOffset = offset;
+ req->longLength = length;
+ error.sequenceNumber = dpy->request;
+
+ if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1); /* not Success */
+ }
+
+ *prop = (unsigned char *) NULL;
+ if (reply.propertyType != None) {
+ long nbytes, netbytes;
+ switch (reply.format) {
+ /*
+ * One extra byte is malloced than is needed to contain the property
+ * data, but this last byte is null terminated and convenient for
+ * returning string properties, so the client doesn't then have to
+ * recopy the string to make it null terminated.
+ */
+ case 8:
+ nbytes = netbytes = reply.nItems;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XReadPad (dpy, (char *) *prop, netbytes);
+ break;
+
+ case 16:
+ nbytes = reply.nItems * sizeof (short);
+ netbytes = reply.nItems << 1;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XRead16Pad (dpy, (short *) *prop, netbytes);
+ break;
+
+ case 32:
+ nbytes = reply.nItems * sizeof (long);
+ netbytes = reply.nItems << 2;
+ if ((*prop = (unsigned char *) Xmalloc ((unsigned)nbytes + 1)))
+ _XRead32 (dpy, (long *) *prop, netbytes);
+ break;
+
+ default:
+ /*
+ * This part of the code should never be reached. If it is,
+ * the server sent back a property with an invalid format.
+ * This is a BadImplementation error.
+ */
+ {
+ /* sequence number stored above */
+ error.type = X_Error;
+ error.majorCode = X_GetProperty;
+ error.minorCode = 0;
+ error.errorCode = BadImplementation;
+ _XError(dpy, &error);
+ }
+ netbytes = 0L;
+ break;
+ }
+ if (! *prop) {
+ _XEatData(dpy, (unsigned long) netbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(BadAlloc); /* not Success */
+ }
+ (*prop)[nbytes] = '\0';
+ }
+ *actual_type = reply.propertyType;
+ *actual_format = reply.format;
+ *nitems = reply.nItems;
+ *bytesafter = reply.bytesAfter;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(Success);
+}
+
diff --git a/src/GetRGBCMap.c b/src/GetRGBCMap.c
new file mode 100644
index 00000000..bde36215
--- /dev/null
+++ b/src/GetRGBCMap.c
@@ -0,0 +1,133 @@
+/* $Xorg: GetRGBCMap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+Status XGetRGBColormaps (dpy, w, stdcmap, count, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap **stdcmap; /* RETURN */
+ int *count; /* RETURN */
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ register int i; /* iterator variable */
+ xPropStandardColormap *data = NULL; /* data read in from prop */
+ Atom actual_type; /* how the prop was actually stored */
+ int actual_format; /* ditto */
+ unsigned long leftover; /* how much was left over */
+ unsigned long nitems; /* number of 32bits read */
+ int ncmaps; /* number of structs this makes */
+ Bool old_style = False; /* if was too short */
+ VisualID def_visual = None; /* visual to use if prop too short */
+ XStandardColormap *cmaps; /* return value */
+
+
+ if (XGetWindowProperty (dpy, w, property, 0L, 1000000L, False,
+ XA_RGB_COLOR_MAP, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **)&data)
+ != Success)
+ return False;
+
+ /* if wrong type or format, or too small for us, then punt */
+ if ((actual_type != XA_RGB_COLOR_MAP) || (actual_format != 32) ||
+ (nitems < OldNumPropStandardColormapElements)) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ /*
+ * See how many properties were found; if pre-ICCCM then assume
+ * default visual and a kill id of 1.
+ */
+ if (nitems < NumPropStandardColormapElements) {
+ ncmaps = 1;
+ old_style = True;
+ if (nitems < (NumPropStandardColormapElements - 1)) {
+ Screen *sp = _XScreenOfWindow (dpy, w);
+
+ if (!sp) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+ def_visual = sp->root_visual->visualid;
+ }
+ } else {
+ /*
+ * make sure we have an integral number of colormaps
+ */
+ ncmaps = (nitems / NumPropStandardColormapElements);
+ if ((((unsigned long) ncmaps) * NumPropStandardColormapElements) !=
+ nitems) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+ }
+
+
+ /*
+ * allocate array
+ */
+ cmaps = (XStandardColormap *) Xmalloc (ncmaps *
+ sizeof (XStandardColormap));
+ if (!cmaps) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+
+ /*
+ * and fill it in, handling compatibility with pre-ICCCM short stdcmaps
+ */
+ {
+ register XStandardColormap *map;
+ register xPropStandardColormap *prop;
+
+ for (i = ncmaps, map = cmaps, prop = data; i > 0; i--, map++, prop++) {
+ map->colormap = prop->colormap;
+ map->red_max = prop->red_max;
+ map->red_mult = prop->red_mult;
+ map->green_max = prop->green_max;
+ map->green_mult = prop->green_mult;
+ map->blue_max = prop->blue_max;
+ map->blue_mult = prop->blue_mult;
+ map->base_pixel = prop->base_pixel;
+ map->visualid = (def_visual ? def_visual : prop->visualid);
+ map->killid = (old_style ? None : prop->killid);
+ }
+ }
+ Xfree ((char *) data);
+ *stdcmap = cmaps;
+ *count = ncmaps;
+ return True;
+}
+
diff --git a/src/GetSOwner.c b/src/GetSOwner.c
new file mode 100644
index 00000000..b9bacdfc
--- /dev/null
+++ b/src/GetSOwner.c
@@ -0,0 +1,44 @@
+/* $Xorg: GetSOwner.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Window XGetSelectionOwner(dpy, selection)
+register Display *dpy;
+Atom selection;
+{
+ xGetSelectionOwnerReply rep;
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(GetSelectionOwner, selection, req);
+
+ if (_XReply(dpy, (xReply *)&rep, 0, xTrue) == 0) rep.owner = None;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(rep.owner);
+}
diff --git a/src/GetSSaver.c b/src/GetSSaver.c
new file mode 100644
index 00000000..60a7ef08
--- /dev/null
+++ b/src/GetSSaver.c
@@ -0,0 +1,52 @@
+/* $Xorg: GetSSaver.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XGetScreenSaver(dpy, timeout, interval, prefer_blanking, allow_exp)
+ register Display *dpy;
+ /* the following are return only vars */
+ int *timeout, *interval;
+ int *prefer_blanking, *allow_exp; /*boolean */
+
+{
+ xGetScreenSaverReply rep;
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GetScreenSaver, req);
+
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *timeout = rep.timeout;
+ *interval = rep.interval;
+ *prefer_blanking = rep.preferBlanking;
+ *allow_exp = rep.allowExposures;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/GetStCmap.c b/src/GetStCmap.c
new file mode 100644
index 00000000..0674bcb8
--- /dev/null
+++ b/src/GetStCmap.c
@@ -0,0 +1,115 @@
+/* $Xorg: GetStCmap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+/*
+ * WARNING
+ *
+ * This is a pre-ICCCM routine. It must not reference any of the new fields
+ * in the XStandardColormap structure.
+ */
+
+Status XGetStandardColormap (dpy, w, cmap, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmap;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ Status stat; /* return value */
+ XStandardColormap *stdcmaps; /* will get malloced value */
+ int nstdcmaps; /* count of above */
+
+ stat = XGetRGBColormaps (dpy, w, &stdcmaps, &nstdcmaps, property);
+ if (stat) {
+ XStandardColormap *use;
+
+ if (nstdcmaps > 1) {
+ VisualID vid;
+ Screen *sp = _XScreenOfWindow (dpy, w);
+ int i;
+
+ if (!sp) {
+ if (stdcmaps) Xfree ((char *) stdcmaps);
+ return False;
+ }
+ vid = sp->root_visual->visualid;
+
+ for (i = 0; i < nstdcmaps; i++) {
+ if (stdcmaps[i].visualid == vid) break;
+ }
+
+ if (i == nstdcmaps) { /* not found */
+ Xfree ((char *) stdcmaps);
+ return False;
+ }
+ use = &stdcmaps[i];
+ } else {
+ use = stdcmaps;
+ }
+
+ /*
+ * assign only those fields which were in the pre-ICCCM version
+ */
+ cmap->colormap = use->colormap;
+ cmap->red_max = use->red_max;
+ cmap->red_mult = use->red_mult;
+ cmap->green_max = use->green_max;
+ cmap->green_mult = use->green_mult;
+ cmap->blue_max = use->blue_max;
+ cmap->blue_mult = use->blue_mult;
+ cmap->base_pixel = use->base_pixel;
+
+ Xfree ((char *) stdcmaps); /* don't need alloced memory */
+ }
+ return stat;
+}
diff --git a/src/GetTxtProp.c b/src/GetTxtProp.c
new file mode 100644
index 00000000..bbd62851
--- /dev/null
+++ b/src/GetTxtProp.c
@@ -0,0 +1,111 @@
+/* $Xorg: GetTxtProp.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
+
+ All Rights Reserved
+
+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 Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+Status XGetTextProperty (display, window, tp, property)
+ Display *display;
+ Window window;
+ XTextProperty *tp;
+ Atom property;
+{
+ Atom actual_type;
+ int actual_format = 0;
+ unsigned long nitems = 0L, leftover = 0L;
+ unsigned char *prop = NULL;
+
+ if (XGetWindowProperty (display, window, property, 0L, 1000000L, False,
+ AnyPropertyType, &actual_type, &actual_format,
+ &nitems, &leftover, &prop) == Success &&
+ actual_type != None) {
+ /* okay, fill it in */
+ tp->value = prop;
+ tp->encoding = actual_type;
+ tp->format = actual_format;
+ tp->nitems = nitems;
+ return True;
+ }
+
+ tp->value = NULL;
+ tp->encoding = None;
+ tp->format = 0;
+ tp->nitems = 0;
+ return False;
+}
+
+Status XGetWMName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_NAME));
+}
+
+Status XGetWMIconName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_ICON_NAME));
+}
+
+Status XGetWMClientMachine (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ return (XGetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE));
+}
+
diff --git a/src/GetWAttrs.c b/src/GetWAttrs.c
new file mode 100644
index 00000000..7856b6f0
--- /dev/null
+++ b/src/GetWAttrs.c
@@ -0,0 +1,144 @@
+/* $Xorg: GetWAttrs.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+typedef struct _WAttrsState {
+ unsigned long attr_seq;
+ unsigned long geom_seq;
+ XWindowAttributes *attr;
+} _XWAttrsState;
+
+static Bool
+_XWAttrsHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XWAttrsState *state;
+ xGetWindowAttributesReply replbuf;
+ register xGetWindowAttributesReply *repl;
+ register XWindowAttributes *attr;
+
+ state = (_XWAttrsState *)data;
+ if (dpy->last_request_read != state->attr_seq) {
+ if (dpy->last_request_read == state->geom_seq &&
+ !state->attr &&
+ rep->generic.type == X_Error &&
+ rep->error.errorCode == BadDrawable)
+ return True;
+ return False;
+ }
+ if (rep->generic.type == X_Error) {
+ state->attr = (XWindowAttributes *)NULL;
+ return False;
+ }
+ repl = (xGetWindowAttributesReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xGetWindowAttributesReply) - SIZEOF(xReply)) >> 2,
+ True);
+ attr = state->attr;
+ attr->class = repl->class;
+ attr->bit_gravity = repl->bitGravity;
+ attr->win_gravity = repl->winGravity;
+ attr->backing_store = repl->backingStore;
+ attr->backing_planes = repl->backingBitPlanes;
+ attr->backing_pixel = repl->backingPixel;
+ attr->save_under = repl->saveUnder;
+ attr->colormap = repl->colormap;
+ attr->map_installed = repl->mapInstalled;
+ attr->map_state = repl->mapState;
+ attr->all_event_masks = repl->allEventMasks;
+ attr->your_event_mask = repl->yourEventMask;
+ attr->do_not_propagate_mask = repl->doNotPropagateMask;
+ attr->override_redirect = repl->override;
+ attr->visual = _XVIDtoVisual (dpy, repl->visualID);
+ return True;
+}
+
+Status XGetWindowAttributes(dpy, w, attr)
+ register Display *dpy;
+ Window w;
+ XWindowAttributes *attr;
+{
+ xGetGeometryReply rep;
+ register xResourceReq *req;
+ register int i;
+ register Screen *sp;
+ _XAsyncHandler async;
+ _XWAttrsState async_state;
+
+ LockDisplay(dpy);
+ GetResReq(GetWindowAttributes, w, req);
+
+ async_state.attr_seq = dpy->request;
+ async_state.geom_seq = 0;
+ async_state.attr = attr;
+ async.next = dpy->async_handlers;
+ async.handler = _XWAttrsHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+
+ GetResReq(GetGeometry, w, req);
+
+ async_state.geom_seq = dpy->request;
+
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (!async_state.attr) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ attr->x = cvtINT16toInt (rep.x);
+ attr->y = cvtINT16toInt (rep.y);
+ attr->width = rep.width;
+ attr->height = rep.height;
+ attr->border_width = rep.borderWidth;
+ attr->depth = rep.depth;
+ attr->root = rep.root;
+ /* find correct screen so that applications find it easier.... */
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ if (sp->root == attr->root) {
+ attr->screen = sp;
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(1);
+}
+
diff --git a/src/GetWMCMapW.c b/src/GetWMCMapW.c
new file mode 100644
index 00000000..6c56a136
--- /dev/null
+++ b/src/GetWMCMapW.c
@@ -0,0 +1,85 @@
+/* $Xorg: GetWMCMapW.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetWMColormapWindows (dpy, w, colormapWindows, countReturn)
+ Display *dpy;
+ Window w;
+ Window **colormapWindows;
+ int *countReturn;
+{
+ Atom *data = NULL;
+ Atom actual_type;
+ Atom prop;
+ int actual_format;
+ unsigned long leftover, nitems;
+
+ prop = XInternAtom(dpy, "WM_COLORMAP_WINDOWS", False);
+ if (prop == None) return False;
+
+ /* get the property */
+ if (XGetWindowProperty (dpy, w, prop,
+ 0L, 1000000L, False,
+ XA_WINDOW, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **) &data)
+ != Success)
+ return False;
+
+ if (actual_type != XA_WINDOW || actual_format != 32) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ *colormapWindows = (Window *) data;
+ *countReturn = (int) nitems;
+ return True;
+}
diff --git a/src/GetWMProto.c b/src/GetWMProto.c
new file mode 100644
index 00000000..84e79b60
--- /dev/null
+++ b/src/GetWMProto.c
@@ -0,0 +1,85 @@
+/* $Xorg: GetWMProto.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+Status XGetWMProtocols (dpy, w, protocols, countReturn)
+ Display *dpy;
+ Window w;
+ Atom **protocols;
+ int *countReturn;
+{
+ Atom *data = NULL;
+ Atom actual_type;
+ Atom prop;
+ int actual_format;
+ unsigned long leftover, nitems;
+
+ prop = XInternAtom(dpy, "WM_PROTOCOLS", False);
+ if (prop == None) return False;
+
+ /* get the property */
+ if (XGetWindowProperty (dpy, w, prop,
+ 0L, 1000000L, False,
+ XA_ATOM, &actual_type, &actual_format,
+ &nitems, &leftover, (unsigned char **) &data)
+ != Success)
+ return False;
+
+ if (actual_type != XA_ATOM || actual_format != 32) {
+ if (data) Xfree ((char *) data);
+ return False;
+ }
+
+ *protocols = (Atom *) data;
+ *countReturn = (int) nitems;
+ return True;
+}
diff --git a/src/GrButton.c b/src/GrButton.c
new file mode 100644
index 00000000..f0a8ebfb
--- /dev/null
+++ b/src/GrButton.c
@@ -0,0 +1,57 @@
+/* $Xorg: GrButton.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabButton(dpy, button, modifiers, grab_window, owner_events, event_mask,
+ pointer_mode, keyboard_mode, confine_to, curs)
+register Display *dpy;
+unsigned int modifiers; /* CARD16 */
+unsigned int button; /* CARD8 */
+Window grab_window;
+Bool owner_events;
+unsigned int event_mask; /* CARD16 */
+int pointer_mode, keyboard_mode;
+Window confine_to;
+Cursor curs;
+{
+ register xGrabButtonReq *req;
+ LockDisplay(dpy);
+ GetReq(GrabButton, req);
+ req->modifiers = modifiers;
+ req->button = button;
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->eventMask = event_mask;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ req->confineTo = confine_to;
+ req->cursor = curs;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/GrKey.c b/src/GrKey.c
new file mode 100644
index 00000000..4f339b75
--- /dev/null
+++ b/src/GrKey.c
@@ -0,0 +1,55 @@
+/* $Xorg: GrKey.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabKey(dpy, key, modifiers, grab_window, owner_events,
+ pointer_mode, keyboard_mode)
+ register Display *dpy;
+ int key;
+ unsigned int modifiers;
+ Window grab_window;
+ Bool owner_events;
+ int pointer_mode, keyboard_mode;
+
+{
+ register xGrabKeyReq *req;
+ LockDisplay(dpy);
+ GetReq(GrabKey, req);
+ req->ownerEvents = owner_events;
+ req->grabWindow = grab_window;
+ req->modifiers = modifiers;
+ req->key = key;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/src/GrKeybd.c b/src/GrKeybd.c
new file mode 100644
index 00000000..3f43f7ae
--- /dev/null
+++ b/src/GrKeybd.c
@@ -0,0 +1,56 @@
+/* $Xorg: GrKeybd.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+int XGrabKeyboard (dpy, window, ownerEvents, pointerMode, keyboardMode, time)
+ register Display *dpy;
+ Window window;
+ Bool ownerEvents;
+ int pointerMode, keyboardMode;
+ Time time;
+{
+ xGrabKeyboardReply rep;
+ register xGrabKeyboardReq *req;
+ register int status;
+ LockDisplay(dpy);
+ GetReq(GrabKeyboard, req);
+ req->grabWindow = window;
+ req->ownerEvents = ownerEvents;
+ req->pointerMode = pointerMode;
+ req->keyboardMode = keyboardMode;
+ req->time = time;
+
+ /* if we ever return, suppress the error */
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ status = rep.status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+}
+
diff --git a/src/GrPointer.c b/src/GrPointer.c
new file mode 100644
index 00000000..544337a9
--- /dev/null
+++ b/src/GrPointer.c
@@ -0,0 +1,63 @@
+/* $Xorg: GrPointer.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+int XGrabPointer(dpy, grab_window, owner_events, event_mask, pointer_mode,
+ keyboard_mode, confine_to, curs, time)
+register Display *dpy;
+Window grab_window;
+Bool owner_events;
+unsigned int event_mask; /* CARD16 */
+int pointer_mode, keyboard_mode;
+Window confine_to;
+Cursor curs;
+Time time;
+{
+ xGrabPointerReply rep;
+ register xGrabPointerReq *req;
+ register int status;
+ LockDisplay(dpy);
+ GetReq(GrabPointer, req);
+ req->grabWindow = grab_window;
+ req->ownerEvents = owner_events;
+ req->eventMask = event_mask;
+ req->pointerMode = pointer_mode;
+ req->keyboardMode = keyboard_mode;
+ req->confineTo = confine_to;
+ req->cursor = curs;
+ req->time = time;
+
+ /* if we ever return, suppress the error */
+ if (_XReply (dpy, (xReply *) &rep, 0, xTrue) == 0)
+ rep.status = GrabSuccess;
+ status = rep.status;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (status);
+}
diff --git a/src/GrServer.c b/src/GrServer.c
new file mode 100644
index 00000000..9dfc04ac
--- /dev/null
+++ b/src/GrServer.c
@@ -0,0 +1,40 @@
+/* $Xorg: GrServer.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XGrabServer (dpy)
+register Display *dpy;
+{
+ register xReq *req;
+ LockDisplay(dpy);
+ GetEmptyReq(GrabServer, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Host.c b/src/Host.c
new file mode 100644
index 00000000..863ff8ef
--- /dev/null
+++ b/src/Host.c
@@ -0,0 +1,91 @@
+/* $Xorg: Host.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* this might be rightly reguarded an os dependent file */
+
+#include "Xlibint.h"
+
+XAddHost (dpy, host)
+ register Display *dpy;
+ XHostAddress *host;
+ {
+ register xChangeHostsReq *req;
+ register int length = (host->length + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostInsert;
+ req->hostFamily = host->family;
+ req->hostLength = host->length;
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, host->length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+XRemoveHost (dpy, host)
+ register Display *dpy;
+ XHostAddress *host;
+ {
+ register xChangeHostsReq *req;
+ register int length = (host->length + 3) & ~0x3; /* round up */
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeHosts, length, req);
+ req->mode = HostDelete;
+ req->hostFamily = host->family;
+ req->hostLength = host->length;
+ memcpy((char *) NEXTPTR(req,xChangeHostsReq), host->address, host->length);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+XAddHosts (dpy, hosts, n)
+ register Display *dpy;
+ XHostAddress *hosts;
+ int n;
+{
+ register int i;
+ for (i = 0; i < n; i++) {
+ (void) XAddHost(dpy, &hosts[i]);
+ }
+ return 1;
+}
+
+XRemoveHosts (dpy, hosts, n)
+ register Display *dpy;
+ XHostAddress *hosts;
+ int n;
+{
+ register int i;
+ for (i = 0; i < n; i++) {
+ (void) XRemoveHost(dpy, &hosts[i]);
+ }
+ return 1;
+}
diff --git a/src/Iconify.c b/src/Iconify.c
new file mode 100644
index 00000000..b67b6602
--- /dev/null
+++ b/src/Iconify.c
@@ -0,0 +1,84 @@
+/* $Xorg: Iconify.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.
+
+ All Rights Reserved
+
+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 Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+/*
+ * This function instructs the window manager to change this window from
+ * NormalState to IconicState.
+ */
+Status XIconifyWindow (dpy, w, screen)
+ Display *dpy;
+ Window w;
+ int screen;
+{
+ XClientMessageEvent ev;
+ Window root = RootWindow (dpy, screen);
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_CHANGE_STATE", False);
+ if (prop == None) return False;
+
+ ev.type = ClientMessage;
+ ev.window = w;
+ ev.message_type = prop;
+ ev.format = 32;
+ ev.data.l[0] = IconicState;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/src/IfEvent.c b/src/IfEvent.c
new file mode 100644
index 00000000..975d77a1
--- /dev/null
+++ b/src/IfEvent.c
@@ -0,0 +1,72 @@
+/* $Xorg: IfEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Flush output and (wait for and) return the next event matching the
+ * predicate in the queue.
+ */
+
+XIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+#endif
+ ); /* function to call */
+ register XEvent *event;
+ char *arg;
+{
+ register _XQEvent *qelt, *prev;
+ unsigned long qe_serial = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if(qelt->qserial_num > qe_serial
+ && (*predicate)(dpy, &qelt->event, arg)) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ _XReadEvents(dpy);
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+}
diff --git a/src/ImText.c b/src/ImText.c
new file mode 100644
index 00000000..45f17983
--- /dev/null
+++ b/src/ImText.c
@@ -0,0 +1,109 @@
+/* $Xorg: ImText.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawImageString(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *string,
+ int length)
+#else
+XDrawImageString(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ char *string;
+ int length;
+#endif
+{
+ register xImageText8Req *req;
+ char *CharacterOffset = (char *)string;
+ int FirstTimeThrough = True;
+ int lastX = 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ while (length > 0)
+ {
+ int Unit;
+
+ if (length > 255) Unit = 255;
+ else Unit = length;
+
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ }
+ else
+ {
+ char buf[512];
+ char *ptr, *str;
+ xQueryTextExtentsReq *qreq;
+ xQueryTextExtentsReply rep;
+ int i;
+
+ GetReq(QueryTextExtents, qreq);
+ qreq->fid = gc->gid;
+ qreq->length += (510 + 3)>>2;
+ qreq->oddLength = 1;
+ str = CharacterOffset - 255;
+ for (ptr = buf, i = 255; --i >= 0; ) {
+ *ptr++ = 0;
+ *ptr++ = *str++;
+ }
+ Data (dpy, buf, 510);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
+ break;
+
+ x = lastX + cvtINT32toInt (rep.overallWidth);
+ }
+
+ GetReq (ImageText8, req);
+ req->length += (Unit + 3) >> 2;
+ req->nChars = Unit;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->y = y;
+
+ lastX = req->x = x;
+ Data (dpy, CharacterOffset, (long)Unit);
+ CharacterOffset += Unit;
+ length -= Unit;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/src/ImText16.c b/src/ImText16.c
new file mode 100644
index 00000000..fdc171ad
--- /dev/null
+++ b/src/ImText16.c
@@ -0,0 +1,111 @@
+/* $Xorg: ImText16.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawImageString16(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst XChar2b *string,
+ int length)
+#else
+XDrawImageString16(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XChar2b *string;
+ int length;
+#endif
+{
+ register xImageText16Req *req;
+ XChar2b *CharacterOffset = (XChar2b *)string;
+ int FirstTimeThrough = True;
+ int lastX = 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ while (length > 0)
+ {
+ int Unit, Datalength;
+
+ if (length > 255) Unit = 255;
+ else Unit = length;
+
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ }
+ else
+ {
+ char buf[512];
+ xQueryTextExtentsReq *qreq;
+ xQueryTextExtentsReply rep;
+ unsigned char *ptr;
+ XChar2b *str;
+ int i;
+
+ GetReq(QueryTextExtents, qreq);
+ qreq->fid = gc->gid;
+ qreq->length += (510 + 3)>>2;
+ qreq->oddLength = 1;
+ str = CharacterOffset - 255;
+ for (ptr = (unsigned char *)buf, i = 255; --i >= 0; str++) {
+ *ptr++ = str->byte1;
+ *ptr++ = str->byte2;
+ }
+ Data (dpy, buf, 510);
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue))
+ break;
+
+ x = lastX + cvtINT32toInt (rep.overallWidth);
+ }
+
+ GetReq (ImageText16, req);
+ req->length += ((Unit << 1) + 3) >> 2;
+ req->nChars = Unit;
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->y = y;
+
+ lastX = req->x = x;
+ Datalength = Unit << 1;
+ Data (dpy, (char *)CharacterOffset, (long)Datalength);
+ CharacterOffset += Unit;
+ length -= Unit;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/src/ImUtil.c b/src/ImUtil.c
new file mode 100644
index 00000000..b358e511
--- /dev/null
+++ b/src/ImUtil.c
@@ -0,0 +1,1016 @@
+/* $Xorg: ImUtil.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+#if NeedFunctionPrototypes
+static int _XDestroyImage(XImage *);
+static unsigned long _XGetPixel(XImage *, int, int);
+static unsigned long _XGetPixel1(XImage *, int, int);
+static unsigned long _XGetPixel8(XImage *, int, int);
+static unsigned long _XGetPixel16(XImage *, int, int);
+static unsigned long _XGetPixel32(XImage *, int, int);
+static int _XPutPixel(XImage *, int, int, unsigned long);
+static int _XPutPixel1(XImage *, int, int, unsigned long);
+static int _XPutPixel8(XImage *, int, int, unsigned long);
+static int _XPutPixel16(XImage *, int, int, unsigned long);
+static int _XPutPixel32(XImage *, int, int, unsigned long);
+static XImage *_XSubImage(XImage *, int, int, unsigned int, unsigned int);
+static int _XAddPixel(XImage *, long);
+#endif
+
+static unsigned char Const _lomask[0x09] = { 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f, 0x7f, 0xff };
+static unsigned char Const _himask[0x09] = { 0xff, 0xfe, 0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00 };
+
+/* These two convenience routines return the scanline_pad and bits_per_pixel
+ associated with a specific depth of ZPixmap format image for a
+ display. */
+
+ _XGetScanlinePad(dpy, depth)
+ Display *dpy;
+ int depth;
+ {
+ register ScreenFormat *fmt = dpy->pixmap_format;
+ register int i;
+
+ for (i = dpy->nformats + 1; --i; ++fmt)
+ if (fmt->depth == depth)
+ return(fmt->scanline_pad);
+
+ return(dpy->bitmap_pad);
+ }
+
+ _XGetBitsPerPixel(dpy, depth)
+ Display *dpy;
+ int depth;
+ {
+ register ScreenFormat *fmt = dpy->pixmap_format;
+ register int i;
+
+ for (i = dpy->nformats + 1; --i; ++fmt)
+ if (fmt->depth == depth)
+ return(fmt->bits_per_pixel);
+ if (depth <= 4)
+ return 4;
+ if (depth <= 8)
+ return 8;
+ if (depth <= 16)
+ return 16;
+ return 32;
+ }
+
+
+/*
+ * This module provides rudimentary manipulation routines for image data
+ * structures. The functions provided are:
+ *
+ * XCreateImage Creates a default XImage data structure
+ * _XDestroyImage Deletes an XImage data structure
+ * _XGetPixel Reads a pixel from an image data structure
+ * _XGetPixel32 Reads a pixel from a 32-bit Z image data structure
+ * _XGetPixel16 Reads a pixel from a 16-bit Z image data structure
+ * _XGetPixel8 Reads a pixel from an 8-bit Z image data structure
+ * _XGetPixel1 Reads a pixel from an 1-bit image data structure
+ * _XPutPixel Writes a pixel into an image data structure
+ * _XPutPixel32 Writes a pixel into a 32-bit Z image data structure
+ * _XPutPixel16 Writes a pixel into a 16-bit Z image data structure
+ * _XPutPixel8 Writes a pixel into an 8-bit Z image data structure
+ * _XPutPixel1 Writes a pixel into an 1-bit image data structure
+ * _XSubImage Clones a new (sub)image from an existing one
+ * _XSetImage Writes an image data pattern into another image
+ * _XAddPixel Adds a constant value to every pixel in an image
+ *
+ * The logic contained in these routines makes several assumptions about
+ * the image data structures, and at least for current implementations
+ * these assumptions are believed to be true. They are:
+ *
+ * For all formats, bits_per_pixel is less than or equal to 32.
+ * For XY formats, bitmap_unit is always less than or equal to bitmap_pad.
+ * For XY formats, bitmap_unit is 8, 16, or 32 bits.
+ * For Z format, bits_per_pixel is 1, 4, 8, 16, 24, or 32 bits.
+ */
+static void _xynormalizeimagebits (bp, img)
+ register unsigned char *bp;
+ register XImage *img;
+{
+ register unsigned char c;
+
+ if (img->byte_order != img->bitmap_bit_order) {
+ switch (img->bitmap_unit) {
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+ }
+ if (img->bitmap_bit_order == MSBFirst)
+ _XReverse_Bytes (bp, img->bitmap_unit >> 3);
+}
+
+static void _znormalizeimagebits (bp, img)
+ register unsigned char *bp;
+ register XImage *img;
+{
+ register unsigned char c;
+ switch (img->bits_per_pixel) {
+
+ case 4:
+ *bp = ((*bp >> 4) & 0xF) | ((*bp << 4) & ~0xF);
+ break;
+
+ case 16:
+ c = *bp;
+ *bp = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+
+ case 24:
+ c = *(bp + 2);
+ *(bp + 2) = *bp;
+ *bp = c;
+ break;
+
+ case 32:
+ c = *(bp + 3);
+ *(bp + 3) = *bp;
+ *bp = c;
+ c = *(bp + 2);
+ *(bp + 2) = *(bp + 1);
+ *(bp + 1) = c;
+ break;
+ }
+}
+
+static void _putbits (src, dstoffset, numbits, dst)
+ register char *src; /* address of source bit string */
+ int dstoffset; /* bit offset into destination; range is 0-31 */
+ register int numbits;/* number of bits to copy to destination */
+ register char *dst; /* address of destination bit string */
+{
+ register unsigned char chlo, chhi;
+ int hibits;
+ dst = dst + (dstoffset >> 3);
+ dstoffset = dstoffset & 7;
+ hibits = 8 - dstoffset;
+ chlo = *dst & _lomask[dstoffset];
+ for (;;) {
+ chhi = (*src << dstoffset) & _himask[dstoffset];
+ if (numbits <= hibits) {
+ chhi = chhi & _lomask[dstoffset + numbits];
+ *dst = (*dst & _himask[dstoffset + numbits]) | chlo | chhi;
+ break;
+ }
+ *dst = chhi | chlo;
+ dst++;
+ numbits = numbits - hibits;
+ chlo = (unsigned char) (*src & _himask[hibits]) >> hibits;
+ src++;
+ if (numbits <= dstoffset) {
+ chlo = chlo & _lomask[numbits];
+ *dst = (*dst & _himask[numbits]) | chlo;
+ break;
+ }
+ numbits = numbits - dstoffset;
+ }
+}
+
+
+/*
+ * Macros
+ *
+ * The ROUNDUP macro rounds up a quantity to the specified boundary,
+ * then truncates to bytes.
+ *
+ * The XYNORMALIZE macro determines whether XY format data requires
+ * normalization and calls a routine to do so if needed. The logic in
+ * this module is designed for LSBFirst byte and bit order, so
+ * normalization is done as required to present the data in this order.
+ *
+ * The ZNORMALIZE macro performs byte and nibble order normalization if
+ * required for Z format data.
+ *
+ * The XYINDEX macro computes the index to the starting byte (char) boundary
+ * for a bitmap_unit containing a pixel with coordinates x and y for image
+ * data in XY format.
+ *
+ * The ZINDEX macro computes the index to the starting byte (char) boundary
+ * for a pixel with coordinates x and y for image data in ZPixmap format.
+ *
+ */
+
+#define ROUNDUP(nbytes, pad) ((((nbytes) + ((pad)-1)) / (pad)) * ((pad)>>3))
+
+#define XYNORMALIZE(bp, img) \
+ if ((img->byte_order == MSBFirst) || (img->bitmap_bit_order == MSBFirst)) \
+ _xynormalizeimagebits((unsigned char *)(bp), img)
+
+#define ZNORMALIZE(bp, img) \
+ if (img->byte_order == MSBFirst) \
+ _znormalizeimagebits((unsigned char *)(bp), img)
+
+#define XYINDEX(x, y, img) \
+ ((y) * img->bytes_per_line) + \
+ (((x) + img->xoffset) / img->bitmap_unit) * (img->bitmap_unit >> 3)
+
+#define ZINDEX(x, y, img) ((y) * img->bytes_per_line) + \
+ (((x) * img->bits_per_pixel) >> 3)
+
+/*
+ * This routine initializes the image object function pointers. The
+ * intent is to provide native (i.e. fast) routines for native format images
+ * only using the generic (i.e. slow) routines when fast ones don't exist.
+ * However, with the current rather botched external interface, clients may
+ * have to mung image attributes after the image gets created, so the fast
+ * routines always have to check to make sure the optimization is still
+ * valid, and reinit the functions if not.
+ */
+void _XInitImageFuncPtrs (image)
+ register XImage *image;
+{
+ image->f.create_image = XCreateImage;
+ image->f.destroy_image = _XDestroyImage;
+ if ((image->format == ZPixmap) && (image->bits_per_pixel == 8)) {
+ image->f.get_pixel = _XGetPixel8;
+ image->f.put_pixel = _XPutPixel8;
+ } else if (((image->bits_per_pixel | image->depth) == 1) &&
+ (image->byte_order == image->bitmap_bit_order)) {
+ image->f.get_pixel = _XGetPixel1;
+ image->f.put_pixel = _XPutPixel1;
+ } else if ((image->format == ZPixmap) &&
+ (image->bits_per_pixel == 32)) {
+ image->f.get_pixel = _XGetPixel32;
+ image->f.put_pixel = _XPutPixel32;
+ } else if ((image->format == ZPixmap) &&
+ (image->bits_per_pixel == 16)) {
+ image->f.get_pixel = _XGetPixel16;
+ image->f.put_pixel = _XPutPixel16;
+ } else {
+ image->f.get_pixel = _XGetPixel;
+ image->f.put_pixel = _XPutPixel;
+ }
+ image->f.sub_image = _XSubImage;
+/* image->f.set_image = _XSetImage;*/
+ image->f.add_pixel = _XAddPixel;
+}
+
+/*
+ * CreateImage
+ *
+ * Allocates the memory necessary for an XImage data structure.
+ * Initializes the structure with "default" values and returns XImage.
+ *
+ */
+
+XImage *XCreateImage (dpy, visual, depth, format, offset, data, width, height,
+ xpad, image_bytes_per_line)
+ register Display *dpy;
+ register Visual *visual;
+ unsigned int depth;
+ int format;
+ int offset; /*How many pixels from the start of the data does the
+ picture to be transmitted start?*/
+
+ char *data;
+ unsigned int width;
+ unsigned int height;
+ int xpad;
+ int image_bytes_per_line;
+ /*How many bytes between a pixel on one line and the pixel with
+ the same X coordinate on the next line? 0 means
+ XCreateImage can calculate it.*/
+{
+ register XImage *image;
+ int bits_per_pixel = 1;
+
+ if (depth == 0 || depth > 32 ||
+ (format != XYBitmap && format != XYPixmap && format != ZPixmap) ||
+ (format == XYBitmap && depth != 1) ||
+ (xpad != 8 && xpad != 16 && xpad != 32) ||
+ offset < 0 || image_bytes_per_line < 0)
+ return (XImage *) NULL;
+ if ((image = (XImage *) Xcalloc(1, (unsigned) sizeof(XImage))) == NULL)
+ return (XImage *) NULL;
+
+ image->width = width;
+ image->height = height;
+ image->format = format;
+ image->byte_order = dpy->byte_order;
+ image->bitmap_unit = dpy->bitmap_unit;
+ image->bitmap_bit_order = dpy->bitmap_bit_order;
+ if (visual != NULL) {
+ image->red_mask = visual->red_mask;
+ image->green_mask = visual->green_mask;
+ image->blue_mask = visual->blue_mask;
+ }
+ else {
+ image->red_mask = image->green_mask = image->blue_mask = 0;
+ }
+ if (format == ZPixmap)
+ {
+ bits_per_pixel = _XGetBitsPerPixel(dpy, (int) depth);
+ }
+
+ image->xoffset = offset;
+ image->bitmap_pad = xpad;
+ image->depth = depth;
+ image->data = data;
+ /*
+ * compute per line accelerator.
+ */
+ if (image_bytes_per_line == 0)
+ {
+ if (format == ZPixmap)
+ image->bytes_per_line =
+ ROUNDUP((bits_per_pixel * width), image->bitmap_pad);
+ else
+ image->bytes_per_line =
+ ROUNDUP((width + offset), image->bitmap_pad);
+ }
+ else image->bytes_per_line = image_bytes_per_line;
+
+ image->bits_per_pixel = bits_per_pixel;
+ image->obdata = NULL;
+ _XInitImageFuncPtrs (image);
+
+ return image;
+}
+
+Status XInitImage (image)
+ XImage *image;
+{
+ if (image->depth == 0 || image->depth > 32 ||
+ (image->format != XYBitmap &&
+ image->format != XYPixmap &&
+ image->format != ZPixmap) ||
+ (image->format == XYBitmap && image->depth != 1) ||
+ (image->bitmap_pad != 8 &&
+ image->bitmap_pad != 16 &&
+ image->bitmap_pad != 32) ||
+ image->xoffset < 0 || image->bytes_per_line < 0)
+ return 0;
+
+ /*
+ * compute per line accelerator.
+ */
+ if (image->bytes_per_line == 0)
+ {
+ if (image->format == ZPixmap)
+ image->bytes_per_line =
+ ROUNDUP((image->bits_per_pixel * image->width),
+ image->bitmap_pad);
+ else
+ image->bytes_per_line =
+ ROUNDUP((image->width + image->xoffset), image->bitmap_pad);
+ }
+
+ _XInitImageFuncPtrs (image);
+
+ return 1;
+}
+
+/*
+ * _DestroyImage
+ *
+ * Deallocates the memory associated with the ximage data structure.
+ * this version handles the case of the image data being malloc'd
+ * entirely by the library.
+ */
+
+static int _XDestroyImage (ximage)
+ XImage *ximage;
+
+{
+ if (ximage->data != NULL) Xfree((char *)ximage->data);
+ if (ximage->obdata != NULL) Xfree((char *)ximage->obdata);
+ Xfree((char *)ximage);
+ return 1;
+}
+
+
+/*
+ * GetPixel
+ *
+ * Returns the specified pixel. The X and Y coordinates are relative to
+ * the origin (upper left [0,0]) of the image. The pixel value is returned
+ * in normalized format, i.e. the LSB of the long is the LSB of the pixel.
+ * The algorithm used is:
+ *
+ * copy the source bitmap_unit or Zpixel into temp
+ * normalize temp if needed
+ * extract the pixel bits into return value
+ *
+ */
+
+static unsigned long Const low_bits_table[] = {
+ 0x00000000, 0x00000001, 0x00000003, 0x00000007,
+ 0x0000000f, 0x0000001f, 0x0000003f, 0x0000007f,
+ 0x000000ff, 0x000001ff, 0x000003ff, 0x000007ff,
+ 0x00000fff, 0x00001fff, 0x00003fff, 0x00007fff,
+ 0x0000ffff, 0x0001ffff, 0x0003ffff, 0x0007ffff,
+ 0x000fffff, 0x001fffff, 0x003fffff, 0x007fffff,
+ 0x00ffffff, 0x01ffffff, 0x03ffffff, 0x07ffffff,
+ 0x0fffffff, 0x1fffffff, 0x3fffffff, 0x7fffffff,
+ 0xffffffff
+};
+
+static unsigned long _XGetPixel (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+
+{
+ unsigned long pixel, px;
+ register char *src;
+ register char *dst;
+ register int i, j;
+ int bits, nbytes;
+ long plane;
+
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ src = &ximage->data[XYINDEX(x, y, ximage)];
+ dst = (char *)&pixel;
+ pixel = 0;
+ for (i = ximage->bitmap_unit >> 3; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&pixel, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = ((((char *)&pixel)[bits>>3])>>(bits&7)) & 1;
+ } else if (ximage->format == XYPixmap) {
+ pixel = 0;
+ plane = 0;
+ nbytes = ximage->bitmap_unit >> 3;
+ for (i = ximage->depth; --i >= 0; ) {
+ src = &ximage->data[XYINDEX(x, y, ximage)+ plane];
+ dst = (char *)&px;
+ px = 0;
+ for (j = nbytes; --j >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ bits = (x + ximage->xoffset) % ximage->bitmap_unit;
+ pixel = (pixel << 1) |
+ (((((char *)&px)[bits>>3])>>(bits&7)) & 1);
+ plane = plane + (ximage->bytes_per_line * ximage->height);
+ }
+ } else if (ximage->format == ZPixmap) {
+ src = &ximage->data[ZINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ for (i = (ximage->bits_per_pixel + 7) >> 3; --i >= 0; )
+ *dst++ = *src++;
+ ZNORMALIZE(&px, ximage);
+ pixel = 0;
+ for (i=sizeof(unsigned long); --i >= 0; )
+ pixel = (pixel << 8) | ((unsigned char *)&px)[i];
+ if (ximage->bits_per_pixel == 4) {
+ if (x & 1)
+ pixel >>= 4;
+ else
+ pixel &= 0xf;
+ }
+ } else {
+ return 0; /* bad image */
+ }
+ if (ximage->bits_per_pixel == ximage->depth)
+ return pixel;
+ else
+ return (pixel & low_bits_table[ximage->depth]);
+}
+
+#ifndef WORD64
+static unsigned long byteorderpixel = MSBFirst << 24;
+#endif
+
+static unsigned long _XGetPixel32 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ register unsigned char *addr;
+ unsigned long pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 32)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 2)];
+#ifndef WORD64
+ if (*((char *)&byteorderpixel) == ximage->byte_order)
+ pixel = *((CARD32 *)addr);
+ else
+#endif
+ if (ximage->byte_order == MSBFirst)
+ pixel = ((unsigned long)addr[0] << 24 |
+ (unsigned long)addr[1] << 16 |
+ (unsigned long)addr[2] << 8 |
+ addr[3]);
+ else
+ pixel = ((unsigned long)addr[3] << 24 |
+ (unsigned long)addr[2] << 16 |
+ (unsigned long)addr[1] << 8 |
+ addr[0]);
+ if (ximage->depth != 32)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel16 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ register unsigned char *addr;
+ unsigned long pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 16)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 1)];
+ if (ximage->byte_order == MSBFirst)
+ pixel = addr[0] << 8 | addr[1];
+ else
+ pixel = addr[1] << 8 | addr[0];
+ if (ximage->depth != 16)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel8 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ unsigned char pixel;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 8)) {
+ pixel = ((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + x];
+ if (ximage->depth != 8)
+ pixel &= low_bits_table[ximage->depth];
+ return pixel;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+static unsigned long _XGetPixel1 (ximage, x, y)
+ register XImage *ximage;
+ int x;
+ int y;
+{
+ unsigned char bit;
+ int xoff, yoff;
+
+ if (((ximage->bits_per_pixel | ximage->depth) == 1) &&
+ (ximage->byte_order == ximage->bitmap_bit_order)) {
+ xoff = x + ximage->xoffset;
+ yoff = y * ximage->bytes_per_line + (xoff >> 3);
+ xoff &= 7;
+ if (ximage->bitmap_bit_order == MSBFirst)
+ bit = 0x80 >> xoff;
+ else
+ bit = 1 << xoff;
+ return (ximage->data[yoff] & bit) ? 1 : 0;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XGetPixel(ximage, x, y);
+ }
+}
+
+/*
+ * PutPixel
+ *
+ * Overwrites the specified pixel. The X and Y coordinates are relative to
+ * the origin (upper left [0,0]) of the image. The input pixel value must be
+ * in normalized format, i.e. the LSB of the long is the LSB of the pixel.
+ * The algorithm used is:
+ *
+ * copy the destination bitmap_unit or Zpixel to temp
+ * normalize temp if needed
+ * copy the pixel bits into the temp
+ * renormalize temp if needed
+ * copy the temp back into the destination image data
+ *
+ */
+
+static int _XPutPixel (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+
+{
+ unsigned long px, npixel;
+ register char *src;
+ register char *dst;
+ register int i;
+ int j, nbytes;
+ long plane;
+
+ if (ximage->depth == 4)
+ pixel &= 0xf;
+ npixel = pixel;
+ for (i=0, px=pixel; i<sizeof(unsigned long); i++, px>>=8)
+ ((unsigned char *)&pixel)[i] = px;
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ src = &ximage->data[XYINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ nbytes = ximage->bitmap_unit >> 3;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ i = ((x + ximage->xoffset) % ximage->bitmap_unit);
+ _putbits ((char *)&pixel, i, 1, (char *)&px);
+ XYNORMALIZE(&px, ximage);
+ src = (char *) &px;
+ dst = &ximage->data[XYINDEX(x, y, ximage)];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ } else if (ximage->format == XYPixmap) {
+ plane = (ximage->bytes_per_line * ximage->height) *
+ (ximage->depth - 1); /* do least signif plane 1st */
+ nbytes = ximage->bitmap_unit >> 3;
+ for (j = ximage->depth; --j >= 0; ) {
+ src = &ximage->data[XYINDEX(x, y, ximage) + plane];
+ dst = (char *) &px;
+ px = 0;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ XYNORMALIZE(&px, ximage);
+ i = ((x + ximage->xoffset) % ximage->bitmap_unit);
+ _putbits ((char *)&pixel, i, 1, (char *)&px);
+ XYNORMALIZE(&px, ximage);
+ src = (char *)&px;
+ dst = &ximage->data[XYINDEX(x, y, ximage) + plane];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ npixel = npixel >> 1;
+ for (i=0, px=npixel; i<sizeof(unsigned long); i++, px>>=8)
+ ((unsigned char *)&pixel)[i] = px;
+ plane = plane - (ximage->bytes_per_line * ximage->height);
+ }
+ } else if (ximage->format == ZPixmap) {
+ src = &ximage->data[ZINDEX(x, y, ximage)];
+ dst = (char *)&px;
+ px = 0;
+ nbytes = (ximage->bits_per_pixel + 7) >> 3;
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ ZNORMALIZE(&px, ximage);
+ _putbits ((char *)&pixel,
+ (x * ximage->bits_per_pixel) & 7,
+ ximage->bits_per_pixel, (char *)&px);
+ ZNORMALIZE(&px, ximage);
+ src = (char *)&px;
+ dst = &ximage->data[ZINDEX(x, y, ximage)];
+ for (i = nbytes; --i >= 0; ) *dst++ = *src++;
+ } else {
+ return 0; /* bad image */
+ }
+ return 1;
+}
+
+static int _XPutPixel32 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char *addr;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 32)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 2)];
+#ifndef WORD64
+ if (*((char *)&byteorderpixel) == ximage->byte_order)
+ *((CARD32 *)addr) = pixel;
+ else
+#endif
+ if (ximage->byte_order == MSBFirst) {
+ addr[0] = pixel >> 24;
+ addr[1] = pixel >> 16;
+ addr[2] = pixel >> 8;
+ addr[3] = pixel;
+ } else {
+ addr[3] = pixel >> 24;
+ addr[2] = pixel >> 16;
+ addr[1] = pixel >> 8;
+ addr[0] = pixel;
+ }
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel16 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char *addr;
+
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 16)) {
+ addr = &((unsigned char *)ximage->data)
+ [y * ximage->bytes_per_line + (x << 1)];
+ if (ximage->byte_order == MSBFirst) {
+ addr[0] = pixel >> 8;
+ addr[1] = pixel;
+ } else {
+ addr[1] = pixel >> 8;
+ addr[0] = pixel;
+ }
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel8 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ if ((ximage->format == ZPixmap) && (ximage->bits_per_pixel == 8)) {
+ ximage->data[y * ximage->bytes_per_line + x] = pixel;
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+static int _XPutPixel1 (ximage, x, y, pixel)
+ register XImage *ximage;
+ int x;
+ int y;
+ unsigned long pixel;
+{
+ unsigned char bit;
+ int xoff, yoff;
+
+ if (((ximage->bits_per_pixel | ximage->depth) == 1) &&
+ (ximage->byte_order == ximage->bitmap_bit_order)) {
+ xoff = x + ximage->xoffset;
+ yoff = y * ximage->bytes_per_line + (xoff >> 3);
+ xoff &= 7;
+ if (ximage->bitmap_bit_order == MSBFirst)
+ bit = 0x80 >> xoff;
+ else
+ bit = 1 << xoff;
+ if (pixel & 1)
+ ximage->data[yoff] |= bit;
+ else
+ ximage->data[yoff] &= ~bit;
+ return 1;
+ } else {
+ _XInitImageFuncPtrs(ximage);
+ return XPutPixel(ximage, x, y, pixel);
+ }
+}
+
+/*
+ * SubImage
+ *
+ * Creates a new image that is a subsection of an existing one.
+ * Allocates the memory necessary for the new XImage data structure.
+ * Pointer to new image is returned. The algorithm used is repetitive
+ * calls to get and put pixel.
+ *
+ */
+
+static XImage *_XSubImage (ximage, x, y, width, height)
+ XImage *ximage;
+ register int x; /* starting x coordinate in existing image */
+ register int y; /* starting y coordinate in existing image */
+ unsigned int width; /* width in pixels of new subimage */
+ unsigned int height;/* height in pixels of new subimage */
+
+{
+ register XImage *subimage;
+ int dsize;
+ register int row, col;
+ register unsigned long pixel;
+ char *data;
+
+ if ((subimage = (XImage *) Xcalloc (1, sizeof (XImage))) == NULL)
+ return (XImage *) NULL;
+ subimage->width = width;
+ subimage->height = height;
+ subimage->xoffset = 0;
+ subimage->format = ximage->format;
+ subimage->byte_order = ximage->byte_order;
+ subimage->bitmap_unit = ximage->bitmap_unit;
+ subimage->bitmap_bit_order = ximage->bitmap_bit_order;
+ subimage->bitmap_pad = ximage->bitmap_pad;
+ subimage->bits_per_pixel = ximage->bits_per_pixel;
+ subimage->depth = ximage->depth;
+ /*
+ * compute per line accelerator.
+ */
+ if (subimage->format == ZPixmap)
+ subimage->bytes_per_line =
+ ROUNDUP(subimage->bits_per_pixel * width,
+ subimage->bitmap_pad);
+ else
+ subimage->bytes_per_line =
+ ROUNDUP(width, subimage->bitmap_pad);
+ subimage->obdata = NULL;
+ _XInitImageFuncPtrs (subimage);
+ dsize = subimage->bytes_per_line * height;
+ if (subimage->format == XYPixmap) dsize = dsize * subimage->depth;
+ if (((data = Xcalloc (1, (unsigned) dsize)) == NULL) && (dsize > 0)) {
+ Xfree((char *) subimage);
+ return (XImage *) NULL;
+ }
+ subimage->data = data;
+
+ /*
+ * Test for cases where the new subimage is larger than the region
+ * that we are copying from the existing data. In those cases,
+ * copy the area of the existing image, and allow the "uncovered"
+ * area of new subimage to remain with zero filled pixels.
+ */
+ if (height > ximage->height - y ) height = ximage->height - y;
+ if (width > ximage->width - x ) width = ximage->width - x;
+
+ for (row = y; row < (y + height); row++) {
+ for (col = x; col < (x + width); col++) {
+ pixel = XGetPixel(ximage, col, row);
+ XPutPixel(subimage, (col - x), (row - y), pixel);
+ }
+ }
+ return subimage;
+}
+
+
+/*
+ * SetImage
+ *
+ * Overwrites a section of one image with all of the data from another.
+ * If the two images are not of the same format (i.e. XYPixmap and ZPixmap),
+ * the image data is converted to the destination format. The following
+ * restrictions apply:
+ *
+ * 1. The depths of the source and destination images must be equal.
+ *
+ * 2. If the height of the source image is too large to fit between
+ * the specified y starting point and the bottom of the image,
+ * then scanlines are truncated on the bottom.
+ *
+ * 3. If the width of the source image is too large to fit between
+ * the specified x starting point and the end of the scanline,
+ * then pixels are truncated on the right.
+ *
+ * The images need not have the same bitmap_bit_order, byte_order,
+ * bitmap_unit, bits_per_pixel, bitmap_pad, or xoffset.
+ *
+ */
+
+int _XSetImage (srcimg, dstimg, x, y)
+ XImage *srcimg;
+ register XImage *dstimg;
+ register int x;
+ register int y;
+
+{
+ register unsigned long pixel;
+ register int row, col;
+ int width, height, startrow, startcol;
+ if (x < 0) {
+ startcol = -x;
+ x = 0;
+ } else
+ startcol = 0;
+ if (y < 0) {
+ startrow = -y;
+ y = 0;
+ } else
+ startrow = 0;
+ width = dstimg->width - x;
+ if (srcimg->width < width)
+ width = srcimg->width;
+ height = dstimg->height - y;
+ if (srcimg->height < height)
+ height = srcimg->height;
+
+ /* this is slow, will do better later */
+ for (row = startrow; row < height; row++) {
+ for (col = startcol; col < width; col++) {
+ pixel = XGetPixel(srcimg, col, row);
+ XPutPixel(dstimg, x + col, y + row, pixel);
+ }
+ }
+ return 1;
+}
+
+/*
+ * AddPixel
+ *
+ * Adds a constant value to every pixel in a pixmap.
+ *
+ */
+
+static _XAddPixel (ximage, value)
+ register XImage *ximage;
+ register long value;
+{
+ register int x;
+ register int y;
+
+ if (!value)
+ return 0;
+ if ((ximage->bits_per_pixel | ximage->depth) == 1) {
+ /* The only value that we can add here to an XYBitmap
+ * is one. Since 1 + value = ~value for one bit wide
+ * data, we do this quickly by taking the ones complement
+ * of the entire bitmap data (offset and pad included!).
+ * Note that we don't need to be concerned with bit or
+ * byte order at all.
+ */
+ register unsigned char *dp = (unsigned char *) ximage->data;
+ x = ximage->bytes_per_line * ximage->height;
+ while (--x >= 0) {
+ *dp = ~*dp;
+ dp++;
+ }
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 8)) {
+ register unsigned char *dp = (unsigned char *) ximage->data;
+ x = ximage->bytes_per_line * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+#ifndef WORD64
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 16) &&
+ (*((char *)&byteorderpixel) == ximage->byte_order)) {
+ register unsigned short *dp = (unsigned short *) ximage->data;
+ x = (ximage->bytes_per_line >> 1) * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+ } else if ((ximage->format == ZPixmap) &&
+ (ximage->bits_per_pixel == 32) &&
+ (*((char *)&byteorderpixel) == ximage->byte_order)) {
+ register CARD32 *dp = (CARD32 *) ximage->data;
+ x = (ximage->bytes_per_line >> 2) * ximage->height;
+ while (--x >= 0)
+ *dp++ += value;
+#endif
+ } else {
+ for (y = ximage->height; --y >= 0; ) {
+ for (x = ximage->width; --x >= 0; ) {
+ register unsigned long pixel = XGetPixel(ximage, x, y);
+ pixel = pixel + value;
+ XPutPixel(ximage, x, y, pixel);
+ }
+ }
+ }
+ return 0;
+}
+
diff --git a/src/InitExt.c b/src/InitExt.c
new file mode 100644
index 00000000..c24d4490
--- /dev/null
+++ b/src/InitExt.c
@@ -0,0 +1,473 @@
+/* $Xorg: InitExt.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+extern Bool _XUnknownWireEvent();
+extern Status _XUnknownNativeEvent();
+extern Bool _XDefaultWireError();
+
+/*
+ * This routine is used to link a extension in so it will be called
+ * at appropriate times.
+ */
+
+#if NeedFunctionPrototypes
+XExtCodes *XInitExtension (
+ Display *dpy,
+ _Xconst char *name)
+#else
+XExtCodes *XInitExtension (dpy, name)
+ Display *dpy;
+ char *name;
+#endif
+{
+ XExtCodes codes; /* temp. place for extension information. */
+ register _XExtension *ext;/* need a place to build it all */
+ if (!XQueryExtension(dpy, name,
+ &codes.major_opcode, &codes.first_event,
+ &codes.first_error)) return (NULL);
+
+ LockDisplay (dpy);
+ if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension))) ||
+ ! (ext->name = Xmalloc((unsigned) strlen(name) + 1))) {
+ if (ext) Xfree((char *) ext);
+ UnlockDisplay(dpy);
+ return (XExtCodes *) NULL;
+ }
+ codes.extension = dpy->ext_number++;
+ ext->codes = codes;
+ (void) strcpy(ext->name, name);
+
+ /* chain it onto the display list */
+ ext->next = dpy->ext_procs;
+ dpy->ext_procs = ext;
+ UnlockDisplay (dpy);
+
+ return (&ext->codes); /* tell him which extension */
+}
+
+XExtCodes *XAddExtension (dpy)
+ Display *dpy;
+{
+ register _XExtension *ext;
+
+ LockDisplay (dpy);
+ if (! (ext = (_XExtension *) Xcalloc (1, sizeof (_XExtension)))) {
+ UnlockDisplay(dpy);
+ return (XExtCodes *) NULL;
+ }
+ ext->codes.extension = dpy->ext_number++;
+
+ /* chain it onto the display list */
+ ext->next = dpy->ext_procs;
+ dpy->ext_procs = ext;
+ UnlockDisplay (dpy);
+
+ return (&ext->codes); /* tell him which extension */
+}
+
+static _XExtension *XLookupExtension (dpy, extension)
+ register Display *dpy; /* display */
+ register int extension; /* extension number */
+{
+ register _XExtension *ext;
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->codes.extension == extension) return (ext);
+ return (NULL);
+}
+
+XExtData **XEHeadOfExtensionList(object)
+ XEDataObject object;
+{
+ return *(XExtData ***)&object;
+}
+
+XAddToExtensionList(structure, ext_data)
+ XExtData **structure;
+ XExtData *ext_data;
+{
+ ext_data->next = *structure;
+ *structure = ext_data;
+ return 1;
+}
+
+XExtData *XFindOnExtensionList(structure, number)
+ XExtData **structure;
+ int number;
+{
+ XExtData *ext;
+
+ ext = *structure;
+ while (ext && (ext->number != number))
+ ext = ext->next;
+ return ext;
+}
+
+typedef int (*CreateGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+/*
+ * Routines to hang procs on the extension structure.
+ */
+CreateGCType XESetCreateGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CreateGCType proc; /* routine to call when GC created */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_GC;
+ e->create_GC = proc;
+ UnlockDisplay(dpy);
+ return (CreateGCType)oldproc;
+}
+
+typedef int (*CopyGCType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CopyGCType XESetCopyGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CopyGCType proc; /* routine to call when GC copied */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->copy_GC;
+ e->copy_GC = proc;
+ UnlockDisplay(dpy);
+ return (CopyGCType)oldproc;
+}
+
+typedef int (*FlushGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FlushGCType XESetFlushGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FlushGCType proc; /* routine to call when GC copied */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->flush_GC;
+ e->flush_GC = proc;
+ UnlockDisplay(dpy);
+ return (FlushGCType)oldproc;
+}
+
+typedef int (*FreeGCType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ GC /* gc */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FreeGCType XESetFreeGC(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FreeGCType proc; /* routine to call when GC freed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_GC;
+ e->free_GC = proc;
+ UnlockDisplay(dpy);
+ return (FreeGCType)oldproc;
+}
+
+typedef int (*CreateFontType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CreateFontType XESetCreateFont(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CreateFontType proc; /* routine to call when font created */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->create_Font;
+ e->create_Font = proc;
+ UnlockDisplay(dpy);
+ return (CreateFontType)oldproc;
+}
+
+typedef int (*FreeFontType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XFontStruct* /* fs */,
+ XExtCodes* /* codes */
+#endif
+);
+
+FreeFontType XESetFreeFont(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ FreeFontType proc; /* routine to call when font freed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->free_Font;
+ e->free_Font = proc;
+ UnlockDisplay(dpy);
+ return (FreeFontType)oldproc;
+}
+
+typedef int (*CloseDisplayType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */
+#endif
+);
+
+CloseDisplayType XESetCloseDisplay(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ CloseDisplayType proc; /* routine to call when display closed */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->close_display;
+ e->close_display = proc;
+ UnlockDisplay(dpy);
+ return (CloseDisplayType)oldproc;
+}
+
+typedef Bool (*WireToEventType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+);
+
+WireToEventType XESetWireToEvent(dpy, event_number, proc)
+ Display *dpy; /* display */
+ WireToEventType proc; /* routine to call when converting event */
+ int event_number; /* event routine to replace */
+{
+ register Bool (*oldproc)();
+ if (proc == NULL) proc = (WireToEventType)_XUnknownWireEvent;
+ LockDisplay (dpy);
+ oldproc = dpy->event_vec[event_number];
+ dpy->event_vec[event_number] = proc;
+ UnlockDisplay (dpy);
+ return (WireToEventType)oldproc;
+}
+
+typedef Status (*EventToWireType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XEvent* /* re */,
+ xEvent* /* event */
+#endif
+);
+
+EventToWireType XESetEventToWire(dpy, event_number, proc)
+ Display *dpy; /* display */
+ EventToWireType proc; /* routine to call when converting event */
+ int event_number; /* event routine to replace */
+{
+ register Status (*oldproc)();
+ if (proc == NULL) proc = (EventToWireType) _XUnknownNativeEvent;
+ LockDisplay (dpy);
+ oldproc = dpy->wire_vec[event_number];
+ dpy->wire_vec[event_number] = proc;
+ UnlockDisplay(dpy);
+ return (EventToWireType)oldproc;
+}
+
+typedef Bool (*WireToErrorType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XErrorEvent* /* he */,
+ xError* /* we */
+#endif
+);
+
+WireToErrorType XESetWireToError(dpy, error_number, proc)
+ Display *dpy; /* display */
+ WireToErrorType proc; /* routine to call when converting error */
+ int error_number; /* error routine to replace */
+{
+ register Bool (*oldproc)();
+ if (proc == NULL) proc = (WireToErrorType)_XDefaultWireError;
+ LockDisplay (dpy);
+ if (!dpy->error_vec) {
+ int i;
+ dpy->error_vec = (Bool (**)())Xmalloc(256 * sizeof(oldproc));
+ for (i = 1; i < 256; i++)
+ dpy->error_vec[i] = _XDefaultWireError;
+ }
+ if (dpy->error_vec) {
+ oldproc = dpy->error_vec[error_number];
+ dpy->error_vec[error_number] = proc;
+ }
+ UnlockDisplay (dpy);
+ return (WireToErrorType)oldproc;
+}
+
+typedef int (*ErrorType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ xError* /* err */,
+ XExtCodes* /* codes */,
+ int* /* ret_code */
+#endif
+);
+
+ErrorType XESetError(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ ErrorType proc; /* routine to call when X error happens */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register int (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error;
+ e->error = proc;
+ UnlockDisplay(dpy);
+ return (ErrorType)oldproc;
+}
+
+typedef char* (*ErrorStringType) (
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ int /* code */,
+ XExtCodes* /* codes */,
+ char* /* buffer */,
+ int /* nbytes */
+#endif
+);
+
+ErrorStringType XESetErrorString(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ ErrorStringType proc; /* routine to call when I/O error happens */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register char *(*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_string;
+ e->error_string = proc;
+ UnlockDisplay(dpy);
+ return (ErrorStringType)oldproc;
+}
+
+typedef void (*PrintErrorType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XErrorEvent* /* ev */,
+ void* /* fp */
+#endif
+);
+
+PrintErrorType XESetPrintErrorValues(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ PrintErrorType proc; /* routine to call to print */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register void (*oldproc)();
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->error_values;
+ e->error_values = proc;
+ UnlockDisplay(dpy);
+ return (PrintErrorType)oldproc;
+}
+
+typedef void (*BeforeFlushType)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ XExtCodes* /* codes */,
+ char* /* data */,
+ long /* len */
+#endif
+);
+
+BeforeFlushType XESetBeforeFlush(dpy, extension, proc)
+ Display *dpy; /* display */
+ int extension; /* extension number */
+ BeforeFlushType proc; /* routine to call on flush */
+{
+ register _XExtension *e; /* for lookup of extension */
+ register void (*oldproc)();
+ register _XExtension *ext;
+ if ((e = XLookupExtension (dpy, extension)) == NULL) return (NULL);
+ LockDisplay(dpy);
+ oldproc = e->before_flush;
+ e->before_flush = proc;
+ for (ext = dpy->flushes; ext && ext != e; ext = ext->next)
+ ;
+ if (!ext) {
+ e->next_flush = dpy->flushes;
+ dpy->flushes = e;
+ }
+ UnlockDisplay(dpy);
+ return (BeforeFlushType)oldproc;
+}
diff --git a/src/InsCmap.c b/src/InsCmap.c
new file mode 100644
index 00000000..1e10d953
--- /dev/null
+++ b/src/InsCmap.c
@@ -0,0 +1,41 @@
+/* $Xorg: InsCmap.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XInstallColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(InstallColormap, cmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/IntAtom.c b/src/IntAtom.c
new file mode 100644
index 00000000..467286b0
--- /dev/null
+++ b/src/IntAtom.c
@@ -0,0 +1,319 @@
+/* $Xorg: IntAtom.c,v 1.5 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+/* XXX this table def is duplicated in GetAtomNm.c, keep them consistent! */
+
+#define TABLESIZE 64
+
+typedef struct _Entry {
+ unsigned long sig;
+ Atom atom;
+} EntryRec, *Entry;
+
+#define RESERVED ((Entry) 1)
+
+#define EntryName(e) ((char *)(e+1))
+
+typedef struct _XDisplayAtoms {
+ Entry table[TABLESIZE];
+} AtomTable;
+
+#define HASH(sig) ((sig) & (TABLESIZE-1))
+#define REHASHVAL(sig) ((((sig) % (TABLESIZE-3)) + 2) | 1)
+#define REHASH(idx,rehash) ((idx + rehash) & (TABLESIZE-1))
+
+void
+_XFreeAtomTable(dpy)
+ Display *dpy;
+{
+ register Entry *table;
+ register int i;
+ register Entry e;
+
+ if (dpy->atoms) {
+ table = dpy->atoms->table;
+ for (i = TABLESIZE; --i >= 0; ) {
+ if ((e = *table++) && (e != RESERVED))
+ Xfree((char *)e);
+ }
+ Xfree((char *)dpy->atoms);
+ }
+}
+
+static
+Atom _XInternAtom(dpy, name, onlyIfExists, psig, pidx, pn)
+ Display *dpy;
+ char *name;
+ Bool onlyIfExists;
+ unsigned long *psig;
+ int *pidx;
+ int *pn;
+{
+ register AtomTable *atoms;
+ register char *s1, c, *s2;
+ register unsigned long sig;
+ register int idx, i;
+ Entry e;
+ int n, firstidx, rehash;
+ xInternAtomReq *req;
+
+ /* look in the cache first */
+ if (!(atoms = dpy->atoms)) {
+ dpy->atoms = atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->free_funcs->atoms = _XFreeAtomTable;
+ }
+ sig = 0;
+ for (s1 = (char *)name; (c = *s1++); )
+ sig += c;
+ n = s1 - (char *)name - 1;
+ if (atoms) {
+ firstidx = idx = HASH(sig);
+ while ((e = atoms->table[idx])) {
+ if (e != RESERVED && e->sig == sig) {
+ for (i = n, s1 = (char *)name, s2 = EntryName(e); --i >= 0; ) {
+ if (*s1++ != *s2++)
+ goto nomatch;
+ }
+ if (!*s2)
+ return e->atom;
+ }
+nomatch: if (idx == firstidx)
+ rehash = REHASHVAL(sig);
+ idx = REHASH(idx, rehash);
+ if (idx == firstidx)
+ break;
+ }
+ }
+ *psig = sig;
+ *pidx = idx;
+ if (atoms && !atoms->table[idx])
+ atoms->table[idx] = RESERVED; /* reserve slot */
+ *pn = n;
+ /* not found, go to the server */
+ GetReq(InternAtom, req);
+ req->nbytes = n;
+ req->onlyIfExists = onlyIfExists;
+ req->length += (n+3)>>2;
+ Data(dpy, name, n);
+ return None;
+}
+
+void
+_XUpdateAtomCache(dpy, name, atom, sig, idx, n)
+ Display *dpy;
+ char *name;
+ Atom atom;
+ unsigned long sig;
+ int idx;
+ int n;
+{
+ Entry e, oe;
+ register char *s1;
+ register char c;
+ int firstidx, rehash;
+
+ if (!dpy->atoms) {
+ if (idx < 0) {
+ dpy->atoms = (AtomTable *)Xcalloc(1, sizeof(AtomTable));
+ dpy->free_funcs->atoms = _XFreeAtomTable;
+ }
+ if (!dpy->atoms)
+ return;
+ }
+ if (!sig) {
+ for (s1 = (char *)name; (c = *s1++); )
+ sig += c;
+ n = s1 - (char *)name - 1;
+ if (idx < 0) {
+ firstidx = idx = HASH(sig);
+ if (dpy->atoms->table[idx]) {
+ rehash = REHASHVAL(sig);
+ do
+ idx = REHASH(idx, rehash);
+ while (idx != firstidx && dpy->atoms->table[idx]);
+ }
+ }
+ }
+ e = (Entry)Xmalloc(sizeof(EntryRec) + n + 1);
+ if (e) {
+ e->sig = sig;
+ e->atom = atom;
+ strcpy(EntryName(e), name);
+ if ((oe = dpy->atoms->table[idx]) && (oe != RESERVED))
+ Xfree((char *)oe);
+ dpy->atoms->table[idx] = e;
+ }
+}
+
+#if NeedFunctionPrototypes
+Atom XInternAtom (
+ Display *dpy,
+ _Xconst char *name,
+ Bool onlyIfExists)
+#else
+Atom XInternAtom (dpy, name, onlyIfExists)
+ Display *dpy;
+ char *name;
+ Bool onlyIfExists;
+#endif
+{
+ Atom atom;
+ unsigned long sig;
+ int idx, n;
+ xInternAtomReply rep;
+
+ if (!name)
+ name = "";
+ LockDisplay(dpy);
+ if ((atom = _XInternAtom(dpy, name, onlyIfExists, &sig, &idx, &n))) {
+ UnlockDisplay(dpy);
+ return atom;
+ }
+ if (dpy->atoms && dpy->atoms->table[idx] == RESERVED)
+ dpy->atoms->table[idx] = NULL; /* unreserve slot */
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ if ((atom = rep.atom))
+ _XUpdateAtomCache(dpy, name, atom, sig, idx, n);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.atom);
+}
+
+typedef struct {
+ unsigned long start_seq;
+ unsigned long stop_seq;
+ char **names;
+ Atom *atoms;
+ int count;
+ Status status;
+} _XIntAtomState;
+
+static
+Bool _XIntAtomHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XIntAtomState *state;
+ register int i, idx;
+ xInternAtomReply replbuf;
+ register xInternAtomReply *repl;
+
+ state = (_XIntAtomState *)data;
+ if (dpy->last_request_read < state->start_seq ||
+ dpy->last_request_read > state->stop_seq)
+ return False;
+ for (i = 0; i < state->count; i++) {
+ if (state->atoms[i] & 0x80000000) {
+ idx = ~state->atoms[i];
+ state->atoms[i] = None;
+ break;
+ }
+ }
+ if (i >= state->count)
+ return False;
+ if (rep->generic.type == X_Error) {
+ state->status = 0;
+ return False;
+ }
+ repl = (xInternAtomReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xInternAtomReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if ((state->atoms[i] = repl->atom))
+ _XUpdateAtomCache(dpy, state->names[i], (Atom) repl->atom,
+ (unsigned long)0, idx, 0);
+ return True;
+}
+
+Status
+XInternAtoms (dpy, names, count, onlyIfExists, atoms_return)
+ Display *dpy;
+ char **names;
+ int count;
+ Bool onlyIfExists;
+ Atom *atoms_return;
+{
+ int i, idx, n, tidx;
+ unsigned long sig;
+ _XAsyncHandler async;
+ _XIntAtomState async_state;
+ int missed = -1;
+ xInternAtomReply rep;
+
+ LockDisplay(dpy);
+ async_state.start_seq = dpy->request + 1;
+ async_state.atoms = atoms_return;
+ async_state.names = names;
+ async_state.count = count - 1;
+ async_state.status = 1;
+ async.next = dpy->async_handlers;
+ async.handler = _XIntAtomHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ for (i = 0; i < count; i++) {
+ if (!(atoms_return[i] = _XInternAtom(dpy, names[i], onlyIfExists,
+ &sig, &idx, &n))) {
+ missed = i;
+ atoms_return[i] = ~((Atom)idx);
+ async_state.stop_seq = dpy->request;
+ }
+ }
+ if (missed >= 0) {
+ if (dpy->atoms) {
+ /* unreserve anything we just reserved */
+ for (i = 0; i < count; i++) {
+ if (atoms_return[i] & 0x80000000) {
+ tidx = ~atoms_return[i];
+ if (dpy->atoms->table[tidx] == RESERVED)
+ dpy->atoms->table[tidx] = NULL;
+ }
+ }
+ }
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue)) {
+ if ((atoms_return[missed] = rep.atom))
+ _XUpdateAtomCache(dpy, names[missed], (Atom) rep.atom,
+ sig, idx, n);
+ } else {
+ atoms_return[missed] = None;
+ async_state.status = 0;
+ }
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ if (missed >= 0)
+ SyncHandle();
+ return async_state.status;
+}
diff --git a/src/KeyBind.c b/src/KeyBind.c
new file mode 100644
index 00000000..f56a06a4
--- /dev/null
+++ b/src/KeyBind.c
@@ -0,0 +1,731 @@
+/* $Xorg: KeyBind.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* Beware, here be monsters (still under construction... - JG */
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#define XK_MISCELLANY
+#define XK_LATIN1
+#define XK_LATIN2
+#define XK_LATIN3
+#define XK_LATIN4
+#define XK_CYRILLIC
+#define XK_GREEK
+#define XK_XKB_KEYS
+#include <X11/keysymdef.h>
+#include <stdio.h>
+
+#ifdef USE_OWN_COMPOSE
+#include "imComp.h"
+#endif
+
+#ifdef XKB
+#define XKeycodeToKeysym _XKeycodeToKeysym
+#define XKeysymToKeycode _XKeysymToKeycode
+#define XLookupKeysym _XLookupKeysym
+#define XRefreshKeyboardMapping _XRefreshKeyboardMapping
+#define XLookupString _XLookupString
+#else
+#define XkbKeysymToModifiers _XKeysymToModifiers
+#endif
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+static void ComputeMaskFromKeytrans();
+
+struct _XKeytrans {
+ struct _XKeytrans *next;/* next on list */
+ char *string; /* string to return when the time comes */
+ int len; /* length of string (since NULL is legit)*/
+ KeySym key; /* keysym rebound */
+ unsigned int state; /* modifier state */
+ KeySym *modifiers; /* modifier keysyms you want */
+ int mlen; /* length of modifier list */
+};
+
+static KeySym
+#if NeedFunctionPrototypes
+KeyCodetoKeySym(register Display *dpy, KeyCode keycode, int col)
+#else
+KeyCodetoKeySym(dpy, keycode, col)
+ register Display *dpy;
+ KeyCode keycode;
+ int col;
+#endif
+{
+ register int per = dpy->keysyms_per_keycode;
+ register KeySym *syms;
+ KeySym lsym, usym;
+
+ if ((col < 0) || ((col >= per) && (col > 3)) ||
+ ((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
+ return NoSymbol;
+
+ syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
+ if (col < 4) {
+ if (col > 1) {
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if (per < 3)
+ col -= 2;
+ }
+ if ((per <= (col|1)) || (syms[col|1] == NoSymbol)) {
+ XConvertCase(syms[col&~1], &lsym, &usym);
+ if (!(col & 1))
+ return lsym;
+ else if (usym == lsym)
+ return NoSymbol;
+ else
+ return usym;
+ }
+ }
+ return syms[col];
+}
+
+#if NeedFunctionPrototypes
+KeySym
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int col)
+#else
+KeySym
+XKeycodeToKeysym(dpy, kc, col)
+ Display *dpy;
+ KeyCode kc;
+ int col;
+#endif
+{
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return NoSymbol;
+ return KeyCodetoKeySym(dpy, kc, col);
+}
+
+KeyCode
+XKeysymToKeycode(dpy, ks)
+ Display *dpy;
+ KeySym ks;
+{
+ register int i, j;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return (KeyCode) 0;
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+ if (KeyCodetoKeySym(dpy, (KeyCode) i, j) == ks)
+ return i;
+ }
+ }
+ return 0;
+}
+
+KeySym
+XLookupKeysym(event, col)
+ register XKeyEvent *event;
+ int col;
+{
+ if ((! event->display->keysyms) && (! _XKeyInitialize(event->display)))
+ return NoSymbol;
+ return KeyCodetoKeySym(event->display, event->keycode, col);
+}
+
+static void
+ResetModMap(dpy)
+ Display *dpy;
+{
+ register XModifierKeymap *map;
+ register int i, j, n;
+ KeySym sym;
+ register struct _XKeytrans *p;
+
+ map = dpy->modifiermap;
+ /* If any Lock key contains Caps_Lock, then interpret as Caps_Lock,
+ * else if any contains Shift_Lock, then interpret as Shift_Lock,
+ * else ignore Lock altogether.
+ */
+ dpy->lock_meaning = NoSymbol;
+ /* Lock modifiers are in the second row of the matrix */
+ n = 2 * map->max_keypermod;
+ for (i = map->max_keypermod; i < n; i++) {
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
+ if (sym == XK_Caps_Lock) {
+ dpy->lock_meaning = XK_Caps_Lock;
+ break;
+ } else if (sym == XK_Shift_Lock) {
+ dpy->lock_meaning = XK_Shift_Lock;
+ }
+ else if (sym == XK_ISO_Lock) {
+ dpy->lock_meaning = XK_Caps_Lock;
+ break;
+ }
+ }
+ }
+ /* Now find any Mod<n> modifier acting as the Group or Numlock modifier */
+ dpy->mode_switch = 0;
+ dpy->num_lock = 0;
+ n *= 4;
+ for (i = 3*map->max_keypermod; i < n; i++) {
+ for (j = 0; j < dpy->keysyms_per_keycode; j++) {
+ sym = KeyCodetoKeySym(dpy, map->modifiermap[i], j);
+ if (sym == XK_Mode_switch)
+ dpy->mode_switch |= 1 << (i / map->max_keypermod);
+ if (sym == XK_Num_Lock)
+ dpy->num_lock |= 1 << (i / map->max_keypermod);
+ }
+ }
+ for (p = dpy->key_bindings; p; p = p->next)
+ ComputeMaskFromKeytrans(dpy, p);
+}
+
+static int
+InitModMap(dpy)
+ Display *dpy;
+{
+ register XModifierKeymap *map;
+
+ if (! (map = XGetModifierMapping(dpy)))
+ return 0;
+ LockDisplay(dpy);
+ if (dpy->modifiermap)
+ XFreeModifiermap(dpy->modifiermap);
+ dpy->modifiermap = map;
+ dpy->free_funcs->modifiermap = XFreeModifiermap;
+ if (dpy->keysyms)
+ ResetModMap(dpy);
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+XRefreshKeyboardMapping(event)
+ register XMappingEvent *event;
+{
+
+ if(event->request == MappingKeyboard) {
+ /* XXX should really only refresh what is necessary
+ * for now, make initialize test fail
+ */
+ LockDisplay(event->display);
+ if (event->display->keysyms) {
+ Xfree ((char *)event->display->keysyms);
+ event->display->keysyms = NULL;
+ }
+ UnlockDisplay(event->display);
+ }
+ if(event->request == MappingModifier) {
+ LockDisplay(event->display);
+ if (event->display->modifiermap) {
+ XFreeModifiermap(event->display->modifiermap);
+ event->display->modifiermap = NULL;
+ }
+ UnlockDisplay(event->display);
+ /* go ahead and get it now, since initialize test may not fail */
+ if (event->display->keysyms)
+ (void) InitModMap(event->display);
+ }
+ return 1;
+}
+
+int
+_XKeyInitialize(dpy)
+ Display *dpy;
+{
+ int per, n;
+ KeySym *keysyms;
+
+ /*
+ * lets go get the keysyms from the server.
+ */
+ if (!dpy->keysyms) {
+ n = dpy->max_keycode - dpy->min_keycode + 1;
+ keysyms = XGetKeyboardMapping (dpy, (KeyCode) dpy->min_keycode,
+ n, &per);
+ /* keysyms may be NULL */
+ if (! keysyms) return 0;
+
+ LockDisplay(dpy);
+ if (dpy->keysyms)
+ Xfree ((char *)dpy->keysyms);
+ dpy->keysyms = keysyms;
+ dpy->keysyms_per_keycode = per;
+ if (dpy->modifiermap)
+ ResetModMap(dpy);
+ UnlockDisplay(dpy);
+ }
+ if (!dpy->modifiermap)
+ return InitModMap(dpy);
+ return 1;
+}
+
+void
+XConvertCase(sym, lower, upper)
+ register KeySym sym;
+ KeySym *lower;
+ KeySym *upper;
+{
+ *lower = sym;
+ *upper = sym;
+ switch(sym >> 8) {
+ case 0: /* Latin 1 */
+ if ((sym >= XK_A) && (sym <= XK_Z))
+ *lower += (XK_a - XK_A);
+ else if ((sym >= XK_a) && (sym <= XK_z))
+ *upper -= (XK_a - XK_A);
+ else if ((sym >= XK_Agrave) && (sym <= XK_Odiaeresis))
+ *lower += (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_agrave) && (sym <= XK_odiaeresis))
+ *upper -= (XK_agrave - XK_Agrave);
+ else if ((sym >= XK_Ooblique) && (sym <= XK_Thorn))
+ *lower += (XK_oslash - XK_Ooblique);
+ else if ((sym >= XK_oslash) && (sym <= XK_thorn))
+ *upper -= (XK_oslash - XK_Ooblique);
+ break;
+ case 1: /* Latin 2 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym == XK_Aogonek)
+ *lower = XK_aogonek;
+ else if (sym >= XK_Lstroke && sym <= XK_Sacute)
+ *lower += (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_Scaron && sym <= XK_Zacute)
+ *lower += (XK_scaron - XK_Scaron);
+ else if (sym >= XK_Zcaron && sym <= XK_Zabovedot)
+ *lower += (XK_zcaron - XK_Zcaron);
+ else if (sym == XK_aogonek)
+ *upper = XK_Aogonek;
+ else if (sym >= XK_lstroke && sym <= XK_sacute)
+ *upper -= (XK_lstroke - XK_Lstroke);
+ else if (sym >= XK_scaron && sym <= XK_zacute)
+ *upper -= (XK_scaron - XK_Scaron);
+ else if (sym >= XK_zcaron && sym <= XK_zabovedot)
+ *upper -= (XK_zcaron - XK_Zcaron);
+ else if (sym >= XK_Racute && sym <= XK_Tcedilla)
+ *lower += (XK_racute - XK_Racute);
+ else if (sym >= XK_racute && sym <= XK_tcedilla)
+ *upper -= (XK_racute - XK_Racute);
+ break;
+ case 2: /* Latin 3 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Hstroke && sym <= XK_Hcircumflex)
+ *lower += (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_Gbreve && sym <= XK_Jcircumflex)
+ *lower += (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_hstroke && sym <= XK_hcircumflex)
+ *upper -= (XK_hstroke - XK_Hstroke);
+ else if (sym >= XK_gbreve && sym <= XK_jcircumflex)
+ *upper -= (XK_gbreve - XK_Gbreve);
+ else if (sym >= XK_Cabovedot && sym <= XK_Scircumflex)
+ *lower += (XK_cabovedot - XK_Cabovedot);
+ else if (sym >= XK_cabovedot && sym <= XK_scircumflex)
+ *upper -= (XK_cabovedot - XK_Cabovedot);
+ break;
+ case 3: /* Latin 4 */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Rcedilla && sym <= XK_Tslash)
+ *lower += (XK_rcedilla - XK_Rcedilla);
+ else if (sym >= XK_rcedilla && sym <= XK_tslash)
+ *upper -= (XK_rcedilla - XK_Rcedilla);
+ else if (sym == XK_ENG)
+ *lower = XK_eng;
+ else if (sym == XK_eng)
+ *upper = XK_ENG;
+ else if (sym >= XK_Amacron && sym <= XK_Umacron)
+ *lower += (XK_amacron - XK_Amacron);
+ else if (sym >= XK_amacron && sym <= XK_umacron)
+ *upper -= (XK_amacron - XK_Amacron);
+ break;
+ case 6: /* Cyrillic */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Serbian_DJE && sym <= XK_Serbian_DZE)
+ *lower -= (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Serbian_dje && sym <= XK_Serbian_dze)
+ *upper += (XK_Serbian_DJE - XK_Serbian_dje);
+ else if (sym >= XK_Cyrillic_YU && sym <= XK_Cyrillic_HARDSIGN)
+ *lower -= (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ else if (sym >= XK_Cyrillic_yu && sym <= XK_Cyrillic_hardsign)
+ *upper += (XK_Cyrillic_YU - XK_Cyrillic_yu);
+ break;
+ case 7: /* Greek */
+ /* Assume the KeySym is a legal value (ignore discontinuities) */
+ if (sym >= XK_Greek_ALPHAaccent && sym <= XK_Greek_OMEGAaccent)
+ *lower += (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_alphaaccent && sym <= XK_Greek_omegaaccent &&
+ sym != XK_Greek_iotaaccentdieresis &&
+ sym != XK_Greek_upsilonaccentdieresis)
+ *upper -= (XK_Greek_alphaaccent - XK_Greek_ALPHAaccent);
+ else if (sym >= XK_Greek_ALPHA && sym <= XK_Greek_OMEGA)
+ *lower += (XK_Greek_alpha - XK_Greek_ALPHA);
+ else if (sym >= XK_Greek_alpha && sym <= XK_Greek_omega &&
+ sym != XK_Greek_finalsmallsigma)
+ *upper -= (XK_Greek_alpha - XK_Greek_ALPHA);
+ break;
+ }
+}
+
+int
+#if NeedFunctionPrototypes
+_XTranslateKey( register Display *dpy,
+ KeyCode keycode,
+ register unsigned int modifiers,
+ unsigned int *modifiers_return,
+ KeySym *keysym_return)
+#else
+_XTranslateKey(dpy, keycode, modifiers, modifiers_return, keysym_return)
+ register Display *dpy;
+ KeyCode keycode;
+ register unsigned int modifiers;
+ unsigned int *modifiers_return;
+ KeySym *keysym_return;
+#endif
+{
+ int per;
+ register KeySym *syms;
+ KeySym sym, lsym, usym;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ *modifiers_return = ((ShiftMask|LockMask)
+ | dpy->mode_switch | dpy->num_lock);
+ if (((int)keycode < dpy->min_keycode) || ((int)keycode > dpy->max_keycode))
+ {
+ *keysym_return = NoSymbol;
+ return 1;
+ }
+ per = dpy->keysyms_per_keycode;
+ syms = &dpy->keysyms[(keycode - dpy->min_keycode) * per];
+ while ((per > 2) && (syms[per - 1] == NoSymbol))
+ per--;
+ if ((per > 2) && (modifiers & dpy->mode_switch)) {
+ syms += 2;
+ per -= 2;
+ }
+ if ((modifiers & dpy->num_lock) &&
+ (per > 1 && (IsKeypadKey(syms[1]) || IsPrivateKeypadKey(syms[1])))) {
+ if ((modifiers & ShiftMask) ||
+ ((modifiers & LockMask) && (dpy->lock_meaning == XK_Shift_Lock)))
+ *keysym_return = syms[0];
+ else
+ *keysym_return = syms[1];
+ } else if (!(modifiers & ShiftMask) &&
+ (!(modifiers & LockMask) || (dpy->lock_meaning == NoSymbol))) {
+ if ((per == 1) || (syms[1] == NoSymbol))
+ XConvertCase(syms[0], keysym_return, &usym);
+ else
+ *keysym_return = syms[0];
+ } else if (!(modifiers & LockMask) ||
+ (dpy->lock_meaning != XK_Caps_Lock)) {
+ if ((per == 1) || ((usym = syms[1]) == NoSymbol))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ } else {
+ if ((per == 1) || ((sym = syms[1]) == NoSymbol))
+ sym = syms[0];
+ XConvertCase(sym, &lsym, &usym);
+ if (!(modifiers & ShiftMask) && (sym != syms[0]) &&
+ ((sym != usym) || (lsym == usym)))
+ XConvertCase(syms[0], &lsym, &usym);
+ *keysym_return = usym;
+ }
+ if (*keysym_return == XK_VoidSymbol)
+ *keysym_return = NoSymbol;
+ return 1;
+}
+
+int
+_XTranslateKeySym(dpy, symbol, modifiers, buffer, nbytes)
+ Display *dpy;
+ register KeySym symbol;
+ unsigned int modifiers;
+ char *buffer;
+ int nbytes;
+{
+ register struct _XKeytrans *p;
+ int length;
+ unsigned long hiBytes;
+ register unsigned char c;
+
+ if (!symbol)
+ return 0;
+ /* see if symbol rebound, if so, return that string. */
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((modifiers & AllMods) == p->state) && (symbol == p->key)) {
+ length = p->len;
+ if (length > nbytes) length = nbytes;
+ memcpy (buffer, p->string, length);
+ return length;
+ }
+ }
+ /* try to convert to Latin-1, handling control */
+ hiBytes = symbol >> 8;
+ if (!(nbytes &&
+ ((hiBytes == 0) ||
+ ((hiBytes == 0xFF) &&
+ (((symbol >= XK_BackSpace) && (symbol <= XK_Clear)) ||
+ (symbol == XK_Return) ||
+ (symbol == XK_Escape) ||
+ (symbol == XK_KP_Space) ||
+ (symbol == XK_KP_Tab) ||
+ (symbol == XK_KP_Enter) ||
+ ((symbol >= XK_KP_Multiply) && (symbol <= XK_KP_9)) ||
+ (symbol == XK_KP_Equal) ||
+ (symbol == XK_Delete))))))
+ return 0;
+
+ /* if X keysym, convert to ascii by grabbing low 7 bits */
+ if (symbol == XK_KP_Space)
+ c = XK_space & 0x7F; /* patch encoding botch */
+ else if (hiBytes == 0xFF)
+ c = symbol & 0x7F;
+ else
+ c = symbol & 0xFF;
+ /* only apply Control key if it makes sense, else ignore it */
+ if (modifiers & ControlMask) {
+ if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
+ else if (c == '2') c = '\000';
+ else if (c >= '3' && c <= '7') c -= ('3' - '\033');
+ else if (c == '8') c = '\177';
+ else if (c == '/') c = '_' & 0x1F;
+ }
+ buffer[0] = c;
+ return 1;
+}
+
+/*ARGSUSED*/
+int
+XLookupString (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer; /* buffer */
+ int nbytes; /* space in buffer for characters */
+ KeySym *keysym;
+ XComposeStatus *status; /* not implemented */
+{
+ unsigned int modifiers;
+ KeySym symbol;
+
+ if (! _XTranslateKey(event->display, event->keycode, event->state,
+ &modifiers, &symbol))
+ return 0;
+
+#ifdef USE_OWN_COMPOSE
+ if ( status ) {
+ static int been_here= 0;
+ if ( !been_here ) {
+ XimCompInitTables();
+ been_here = 1;
+ }
+ if ( !XimCompLegalStatus(status) ) {
+ status->compose_ptr = NULL;
+ status->chars_matched = 0;
+ }
+ if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
+ XimCompIsComposeKey(symbol,event->keycode,status) ) {
+ XimCompRtrn rtrn;
+ switch (XimCompProcessSym(status,symbol,&rtrn)) {
+ case XIM_COMP_IGNORE:
+ break;
+ case XIM_COMP_IN_PROGRESS:
+ if ( keysym!=NULL )
+ *keysym = NoSymbol;
+ return 0;
+ case XIM_COMP_FAIL:
+ {
+ int n = 0, len= 0;
+ for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= _XTranslateKeySym(event->display,rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len);
+ }
+ }
+ if ( keysym!=NULL ) {
+ if ( n==1 ) *keysym = rtrn.sym[0];
+ else *keysym = NoSymbol;
+ }
+ return len;
+ }
+ case XIM_COMP_SUCCEED:
+ {
+ int len,n = 0;
+
+ symbol = rtrn.matchSym;
+ if ( keysym!=NULL ) *keysym = symbol;
+ if ( rtrn.str[0]!='\0' ) {
+ strncpy(buffer,rtrn.str,nbytes-1);
+ buffer[nbytes-1]= '\0';
+ len = strlen(buffer);
+ }
+ else {
+ len = _XTranslateKeySym(event->display,symbol,
+ event->state,
+ buffer,nbytes);
+ }
+ for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= _XTranslateKeySym(event->display,rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len);
+ }
+ }
+ return len;
+ }
+ }
+ }
+ }
+#endif
+
+ if (keysym)
+ *keysym = symbol;
+ /* arguable whether to use (event->state & ~modifiers) here */
+ return _XTranslateKeySym(event->display, symbol, event->state,
+ buffer, nbytes);
+}
+
+static void
+_XFreeKeyBindings (dpy)
+ Display *dpy;
+{
+ register struct _XKeytrans *p, *np;
+
+ for (p = dpy->key_bindings; p; p = np) {
+ np = p->next;
+ Xfree(p->string);
+ Xfree((char *)p->modifiers);
+ Xfree((char *)p);
+ }
+}
+
+#if NeedFunctionPrototypes
+XRebindKeysym (
+ Display *dpy,
+ KeySym keysym,
+ KeySym *mlist,
+ int nm, /* number of modifiers in mlist */
+ _Xconst unsigned char *str,
+ int nbytes)
+#else
+XRebindKeysym (dpy, keysym, mlist, nm, str, nbytes)
+ Display *dpy;
+ KeySym keysym;
+ KeySym *mlist;
+ int nm; /* number of modifiers in mlist */
+ unsigned char *str;
+ int nbytes;
+#endif
+{
+ register struct _XKeytrans *tmp, *p;
+ int nb;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ LockDisplay(dpy);
+ tmp = dpy->key_bindings;
+ nb = sizeof(KeySym) * nm;
+
+ if ((! (p = (struct _XKeytrans *) Xmalloc( sizeof(struct _XKeytrans)))) ||
+ ((! (p->string = (char *) Xmalloc( (unsigned) nbytes))) &&
+ (nbytes > 0)) ||
+ ((! (p->modifiers = (KeySym *) Xmalloc( (unsigned) nb))) &&
+ (nb > 0))) {
+ if (p) {
+ if (p->string) Xfree(p->string);
+ if (p->modifiers) Xfree((char *) p->modifiers);
+ Xfree((char *) p);
+ }
+ UnlockDisplay(dpy);
+ return 0;
+ }
+
+ dpy->key_bindings = p;
+ dpy->free_funcs->key_bindings = _XFreeKeyBindings;
+ p->next = tmp; /* chain onto list */
+ memcpy (p->string, (char *) str, nbytes);
+ p->len = nbytes;
+ memcpy ((char *) p->modifiers, (char *) mlist, nb);
+ p->key = keysym;
+ p->mlen = nm;
+ ComputeMaskFromKeytrans(dpy, p);
+ UnlockDisplay(dpy);
+ return 0;
+}
+
+unsigned
+_XKeysymToModifiers(dpy,ks)
+ Display *dpy;
+ KeySym ks;
+{
+ CARD8 code,mods;
+ register KeySym *kmax;
+ register KeySym *k;
+ register XModifierKeymap *m;
+
+ if ((! dpy->keysyms) && (! _XKeyInitialize(dpy)))
+ return 0;
+ kmax = dpy->keysyms +
+ (dpy->max_keycode - dpy->min_keycode + 1) * dpy->keysyms_per_keycode;
+ k = dpy->keysyms;
+ m = dpy->modifiermap;
+ mods= 0;
+ while (k<kmax) {
+ if (*k == ks ) {
+ register int j = m->max_keypermod<<3;
+
+ code=(((k-dpy->keysyms)/dpy->keysyms_per_keycode)+dpy->min_keycode);
+
+ while (--j >= 0) {
+ if (code == m->modifiermap[j])
+ mods|= (1<<(j/m->max_keypermod));
+ }
+ }
+ k++;
+ }
+ return mods;
+}
+
+/*
+ * given a list of modifiers, computes the mask necessary for later matching.
+ * This routine must lookup the key in the Keymap and then search to see
+ * what modifier it is bound to, if any. Sets the AnyModifier bit if it
+ * can't map some keysym to a modifier.
+ */
+static void
+ComputeMaskFromKeytrans(dpy, p)
+ Display *dpy;
+ register struct _XKeytrans *p;
+{
+ register int i;
+
+ p->state = AnyModifier;
+ for (i = 0; i < p->mlen; i++) {
+ p->state|= XkbKeysymToModifiers(dpy,p->modifiers[i]);
+ }
+ p->state &= AllMods;
+}
diff --git a/src/KeysymStr.c b/src/KeysymStr.c
new file mode 100644
index 00000000..1e94a5d7
--- /dev/null
+++ b/src/KeysymStr.c
@@ -0,0 +1,137 @@
+/* $Xorg: KeysymStr.c,v 1.5 2001/02/09 02:03:34 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+typedef unsigned long Signature;
+
+#define NEEDVTABLE
+#include "ks_tables.h"
+
+extern XrmDatabase _XInitKeysymDB();
+extern Const unsigned char _XkeyTable[];
+
+
+typedef struct _GRNData {
+ char *name;
+ XrmRepresentation type;
+ XrmValuePtr value;
+} GRNData;
+
+#if NeedFunctionPrototypes
+/*ARGSUSED*/
+static Bool SameValue(
+ XrmDatabase* db,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ XrmRepresentation* type,
+ XrmValuePtr value,
+ XPointer data
+)
+#else
+static Bool SameValue(db, bindings, quarks, type, value, data)
+ XrmDatabase *db;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ XrmRepresentation *type;
+ XrmValuePtr value;
+ XPointer data;
+#endif
+{
+ GRNData *gd = (GRNData *)data;
+
+ if ((*type == gd->type) && (value->size == gd->value->size) &&
+ !strncmp((char *)value->addr, (char *)gd->value->addr, value->size))
+ {
+ gd->name = XrmQuarkToString(*quarks); /* XXX */
+ return True;
+ }
+ return False;
+}
+
+char *XKeysymToString(ks)
+ KeySym ks;
+{
+ register int i, n;
+ int h;
+ register int idx;
+ Const unsigned char *entry;
+ unsigned char val1, val2;
+ XrmDatabase keysymdb;
+
+ if (!ks || (ks & ((unsigned long) ~0x1fffffff)) != 0)
+ return ((char *)NULL);
+ if (ks == XK_VoidSymbol)
+ ks = 0;
+ if (ks <= 0xffff)
+ {
+ val1 = ks >> 8;
+ val2 = ks & 0xff;
+ i = ks % VTABLESIZE;
+ h = i + 1;
+ n = VMAXHASH;
+ while ((idx = hashKeysym[i]))
+ {
+ entry = &_XkeyTable[idx];
+ if ((entry[0] == val1) && (entry[1] == val2))
+ return ((char *)entry + 2);
+ if (!--n)
+ break;
+ i += h;
+ if (i >= VTABLESIZE)
+ i -= VTABLESIZE;
+ }
+ }
+
+ if ((keysymdb = _XInitKeysymDB()))
+ {
+ char buf[9];
+ XrmValue resval;
+ XrmQuark empty = NULLQUARK;
+ GRNData data;
+
+ sprintf(buf, "%lX", ks);
+ resval.addr = (XPointer)buf;
+ resval.size = strlen(buf) + 1;
+ data.name = (char *)NULL;
+ data.type = XrmPermStringToQuark("String");
+ data.value = &resval;
+ (void)XrmEnumerateDatabase(keysymdb, &empty, &empty, XrmEnumAllLevels,
+ SameValue, (XPointer)&data);
+ return data.name;
+ }
+ return ((char *) NULL);
+}
diff --git a/src/KillCl.c b/src/KillCl.c
new file mode 100644
index 00000000..750ea825
--- /dev/null
+++ b/src/KillCl.c
@@ -0,0 +1,41 @@
+/* $Xorg: KillCl.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XKillClient(dpy, resource)
+ register Display *dpy;
+ XID resource;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(KillClient, resource, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/LiHosts.c b/src/LiHosts.c
new file mode 100644
index 00000000..2f22d71d
--- /dev/null
+++ b/src/LiHosts.c
@@ -0,0 +1,100 @@
+/* $Xorg: LiHosts.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/* This can really be considered an os dependent routine */
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+/*
+ * can be freed using XFree.
+ */
+
+XHostAddress *XListHosts (dpy, nhosts, enabled)
+ register Display *dpy;
+ int *nhosts; /* RETURN */
+ Bool *enabled; /* RETURN */
+ {
+ register XHostAddress *outbuf = 0, *op;
+ xListHostsReply reply;
+ long nbytes;
+ unsigned char *buf, *bp;
+ register unsigned i;
+ register xListHostsReq *req;
+
+ *nhosts = 0;
+ LockDisplay(dpy);
+ GetReq (ListHosts, req);
+
+ if (!_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+
+ if (reply.nHosts) {
+ nbytes = reply.length << 2; /* compute number of bytes in reply */
+ op = outbuf = (XHostAddress *)
+ Xmalloc((unsigned) (nbytes + reply.nHosts * sizeof(XHostAddress)));
+
+ if (! outbuf) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XHostAddress *) NULL;
+ }
+ bp = buf =
+ ((unsigned char *) outbuf) + reply.nHosts * sizeof(XHostAddress);
+
+ _XRead (dpy, (char *) buf, nbytes);
+
+ for (i = 0; i < reply.nHosts; i++) {
+#ifdef WORD64
+ xHostEntry xhe;
+ memcpy((char *)&xhe, bp, SIZEOF(xHostEntry));
+ op->family = xhe.family;
+ op->length = xhe.length;
+#else
+ op->family = ((xHostEntry *) bp)->family;
+ op->length =((xHostEntry *) bp)->length;
+#endif
+ op->address = (char *) (bp + SIZEOF(xHostEntry));
+ bp += SIZEOF(xHostEntry) + (((op->length + 3) >> 2) << 2);
+ op++;
+ }
+ }
+
+ *enabled = reply.enabled;
+ *nhosts = reply.nHosts;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (outbuf);
+}
+
+
+
+
+
diff --git a/src/LiICmaps.c b/src/LiICmaps.c
new file mode 100644
index 00000000..93076cc7
--- /dev/null
+++ b/src/LiICmaps.c
@@ -0,0 +1,70 @@
+/* $Xorg: LiICmaps.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Colormap *XListInstalledColormaps(dpy, win, n)
+register Display *dpy;
+Window win;
+int *n; /* RETURN */
+{
+ long nbytes;
+ Colormap *cmaps;
+ xListInstalledColormapsReply rep;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(ListInstalledColormaps, win, req);
+
+ if(_XReply(dpy, (xReply *) &rep, 0, xFalse) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *n = 0;
+ return((Colormap *) NULL);
+ }
+
+ if (rep.nColormaps) {
+ nbytes = rep.nColormaps * sizeof(Colormap);
+ cmaps = (Colormap *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.nColormaps << 2;
+ if (! cmaps) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return((Colormap *) NULL);
+ }
+ _XRead32 (dpy, (char *) cmaps, nbytes);
+ }
+ else cmaps = (Colormap *) NULL;
+
+ *n = rep.nColormaps;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(cmaps);
+}
+
diff --git a/src/LiProps.c b/src/LiProps.c
new file mode 100644
index 00000000..ae733d74
--- /dev/null
+++ b/src/LiProps.c
@@ -0,0 +1,68 @@
+/* $Xorg: LiProps.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Atom *XListProperties(dpy, window, n_props)
+register Display *dpy;
+Window window;
+int *n_props; /* RETURN */
+{
+ long nbytes;
+ xListPropertiesReply rep;
+ Atom *properties;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(ListProperties, window, req);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ *n_props = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((Atom *) NULL);
+ }
+
+ if (rep.nProperties) {
+ nbytes = rep.nProperties * sizeof(Atom);
+ properties = (Atom *) Xmalloc ((unsigned) nbytes);
+ nbytes = rep.nProperties << 2;
+ if (! properties) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (Atom *) NULL;
+ }
+ _XRead32 (dpy, (char *) properties, nbytes);
+ }
+ else properties = (Atom *) NULL;
+
+ *n_props = rep.nProperties;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (properties);
+}
diff --git a/src/ListExt.c b/src/ListExt.c
new file mode 100644
index 00000000..6d626be9
--- /dev/null
+++ b/src/ListExt.c
@@ -0,0 +1,96 @@
+/* $Xorg: ListExt.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+char **XListExtensions(dpy, nextensions)
+register Display *dpy;
+int *nextensions; /* RETURN */
+{
+ xListExtensionsReply rep;
+ char **list;
+ char *ch;
+ register unsigned i;
+ register int length;
+ register xReq *req;
+ register long rlen;
+
+ LockDisplay(dpy);
+ GetEmptyReq (ListExtensions, req);
+
+ if (! _XReply (dpy, (xReply *) &rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ if (rep.nExtensions) {
+ list = (char **) Xmalloc (
+ (unsigned)(rep.nExtensions * sizeof (char *)));
+ rlen = rep.length << 2;
+ ch = (char *) Xmalloc ((unsigned) rlen + 1);
+ /* +1 to leave room for last null-terminator */
+
+ if ((!list) || (!ch)) {
+ if (list) Xfree((char *) list);
+ if (ch) Xfree((char *) ch);
+ _XEatData(dpy, (unsigned long) rlen);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (char **) NULL;
+ }
+
+ _XReadPad (dpy, ch, rlen);
+ /*
+ * unpack into null terminated strings.
+ */
+ length = *ch;
+ for (i = 0; i < rep.nExtensions; i++) {
+ list[i] = ch+1; /* skip over length */
+ ch += length + 1; /* find next length ... */
+ length = *ch;
+ *ch = '\0'; /* and replace with null-termination */
+ }
+ }
+ else list = (char **) NULL;
+
+ *nextensions = rep.nExtensions;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (list);
+}
+
+XFreeExtensionList (list)
+char **list;
+{
+ if (list != NULL) {
+ Xfree (list[0]-1);
+ Xfree ((char *)list);
+ }
+ return 1;
+}
diff --git a/src/LoadFont.c b/src/LoadFont.c
new file mode 100644
index 00000000..6dd96ad6
--- /dev/null
+++ b/src/LoadFont.c
@@ -0,0 +1,54 @@
+/* $Xorg: LoadFont.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+Font XLoadFont (
+ register Display *dpy,
+ _Xconst char *name)
+#else
+Font XLoadFont (dpy, name)
+ register Display *dpy;
+ char *name;
+#endif
+{
+ register long nbytes;
+ Font fid;
+ register xOpenFontReq *req;
+ LockDisplay(dpy);
+ GetReq(OpenFont, req);
+ nbytes = req->nbytes = name ? strlen(name) : 0;
+ req->fid = fid = XAllocID(dpy);
+ req->length += (nbytes+3)>>2;
+ Data (dpy, name, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (fid);
+ /* can't return (req->fid) since request may have already been sent */
+}
+
diff --git a/src/LockDis.c b/src/LockDis.c
new file mode 100644
index 00000000..91766791
--- /dev/null
+++ b/src/LockDis.c
@@ -0,0 +1,90 @@
+/* $Xorg: LockDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+
+/*
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * XLockDis.c - multi-thread application-level locking routines
+ */
+
+#include "Xlibint.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+
+#if NeedFunctionPrototypes
+void XLockDisplay(
+ register Display* dpy)
+#else
+void XLockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ /*
+ * We want the threads in the reply queue to all get out before
+ * XLockDisplay returns, in case they have any side effects the
+ * caller of XLockDisplay was trying to protect against.
+ * XLockDisplay puts itself at the head of the event waiters queue
+ * to wait for all the replies to come in.
+ */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ struct _XCVList *cvl;
+
+ cvl = (*dpy->lock->create_cvl)(dpy);
+
+ /* stuff ourselves on the head of the queue */
+ cvl->next = dpy->lock->event_awaiters;
+ dpy->lock->event_awaiters = cvl;
+
+ while (dpy->lock->reply_awaiters)
+ ConditionWait(dpy, cvl->cv);
+ UnlockNextEventReader(dpy); /* pass the signal on */
+ }
+ UnlockDisplay(dpy);
+#endif
+}
+
+#if NeedFunctionPrototypes
+void XUnlockDisplay(
+ register Display* dpy)
+#else
+void XUnlockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif
+}
diff --git a/src/LookupCol.c b/src/LookupCol.c
new file mode 100644
index 00000000..b7f56d3d
--- /dev/null
+++ b/src/LookupCol.c
@@ -0,0 +1,104 @@
+/* $Xorg: LookupCol.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+extern void _XUnresolveColor();
+
+#if NeedFunctionPrototypes
+Status XLookupColor (
+ register Display *dpy,
+ Colormap cmap,
+ _Xconst char *spec,
+ XColor *def,
+ XColor *scr)
+#else
+Status XLookupColor (dpy, cmap, spec, def, scr)
+ register Display *dpy;
+ Colormap cmap;
+ char *spec;
+ XColor *def, *scr;
+#endif
+{
+ register int n;
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ /* copy string to allow overwrite by _XcmsResolveColorString() */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &spec,
+ &cmsColor_exact, XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, def, 1);
+ memcpy((char *)scr, (char *)def, sizeof(XColor));
+ _XUnresolveColor(ccc, scr);
+ return(1);
+ }
+ /*
+ * Otherwise we failed; or spec was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ n = strlen (spec);
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n;
+ req->length += (n + 3) >> 2;
+ Data (dpy, spec, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ def->red = reply.exactRed;
+ def->green = reply.exactGreen;
+ def->blue = reply.exactBlue;
+
+ scr->red = reply.screenRed;
+ scr->green = reply.screenGreen;
+ scr->blue = reply.screenBlue;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
diff --git a/src/LowerWin.c b/src/LowerWin.c
new file mode 100644
index 00000000..fb53df0a
--- /dev/null
+++ b/src/LowerWin.c
@@ -0,0 +1,46 @@
+/* $Xorg: LowerWin.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XLowerWindow(dpy, w)
+Display *dpy;
+Window w;
+{
+ register xConfigureWindowReq *req;
+ unsigned long val = Below; /* needed for macro */
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWStackMode;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/Macros.c b/src/Macros.c
new file mode 100644
index 00000000..61188588
--- /dev/null
+++ b/src/Macros.c
@@ -0,0 +1,250 @@
+/* $Xorg: Macros.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+/*
+ * This file makes full definitions of routines for each macro.
+ * We do not expect C programs to use these, but other languages may
+ * need them.
+ */
+
+int XConnectionNumber(dpy) Display *dpy; { return (ConnectionNumber(dpy)); }
+
+Window XRootWindow (dpy, scr)
+ Display *dpy; int scr;
+ { return (RootWindow(dpy,scr)); }
+
+int XDefaultScreen(dpy) Display *dpy; { return (DefaultScreen(dpy)); }
+
+Window XDefaultRootWindow (dpy)
+ Display *dpy;
+ { return (RootWindow(dpy,DefaultScreen(dpy))); }
+
+Visual *XDefaultVisual(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultVisual(dpy, scr)); }
+
+GC XDefaultGC(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultGC(dpy,scr)); }
+
+unsigned long XBlackPixel(dpy, scr)
+ Display *dpy; int scr;
+ { return (BlackPixel(dpy, scr)); }
+
+unsigned long XWhitePixel(dpy, scr)
+ Display *dpy; int scr;
+ { return (WhitePixel(dpy,scr)); }
+
+unsigned long XAllPlanes() { return AllPlanes; }
+
+int XQLength(dpy) Display *dpy; { return (QLength(dpy)); }
+
+int XDisplayWidth(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayWidth(dpy,scr)); }
+
+int XDisplayHeight(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayHeight(dpy, scr)); }
+
+int XDisplayWidthMM(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayWidthMM(dpy, scr)); }
+
+int XDisplayHeightMM(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayHeightMM(dpy, scr)); }
+
+int XDisplayPlanes(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayPlanes(dpy, scr)); }
+
+int XDisplayCells(dpy, scr)
+ Display *dpy; int scr;
+ { return (DisplayCells (dpy, scr)); }
+
+int XScreenCount(dpy) Display *dpy; { return (ScreenCount(dpy)); }
+
+char *XServerVendor(dpy) Display *dpy; { return (ServerVendor(dpy)); }
+
+int XProtocolVersion(dpy) Display *dpy; { return (ProtocolVersion(dpy)); }
+
+int XProtocolRevision(dpy) Display *dpy; { return (ProtocolRevision(dpy));}
+
+int XVendorRelease(dpy) Display *dpy; { return (VendorRelease(dpy)); }
+
+char *XDisplayString(dpy) Display *dpy; { return (DisplayString(dpy)); }
+
+int XDefaultDepth(dpy, scr)
+ Display *dpy; int scr;
+ { return(DefaultDepth(dpy, scr)); }
+
+Colormap XDefaultColormap(dpy, scr)
+ Display *dpy; int scr;
+ { return (DefaultColormap(dpy, scr)); }
+
+int XBitmapUnit(dpy) Display *dpy; { return (BitmapUnit(dpy)); }
+
+int XBitmapBitOrder(dpy) Display *dpy; { return (BitmapBitOrder(dpy)); }
+
+int XBitmapPad(dpy) Display *dpy; { return (BitmapPad(dpy)); }
+
+int XImageByteOrder(dpy) Display *dpy; { return (ImageByteOrder(dpy)); }
+
+unsigned long XNextRequest(dpy)
+ Display *dpy;
+ {
+#ifdef WORD64
+ WORD64ALIGN
+ return dpy->request + 1;
+#else
+ return (NextRequest(dpy));
+#endif
+ }
+
+unsigned long XLastKnownRequestProcessed(dpy)
+ Display *dpy;
+ { return (LastKnownRequestProcessed(dpy)); }
+
+/* screen oriented macros (toolkit) */
+Screen *XScreenOfDisplay(dpy, scr) Display *dpy; int scr;
+ { return (ScreenOfDisplay(dpy, scr)); }
+
+Screen *XDefaultScreenOfDisplay(dpy) Display *dpy;
+ { return (DefaultScreenOfDisplay(dpy)); }
+
+Display *XDisplayOfScreen(s) Screen *s; { return (DisplayOfScreen(s)); }
+
+Window XRootWindowOfScreen(s) Screen *s; { return (RootWindowOfScreen(s)); }
+
+unsigned long XBlackPixelOfScreen(s) Screen *s;
+ { return (BlackPixelOfScreen(s)); }
+
+unsigned long XWhitePixelOfScreen(s) Screen *s;
+ { return (WhitePixelOfScreen(s)); }
+
+Colormap XDefaultColormapOfScreen(s) Screen *s;
+ { return (DefaultColormapOfScreen(s)); }
+
+int XDefaultDepthOfScreen(s) Screen *s; { return (DefaultDepthOfScreen(s)); }
+
+GC XDefaultGCOfScreen(s) Screen *s; { return (DefaultGCOfScreen(s)); }
+
+Visual *XDefaultVisualOfScreen(s) Screen *s;
+ { return (DefaultVisualOfScreen(s)); }
+
+int XWidthOfScreen(s) Screen *s; { return (WidthOfScreen(s)); }
+
+int XHeightOfScreen(s) Screen *s; { return (HeightOfScreen(s)); }
+
+int XWidthMMOfScreen(s) Screen *s; { return (WidthMMOfScreen(s)); }
+
+int XHeightMMOfScreen(s) Screen *s; { return (HeightMMOfScreen(s)); }
+
+int XPlanesOfScreen(s) Screen *s; { return (PlanesOfScreen(s)); }
+
+int XCellsOfScreen(s) Screen *s; { return (CellsOfScreen(s)); }
+
+int XMinCmapsOfScreen(s) Screen *s; { return (MinCmapsOfScreen(s)); }
+
+int XMaxCmapsOfScreen(s) Screen *s; { return (MaxCmapsOfScreen(s)); }
+
+Bool XDoesSaveUnders(s) Screen *s; { return (DoesSaveUnders(s)); }
+
+int XDoesBackingStore(s) Screen *s; { return (DoesBackingStore(s)); }
+
+long XEventMaskOfScreen(s) Screen *s; { return (EventMaskOfScreen(s)); }
+
+int XScreenNumberOfScreen (scr)
+ register Screen *scr;
+{
+ register Display *dpy = scr->display;
+ register Screen *dpyscr = dpy->screens;
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++, dpyscr++) {
+ if (scr == dpyscr) return i;
+ }
+ return -1;
+}
+
+/*
+ * These macros are used to give some sugar to the image routines so that
+ * naive people are more comfortable with them.
+ */
+#undef XDestroyImage
+XDestroyImage(ximage)
+ XImage *ximage;
+{
+ return((*((ximage)->f.destroy_image))((ximage)));
+}
+#undef XGetPixel
+unsigned long XGetPixel(ximage, x, y)
+ XImage *ximage;
+ int x, y;
+{
+ return ((*((ximage)->f.get_pixel))((ximage), (x), (y)));
+}
+#undef XPutPixel
+int XPutPixel(ximage, x, y, pixel)
+ XImage *ximage;
+ int x, y;
+ unsigned long pixel;
+{
+ return((*((ximage)->f.put_pixel))((ximage), (x), (y), (pixel)));
+}
+#undef XSubImage
+XImage *XSubImage(ximage, x, y, width, height)
+ XImage *ximage;
+ int x, y;
+ unsigned int width, height;
+{
+ return((*((ximage)->f.sub_image))((ximage), (x),
+ (y), (width), (height)));
+}
+#undef XAddPixel
+int XAddPixel(ximage, value)
+ XImage *ximage;
+ long value;
+{
+ return((*((ximage)->f.add_pixel))((ximage), (value)));
+}
+
+
+XNoOp (dpy)
+ register Display *dpy;
+{
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(NoOperation, req);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/MapRaised.c b/src/MapRaised.c
new file mode 100644
index 00000000..e00cb75a
--- /dev/null
+++ b/src/MapRaised.c
@@ -0,0 +1,48 @@
+/* $Xorg: MapRaised.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapRaised (dpy, w)
+ Window w;
+ register Display *dpy;
+{
+ register xConfigureWindowReq *req;
+ register xResourceReq *req2;
+ unsigned long val = Above; /* needed for macro */
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWStackMode;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val);
+ GetResReq (MapWindow, w, req2);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/MapSubs.c b/src/MapSubs.c
new file mode 100644
index 00000000..39589e93
--- /dev/null
+++ b/src/MapSubs.c
@@ -0,0 +1,40 @@
+/* $Xorg: MapSubs.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapSubwindows(dpy, win)
+ register Display *dpy;
+ Window win;
+{
+ register xResourceReq *req;
+ LockDisplay(dpy);
+ GetResReq(MapSubwindows, win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/MapWindow.c b/src/MapWindow.c
new file mode 100644
index 00000000..e0c06efe
--- /dev/null
+++ b/src/MapWindow.c
@@ -0,0 +1,41 @@
+/* $Xorg: MapWindow.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMapWindow (dpy, w)
+ Window w;
+ register Display *dpy;
+{
+ register xResourceReq *req;
+ LockDisplay (dpy);
+ GetResReq(MapWindow, w, req);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/MaskEvent.c b/src/MaskEvent.c
new file mode 100644
index 00000000..c51d7b9d
--- /dev/null
+++ b/src/MaskEvent.c
@@ -0,0 +1,80 @@
+/* $Xorg: MaskEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+extern long Const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * return the next event in the queue matching one of the events in the mask.
+ * If no event, flush output, and wait until match succeeds.
+ * Events earlier in the queue are not discarded.
+ */
+
+XMaskEvent (dpy, mask, event)
+ register Display *dpy;
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ _XReadEvents(dpy);
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+}
diff --git a/src/Misc.c b/src/Misc.c
new file mode 100644
index 00000000..3b0b17d8
--- /dev/null
+++ b/src/Misc.c
@@ -0,0 +1,67 @@
+/* $Xorg: Misc.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+long XMaxRequestSize(dpy)
+ Display *dpy;
+{
+ return dpy->max_request_size;
+}
+
+char *XResourceManagerString(dpy)
+ Display *dpy;
+{
+ return dpy->xdefaults;
+}
+
+unsigned long XDisplayMotionBufferSize(dpy)
+ Display *dpy;
+{
+ return dpy->motion_buffer;
+}
+
+XDisplayKeycodes(dpy, min_keycode_return, max_keycode_return)
+ Display *dpy;
+ int *min_keycode_return, *max_keycode_return;
+{
+ *min_keycode_return = dpy->min_keycode;
+ *max_keycode_return = dpy->max_keycode;
+ return 1;
+}
+
+VisualID XVisualIDFromVisual(visual)
+ Visual *visual;
+{
+ return visual->visualid;
+}
+
+long XExtendedMaxRequestSize(dpy)
+ Display *dpy;
+{
+ return dpy->bigreq_size;
+}
diff --git a/src/ModMap.c b/src/ModMap.c
new file mode 100644
index 00000000..51a32101
--- /dev/null
+++ b/src/ModMap.c
@@ -0,0 +1,198 @@
+/* $Xorg: ModMap.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XModifierKeymap *
+XGetModifierMapping(dpy)
+ register Display *dpy;
+{
+ xGetModifierMappingReply rep;
+ register xReq *req;
+ unsigned long nbytes;
+ XModifierKeymap *res;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetModifierMapping, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xFalse);
+
+ nbytes = (unsigned long)rep.length << 2;
+ res = (XModifierKeymap *) Xmalloc(sizeof (XModifierKeymap));
+ if (res) res->modifiermap = (KeyCode *) Xmalloc ((unsigned) nbytes);
+ if ((! res) || (! res->modifiermap)) {
+ if (res) Xfree((char *) res);
+ res = (XModifierKeymap *) NULL;
+ _XEatData(dpy, nbytes);
+ } else {
+ _XReadPad(dpy, (char *) res->modifiermap, (long) nbytes);
+ res->max_keypermod = rep.numKeyPerModifier;
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (res);
+}
+
+/*
+ * Returns:
+ * 0 Success
+ * 1 Busy - one or more old or new modifiers are down
+ * 2 Failed - one or more new modifiers unacceptable
+ */
+int
+XSetModifierMapping(dpy, modifier_map)
+ register Display *dpy;
+ register XModifierKeymap *modifier_map;
+{
+ register xSetModifierMappingReq *req;
+ xSetModifierMappingReply rep;
+ int mapSize = modifier_map->max_keypermod << 3; /* 8 modifiers */
+
+ LockDisplay(dpy);
+ GetReqExtra(SetModifierMapping, mapSize, req);
+
+ req->numKeyPerModifier = modifier_map->max_keypermod;
+
+ memcpy((char *) NEXTPTR(req,xSetModifierMappingReq),
+ (char *) modifier_map->modifiermap,
+ mapSize);
+
+ (void) _XReply(dpy, (xReply *) & rep,
+ (SIZEOF(xSetModifierMappingReply) - SIZEOF(xReply)) >> 2, xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.success);
+}
+
+XModifierKeymap *
+XNewModifiermap(keyspermodifier)
+ int keyspermodifier;
+{
+ XModifierKeymap *res = (XModifierKeymap *) Xmalloc((sizeof (XModifierKeymap)));
+ if (res) {
+ res->max_keypermod = keyspermodifier;
+ res->modifiermap = (keyspermodifier > 0 ?
+ (KeyCode *) Xmalloc((unsigned) (8 * keyspermodifier))
+ : (KeyCode *) NULL);
+ if (keyspermodifier && (res->modifiermap == NULL)) {
+ Xfree((char *) res);
+ return (XModifierKeymap *) NULL;
+ }
+ }
+ return (res);
+}
+
+
+XFreeModifiermap(map)
+ XModifierKeymap *map;
+{
+ if (map) {
+ if (map->modifiermap)
+ Xfree((char *) map->modifiermap);
+ Xfree((char *) map);
+ }
+ return 1;
+}
+
+#if NeedFunctionPrototypes
+XModifierKeymap *
+XInsertModifiermapEntry(XModifierKeymap *map,
+#if NeedWidePrototypes
+ unsigned int keycode,
+#else
+ KeyCode keycode,
+#endif
+ int modifier)
+#else
+XModifierKeymap *
+XInsertModifiermapEntry(map, keycode, modifier)
+ XModifierKeymap *map;
+ KeyCode keycode;
+ int modifier;
+#endif
+{
+ XModifierKeymap *newmap;
+ int i,
+ row = modifier * map->max_keypermod,
+ newrow,
+ lastrow;
+
+ for (i=0; i<map->max_keypermod; i++) {
+ if (map->modifiermap[ row+i ] == keycode)
+ return(map); /* already in the map */
+ if (map->modifiermap[ row+i ] == 0) {
+ map->modifiermap[ row+i ] = keycode;
+ return(map); /* we added it without stretching the map */
+ }
+ }
+
+ /* stretch the map */
+ if ((newmap = XNewModifiermap(map->max_keypermod+1)) == NULL)
+ return (XModifierKeymap *) NULL;
+ newrow = row = 0;
+ lastrow = newmap->max_keypermod * 8;
+ while (newrow < lastrow) {
+ for (i=0; i<map->max_keypermod; i++)
+ newmap->modifiermap[ newrow+i ] = map->modifiermap[ row+i ];
+ newmap->modifiermap[ newrow+i ] = 0;
+ row += map->max_keypermod;
+ newrow += newmap->max_keypermod;
+ }
+ (void) XFreeModifiermap(map);
+ newrow = newmap->max_keypermod * modifier + newmap->max_keypermod - 1;
+ newmap->modifiermap[ newrow ] = keycode;
+ return(newmap);
+}
+
+#if NeedFunctionPrototypes
+XModifierKeymap *
+XDeleteModifiermapEntry(XModifierKeymap *map,
+#if NeedWidePrototypes
+ unsigned int keycode,
+#else
+ KeyCode keycode,
+#endif
+ int modifier)
+#else
+XModifierKeymap *
+XDeleteModifiermapEntry(map, keycode, modifier)
+ XModifierKeymap *map;
+ KeyCode keycode;
+ int modifier;
+#endif
+{
+ int i,
+ row = modifier * map->max_keypermod;
+
+ for (i=0; i<map->max_keypermod; i++) {
+ if (map->modifiermap[ row+i ] == keycode)
+ map->modifiermap[ row+i ] = 0;
+ }
+ /* should we shrink the map?? */
+ return (map);
+}
diff --git a/src/MoveWin.c b/src/MoveWin.c
new file mode 100644
index 00000000..0ec2c8a8
--- /dev/null
+++ b/src/MoveWin.c
@@ -0,0 +1,61 @@
+/* $Xorg: MoveWin.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XMoveWindow (dpy, w, x, y)
+ register Display *dpy;
+ Window w;
+ int x, y;
+{
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 8, req);
+
+ req->window = w;
+ req->mask = CWX | CWY;
+
+#ifdef MUSTCOPY
+ {
+ long lx = (long) x, ly = (long) y;
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *) &lx, 4); /* order dictated by CWX and CWY */
+ Data32 (dpy, (long *) &ly, 4);
+ }
+#else
+ {
+ CARD32 *valuePtr = (CARD32 *) NEXTPTR(req,xConfigureWindowReq);
+ *valuePtr++ = x;
+ *valuePtr = y;
+ }
+#endif /* MUSTCOPY */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/NextEvent.c b/src/NextEvent.c
new file mode 100644
index 00000000..40e7528a
--- /dev/null
+++ b/src/NextEvent.c
@@ -0,0 +1,52 @@
+/* $Xorg: NextEvent.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Return next event in queue, or if none, flush output and wait for
+ * events.
+ */
+
+XNextEvent (dpy, event)
+ register Display *dpy;
+ register XEvent *event;
+{
+ register _XQEvent *qelt;
+
+ LockDisplay(dpy);
+
+ if (dpy->head == NULL)
+ _XReadEvents(dpy);
+ qelt = dpy->head;
+ *event = qelt->event;
+ _XDeq(dpy, NULL, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+}
+
diff --git a/src/OCWrap.c b/src/OCWrap.c
new file mode 100644
index 00000000..97a3aee0
--- /dev/null
+++ b/src/OCWrap.c
@@ -0,0 +1,161 @@
+/* $Xorg: OCWrap.c,v 1.4 2000/08/17 19:44:47 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#if NeedVarargsPrototypes
+XOC
+XCreateOC(XOM om, ...)
+#else
+XOC
+XCreateOC(om, va_alist)
+ XOM om;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ XOC oc;
+ int num_args;
+
+ Va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (XOC) NULL;
+
+ oc = (*om->methods->create_oc)(om, args, num_args);
+
+ Xfree(args);
+
+ if (oc) {
+ oc->core.next = om->core.oc_list;
+ om->core.oc_list = oc;
+ }
+
+ return oc;
+}
+
+void
+XDestroyOC(oc)
+ XOC oc;
+{
+ XOC prev, oc_list;
+
+ prev = oc_list = oc->core.om->core.oc_list;
+ if (oc_list == oc)
+ oc->core.om->core.oc_list = oc_list->core.next;
+ else {
+ while ((oc_list = oc_list->core.next)) {
+ if (oc_list == oc) {
+ prev->core.next = oc_list->core.next;
+ break;
+ }
+ prev = oc_list;
+ }
+ }
+
+ (*oc->methods->destroy)(oc);
+}
+
+XOM
+XOMOfOC(oc)
+ XOC oc;
+{
+ return oc->core.om;
+}
+
+#if NeedVarargsPrototypes
+char *
+XSetOCValues(XOC oc, ...)
+#else
+char *
+XSetOCValues(oc, va_alist)
+ XOC oc;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ Va_start(var, oc);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, oc);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*oc->methods->set_values)(oc, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+#if NeedVarargsPrototypes
+char *
+XGetOCValues(XOC oc, ...)
+#else
+char *
+XGetOCValues(oc, va_alist)
+ XOC oc;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ Va_start(var, oc);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, oc);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*oc->methods->get_values)(oc, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
diff --git a/src/OMWrap.c b/src/OMWrap.c
new file mode 100644
index 00000000..d97bd647
--- /dev/null
+++ b/src/OMWrap.c
@@ -0,0 +1,152 @@
+/* $Xorg: OMWrap.c,v 1.4 2000/08/17 19:44:47 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+XOM
+#if NeedFunctionPrototypes
+XOpenOM(Display *dpy, XrmDatabase rdb, _Xconst char *res_name,
+ _Xconst char *res_class)
+#else
+XOpenOM(dpy, rdb, res_name, res_class)
+ Display *dpy;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+#endif
+{
+ XLCd lcd = _XOpenLC((char *) NULL);
+
+ if (lcd == NULL)
+ return (XOM) NULL;
+
+ if (lcd->methods->open_om)
+ return (*lcd->methods->open_om)(lcd, dpy, rdb, res_name, res_class);
+
+ return (XOM) NULL;
+}
+
+Status
+XCloseOM(om)
+ XOM om;
+{
+ XOC oc, next;
+ XLCd lcd = om->core.lcd;
+
+ next = om->core.oc_list;
+
+ while ((oc = next)) {
+ next = oc->core.next;
+ (*oc->methods->destroy)(oc);
+ }
+
+ om->core.oc_list = NULL;
+
+ _XCloseLC(lcd);
+
+ return (*om->methods->close)(om);
+}
+
+#if NeedVarargsPrototypes
+char *
+XSetOMValues(XOM om, ...)
+#else
+char *
+XSetOMValues(om, va_alist)
+ XOM om;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ Va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*om->methods->set_values)(om, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+#if NeedVarargsPrototypes
+char *
+XGetOMValues(XOM om, ...)
+#else
+char *
+XGetOMValues(om, va_alist)
+ XOM om;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ Va_start(var, om);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, om);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*om->methods->get_values)(om, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+Display *
+XDisplayOfOM(om)
+ XOM om;
+{
+ return om->core.display;
+}
+
+char *
+XLocaleOfOM(om)
+ XOM om;
+{
+ return om->core.lcd->core->name;
+}
diff --git a/src/OpenDis.c b/src/OpenDis.c
new file mode 100644
index 00000000..6207fdd2
--- /dev/null
+++ b/src/OpenDis.c
@@ -0,0 +1,760 @@
+/* $Xorg: OpenDis.c,v 1.4 2001/02/09 02:03:34 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/Xtrans.h>
+#include <X11/Xatom.h>
+#include "bigreqstr.h"
+#include <stdio.h>
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+#define bignamelen (sizeof(XBigReqExtensionName) - 1)
+
+typedef struct {
+ unsigned long seq;
+ int opcode;
+} _XBigReqState;
+
+extern int _Xdebug;
+#ifdef WIN32
+int *_Xdebug_p = &_Xdebug;
+#endif
+
+#ifdef XTHREADS
+int (*_XInitDisplayLock_fn)() = NULL;
+void (*_XFreeDisplayLock_fn)() = NULL;
+
+#define InitDisplayLock(d) (_XInitDisplayLock_fn ? (*_XInitDisplayLock_fn)(d) : Success)
+#define FreeDisplayLock(d) if (_XFreeDisplayLock_fn) (*_XFreeDisplayLock_fn)(d)
+#else
+#define InitDisplayLock(dis) Success
+#define FreeDisplayLock(dis)
+#endif
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+static void OutOfMemory();
+static Bool _XBigReqHandler();
+
+extern Bool _XWireToEvent();
+extern Status _XUnknownNativeEvent();
+extern Bool _XUnknownWireEvent();
+/*
+ * Connects to a server, creates a Display object and returns a pointer to
+ * the newly created Display back to the caller.
+ */
+#if NeedFunctionPrototypes
+Display *XOpenDisplay (
+ register _Xconst char *display)
+#else
+Display *XOpenDisplay (display)
+ register char *display;
+#endif
+{
+ register Display *dpy; /* New Display object being created. */
+ register int i;
+ int j, k; /* random iterator indexes */
+ char *display_name; /* pointer to display name */
+ int endian; /* to determine which endian. */
+ xConnClientPrefix client; /* client information */
+ xConnSetupPrefix prefix; /* prefix information */
+ int vendorlen; /* length of vendor string */
+ char *setup = NULL; /* memory allocated at startup */
+ char *fullname = NULL; /* expanded name of display */
+ int idisplay; /* display number */
+ int iscreen; /* screen number */
+ int prefixread = 0; /* setup prefix already read? */
+ union {
+ xConnSetup *setup;
+ char *failure;
+ char *vendor;
+ xPixmapFormat *sf;
+ xWindowRoot *rp;
+ xDepth *dp;
+ xVisualType *vp;
+ } u; /* proto data returned from server */
+ long setuplength; /* number of bytes in setup message */
+ char *conn_auth_name, *conn_auth_data;
+ int conn_auth_namelen, conn_auth_datalen;
+ unsigned long mask;
+ extern Bool _XSendClientPrefix();
+ extern XtransConnInfo _X11TransConnectDisplay();
+ extern XID _XAllocID();
+ extern void _XAllocIDs();
+
+ /*
+ * If the display specifier string supplied as an argument to this
+ * routine is NULL or a pointer to NULL, read the DISPLAY variable.
+ */
+ if (display == NULL || *display == '\0') {
+ if ((display_name = getenv("DISPLAY")) == NULL) {
+ /* Oops! No DISPLAY environment variable - error. */
+ return(NULL);
+ }
+ }
+ else {
+ /* Display is non-NULL, copy the pointer */
+ display_name = (char *)display;
+ }
+/*
+ * Set the default error handlers. This allows the global variables to
+ * default to NULL for use with shared libraries.
+ */
+ if (_XErrorFunction == NULL) (void) XSetErrorHandler (NULL);
+ if (_XIOErrorFunction == NULL) (void) XSetIOErrorHandler (NULL);
+
+/*
+ * Attempt to allocate a display structure. Return NULL if allocation fails.
+ */
+ if ((dpy = (Display *)Xcalloc(1, sizeof(Display))) == NULL) {
+ return(NULL);
+ }
+
+/*
+ * Call the Connect routine to get the transport connection object.
+ * If NULL is returned, the connection failed. The connect routine
+ * will set fullname to point to the expanded name.
+ */
+
+ if ((dpy->trans_conn = _X11TransConnectDisplay (
+ display_name, &fullname, &idisplay,
+ &iscreen, &conn_auth_name,
+ &conn_auth_namelen, &conn_auth_data,
+ &conn_auth_datalen)) == NULL) {
+ Xfree ((char *) dpy);
+ return(NULL);
+ }
+
+ dpy->fd = _X11TransGetConnectionNumber (dpy->trans_conn);
+
+ /* Initialize as much of the display structure as we can.
+ * Initialize pointers to NULL so that XFreeDisplayStructure will
+ * work if we run out of memory before we finish initializing.
+ */
+ dpy->display_name = fullname;
+ dpy->keysyms = (KeySym *) NULL;
+ dpy->modifiermap = NULL;
+ dpy->lock_meaning = NoSymbol;
+ dpy->keysyms_per_keycode = 0;
+ dpy->xdefaults = (char *)NULL;
+ dpy->scratch_length = 0L;
+ dpy->scratch_buffer = NULL;
+ dpy->key_bindings = NULL;
+ dpy->ext_procs = (_XExtension *)NULL;
+ dpy->ext_data = (XExtData *)NULL;
+ dpy->ext_number = 0;
+ dpy->event_vec[X_Error] = _XUnknownWireEvent;
+ dpy->event_vec[X_Reply] = _XUnknownWireEvent;
+ dpy->wire_vec[X_Error] = _XUnknownNativeEvent;
+ dpy->wire_vec[X_Reply] = _XUnknownNativeEvent;
+ for (i = KeyPress; i < LASTEvent; i++) {
+ dpy->event_vec[i] = _XWireToEvent;
+ dpy->wire_vec[i] = NULL;
+ }
+ for (i = LASTEvent; i < 128; i++) {
+ dpy->event_vec[i] = _XUnknownWireEvent;
+ dpy->wire_vec[i] = _XUnknownNativeEvent;
+ }
+ dpy->resource_id = 0;
+ dpy->db = (struct _XrmHashBucketRec *)NULL;
+ dpy->cursor_font = None;
+ dpy->flags = 0;
+ dpy->async_handlers = NULL;
+ dpy->screens = NULL;
+ dpy->vendor = NULL;
+ dpy->buffer = NULL;
+ dpy->atoms = NULL;
+ dpy->error_vec = NULL;
+ dpy->context_db = NULL;
+ dpy->free_funcs = NULL;
+ dpy->pixmap_format = NULL;
+ dpy->cms.clientCmaps = NULL;
+ dpy->cms.defaultCCCs = NULL;
+ dpy->cms.perVisualIntensityMaps = NULL;
+ dpy->im_filters = NULL;
+ dpy->bigreq_size = 0;
+ dpy->lock = NULL;
+ dpy->lock_fns = NULL;
+ dpy->qfree = NULL;
+ dpy->next_event_serial_num = 1;
+ dpy->im_fd_info = NULL;
+ dpy->im_fd_length = 0;
+ dpy->conn_watchers = NULL;
+ dpy->watcher_count = 0;
+ dpy->filedes = NULL;
+ dpy->flushes = NULL;
+ dpy->xcmisc_opcode = 0;
+ dpy->xkb_info = NULL;
+
+/*
+ * Setup other information in this display structure.
+ */
+ dpy->vnumber = X_PROTOCOL;
+ dpy->resource_alloc = _XAllocID;
+ dpy->idlist_alloc = _XAllocIDs;
+ dpy->synchandler = NULL;
+ dpy->savedsynchandler = NULL;
+ dpy->request = 0;
+ dpy->last_request_read = 0;
+ dpy->default_screen = iscreen; /* Value returned by ConnectDisplay */
+ dpy->last_req = (char *)&_dummy_request;
+
+ /* Initialize the display lock */
+ if (InitDisplayLock(dpy) != 0) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ if (!_XPollfdCacheInit(dpy)) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+ /* Set up the output buffers. */
+ if ((dpy->bufptr = dpy->buffer = Xmalloc(BUFSIZE)) == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ dpy->bufmax = dpy->buffer + BUFSIZE;
+
+ /* Set up the input event queue and input event queue parameters. */
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+
+ /* Set up free-function record */
+ if ((dpy->free_funcs = (_XFreeFuncRec *)Xcalloc(1,
+ sizeof(_XFreeFuncRec)))
+ == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+
+/*
+ * The xConnClientPrefix describes the initial connection setup information
+ * and is followed by the authorization information. Sites that are interested
+ * in security are strongly encouraged to use an authentication and
+ * authorization system such as Kerberos.
+ */
+ endian = 1;
+ if (*(char *) &endian)
+ client.byteOrder = '\154'; /* 'l' */
+ else
+ client.byteOrder = '\102'; /* 'B' */
+ client.majorVersion = X_PROTOCOL;
+ client.minorVersion = X_PROTOCOL_REVISION;
+ client.nbytesAuthProto = conn_auth_namelen;
+ client.nbytesAuthString = conn_auth_datalen;
+ prefixread = _XSendClientPrefix(dpy, &client,
+ conn_auth_name, conn_auth_data,
+ &prefix);
+ if (prefixread < 0)
+ {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ if (conn_auth_name) Xfree(conn_auth_name);
+ if (conn_auth_data) Xfree(conn_auth_data);
+/*
+ * Now see if connection was accepted...
+ */
+ /* these internal functions expect the display to be locked */
+ LockDisplay(dpy);
+
+ if (prefixread == 0)
+ _XRead (dpy, (char *)&prefix,(long)SIZEOF(xConnSetupPrefix));
+
+ /* an Authenticate reply we weren't expecting? */
+ if (prefix.success != xTrue && prefix.success != xFalse) {
+ fprintf (stderr,
+ "Xlib: unexpected connection setup reply from server, type %d.\r\n",
+ prefix.success);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ if (prefix.majorVersion != X_PROTOCOL) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: client uses different protocol version (%d) than server (%d)!\r\n",
+ X_PROTOCOL, prefix.majorVersion);
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+
+ setuplength = prefix.length << 2;
+ if ( (u.setup = (xConnSetup *)
+ (setup = Xmalloc ((unsigned) setuplength))) == NULL) {
+ _XDisconnectDisplay (dpy->trans_conn);
+ Xfree ((char *)dpy);
+ return(NULL);
+ }
+ _XRead (dpy, (char *)u.setup, setuplength);
+/*
+ * If the connection was not accepted by the server due to problems,
+ * give error message to the user....
+ */
+ if (prefix.success != xTrue) {
+ /* XXX - printing messages marks a bad programming interface */
+ fprintf (stderr,
+ "Xlib: connection to \"%s\" refused by server\r\nXlib: ",
+ fullname);
+ (void) fwrite (u.failure, (Size_t)sizeof(char),
+ (Size_t)prefix.lengthReason, stderr);
+ (void) fwrite ("\r\n", sizeof(char), 2, stderr);
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+
+/*
+ * We succeeded at authorization, so let us move the data into
+ * the display structure.
+ */
+ dpy->proto_major_version= prefix.majorVersion;
+ dpy->proto_minor_version= prefix.minorVersion;
+ dpy->release = u.setup->release;
+ dpy->resource_base = u.setup->ridBase;
+ dpy->resource_mask = u.setup->ridMask;
+ dpy->min_keycode = u.setup->minKeyCode;
+ dpy->max_keycode = u.setup->maxKeyCode;
+ dpy->motion_buffer = u.setup->motionBufferSize;
+ dpy->nformats = u.setup->numFormats;
+ dpy->nscreens = u.setup->numRoots;
+ dpy->byte_order = u.setup->imageByteOrder;
+ dpy->bitmap_unit = u.setup->bitmapScanlineUnit;
+ dpy->bitmap_pad = u.setup->bitmapScanlinePad;
+ dpy->bitmap_bit_order = u.setup->bitmapBitOrder;
+ dpy->max_request_size = u.setup->maxRequestSize;
+ mask = dpy->resource_mask;
+ dpy->resource_shift = 0;
+ while (!(mask & 1)) {
+ dpy->resource_shift++;
+ mask = mask >> 1;
+ }
+ dpy->resource_max = (dpy->resource_mask >> dpy->resource_shift) - 5;
+/*
+ * now extract the vendor string... String must be null terminated,
+ * padded to multiple of 4 bytes.
+ */
+ dpy->vendor = (char *) Xmalloc((unsigned) (u.setup->nbytesVendor + 1));
+ if (dpy->vendor == NULL) {
+ OutOfMemory(dpy, setup);
+ return (NULL);
+ }
+ vendorlen = u.setup->nbytesVendor;
+ u.setup = (xConnSetup *) (((char *) u.setup) + sz_xConnSetup);
+ (void) strncpy(dpy->vendor, u.vendor, vendorlen);
+ dpy->vendor[vendorlen] = '\0';
+ vendorlen = (vendorlen + 3) & ~3; /* round up */
+ memmove (setup, u.vendor + vendorlen,
+ (int) setuplength - sz_xConnSetup - vendorlen);
+ u.vendor = setup;
+/*
+ * Now iterate down setup information.....
+ */
+ dpy->pixmap_format =
+ (ScreenFormat *)Xmalloc(
+ (unsigned) (dpy->nformats *sizeof(ScreenFormat)));
+ if (dpy->pixmap_format == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * First decode the Z axis Screen format information.
+ */
+ for (i = 0; i < dpy->nformats; i++) {
+ register ScreenFormat *fmt = &dpy->pixmap_format[i];
+ fmt->depth = u.sf->depth;
+ fmt->bits_per_pixel = u.sf->bitsPerPixel;
+ fmt->scanline_pad = u.sf->scanLinePad;
+ fmt->ext_data = NULL;
+ u.sf = (xPixmapFormat *) (((char *) u.sf) + sz_xPixmapFormat);
+ }
+
+/*
+ * next the Screen structures.
+ */
+ dpy->screens =
+ (Screen *)Xmalloc((unsigned) dpy->nscreens*sizeof(Screen));
+ if (dpy->screens == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+/*
+ * Now go deal with each screen structure.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ VisualID root_visualID = u.rp->rootVisualID;
+ sp->display = dpy;
+ sp->root = u.rp->windowId;
+ sp->cmap = u.rp->defaultColormap;
+ sp->white_pixel = u.rp->whitePixel;
+ sp->black_pixel = u.rp->blackPixel;
+ sp->root_input_mask = u.rp->currentInputMask;
+ sp->width = u.rp->pixWidth;
+ sp->height = u.rp->pixHeight;
+ sp->mwidth = u.rp->mmWidth;
+ sp->mheight = u.rp->mmHeight;
+ sp->min_maps = u.rp->minInstalledMaps;
+ sp->max_maps = u.rp->maxInstalledMaps;
+ sp->backing_store= u.rp->backingStore;
+ sp->save_unders = u.rp->saveUnders;
+ sp->root_depth = u.rp->rootDepth;
+ sp->ndepths = u.rp->nDepths;
+ sp->ext_data = NULL;
+ u.rp = (xWindowRoot *) (((char *) u.rp) + sz_xWindowRoot);
+/*
+ * lets set up the depth structures.
+ */
+ sp->depths = (Depth *)Xmalloc(
+ (unsigned)sp->ndepths*sizeof(Depth));
+ if (sp->depths == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ /*
+ * for all depths on this screen.
+ */
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+ dp->depth = u.dp->depth;
+ dp->nvisuals = u.dp->nVisuals;
+ u.dp = (xDepth *) (((char *) u.dp) + sz_xDepth);
+ if (dp->nvisuals > 0) {
+ dp->visuals =
+ (Visual *)Xmalloc((unsigned)dp->nvisuals*sizeof(Visual));
+ if (dp->visuals == NULL) {
+ OutOfMemory (dpy, setup);
+ return(NULL);
+ }
+ for (k = 0; k < dp->nvisuals; k++) {
+ register Visual *vp = &dp->visuals[k];
+ vp->visualid = u.vp->visualID;
+ vp->class = u.vp->class;
+ vp->bits_per_rgb= u.vp->bitsPerRGB;
+ vp->map_entries = u.vp->colormapEntries;
+ vp->red_mask = u.vp->redMask;
+ vp->green_mask = u.vp->greenMask;
+ vp->blue_mask = u.vp->blueMask;
+ vp->ext_data = NULL;
+ u.vp = (xVisualType *) (((char *) u.vp) +
+ sz_xVisualType);
+ }
+ } else {
+ dp->visuals = (Visual *) NULL;
+ }
+ }
+ sp->root_visual = _XVIDtoVisual(dpy, root_visualID);
+ }
+
+
+/*
+ * Now start talking to the server to setup all other information...
+ */
+
+ Xfree (setup); /* all finished with setup information */
+
+/*
+ * Make sure default screen is legal.
+ */
+ if (iscreen >= dpy->nscreens) {
+ OutOfMemory(dpy, (char *) NULL);
+ return(NULL);
+ }
+
+/*
+ * finished calling internal routines, now unlock for external routines
+ */
+ UnlockDisplay(dpy);
+
+/*
+ * Set up other stuff clients are always going to use.
+ */
+ for (i = 0; i < dpy->nscreens; i++) {
+ register Screen *sp = &dpy->screens[i];
+ XGCValues values;
+ values.foreground = sp->black_pixel;
+ values.background = sp->white_pixel;
+ if ((sp->default_gc = XCreateGC (dpy, sp->root,
+ GCForeground|GCBackground,
+ &values)) == NULL) {
+ OutOfMemory(dpy, (char *) NULL);
+ return (NULL);
+ }
+ }
+/*
+ * call into synchronization routine so that all programs can be
+ * forced synchronous
+ */
+ (void) XSynchronize(dpy, _Xdebug);
+
+/*
+ * get availability of large requests, and
+ * get the resource manager database off the root window.
+ */
+ LockDisplay(dpy);
+ {
+ _XAsyncHandler async;
+ _XBigReqState async_state;
+ xQueryExtensionReq *qreq;
+ xGetPropertyReply reply;
+ xGetPropertyReq *req;
+ xBigReqEnableReq *breq;
+ xBigReqEnableReply brep;
+
+ GetReq(QueryExtension, qreq);
+ async_state.seq = dpy->request;
+ async_state.opcode = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XBigReqHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ qreq->nbytes = bignamelen;
+ qreq->length += (bignamelen+3)>>2;
+ Data(dpy, XBigReqExtensionName, bignamelen);
+
+ GetReq (GetProperty, req);
+ req->window = RootWindow(dpy, 0);
+ req->property = XA_RESOURCE_MANAGER;
+ req->type = XA_STRING;
+ req->delete = False;
+ req->longOffset = 0;
+ req->longLength = 100000000L;
+
+ if (_XReply (dpy, (xReply *) &reply, 0, xFalse)) {
+ if (reply.format == 8 && reply.propertyType == XA_STRING &&
+ (dpy->xdefaults = Xmalloc (reply.nItems + 1))) {
+ _XReadPad (dpy, dpy->xdefaults, reply.nItems);
+ dpy->xdefaults[reply.nItems] = '\0';
+ }
+ else if (reply.propertyType != None)
+ _XEatData(dpy, reply.nItems * (reply.format >> 3));
+ }
+ DeqAsyncHandler(dpy, &async);
+ if (async_state.opcode) {
+ GetReq(BigReqEnable, breq);
+ breq->reqType = async_state.opcode;
+ breq->brReqType = X_BigReqEnable;
+ if (_XReply(dpy, (xReply *)&brep, 0, xFalse))
+ dpy->bigreq_size = brep.max_request_size;
+ }
+ }
+ UnlockDisplay(dpy);
+
+#ifdef MOTIFBC
+ {
+ extern Display *_XHeadOfDisplayList;
+ _XHeadOfDisplayList = dpy;
+ }
+#endif
+#ifdef XKB
+ XkbUseExtension(dpy,NULL,NULL);
+#endif
+/*
+ * and return successfully
+ */
+ return(dpy);
+}
+
+static Bool
+_XBigReqHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ _XBigReqState *state;
+ xQueryExtensionReply replbuf;
+ xQueryExtensionReply *repl;
+
+ state = (_XBigReqState *)data;
+ if (dpy->last_request_read != state->seq)
+ return False;
+ if (rep->generic.type == X_Error)
+ return True;
+ repl = (xQueryExtensionReply *)
+ _XGetAsyncReply(dpy, (char *)&replbuf, rep, buf, len,
+ (SIZEOF(xQueryExtensionReply) - SIZEOF(xReply)) >> 2,
+ True);
+ if (repl->present)
+ state->opcode = repl->major_opcode;
+ return True;
+}
+
+
+/* XFreeDisplayStructure frees all the storage associated with a
+ * Display. It is used by XOpenDisplay if it runs out of memory,
+ * and also by XCloseDisplay. It needs to check whether all pointers
+ * are non-NULL before dereferencing them, since it may be called
+ * by XOpenDisplay before the Display structure is fully formed.
+ * XOpenDisplay must be sure to initialize all the pointers to NULL
+ * before the first possible call on this.
+ */
+
+void _XFreeDisplayStructure(dpy)
+ register Display *dpy;
+{
+ while (dpy->ext_procs) {
+ _XExtension *ext = dpy->ext_procs;
+ dpy->ext_procs = ext->next;
+ if (ext->name)
+ Xfree (ext->name);
+ Xfree ((char *)ext);
+ }
+ if (dpy->im_filters)
+ (*dpy->free_funcs->im_filters)(dpy);
+ if (dpy->cms.clientCmaps)
+ (*dpy->free_funcs->clientCmaps)(dpy);
+ if (dpy->cms.defaultCCCs)
+ (*dpy->free_funcs->defaultCCCs)(dpy);
+ if (dpy->cms.perVisualIntensityMaps)
+ (*dpy->free_funcs->intensityMaps)(dpy);
+ if (dpy->atoms)
+ (*dpy->free_funcs->atoms)(dpy);
+ if (dpy->modifiermap)
+ (*dpy->free_funcs->modifiermap)(dpy->modifiermap);
+ if (dpy->key_bindings)
+ (*dpy->free_funcs->key_bindings)(dpy);
+ if (dpy->context_db)
+ (*dpy->free_funcs->context_db)(dpy);
+ if (dpy->xkb_info)
+ (*dpy->free_funcs->xkb)(dpy);
+
+ if (dpy->screens) {
+ register int i;
+
+ for (i = 0; i < dpy->nscreens; i++) {
+ Screen *sp = &dpy->screens[i];
+
+ if (sp->depths) {
+ register int j;
+
+ for (j = 0; j < sp->ndepths; j++) {
+ Depth *dp = &sp->depths[j];
+
+ if (dp->visuals) {
+ register int k;
+
+ for (k = 0; k < dp->nvisuals; k++)
+ _XFreeExtData (dp->visuals[k].ext_data);
+ Xfree ((char *) dp->visuals);
+ }
+ }
+
+ Xfree ((char *) sp->depths);
+ }
+
+ _XFreeExtData (sp->ext_data);
+ }
+
+ Xfree ((char *)dpy->screens);
+ }
+
+ if (dpy->pixmap_format) {
+ register int i;
+
+ for (i = 0; i < dpy->nformats; i++)
+ _XFreeExtData (dpy->pixmap_format[i].ext_data);
+ Xfree ((char *)dpy->pixmap_format);
+ }
+
+ if (dpy->display_name)
+ Xfree (dpy->display_name);
+ if (dpy->vendor)
+ Xfree (dpy->vendor);
+
+ if (dpy->buffer)
+ Xfree (dpy->buffer);
+ if (dpy->keysyms)
+ Xfree ((char *) dpy->keysyms);
+ if (dpy->xdefaults)
+ Xfree (dpy->xdefaults);
+ if (dpy->error_vec)
+ Xfree ((char *)dpy->error_vec);
+
+ _XFreeExtData (dpy->ext_data);
+ if (dpy->free_funcs)
+ Xfree ((char *)dpy->free_funcs);
+ if (dpy->scratch_buffer)
+ Xfree (dpy->scratch_buffer);
+ FreeDisplayLock(dpy);
+
+ if (dpy->qfree) {
+ register _XQEvent *qelt = dpy->qfree;
+
+ while (qelt) {
+ register _XQEvent *qnxt = qelt->next;
+ Xfree ((char *) qelt);
+ qelt = qnxt;
+ }
+ }
+ while (dpy->im_fd_info) {
+ struct _XConnectionInfo *conni = dpy->im_fd_info;
+ dpy->im_fd_info = conni->next;
+ if (conni->watch_data)
+ Xfree (conni->watch_data);
+ Xfree (conni);
+ }
+ if (dpy->conn_watchers) {
+ struct _XConnWatchInfo *watcher = dpy->conn_watchers;
+ dpy->conn_watchers = watcher->next;
+ Xfree (watcher);
+ }
+ if (dpy->filedes)
+ Xfree (dpy->filedes);
+
+ Xfree ((char *)dpy);
+}
+
+/* OutOfMemory is called if malloc fails. XOpenDisplay returns NULL
+ after this returns. */
+
+static void OutOfMemory (dpy, setup)
+ Display *dpy;
+ char *setup;
+{
+ _XDisconnectDisplay (dpy->trans_conn);
+ _XFreeDisplayStructure (dpy);
+ if (setup) Xfree (setup);
+}
diff --git a/src/ParseCmd.c b/src/ParseCmd.c
new file mode 100644
index 00000000..e2e302d0
--- /dev/null
+++ b/src/ParseCmd.c
@@ -0,0 +1,234 @@
+/* $Xorg: ParseCmd.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+/* XrmParseCommand()
+
+ Parse command line and store argument values into resource database
+
+ Allows any un-ambiguous abbreviation for an option name, but requires
+ that the table be ordered with any options that are prefixes of
+ other options appearing before the longer version in the table.
+*/
+
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <stdio.h>
+
+
+static void _XReportParseError(arg, msg)
+ XrmOptionDescRec *arg;
+ char *msg;
+{
+ (void) fprintf(stderr, "Error parsing argument \"%s\" (%s); %s\n",
+ arg->option, arg->specifier, msg);
+ exit(1);
+}
+
+#if NeedFunctionPrototypes
+void XrmParseCommand(
+ XrmDatabase *pdb, /* data base */
+ register XrmOptionDescList options, /* pointer to table of valid options */
+ int num_options, /* number of options */
+ _Xconst char *prefix, /* name to prefix resources with */
+ int *argc, /* address of argument count */
+ char **argv) /* argument list (command line) */
+#else
+void XrmParseCommand(pdb, options, num_options, prefix, argc, argv)
+ XrmDatabase *pdb; /* data base */
+ register XrmOptionDescList options; /* pointer to table of valid options */
+ int num_options; /* number of options */
+ char *prefix; /* name to prefix resources with */
+ int *argc; /* address of argument count */
+ char **argv; /* argument list (command line) */
+#endif
+{
+ int foundOption;
+ char **argsave;
+ register int i, myargc;
+ XrmBinding bindings[100];
+ XrmQuark quarks[100];
+ XrmBinding *start_bindings;
+ XrmQuark *start_quarks;
+ char *optP, *argP, optchar, argchar;
+ int matches;
+ enum {DontCare, Check, NotSorted, Sorted} table_is_sorted;
+ char **argend;
+
+#define PutCommandResource(value_str) \
+ { \
+ XrmStringToBindingQuarkList( \
+ options[i].specifier, start_bindings, start_quarks); \
+ XrmQPutStringResource(pdb, bindings, quarks, value_str); \
+ } /* PutCommandResource */
+
+ myargc = (*argc);
+ argend = argv + myargc;
+ argsave = ++argv;
+
+ /* Initialize bindings/quark list with prefix (typically app name). */
+ quarks[0] = XrmStringToName(prefix);
+ bindings[0] = XrmBindTightly;
+ start_quarks = quarks+1;
+ start_bindings = bindings+1;
+
+ table_is_sorted = (myargc > 2) ? Check : DontCare;
+ for (--myargc; myargc > 0; --myargc, ++argv) {
+ foundOption = False;
+ matches = 0;
+ for (i=0; i < num_options; ++i) {
+ /* checking the sort order first insures we don't have to
+ re-do the check if the arg hits on the last entry in
+ the table. Useful because usually '=' is the last entry
+ and users frequently specify geometry early in the command */
+ if (table_is_sorted == Check && i > 0 &&
+ strcmp(options[i].option, options[i-1].option) < 0) {
+ table_is_sorted = NotSorted;
+ }
+ for (argP = *argv, optP = options[i].option;
+ (optchar = *optP++) &&
+ (argchar = *argP++) &&
+ argchar == optchar;);
+ if (!optchar) {
+ if (!*argP ||
+ options[i].argKind == XrmoptionStickyArg ||
+ options[i].argKind == XrmoptionIsArg) {
+ /* give preference to exact matches, StickyArg and IsArg */
+ matches = 1;
+ foundOption = i;
+ break;
+ }
+ }
+ else if (!argchar) {
+ /* may be an abbreviation for this option */
+ matches++;
+ foundOption = i;
+ }
+ else if (table_is_sorted == Sorted && optchar > argchar) {
+ break;
+ }
+ if (table_is_sorted == Check && i > 0 &&
+ strcmp(options[i].option, options[i-1].option) < 0) {
+ table_is_sorted = NotSorted;
+ }
+ }
+ if (table_is_sorted == Check && i >= (num_options-1))
+ table_is_sorted = Sorted;
+ if (matches == 1) {
+ i = foundOption;
+ switch (options[i].argKind){
+ case XrmoptionNoArg:
+ --(*argc);
+ PutCommandResource(options[i].value);
+ break;
+
+ case XrmoptionIsArg:
+ --(*argc);
+ PutCommandResource(*argv);
+ break;
+
+ case XrmoptionStickyArg:
+ --(*argc);
+ PutCommandResource(argP);
+ break;
+
+ case XrmoptionSepArg:
+ if (myargc > 1) {
+ ++argv; --myargc; --(*argc); --(*argc);
+ PutCommandResource(*argv);
+ } else
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionResArg:
+ if (myargc > 1) {
+ ++argv; --myargc; --(*argc); --(*argc);
+ XrmPutLineResource(pdb, *argv);
+ } else
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionSkipArg:
+ if (myargc > 1) {
+ --myargc;
+ (*argsave++) = (*argv++);
+ }
+ (*argsave++) = (*argv);
+ break;
+
+ case XrmoptionSkipLine:
+ for (; myargc > 0; myargc--)
+ (*argsave++) = (*argv++);
+ break;
+
+ case XrmoptionSkipNArgs:
+ {
+ register int j = 1 + (int) options[i].value;
+
+ if (j > myargc) j = myargc;
+ for (; j > 0; j--) {
+ (*argsave++) = (*argv++);
+ myargc--;
+ }
+ argv--; /* went one too far before */
+ myargc++;
+ }
+ break;
+
+ default:
+ _XReportParseError (&options[i], "unknown kind");
+ break;
+ }
+ }
+ else
+ (*argsave++) = (*argv); /*compress arglist*/
+ }
+
+ if (argsave < argend)
+ (*argsave)=NULL; /* put NULL terminator on compressed argv */
+}
diff --git a/src/ParseCol.c b/src/ParseCol.c
new file mode 100644
index 00000000..1520384a
--- /dev/null
+++ b/src/ParseCol.c
@@ -0,0 +1,135 @@
+/* $Xorg: ParseCol.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+
+#if NeedFunctionPrototypes
+Status XParseColor (
+ register Display *dpy,
+ Colormap cmap,
+ _Xconst char *spec,
+ XColor *def)
+#else
+Status XParseColor (dpy, cmap, spec, def)
+ register Display *dpy;
+ Colormap cmap;
+ char *spec;
+ XColor *def;
+#endif
+{
+ register int n, i;
+ int r, g, b;
+ char c;
+ XcmsCCC ccc;
+ XcmsColor cmsColor;
+
+ if (!spec) return(0);
+ n = strlen (spec);
+ if (*spec == '#') {
+ /*
+ * RGB
+ */
+ spec++;
+ n--;
+ if (n != 3 && n != 6 && n != 9 && n != 12)
+ return (0);
+ n /= 3;
+ g = b = 0;
+ do {
+ r = g;
+ g = b;
+ b = 0;
+ for (i = n; --i >= 0; ) {
+ c = *spec++;
+ b <<= 4;
+ if (c >= '0' && c <= '9')
+ b |= c - '0';
+ else if (c >= 'A' && c <= 'F')
+ b |= c - ('A' - 10);
+ else if (c >= 'a' && c <= 'f')
+ b |= c - ('a' - 10);
+ else return (0);
+ }
+ } while (*spec != '\0');
+ n <<= 2;
+ n = 16 - n;
+ def->red = r << n;
+ def->green = g << n;
+ def->blue = b << n;
+ def->flags = DoRed | DoGreen | DoBlue;
+ return (1);
+ }
+
+
+ /*
+ * Let's Attempt to use Xcms and i18n approach to Parse Color
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &spec,
+ &cmsColor, XcmsRGBFormat) >= XcmsSuccess) {
+ cmsColor.pixel = def->pixel;
+ _XcmsRGB_to_XColor(&cmsColor, def, 1);
+ return(1);
+ }
+ /*
+ * Otherwise we failed; or spec was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+ {
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n = strlen(spec);
+ req->length += (n + 3) >> 2;
+ Data (dpy, spec, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ def->red = reply.exactRed;
+ def->green = reply.exactGreen;
+ def->blue = reply.exactBlue;
+ def->flags = DoRed | DoGreen | DoBlue;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+ }
+}
diff --git a/src/ParseGeom.c b/src/ParseGeom.c
new file mode 100644
index 00000000..6691c887
--- /dev/null
+++ b/src/ParseGeom.c
@@ -0,0 +1,186 @@
+/* $Xorg: ParseGeom.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+
+/*
+
+Copyright 1985, 1986, 1987,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+
+#ifdef notdef
+/*
+ *Returns pointer to first char ins search which is also in what, else NULL.
+ */
+static char *strscan (search, what)
+char *search, *what;
+{
+ int i, len = strlen (what);
+ char c;
+
+ while ((c = *(search++)) != NULL)
+ for (i = 0; i < len; i++)
+ if (c == what [i])
+ return (--search);
+ return (NULL);
+}
+#endif
+
+/*
+ * XParseGeometry parses strings of the form
+ * "=<width>x<height>{+-}<xoffset>{+-}<yoffset>", where
+ * width, height, xoffset, and yoffset are unsigned integers.
+ * Example: "=80x24+300-49"
+ * The equal sign is optional.
+ * It returns a bitmask that indicates which of the four values
+ * were actually found in the string. For each value found,
+ * the corresponding argument is updated; for each value
+ * not found, the corresponding argument is left unchanged.
+ */
+
+static int
+ReadInteger(string, NextString)
+register char *string;
+char **NextString;
+{
+ register int Result = 0;
+ int Sign = 1;
+
+ if (*string == '+')
+ string++;
+ else if (*string == '-')
+ {
+ string++;
+ Sign = -1;
+ }
+ for (; (*string >= '0') && (*string <= '9'); string++)
+ {
+ Result = (Result * 10) + (*string - '0');
+ }
+ *NextString = string;
+ if (Sign >= 0)
+ return (Result);
+ else
+ return (-Result);
+}
+
+#if NeedFunctionPrototypes
+int XParseGeometry (
+_Xconst char *string,
+int *x,
+int *y,
+unsigned int *width, /* RETURN */
+unsigned int *height) /* RETURN */
+#else
+int XParseGeometry (string, x, y, width, height)
+char *string;
+int *x, *y;
+unsigned int *width, *height; /* RETURN */
+#endif
+{
+ int mask = NoValue;
+ register char *strind;
+ unsigned int tempWidth, tempHeight;
+ int tempX, tempY;
+ char *nextCharacter;
+
+ if ( (string == NULL) || (*string == '\0')) return(mask);
+ if (*string == '=')
+ string++; /* ignore possible '=' at beg of geometry spec */
+
+ strind = (char *)string;
+ if (*strind != '+' && *strind != '-' && *strind != 'x') {
+ tempWidth = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= WidthValue;
+ }
+
+ if (*strind == 'x' || *strind == 'X') {
+ strind++;
+ tempHeight = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= HeightValue;
+ }
+
+ if ((*strind == '+') || (*strind == '-')) {
+ if (*strind == '-') {
+ strind++;
+ tempX = -ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return (0);
+ strind = nextCharacter;
+ mask |= XNegative;
+
+ }
+ else
+ { strind++;
+ tempX = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ }
+ mask |= XValue;
+ if ((*strind == '+') || (*strind == '-')) {
+ if (*strind == '-') {
+ strind++;
+ tempY = -ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ mask |= YNegative;
+
+ }
+ else
+ {
+ strind++;
+ tempY = ReadInteger(strind, &nextCharacter);
+ if (strind == nextCharacter)
+ return(0);
+ strind = nextCharacter;
+ }
+ mask |= YValue;
+ }
+ }
+
+ /* If strind isn't at the end of the string the it's an invalid
+ geometry specification. */
+
+ if (*strind != '\0') return (0);
+
+ if (mask & XValue)
+ *x = tempX;
+ if (mask & YValue)
+ *y = tempY;
+ if (mask & WidthValue)
+ *width = tempWidth;
+ if (mask & HeightValue)
+ *height = tempHeight;
+ return (mask);
+}
diff --git a/src/PeekEvent.c b/src/PeekEvent.c
new file mode 100644
index 00000000..ba597eeb
--- /dev/null
+++ b/src/PeekEvent.c
@@ -0,0 +1,48 @@
+/* $Xorg: PeekEvent.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * Return the next event in the queue,
+ * BUT do not remove it from the queue.
+ * If none found, flush and wait until there is an event to peek.
+ */
+
+XPeekEvent (dpy, event)
+ register Display *dpy;
+ register XEvent *event;
+{
+ LockDisplay(dpy);
+ if (dpy->head == NULL)
+ _XReadEvents(dpy);
+ *event = (dpy->head)->event;
+ UnlockDisplay(dpy);
+ return 1;
+}
+
diff --git a/src/PeekIfEv.c b/src/PeekIfEv.c
new file mode 100644
index 00000000..6cb9d118
--- /dev/null
+++ b/src/PeekIfEv.c
@@ -0,0 +1,73 @@
+/* $Xorg: PeekIfEv.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/*
+ * return the next event in the queue that satisfies the predicate.
+ * BUT do not remove it from the queue.
+ * If none found, flush, and then wait until one satisfies the predicate.
+ */
+
+XPeekIfEvent (dpy, event, predicate, arg)
+ register Display *dpy;
+ register XEvent *event;
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ XEvent* /* event */,
+ char* /* arg */
+#endif
+ );
+ char *arg;
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial = 0;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if(qelt->qserial_num > qe_serial
+ && (*predicate)(dpy, &qelt->event, arg)) {
+ *event = qelt->event;
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ _XReadEvents(dpy);
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+}
+
diff --git a/src/Pending.c b/src/Pending.c
new file mode 100644
index 00000000..55e5e71b
--- /dev/null
+++ b/src/Pending.c
@@ -0,0 +1,57 @@
+/* $Xorg: Pending.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* Read in pending events if needed and return the number of queued events. */
+
+int XEventsQueued (dpy, mode)
+ register Display *dpy;
+ int mode;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen || (mode == QueuedAlready))
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, mode);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
+
+int XPending (dpy)
+ register Display *dpy;
+{
+ int ret_val;
+ LockDisplay(dpy);
+ if (dpy->qlen)
+ ret_val = dpy->qlen;
+ else
+ ret_val = _XEventsQueued (dpy, QueuedAfterFlush);
+ UnlockDisplay(dpy);
+ return ret_val;
+}
diff --git a/src/PixFormats.c b/src/PixFormats.c
new file mode 100644
index 00000000..a8b74b1e
--- /dev/null
+++ b/src/PixFormats.c
@@ -0,0 +1,60 @@
+/* $Xorg: PixFormats.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <stdio.h>
+
+/*
+ * XListPixmapFormats - return info from connection setup
+ */
+
+XPixmapFormatValues *XListPixmapFormats (dpy, count)
+ Display *dpy;
+ int *count; /* RETURN */
+{
+ XPixmapFormatValues *formats = (XPixmapFormatValues *)
+ Xmalloc((unsigned) (dpy->nformats * sizeof (XPixmapFormatValues)));
+
+ if (formats) {
+ register int i;
+ register XPixmapFormatValues *f;
+ register ScreenFormat *sf;
+
+ /*
+ * copy data from internal Xlib data structure in display
+ */
+ for (i = dpy->nformats, f = formats, sf = dpy->pixmap_format; i > 0;
+ i--, f++, sf++) {
+ f->depth = sf->depth;
+ f->bits_per_pixel = sf->bits_per_pixel;
+ f->scanline_pad = sf->scanline_pad;
+ }
+
+ *count = dpy->nformats;
+ }
+ return formats;
+}
diff --git a/src/PmapBgnd.c b/src/PmapBgnd.c
new file mode 100644
index 00000000..5a74410f
--- /dev/null
+++ b/src/PmapBgnd.c
@@ -0,0 +1,45 @@
+/* $Xorg: PmapBgnd.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBackgroundPixmap(dpy, w, pixmap)
+ register Display *dpy;
+ Window w;
+ Pixmap pixmap;
+{
+ register xChangeWindowAttributesReq *req;
+ LockDisplay (dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBackPixmap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixmap);
+ UnlockDisplay (dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/PmapBord.c b/src/PmapBord.c
new file mode 100644
index 00000000..e33738ab
--- /dev/null
+++ b/src/PmapBord.c
@@ -0,0 +1,45 @@
+/* $Xorg: PmapBord.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetWindowBorderPixmap(dpy, w, pixmap)
+ register Display *dpy;
+ Window w;
+ Pixmap pixmap;
+{
+ register xChangeWindowAttributesReq *req;
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWBorderPixmap;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), pixmap);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/PolyReg.c b/src/PolyReg.c
new file mode 100644
index 00000000..4d9a0b52
--- /dev/null
+++ b/src/PolyReg.c
@@ -0,0 +1,630 @@
+/* $Xorg: PolyReg.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/************************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+************************************************************************/
+
+#define LARGE_COORDINATE 1000000
+#define SMALL_COORDINATE -LARGE_COORDINATE
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "region.h"
+#include "poly.h"
+
+/*
+ * InsertEdgeInET
+ *
+ * Insert the given edge into the edge table.
+ * First we must find the correct bucket in the
+ * Edge table, then find the right slot in the
+ * bucket. Finally, we can insert it.
+ *
+ */
+static void
+InsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
+ EdgeTable *ET;
+ EdgeTableEntry *ETE;
+ int scanline;
+ ScanLineListBlock **SLLBlock;
+ int *iSLLBlock;
+{
+ register EdgeTableEntry *start, *prev;
+ register ScanLineList *pSLL, *pPrevSLL;
+ ScanLineListBlock *tmpSLLBlock;
+
+ /*
+ * find the right bucket to put the edge into
+ */
+ pPrevSLL = &ET->scanlines;
+ pSLL = pPrevSLL->next;
+ while (pSLL && (pSLL->scanline < scanline))
+ {
+ pPrevSLL = pSLL;
+ pSLL = pSLL->next;
+ }
+
+ /*
+ * reassign pSLL (pointer to ScanLineList) if necessary
+ */
+ if ((!pSLL) || (pSLL->scanline > scanline))
+ {
+ if (*iSLLBlock > SLLSPERBLOCK-1)
+ {
+ tmpSLLBlock =
+ (ScanLineListBlock *)Xmalloc(sizeof(ScanLineListBlock));
+ (*SLLBlock)->next = tmpSLLBlock;
+ tmpSLLBlock->next = (ScanLineListBlock *)NULL;
+ *SLLBlock = tmpSLLBlock;
+ *iSLLBlock = 0;
+ }
+ pSLL = &((*SLLBlock)->SLLs[(*iSLLBlock)++]);
+
+ pSLL->next = pPrevSLL->next;
+ pSLL->edgelist = (EdgeTableEntry *)NULL;
+ pPrevSLL->next = pSLL;
+ }
+ pSLL->scanline = scanline;
+
+ /*
+ * now insert the edge in the right bucket
+ */
+ prev = (EdgeTableEntry *)NULL;
+ start = pSLL->edgelist;
+ while (start && (start->bres.minor_axis < ETE->bres.minor_axis))
+ {
+ prev = start;
+ start = start->next;
+ }
+ ETE->next = start;
+
+ if (prev)
+ prev->next = ETE;
+ else
+ pSLL->edgelist = ETE;
+}
+
+/*
+ * CreateEdgeTable
+ *
+ * This routine creates the edge table for
+ * scan converting polygons.
+ * The Edge Table (ET) looks like:
+ *
+ * EdgeTable
+ * --------
+ * | ymax | ScanLineLists
+ * |scanline|-->------------>-------------->...
+ * -------- |scanline| |scanline|
+ * |edgelist| |edgelist|
+ * --------- ---------
+ * | |
+ * | |
+ * V V
+ * list of ETEs list of ETEs
+ *
+ * where ETE is an EdgeTableEntry data structure,
+ * and there is one ScanLineList per scanline at
+ * which an edge is initially entered.
+ *
+ */
+
+static void
+CreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock)
+ register int count;
+ register XPoint *pts;
+ EdgeTable *ET;
+ EdgeTableEntry *AET;
+ register EdgeTableEntry *pETEs;
+ ScanLineListBlock *pSLLBlock;
+{
+ register XPoint *top, *bottom;
+ register XPoint *PrevPt, *CurrPt;
+ int iSLLBlock = 0;
+ int dy;
+
+ if (count < 2) return;
+
+ /*
+ * initialize the Active Edge Table
+ */
+ AET->next = (EdgeTableEntry *)NULL;
+ AET->back = (EdgeTableEntry *)NULL;
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ AET->bres.minor_axis = SMALL_COORDINATE;
+
+ /*
+ * initialize the Edge Table.
+ */
+ ET->scanlines.next = (ScanLineList *)NULL;
+ ET->ymax = SMALL_COORDINATE;
+ ET->ymin = LARGE_COORDINATE;
+ pSLLBlock->next = (ScanLineListBlock *)NULL;
+
+ PrevPt = &pts[count-1];
+
+ /*
+ * for each vertex in the array of points.
+ * In this loop we are dealing with two vertices at
+ * a time -- these make up one edge of the polygon.
+ */
+ while (count--)
+ {
+ CurrPt = pts++;
+
+ /*
+ * find out which point is above and which is below.
+ */
+ if (PrevPt->y > CurrPt->y)
+ {
+ bottom = PrevPt, top = CurrPt;
+ pETEs->ClockWise = 0;
+ }
+ else
+ {
+ bottom = CurrPt, top = PrevPt;
+ pETEs->ClockWise = 1;
+ }
+
+ /*
+ * don't add horizontal edges to the Edge table.
+ */
+ if (bottom->y != top->y)
+ {
+ pETEs->ymax = bottom->y-1; /* -1 so we don't get last scanline */
+
+ /*
+ * initialize integer edge algorithm
+ */
+ dy = bottom->y - top->y;
+ BRESINITPGONSTRUCT(dy, top->x, bottom->x, pETEs->bres);
+
+ InsertEdgeInET(ET, pETEs, top->y, &pSLLBlock, &iSLLBlock);
+
+ if (PrevPt->y > ET->ymax)
+ ET->ymax = PrevPt->y;
+ if (PrevPt->y < ET->ymin)
+ ET->ymin = PrevPt->y;
+ pETEs++;
+ }
+
+ PrevPt = CurrPt;
+ }
+}
+
+/*
+ * loadAET
+ *
+ * This routine moves EdgeTableEntries from the
+ * EdgeTable into the Active Edge Table,
+ * leaving them sorted by smaller x coordinate.
+ *
+ */
+
+static void
+loadAET(AET, ETEs)
+ register EdgeTableEntry *AET, *ETEs;
+{
+ register EdgeTableEntry *pPrevAET;
+ register EdgeTableEntry *tmp;
+
+ pPrevAET = AET;
+ AET = AET->next;
+ while (ETEs)
+ {
+ while (AET && (AET->bres.minor_axis < ETEs->bres.minor_axis))
+ {
+ pPrevAET = AET;
+ AET = AET->next;
+ }
+ tmp = ETEs->next;
+ ETEs->next = AET;
+ if (AET)
+ AET->back = ETEs;
+ ETEs->back = pPrevAET;
+ pPrevAET->next = ETEs;
+ pPrevAET = ETEs;
+
+ ETEs = tmp;
+ }
+}
+
+/*
+ * computeWAET
+ *
+ * This routine links the AET by the
+ * nextWETE (winding EdgeTableEntry) link for
+ * use by the winding number rule. The final
+ * Active Edge Table (AET) might look something
+ * like:
+ *
+ * AET
+ * ---------- --------- ---------
+ * |ymax | |ymax | |ymax |
+ * | ... | |... | |... |
+ * |next |->|next |->|next |->...
+ * |nextWETE| |nextWETE| |nextWETE|
+ * --------- --------- ^--------
+ * | | |
+ * V-------------------> V---> ...
+ *
+ */
+static void
+computeWAET(AET)
+ register EdgeTableEntry *AET;
+{
+ register EdgeTableEntry *pWETE;
+ register int inside = 1;
+ register int isInside = 0;
+
+ AET->nextWETE = (EdgeTableEntry *)NULL;
+ pWETE = AET;
+ AET = AET->next;
+ while (AET)
+ {
+ if (AET->ClockWise)
+ isInside++;
+ else
+ isInside--;
+
+ if ((!inside && !isInside) ||
+ ( inside && isInside))
+ {
+ pWETE->nextWETE = AET;
+ pWETE = AET;
+ inside = !inside;
+ }
+ AET = AET->next;
+ }
+ pWETE->nextWETE = (EdgeTableEntry *)NULL;
+}
+
+/*
+ * InsertionSort
+ *
+ * Just a simple insertion sort using
+ * pointers and back pointers to sort the Active
+ * Edge Table.
+ *
+ */
+
+static int
+InsertionSort(AET)
+ register EdgeTableEntry *AET;
+{
+ register EdgeTableEntry *pETEchase;
+ register EdgeTableEntry *pETEinsert;
+ register EdgeTableEntry *pETEchaseBackTMP;
+ register int changed = 0;
+
+ AET = AET->next;
+ while (AET)
+ {
+ pETEinsert = AET;
+ pETEchase = AET;
+ while (pETEchase->back->bres.minor_axis > AET->bres.minor_axis)
+ pETEchase = pETEchase->back;
+
+ AET = AET->next;
+ if (pETEchase != pETEinsert)
+ {
+ pETEchaseBackTMP = pETEchase->back;
+ pETEinsert->back->next = AET;
+ if (AET)
+ AET->back = pETEinsert->back;
+ pETEinsert->next = pETEchase;
+ pETEchase->back->next = pETEinsert;
+ pETEchase->back = pETEinsert;
+ pETEinsert->back = pETEchaseBackTMP;
+ changed = 1;
+ }
+ }
+ return(changed);
+}
+
+/*
+ * Clean up our act.
+ */
+static void
+FreeStorage(pSLLBlock)
+ register ScanLineListBlock *pSLLBlock;
+{
+ register ScanLineListBlock *tmpSLLBlock;
+
+ while (pSLLBlock)
+ {
+ tmpSLLBlock = pSLLBlock->next;
+ Xfree((char *)pSLLBlock);
+ pSLLBlock = tmpSLLBlock;
+ }
+}
+
+/*
+ * Create an array of rectangles from a list of points.
+ * If indeed these things (POINTS, RECTS) are the same,
+ * then this proc is still needed, because it allocates
+ * storage for the array, which was allocated on the
+ * stack by the calling procedure.
+ *
+ */
+static int PtsToRegion(numFullPtBlocks, iCurPtBlock, FirstPtBlock, reg)
+ register int numFullPtBlocks, iCurPtBlock;
+ POINTBLOCK *FirstPtBlock;
+ REGION *reg;
+{
+ register BOX *rects;
+ register XPoint *pts;
+ register POINTBLOCK *CurPtBlock;
+ register int i;
+ register BOX *extents;
+ register int numRects;
+ BOX *prevRects = reg->rects;
+
+ extents = &reg->extents;
+
+ numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
+
+ if (!(reg->rects = (BOX *)Xrealloc((char *)reg->rects,
+ (unsigned) (sizeof(BOX) * numRects)))) {
+ Xfree(prevRects);
+ return(0);
+ }
+
+ reg->size = numRects;
+ CurPtBlock = FirstPtBlock;
+ rects = reg->rects - 1;
+ numRects = 0;
+ extents->x1 = MAXSHORT, extents->x2 = MINSHORT;
+
+ for ( ; numFullPtBlocks >= 0; numFullPtBlocks--) {
+ /* the loop uses 2 points per iteration */
+ i = NUMPTSTOBUFFER >> 1;
+ if (!numFullPtBlocks)
+ i = iCurPtBlock >> 1;
+ for (pts = CurPtBlock->pts; i--; pts += 2) {
+ if (pts->x == pts[1].x)
+ continue;
+ if (numRects && pts->x == rects->x1 && pts->y == rects->y2 &&
+ pts[1].x == rects->x2 &&
+ (numRects == 1 || rects[-1].y1 != rects->y1) &&
+ (i && pts[2].y > pts[1].y)) {
+ rects->y2 = pts[1].y + 1;
+ continue;
+ }
+ numRects++;
+ rects++;
+ rects->x1 = pts->x; rects->y1 = pts->y;
+ rects->x2 = pts[1].x; rects->y2 = pts[1].y + 1;
+ if (rects->x1 < extents->x1)
+ extents->x1 = rects->x1;
+ if (rects->x2 > extents->x2)
+ extents->x2 = rects->x2;
+ }
+ CurPtBlock = CurPtBlock->next;
+ }
+
+ if (numRects) {
+ extents->y1 = reg->rects->y1;
+ extents->y2 = rects->y2;
+ } else {
+ extents->x1 = 0;
+ extents->y1 = 0;
+ extents->x2 = 0;
+ extents->y2 = 0;
+ }
+ reg->numRects = numRects;
+
+ return(TRUE);
+}
+
+/*
+ * polytoregion
+ *
+ * Scan converts a polygon by returning a run-length
+ * encoding of the resultant bitmap -- the run-length
+ * encoding is in the form of an array of rectangles.
+ */
+Region
+XPolygonRegion(Pts, Count, rule)
+ int Count; /* number of pts */
+ XPoint *Pts; /* the pts */
+ int rule; /* winding rule */
+{
+ Region region;
+ register EdgeTableEntry *pAET; /* Active Edge Table */
+ register int y; /* current scanline */
+ register int iPts = 0; /* number of pts in buffer */
+ register EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/
+ register ScanLineList *pSLL; /* current scanLineList */
+ register XPoint *pts; /* output buffer */
+ EdgeTableEntry *pPrevAET; /* ptr to previous AET */
+ EdgeTable ET; /* header node for ET */
+ EdgeTableEntry AET; /* header node for AET */
+ EdgeTableEntry *pETEs; /* EdgeTableEntries pool */
+ ScanLineListBlock SLLBlock; /* header for scanlinelist */
+ int fixWAET = FALSE;
+ POINTBLOCK FirstPtBlock, *curPtBlock; /* PtBlock buffers */
+ POINTBLOCK *tmpPtBlock;
+ int numFullPtBlocks = 0;
+
+ if (! (region = XCreateRegion())) return (Region) NULL;
+
+ /* special case a rectangle */
+ pts = Pts;
+ if (((Count == 4) ||
+ ((Count == 5) && (pts[4].x == pts[0].x) && (pts[4].y == pts[0].y))) &&
+ (((pts[0].y == pts[1].y) &&
+ (pts[1].x == pts[2].x) &&
+ (pts[2].y == pts[3].y) &&
+ (pts[3].x == pts[0].x)) ||
+ ((pts[0].x == pts[1].x) &&
+ (pts[1].y == pts[2].y) &&
+ (pts[2].x == pts[3].x) &&
+ (pts[3].y == pts[0].y)))) {
+ region->extents.x1 = min(pts[0].x, pts[2].x);
+ region->extents.y1 = min(pts[0].y, pts[2].y);
+ region->extents.x2 = max(pts[0].x, pts[2].x);
+ region->extents.y2 = max(pts[0].y, pts[2].y);
+ if ((region->extents.x1 != region->extents.x2) &&
+ (region->extents.y1 != region->extents.y2)) {
+ region->numRects = 1;
+ *(region->rects) = region->extents;
+ }
+ return(region);
+ }
+
+ if (! (pETEs = (EdgeTableEntry *)
+ Xmalloc((unsigned) (sizeof(EdgeTableEntry) * Count))))
+ return (Region) NULL;
+
+ pts = FirstPtBlock.pts;
+ CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
+ pSLL = ET.scanlines.next;
+ curPtBlock = &FirstPtBlock;
+
+ if (rule == EvenOddRule) {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL != NULL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ pts->x = pAET->bres.minor_axis, pts->y = y;
+ pts++, iPts++;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ numFullPtBlocks++;
+ iPts = 0;
+ }
+ EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
+ }
+ (void) InsertionSort(&AET);
+ }
+ }
+ else {
+ /*
+ * for each scanline
+ */
+ for (y = ET.ymin; y < ET.ymax; y++) {
+ /*
+ * Add a new edge to the active edge table when we
+ * get to the next edge.
+ */
+ if (pSLL != NULL && y == pSLL->scanline) {
+ loadAET(&AET, pSLL->edgelist);
+ computeWAET(&AET);
+ pSLL = pSLL->next;
+ }
+ pPrevAET = &AET;
+ pAET = AET.next;
+ pWETE = pAET;
+
+ /*
+ * for each active edge
+ */
+ while (pAET) {
+ /*
+ * add to the buffer only those edges that
+ * are in the Winding active edge table.
+ */
+ if (pWETE == pAET) {
+ pts->x = pAET->bres.minor_axis, pts->y = y;
+ pts++, iPts++;
+
+ /*
+ * send out the buffer
+ */
+ if (iPts == NUMPTSTOBUFFER) {
+ tmpPtBlock = (POINTBLOCK *)Xmalloc(sizeof(POINTBLOCK));
+ curPtBlock->next = tmpPtBlock;
+ curPtBlock = tmpPtBlock;
+ pts = curPtBlock->pts;
+ numFullPtBlocks++; iPts = 0;
+ }
+ pWETE = pWETE->nextWETE;
+ }
+ EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
+ }
+
+ /*
+ * recompute the winding active edge table if
+ * we just resorted or have exited an edge.
+ */
+ if (InsertionSort(&AET) || fixWAET) {
+ computeWAET(&AET);
+ fixWAET = FALSE;
+ }
+ }
+ }
+ FreeStorage(SLLBlock.next);
+ (void) PtsToRegion(numFullPtBlocks, iPts, &FirstPtBlock, region);
+ for (curPtBlock = FirstPtBlock.next; --numFullPtBlocks >= 0;) {
+ tmpPtBlock = curPtBlock->next;
+ Xfree((char *)curPtBlock);
+ curPtBlock = tmpPtBlock;
+ }
+ Xfree((char *)pETEs);
+ return(region);
+}
diff --git a/src/PolyTxt.c b/src/PolyTxt.c
new file mode 100644
index 00000000..c90a7b04
--- /dev/null
+++ b/src/PolyTxt.c
@@ -0,0 +1,230 @@
+/* $Xorg: PolyTxt.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawText(dpy, d, gc, x, y, items, nitems)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XTextItem *items;
+ int nitems;
+{
+ register int i;
+ register XTextItem *item;
+ int length = 0;
+ register xPolyText8Req *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText8, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+ item = items;
+ for (i=0; i < nitems; i++) {
+ if (item->font)
+ length += 5; /* a 255 byte, plus size of Font id */
+ if (item->delta)
+ {
+ if (item->delta > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
+ }
+ else
+ {
+ length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
+ }
+ }
+ if (item->nchars > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
+ if (!item->delta) length += SIZEOF(xTextElt);
+ length += item->nchars;
+ }
+ item++;
+ }
+
+ req->length += (length + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + length > dpy->bufmax)
+ _XFlush (dpy);
+
+ item = items;
+ for (i=0; i< nitems; i++) {
+
+ if (item->font) {
+ /* to mark a font shift, write a 255 byte followed by
+ the 4 bytes of font ID, big-end first */
+ register unsigned char *f;
+ BufAlloc (unsigned char *, f, 5);
+
+ f[0] = 255;
+ f[1] = (item->font & 0xff000000) >> 24;
+ f[2] = (item->font & 0x00ff0000) >> 16;
+ f[3] = (item->font & 0x0000ff00) >> 8;
+ f[4] = item->font & 0x000000ff;
+
+ /* update GC shadow */
+ gc->values.font = item->font;
+ }
+
+ {
+ int nbytes = SIZEOF(xTextElt);
+ int PartialNChars = item->nchars;
+ int PartialDelta = item->delta;
+ /* register xTextElt *elt; */
+ int FirstTimeThrough = True;
+ char *CharacterOffset = item->chars;
+ char *tbuf;
+
+ while((PartialDelta < -128) || (PartialDelta > 127))
+ {
+ int nb = SIZEOF(xTextElt);
+
+ BufAlloc (char *, tbuf, nb);
+ *tbuf = 0; /* elt->len */
+ if (PartialDelta > 0 )
+ {
+ *(tbuf+1) = 127; /* elt->delta */
+ PartialDelta = PartialDelta - 127;
+ }
+ else
+ {
+ /* -128 = 0x8, need to be careful of signed chars... */
+ *((unsigned char *)(tbuf+1)) = 0x80; /* elt->delta */
+ PartialDelta = PartialDelta + 128;
+ }
+ }
+ if (PartialDelta)
+ {
+ BufAlloc (char *, tbuf , nbytes);
+ *tbuf = 0; /* elt->len */
+ *(tbuf+1) = PartialDelta; /* elt->delta */
+ }
+ while(PartialNChars > 254)
+ {
+ nbytes = 254;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ /* watch out for signs on chars */
+ *(unsigned char *)tbuf = 254; /* elt->len */
+ memcpy (tbuf+2 , CharacterOffset, 254);
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+
+ }
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (char *, tbuf, nbytes);
+ *(tbuf+1) = 0; /* elt->delta */
+ }
+ *tbuf = PartialNChars; /* elt->len */
+ memcpy (tbuf+2 , CharacterOffset, PartialNChars);
+ }
+ }
+ item++;
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (length &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - length;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
diff --git a/src/PolyTxt16.c b/src/PolyTxt16.c
new file mode 100644
index 00000000..e75ad5c4
--- /dev/null
+++ b/src/PolyTxt16.c
@@ -0,0 +1,264 @@
+/* $Xorg: PolyTxt16.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XDrawText16(dpy, d, gc, x, y, items, nitems)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XTextItem16 *items;
+ int nitems;
+{
+ register int i;
+ register XTextItem16 *item;
+ int length = 0;
+ register xPolyText16Req *req;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText16, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+ item = items;
+ for (i=0; i < nitems; i++) {
+ if (item->font)
+ length += 5; /* a 255 byte, plus size of Font id */
+ if (item->delta)
+ {
+ if (item->delta > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->delta + 126) / 127);
+ }
+ else
+ {
+ length += SIZEOF(xTextElt) * ((-item->delta + 127) / 128);
+ }
+ }
+ if (item->nchars > 0)
+ {
+ length += SIZEOF(xTextElt) * ((item->nchars + 253) / 254 - 1);
+ if (!item->delta) length += SIZEOF(xTextElt);
+ length += item->nchars << 1;
+ }
+ item++;
+ }
+
+ req->length += (length + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + length > dpy->bufmax)
+ _XFlush (dpy);
+
+ item = items;
+ for (i=0; i< nitems; i++) {
+
+ if (item->font) {
+ /* to mark a font shift, write a 255 byte followed by
+ the 4 bytes of font ID, big-end first */
+ register unsigned char *f;
+ BufAlloc (unsigned char *, f, 5);
+
+ f[0] = 255;
+ f[1] = (item->font & 0xff000000) >> 24;
+ f[2] = (item->font & 0x00ff0000) >> 16;
+ f[3] = (item->font & 0x0000ff00) >> 8;
+ f[4] = item->font & 0x000000ff;
+
+ /* update GC shadow */
+ gc->values.font = item->font;
+ }
+
+ {
+ int nbytes = SIZEOF(xTextElt);
+ int PartialNChars = item->nchars;
+ int PartialDelta = item->delta;
+ register xTextElt *elt;
+ int FirstTimeThrough = True;
+ XChar2b *CharacterOffset = item->chars;
+
+ while((PartialDelta < -128) || (PartialDelta > 127))
+ {
+ int nb = SIZEOF(xTextElt);
+
+ BufAlloc (xTextElt *, elt, nb);
+ elt->len = 0;
+ if (PartialDelta > 0 )
+ {
+ elt->delta = 127;
+ PartialDelta = PartialDelta - 127;
+ }
+ else
+ {
+ elt->delta = -128;
+ PartialDelta = PartialDelta + 128;
+ }
+ }
+ if (PartialDelta)
+ {
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->len = 0;
+ elt->delta = PartialDelta;
+ }
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 * 2;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+#ifdef lint
+ DummyChar = DummyChar;
+#endif
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ elt->len = 254;
+
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy ((char *) (elt + 1), (char *)CharacterOffset, 254 * 2);
+#endif
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+
+ }
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars * 2;
+ if (FirstTimeThrough)
+ {
+ FirstTimeThrough = False;
+ if (!item->delta)
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ else
+ {
+ char *DummyChar;
+ BufAlloc(char *, DummyChar, nbytes);
+#ifdef lint
+ DummyChar = DummyChar;
+#endif
+ }
+ }
+ else
+ {
+ nbytes += SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ }
+ elt->len = PartialNChars;
+
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
+ i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy ((char *) (elt + 1), (char *)CharacterOffset,
+ PartialNChars *
+2);
+#endif
+ }
+ }
+ item++;
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (length &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - length;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
diff --git a/src/PropAlloc.c b/src/PropAlloc.c
new file mode 100644
index 00000000..9b95436e
--- /dev/null
+++ b/src/PropAlloc.c
@@ -0,0 +1,73 @@
+/* $Xorg: PropAlloc.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+
+
+/*
+ * Routines for allocating space for structures that are expected to get
+ * longer at some point.
+ */
+
+XSizeHints *XAllocSizeHints ()
+{
+ return ((XSizeHints *) Xcalloc (1, (unsigned) sizeof (XSizeHints)));
+}
+
+
+XStandardColormap *XAllocStandardColormap ()
+{
+ return ((XStandardColormap *)
+ Xcalloc (1, (unsigned) sizeof (XStandardColormap)));
+}
+
+
+XWMHints *XAllocWMHints ()
+{
+ return ((XWMHints *) Xcalloc (1, (unsigned) sizeof (XWMHints)));
+}
+
+
+XClassHint *XAllocClassHint ()
+{
+ register XClassHint *h;
+
+ if ((h = (XClassHint *) Xcalloc (1, (unsigned) sizeof (XClassHint))))
+ h->res_name = h->res_class = NULL;
+
+ return h;
+}
+
+
+XIconSize *XAllocIconSize ()
+{
+ return ((XIconSize *) Xcalloc (1, (unsigned) sizeof (XIconSize)));
+}
+
+
diff --git a/src/PutBEvent.c b/src/PutBEvent.c
new file mode 100644
index 00000000..21f57bb6
--- /dev/null
+++ b/src/PutBEvent.c
@@ -0,0 +1,59 @@
+/* $Xorg: PutBEvent.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* XPutBackEvent puts an event back at the head of the queue. */
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+XPutBackEvent (dpy, event)
+ register Display *dpy;
+ register XEvent *event;
+ {
+ register _XQEvent *qelt;
+
+ LockDisplay(dpy);
+ if (!dpy->qfree) {
+ if ((dpy->qfree = (_XQEvent *) Xmalloc (sizeof (_XQEvent))) == NULL) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ dpy->qfree->next = NULL;
+ }
+ qelt = dpy->qfree;
+ dpy->qfree = qelt->next;
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ qelt->next = dpy->head;
+ qelt->event = *event;
+ dpy->head = qelt;
+ if (dpy->tail == NULL)
+ dpy->tail = qelt;
+ dpy->qlen++;
+ UnlockDisplay(dpy);
+ return 0;
+ }
diff --git a/src/PutImage.c b/src/PutImage.c
new file mode 100644
index 00000000..8c13a097
--- /dev/null
+++ b/src/PutImage.c
@@ -0,0 +1,998 @@
+/* $Xorg: PutImage.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+#if defined(__STDC__) && ((defined(sun) && defined(SVR4)) || defined(WIN32))
+#define RConst /**/
+#else
+#define RConst Const
+#endif
+
+/* assumes pad is a power of 2 */
+#define ROUNDUP(nbytes, pad) (((nbytes) + ((pad) - 1)) & ~(long)((pad) - 1))
+
+static unsigned char Const _reverse_byte[0x100] = {
+ 0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+ 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+ 0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+ 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+ 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+ 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+ 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+ 0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+ 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+ 0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+ 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+ 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+ 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+ 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+ 0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+ 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+ 0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+ 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+ 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+ 0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+ 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+ 0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+ 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+ 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+ 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+ 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+ 0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+ 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+ 0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+ 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+ 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+ 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff
+};
+
+static unsigned char Const _reverse_nibs[0x100] = {
+ 0x00, 0x10, 0x20, 0x30, 0x40, 0x50, 0x60, 0x70,
+ 0x80, 0x90, 0xa0, 0xb0, 0xc0, 0xd0, 0xe0, 0xf0,
+ 0x01, 0x11, 0x21, 0x31, 0x41, 0x51, 0x61, 0x71,
+ 0x81, 0x91, 0xa1, 0xb1, 0xc1, 0xd1, 0xe1, 0xf1,
+ 0x02, 0x12, 0x22, 0x32, 0x42, 0x52, 0x62, 0x72,
+ 0x82, 0x92, 0xa2, 0xb2, 0xc2, 0xd2, 0xe2, 0xf2,
+ 0x03, 0x13, 0x23, 0x33, 0x43, 0x53, 0x63, 0x73,
+ 0x83, 0x93, 0xa3, 0xb3, 0xc3, 0xd3, 0xe3, 0xf3,
+ 0x04, 0x14, 0x24, 0x34, 0x44, 0x54, 0x64, 0x74,
+ 0x84, 0x94, 0xa4, 0xb4, 0xc4, 0xd4, 0xe4, 0xf4,
+ 0x05, 0x15, 0x25, 0x35, 0x45, 0x55, 0x65, 0x75,
+ 0x85, 0x95, 0xa5, 0xb5, 0xc5, 0xd5, 0xe5, 0xf5,
+ 0x06, 0x16, 0x26, 0x36, 0x46, 0x56, 0x66, 0x76,
+ 0x86, 0x96, 0xa6, 0xb6, 0xc6, 0xd6, 0xe6, 0xf6,
+ 0x07, 0x17, 0x27, 0x37, 0x47, 0x57, 0x67, 0x77,
+ 0x87, 0x97, 0xa7, 0xb7, 0xc7, 0xd7, 0xe7, 0xf7,
+ 0x08, 0x18, 0x28, 0x38, 0x48, 0x58, 0x68, 0x78,
+ 0x88, 0x98, 0xa8, 0xb8, 0xc8, 0xd8, 0xe8, 0xf8,
+ 0x09, 0x19, 0x29, 0x39, 0x49, 0x59, 0x69, 0x79,
+ 0x89, 0x99, 0xa9, 0xb9, 0xc9, 0xd9, 0xe9, 0xf9,
+ 0x0a, 0x1a, 0x2a, 0x3a, 0x4a, 0x5a, 0x6a, 0x7a,
+ 0x8a, 0x9a, 0xaa, 0xba, 0xca, 0xda, 0xea, 0xfa,
+ 0x0b, 0x1b, 0x2b, 0x3b, 0x4b, 0x5b, 0x6b, 0x7b,
+ 0x8b, 0x9b, 0xab, 0xbb, 0xcb, 0xdb, 0xeb, 0xfb,
+ 0x0c, 0x1c, 0x2c, 0x3c, 0x4c, 0x5c, 0x6c, 0x7c,
+ 0x8c, 0x9c, 0xac, 0xbc, 0xcc, 0xdc, 0xec, 0xfc,
+ 0x0d, 0x1d, 0x2d, 0x3d, 0x4d, 0x5d, 0x6d, 0x7d,
+ 0x8d, 0x9d, 0xad, 0xbd, 0xcd, 0xdd, 0xed, 0xfd,
+ 0x0e, 0x1e, 0x2e, 0x3e, 0x4e, 0x5e, 0x6e, 0x7e,
+ 0x8e, 0x9e, 0xae, 0xbe, 0xce, 0xde, 0xee, 0xfe,
+ 0x0f, 0x1f, 0x2f, 0x3f, 0x4f, 0x5f, 0x6f, 0x7f,
+ 0x8f, 0x9f, 0xaf, 0xbf, 0xcf, 0xdf, 0xef, 0xff
+};
+
+
+_XReverse_Bytes (bpt, nb)
+ register unsigned char *bpt;
+ register int nb;
+{
+ do {
+ *bpt = _reverse_byte[*bpt];
+ bpt++;
+ } while (--nb > 0);
+ return 0;
+}
+
+
+/* XXX the following functions are declared int instead of void because various
+ * compilers and lints complain about later initialization of SwapFunc and/or
+ * (swapfunc == NoSwap) when void is used.
+ */
+
+/*ARGSUSED*/
+static void
+NoSwap (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long h = height;
+
+ if (srcinc == destinc)
+ memcpy((char *)dest, (char *)src, (int)(srcinc * (h - 1) + srclen));
+ else
+ for (; --h >= 0; src += srcinc, dest += destinc)
+ memcpy((char *)dest, (char *)src, (int)srclen);
+}
+
+static void
+SwapTwoBytes (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long length = ROUNDUP(srclen, 2);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 2;
+ if (half_order == MSBFirst)
+ *(dest + length) = *(src + length + 1);
+ else
+ *(dest + length + 1) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 2, src += 2) {
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapThreeBytes (src, dest, srclen, srcinc, destinc, height, byte_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int byte_order;
+{
+ long length = ((srclen + 2) / 3) * 3;
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 3;
+ if ((srclen - length) == 2)
+ *(dest + length + 1) = *(src + length + 1);
+ if (byte_order == MSBFirst)
+ *(dest + length) = *(src + length + 2);
+ else
+ *(dest + length + 2) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 3, src += 3) {
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapFourBytes (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length) = *(src + length + 3);
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length + 1) = *(src + length + 2);
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 2) = *(src + length + 1);
+ if (half_order == LSBFirst)
+ *(dest + length + 3) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 4, src += 4) {
+ *dest++ = *(src + 3);
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 1);
+ *dest++ = *src;
+ }
+ }
+}
+
+static void
+SwapWords (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length + 1) = *(src + length + 3);
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length) = *(src + length + 2);
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 3) = *(src + length + 1);
+ if (half_order == LSBFirst)
+ *(dest + length + 2) = *(src + length);
+ }
+ for (n = length; n > 0; n -= 4, src += 2) {
+ *dest++ = *(src + 2);
+ *dest++ = *(src + 3);
+ *dest++ = *src++;
+ *dest++ = *src++;
+ }
+ }
+}
+
+static void
+SwapNibbles (src, dest, srclen, srcinc, destinc, height)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+{
+ register long h, n;
+ register Const unsigned char *rev = _reverse_nibs;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; )
+ *dest++ = rev[*src++];
+}
+
+static void
+ShiftNibblesLeft (src, dest, srclen, srcinc, destinc, height, nibble_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int nibble_order;
+{
+ register long h, n;
+ register unsigned char c1, c2;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ if (nibble_order == MSBFirst) {
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; ) {
+ c1 = *src++;
+ c2 = *src;
+ *dest++ = ((c1 & 0x0f) << 4) | ((c2 & (unsigned)0xf0) >> 4);
+ }
+ } else {
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; ) {
+ c1 = *src++;
+ c2 = *src;
+ *dest++ = ((c2 & 0x0f) << 4) | ((c1 & (unsigned)0xf0) >> 4);
+ }
+ }
+}
+
+/*ARGSUSED*/
+static void
+SwapBits (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ register long h, n;
+ register Const unsigned char *rev = _reverse_byte;
+
+ srcinc -= srclen;
+ destinc -= srclen;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc)
+ for (n = srclen; --n >= 0; )
+ *dest++ = rev[*src++];
+}
+
+static void
+SwapBitsAndTwoBytes (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+{
+ long length = ROUNDUP(srclen, 2);
+ register long h, n;
+ register Const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 2;
+ if (half_order == MSBFirst)
+ *(dest + length) = rev[*(src + length + 1)];
+ else
+ *(dest + length + 1) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 2, src += 2) {
+ *dest++ = rev[*(src + 1)];
+ *dest++ = rev[*src];
+ }
+ }
+}
+
+static void
+SwapBitsAndFourBytes (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+ register Const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length) = rev[*(src + length + 3)];
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length + 1) = rev[*(src + length + 2)];
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 2) = rev[*(src + length + 1)];
+ if (half_order == LSBFirst)
+ *(dest + length + 3) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 4, src += 4) {
+ *dest++ = rev[*(src + 3)];
+ *dest++ = rev[*(src + 2)];
+ *dest++ = rev[*(src + 1)];
+ *dest++ = rev[*src];
+ }
+ }
+}
+
+static void
+SwapBitsAndWords (src, dest, srclen, srcinc, destinc, height, half_order)
+ register unsigned char *src, *dest;
+ long srclen, srcinc, destinc;
+ unsigned int height;
+ int half_order;
+{
+ long length = ROUNDUP(srclen, 4);
+ register long h, n;
+ register Const unsigned char *rev = _reverse_byte;
+
+ srcinc -= length;
+ destinc -= length;
+ for (h = height; --h >= 0; src += srcinc, dest += destinc) {
+ if ((h == 0) && (srclen != length)) {
+ length -= 4;
+ if (half_order == MSBFirst)
+ *(dest + length + 1) = rev[*(src + length + 3)];
+ if (((half_order == LSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == MSBFirst) && (srclen & 2)))
+ *(dest + length) = rev[*(src + length + 2)];
+ if (((half_order == MSBFirst) && ((srclen - length) == 3)) ||
+ ((half_order == LSBFirst) && (srclen & 2)))
+ *(dest + length + 3) = rev[*(src + length + 1)];
+ if (half_order == LSBFirst)
+ *(dest + length + 2) = rev[*(src + length)];
+ }
+ for (n = length; n > 0; n -= 4, src += 2) {
+ *dest++ = rev[*(src + 2)];
+ *dest++ = rev[*(src + 3)];
+ *dest++ = rev[*src++];
+ *dest++ = rev[*src++];
+ }
+ }
+}
+
+/*
+
+The following table gives the bit ordering within bytes (when accessed
+sequentially) for a scanline containing 32 bits, with bits numbered 0 to
+31, where bit 0 should be leftmost on the display. For a given byte
+labelled A-B, A is for the most significant bit of the byte, and B is
+for the least significant bit.
+
+legend:
+ 1 scanline-unit = 8
+ 2 scanline-unit = 16
+ 4 scanline-unit = 32
+ M byte-order = MostSignificant
+ L byte-order = LeastSignificant
+ m bit-order = MostSignificant
+ l bit-order = LeastSignificant
+
+
+format ordering
+
+1Mm 00-07 08-15 16-23 24-31
+2Mm 00-07 08-15 16-23 24-31
+4Mm 00-07 08-15 16-23 24-31
+1Ml 07-00 15-08 23-16 31-24
+2Ml 15-08 07-00 31-24 23-16
+4Ml 31-24 23-16 15-08 07-00
+1Lm 00-07 08-15 16-23 24-31
+2Lm 08-15 00-07 24-31 16-23
+4Lm 24-31 16-23 08-15 00-07
+1Ll 07-00 15-08 23-16 31-24
+2Ll 07-00 15-08 23-16 31-24
+4Ll 07-00 15-08 23-16 31-24
+
+
+The following table gives the required conversion between any two
+formats. It is based strictly on the table above. If you believe one,
+you should believe the other.
+
+legend:
+ n no changes
+ s reverse 8-bit units within 16-bit units
+ l reverse 8-bit units within 32-bit units
+ w reverse 16-bit units within 32-bit units
+ R reverse bits within 8-bit units
+ S s+R
+ L l+R
+ W w+R
+
+*/
+
+static void (* RConst (SwapFunction[12][12]))() = {
+#define n NoSwap,
+#define s SwapTwoBytes,
+#define l SwapFourBytes,
+#define w SwapWords,
+#define R SwapBits,
+#define S SwapBitsAndTwoBytes,
+#define L SwapBitsAndFourBytes,
+#define W SwapBitsAndWords,
+
+/* 1Mm 2Mm 4Mm 1Ml 2Ml 4Ml 1Lm 2Lm 4Lm 1Ll 2Ll 4Ll */
+/* 1Mm */ { n n n R S L n s l R R R },
+/* 2Mm */ { n n n R S L n s l R R R },
+/* 4Mm */ { n n n R S L n s l R R R },
+/* 1Ml */ { R R R n s l R S L n n n },
+/* 2Ml */ { S S S s n w S R W s s s },
+/* 4Ml */ { L L L l w n L W R l l l },
+/* 1Lm */ { n n n R S L n s l R R R },
+/* 2Lm */ { s s s S R W s n w S S S },
+/* 4Lm */ { l l l L W R l w n L L L },
+/* 1Ll */ { R R R n s l R S L n n n },
+/* 2Ll */ { R R R n s l R S L n n n },
+/* 4Ll */ { R R R n s l R S L n n n }
+
+#undef n
+#undef s
+#undef l
+#undef w
+#undef R
+#undef S
+#undef L
+#undef W
+
+};
+
+/* Of course, the table above is a lie. We also need to factor in the
+ * order of the source data to cope with swapping half of a unit at the
+ * end of a scanline, since we are trying to avoid de-ref'ing off the
+ * end of the source.
+ *
+ * Defines whether the first half of a unit has the first half of the data
+ */
+static int Const HalfOrder[12] = {
+ LSBFirst, /* 1Mm */
+ LSBFirst, /* 2Mm */
+ LSBFirst, /* 4Mm */
+ LSBFirst, /* 1Ml */
+ MSBFirst, /* 2Ml */
+ MSBFirst, /* 4Ml */
+ LSBFirst, /* 1Lm */
+ MSBFirst, /* 2Lm */
+ MSBFirst, /* 4Lm */
+ LSBFirst, /* 1Ll */
+ LSBFirst, /* 2Ll */
+ LSBFirst /* 4Ll */
+ };
+
+/* Finally, for SwapWords cases, the half order depends not just on the source
+ * but also on the destination scanline unit. Use of this table changes some
+ * MSBFirsts to LSBFirsts that are "do not care" (because the function will be
+ * NoSwap or SwapBits) in addition to changing the desired ones.
+ */
+
+static int Const HalfOrderWord[12] = {
+ MSBFirst, /* 1Mm */
+ MSBFirst, /* 2Mm */
+ MSBFirst, /* 4Mm */
+ MSBFirst, /* 1Ml */
+ MSBFirst, /* 2Ml */
+ LSBFirst, /* 4Ml */
+ MSBFirst, /* 1Lm */
+ MSBFirst, /* 2Lm */
+ LSBFirst, /* 4Lm */
+ MSBFirst, /* 1Ll */
+ MSBFirst, /* 2Ll */
+ MSBFirst /* 4Ll */
+ };
+
+/*
+ * This macro creates a value from 0 to 11 suitable for indexing
+ * into the table above.
+ */
+#define ComposeIndex(bitmap_unit, bitmap_bit_order, byte_order) \
+ (((bitmap_unit == 32) ? 2 : ((bitmap_unit == 16) ? 1 : 0)) \
+ + (((bitmap_bit_order == MSBFirst) ? 0 : 3) \
+ + ((byte_order == MSBFirst) ? 0 : 6)))
+
+/* Cancel a GetReq operation, before doing _XSend or Data */
+
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define UnGetReq(name)\
+ dpy->bufptr -= SIZEOF(x##name##Req);\
+ dpy->request--
+#else
+#define UnGetReq(name)\
+ dpy->bufptr -= SIZEOF(x/**/name/**/Req);\
+ dpy->request--
+#endif
+
+static void
+SendXYImage(dpy, req, image, req_xoffset, req_yoffset)
+ register Display *dpy;
+ register xPutImageReq *req;
+ register XImage *image;
+ int req_xoffset, req_yoffset;
+{
+ register int j;
+ long total_xoffset, bytes_per_src, bytes_per_dest, length;
+ long bytes_per_line, bytes_per_src_plane, bytes_per_dest_plane;
+ char *src, *dest, *buf;
+ char *extra = (char *)NULL;
+ register void (*swapfunc)();
+ int half_order;
+
+ total_xoffset = image->xoffset + req_xoffset;
+ req->leftPad = total_xoffset & (dpy->bitmap_unit - 1);
+ total_xoffset = (unsigned)(total_xoffset - req->leftPad) >> 3;
+ /* The protocol requires left-pad of zero on all ZPixmap, even
+ * though the 1-bit case is identical to bitmap format. This is a
+ * bug in the protocol, caused because 1-bit ZPixmap was added late
+ * in the game. Hairy shifting code compensation isn't worth it,
+ * just use XYPixmap format instead.
+ */
+ if ((req->leftPad != 0) && (req->format == ZPixmap))
+ req->format = XYPixmap;
+ bytes_per_dest = (unsigned long)ROUNDUP((long)req->width + req->leftPad,
+ dpy->bitmap_pad) >> 3;
+ bytes_per_dest_plane = bytes_per_dest * req->height;
+ length = bytes_per_dest_plane * image->depth;
+ req->length += (length + 3) >> 2;
+
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)]
+ [ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+ half_order = HalfOrder[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)];
+ if (half_order == MSBFirst)
+ half_order = HalfOrderWord[ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+
+ src = image->data + (image->bytes_per_line * req_yoffset) + total_xoffset;
+
+ /* when total_xoffset > 0, we have to worry about stepping off the
+ * end of image->data.
+ */
+ if ((swapfunc == NoSwap) &&
+ (image->bytes_per_line == bytes_per_dest) &&
+ (((total_xoffset == 0) &&
+ ((image->depth == 1) || (image->height == req->height))) ||
+ ((image->depth == 1) &&
+ ((req_yoffset + req->height) < (unsigned)image->height)))) {
+ Data(dpy, src, length);
+ return;
+ }
+
+ length = ROUNDUP(length, 4);
+ if ((dpy->bufptr + length) > dpy->bufmax) {
+ if ((buf = _XAllocScratch(dpy, (unsigned long) (length))) == NULL) {
+ UnGetReq(PutImage);
+ return;
+ }
+ }
+ else
+ buf = dpy->bufptr;
+
+ bytes_per_src = (req->width + req->leftPad + (unsigned)7) >> 3;
+ bytes_per_line = image->bytes_per_line;
+ bytes_per_src_plane = bytes_per_line * image->height;
+ total_xoffset &= (image->bitmap_unit - 1) >> 3;
+
+ if ((total_xoffset > 0) &&
+ (image->byte_order != image->bitmap_bit_order)) {
+ char *temp;
+ long bytes_per_temp_plane, temp_length;
+
+ bytes_per_line = bytes_per_src + total_xoffset;
+ src -= total_xoffset;
+ bytes_per_temp_plane = bytes_per_line * req->height;
+ temp_length = ROUNDUP(bytes_per_temp_plane * image->depth, 4);
+ if (buf == dpy->bufptr) {
+ if (! (temp = _XAllocScratch(dpy, (unsigned long) temp_length))) {
+ UnGetReq(PutImage);
+ return;
+ }
+ }
+ else
+ if ((extra = temp = Xmalloc((unsigned) temp_length)) == NULL) {
+ UnGetReq(PutImage);
+ return;
+ }
+
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ image->bitmap_bit_order,
+ image->byte_order)]
+ [ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)];
+ for (dest = temp, j = image->depth;
+ --j >= 0;
+ src += bytes_per_src_plane, dest += bytes_per_temp_plane)
+ (*swapfunc)((unsigned char *)src, (unsigned char *)dest,
+ bytes_per_line, (long)image->bytes_per_line,
+ bytes_per_line, req->height, half_order);
+ swapfunc = SwapFunction[ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)]
+ [ComposeIndex(dpy->bitmap_unit,
+ dpy->bitmap_bit_order,
+ dpy->byte_order)];
+ half_order = HalfOrder[ComposeIndex(image->bitmap_unit,
+ dpy->byte_order,
+ dpy->byte_order)];
+ src = temp + total_xoffset;
+ bytes_per_src_plane = bytes_per_temp_plane;
+ }
+
+ for (dest = buf, j = image->depth;
+ --j >= 0;
+ src += bytes_per_src_plane, dest += bytes_per_dest_plane)
+ (*swapfunc)((unsigned char *)src, (unsigned char *)dest,
+ bytes_per_src, bytes_per_line,
+ bytes_per_dest, req->height, half_order);
+
+ if (extra)
+ Xfree(extra);
+
+ if (buf == dpy->bufptr)
+ dpy->bufptr += length;
+ else
+ _XSend(dpy, buf, length);
+ }
+
+static void
+SendZImage(dpy, req, image, req_xoffset, req_yoffset,
+ dest_bits_per_pixel, dest_scanline_pad)
+ register Display *dpy;
+ register xPutImageReq *req;
+ register XImage *image;
+ int req_xoffset, req_yoffset, dest_bits_per_pixel, dest_scanline_pad;
+{
+ long bytes_per_src, bytes_per_dest, length;
+ unsigned char *src, *dest;
+ unsigned char *shifted_src = NULL;
+
+ req->leftPad = 0;
+ bytes_per_src = ROUNDUP((long)req->width * image->bits_per_pixel, 8) >> 3;
+ bytes_per_dest = ROUNDUP((long)req->width * dest_bits_per_pixel,
+ dest_scanline_pad) >> 3;
+ length = bytes_per_dest * req->height;
+ req->length += (length + 3) >> 2;
+
+ src = (unsigned char *)image->data +
+ (req_yoffset * image->bytes_per_line) +
+ ((req_xoffset * image->bits_per_pixel) >> 3);
+ if ((image->bits_per_pixel == 4) && ((unsigned int) req_xoffset & 0x01)) {
+ if (! (shifted_src = (unsigned char *)
+ Xmalloc((unsigned) (req->height * image->bytes_per_line)))) {
+ UnGetReq(PutImage);
+ return;
+ }
+
+ ShiftNibblesLeft(src, shifted_src, bytes_per_src,
+ (long) image->bytes_per_line,
+ (long) image->bytes_per_line, req->height,
+ image->byte_order);
+ src = shifted_src;
+ }
+
+ /* when req_xoffset > 0, we have to worry about stepping off the
+ * end of image->data.
+ */
+ if (((image->byte_order == dpy->byte_order) ||
+ (image->bits_per_pixel == 8)) &&
+ ((long)image->bytes_per_line == bytes_per_dest) &&
+ ((req_xoffset == 0) ||
+ ((req_yoffset + req->height) < (unsigned)image->height))) {
+ Data(dpy, (char *)src, length);
+ if (shifted_src)
+ Xfree((char *)shifted_src);
+ return;
+ }
+
+ length = ROUNDUP(length, 4);
+ if ((dpy->bufptr + length) <= dpy->bufmax)
+ dest = (unsigned char *)dpy->bufptr;
+ else
+ if ((dest = (unsigned char *)
+ _XAllocScratch(dpy, (unsigned long)(length))) == NULL) {
+ if (shifted_src) Xfree((char *) shifted_src);
+ UnGetReq(PutImage);
+ return;
+ }
+
+ if ((image->byte_order == dpy->byte_order) ||
+ (image->bits_per_pixel == 8))
+ NoSwap(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 32)
+ SwapFourBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 24)
+ SwapThreeBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else if (image->bits_per_pixel == 16)
+ SwapTwoBytes(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height, image->byte_order);
+ else
+ SwapNibbles(src, dest, bytes_per_src, (long)image->bytes_per_line,
+ bytes_per_dest, req->height);
+
+ if (dest == (unsigned char *)dpy->bufptr)
+ dpy->bufptr += length;
+ else
+ _XSend(dpy, (char *)dest, length);
+
+ if (shifted_src)
+ Xfree((char *)shifted_src);
+}
+
+static void
+PutImageRequest(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, req_height, dest_bits_per_pixel, dest_scanline_pad)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ register XImage *image;
+ int x, y;
+ unsigned int req_width, req_height;
+ int req_xoffset, req_yoffset, dest_bits_per_pixel, dest_scanline_pad;
+{
+ register xPutImageReq *req;
+
+ GetReq(PutImage, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->dstX = x;
+ req->dstY = y;
+ req->width = req_width;
+ req->height = req_height;
+ req->depth = image->depth;
+ req->format = image->format;
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap))
+ SendXYImage(dpy, req, image, req_xoffset, req_yoffset);
+ else
+ SendZImage(dpy, req, image, req_xoffset, req_yoffset,
+ dest_bits_per_pixel, dest_scanline_pad);
+}
+
+static void
+PutSubImage (dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, req_height, dest_bits_per_pixel, dest_scanline_pad)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ register XImage *image;
+ int x, y;
+ unsigned int req_width, req_height;
+ int req_xoffset, req_yoffset, dest_bits_per_pixel, dest_scanline_pad;
+
+{
+ int left_pad, BytesPerRow, Available;
+
+ if ((req_width == 0) || (req_height == 0))
+ return;
+
+ Available = ((65536 < dpy->max_request_size) ? (65536 << 2)
+ : (dpy->max_request_size << 2))
+ - SIZEOF(xPutImageReq);
+
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap)) {
+ left_pad = (image->xoffset + req_xoffset) & (dpy->bitmap_unit - 1);
+ BytesPerRow = (ROUNDUP((long)req_width + left_pad,
+ dpy->bitmap_pad) >> 3) * image->depth;
+ } else {
+ left_pad = 0;
+ BytesPerRow = ROUNDUP((long)req_width * dest_bits_per_pixel,
+ dest_scanline_pad) >> 3;
+ }
+
+ if ((BytesPerRow * req_height) <= Available) {
+ PutImageRequest(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, req_height,
+ dest_bits_per_pixel, dest_scanline_pad);
+ } else if (req_height > 1) {
+ int SubImageHeight = Available / BytesPerRow;
+
+ if (SubImageHeight == 0)
+ SubImageHeight = 1;
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ req_width, (unsigned int) SubImageHeight,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset,
+ req_yoffset + SubImageHeight, x, y + SubImageHeight,
+ req_width, req_height - SubImageHeight,
+ dest_bits_per_pixel, dest_scanline_pad);
+ } else {
+ int SubImageWidth = (((Available << 3) / dest_scanline_pad)
+ * dest_scanline_pad) - left_pad;
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ (unsigned int) SubImageWidth, 1,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset + SubImageWidth,
+ req_yoffset, x + SubImageWidth, y,
+ req_width - SubImageWidth, 1,
+ dest_bits_per_pixel, dest_scanline_pad);
+ }
+}
+
+XPutImage (dpy, d, gc, image, req_xoffset, req_yoffset, x, y, req_width,
+ req_height)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ register XImage *image;
+ int x, y;
+ unsigned int req_width, req_height;
+ int req_xoffset, req_yoffset;
+
+{
+ long width = req_width;
+ long height = req_height;
+ int dest_bits_per_pixel, dest_scanline_pad;
+
+ if (req_xoffset < 0) {
+ width += req_xoffset;
+ req_xoffset = 0;
+ }
+ if (req_yoffset < 0) {
+ height += req_yoffset;
+ req_yoffset = 0;
+ }
+ if ((req_xoffset + width) > image->width)
+ width = image->width - req_xoffset;
+ if ((req_yoffset + height) > image->height)
+ height = image->height - req_yoffset;
+ if ((width <= 0) || (height <= 0))
+ return 0;
+
+ if ((image->bits_per_pixel == 1) || (image->format != ZPixmap)) {
+ dest_bits_per_pixel = 1;
+ dest_scanline_pad = dpy->bitmap_pad;
+ } else {
+ register int n;
+ register ScreenFormat *format;
+
+ dest_bits_per_pixel = image->bits_per_pixel;
+ dest_scanline_pad = image->bitmap_pad;
+ for (n = dpy->nformats, format = dpy->pixmap_format; --n >= 0; format++)
+ if (format->depth == image->depth) {
+ dest_bits_per_pixel = format->bits_per_pixel;
+ dest_scanline_pad = format->scanline_pad;
+ }
+ if (dest_bits_per_pixel != image->bits_per_pixel) {
+ XImage img;
+ register long i, j;
+ extern void _XInitImageFuncPtrs();
+ /* XXX slow, but works */
+ img.width = width;
+ img.height = height;
+ img.xoffset = 0;
+ img.format = ZPixmap;
+ img.byte_order = dpy->byte_order;
+ img.bitmap_unit = dpy->bitmap_unit;
+ img.bitmap_bit_order = dpy->bitmap_bit_order;
+ img.bitmap_pad = dest_scanline_pad;
+ img.depth = image->depth;
+ img.bits_per_pixel = dest_bits_per_pixel;
+ img.bytes_per_line = ROUNDUP((dest_bits_per_pixel * width),
+ dest_scanline_pad) >> 3;
+ img.data = Xmalloc((unsigned) (img.bytes_per_line * height));
+ if (img.data == NULL)
+ return 0;
+ _XInitImageFuncPtrs(&img);
+ for (j = height; --j >= 0; )
+ for (i = width; --i >= 0; )
+ XPutPixel(&img, i, j, XGetPixel(image, req_xoffset + i,
+ req_yoffset + j));
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ PutSubImage(dpy, d, gc, &img, 0, 0, x, y,
+ (unsigned int) width, (unsigned int) height,
+ dest_bits_per_pixel, dest_scanline_pad);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(img.data);
+ return 0;
+ }
+ }
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+
+ PutSubImage(dpy, d, gc, image, req_xoffset, req_yoffset, x, y,
+ (unsigned int) width, (unsigned int) height,
+ dest_bits_per_pixel, dest_scanline_pad);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
diff --git a/src/QuBest.c b/src/QuBest.c
new file mode 100644
index 00000000..ac857af4
--- /dev/null
+++ b/src/QuBest.c
@@ -0,0 +1,58 @@
+/* $Xorg: QuBest.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XQueryBestSize(dpy, class, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ int class;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = class;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuColor.c b/src/QuColor.c
new file mode 100644
index 00000000..fcd0517f
--- /dev/null
+++ b/src/QuColor.c
@@ -0,0 +1,59 @@
+/* $Xorg: QuColor.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XQueryColor(dpy, cmap, def)
+ register Display *dpy;
+ Colormap cmap;
+ XColor *def; /* RETURN */
+{
+ xrgb color;
+ xQueryColorsReply rep;
+ register xQueryColorsReq *req;
+ unsigned long val = def->pixel; /* needed for macro below */
+
+ LockDisplay(dpy);
+ GetReqExtra(QueryColors, 4, req); /* a pixel (CARD32) is 4 bytes */
+ req->cmap = cmap;
+
+ OneDataCard32 (dpy, NEXTPTR(req,xQueryColorsReq), val);
+
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
+
+ _XRead(dpy, (char *)&color, (long) SIZEOF(xrgb));
+
+ def->red = color.red;
+ def->blue = color.blue;
+ def->green = color.green;
+ def->flags = DoRed | DoGreen | DoBlue;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/QuColors.c b/src/QuColors.c
new file mode 100644
index 00000000..0aaed02a
--- /dev/null
+++ b/src/QuColors.c
@@ -0,0 +1,75 @@
+/* $Xorg: QuColors.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+XQueryColors(dpy, cmap, defs, ncolors)
+ register Display *dpy;
+ Colormap cmap;
+ XColor *defs; /* RETURN */
+ int ncolors;
+{
+ register int i;
+ xrgb *color;
+ xQueryColorsReply rep;
+ long nbytes;
+ register xQueryColorsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryColors, req);
+
+ req->cmap = cmap;
+ req->length += ncolors; /* each pixel is a CARD32 */
+
+ for (i = 0; i < ncolors; i++)
+ Data32 (dpy, (long *)&defs[i].pixel, 4L);
+ /* XXX this isn't very efficient */
+
+ if (_XReply(dpy, (xReply *) &rep, 0, xFalse) != 0) {
+ if ((color = (xrgb *)
+ Xmalloc((unsigned) (nbytes = (long) ncolors * SIZEOF(xrgb))))) {
+
+ _XRead(dpy, (char *) color, nbytes);
+
+ for (i = 0; i < ncolors; i++) {
+ register XColor *def = &defs[i];
+ register xrgb *rgb = &color[i];
+ def->red = rgb->red;
+ def->green = rgb->green;
+ def->blue = rgb->blue;
+ def->flags = DoRed | DoGreen | DoBlue;
+ }
+ Xfree((char *)color);
+ }
+ else _XEatData(dpy, (unsigned long) nbytes);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuCurShp.c b/src/QuCurShp.c
new file mode 100644
index 00000000..3dd42be1
--- /dev/null
+++ b/src/QuCurShp.c
@@ -0,0 +1,57 @@
+/* $Xorg: QuCurShp.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XQueryBestCursor(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = CursorShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuExt.c b/src/QuExt.c
new file mode 100644
index 00000000..5d49da07
--- /dev/null
+++ b/src/QuExt.c
@@ -0,0 +1,63 @@
+/* $Xorg: QuExt.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+Bool XQueryExtension(
+ register Display *dpy,
+ _Xconst char *name,
+ int *major_opcode, /* RETURN */
+ int *first_event, /* RETURN */
+ int *first_error) /* RETURN */
+#else
+Bool XQueryExtension(dpy, name, major_opcode, first_event, first_error)
+ register Display *dpy;
+ char *name;
+ int *major_opcode; /* RETURN */
+ int *first_event; /* RETURN */
+ int *first_error; /* RETURN */
+#endif
+{
+ xQueryExtensionReply rep;
+ register xQueryExtensionReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryExtension, req);
+ req->nbytes = name ? strlen(name) : 0;
+ req->length += (req->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, name, (long)req->nbytes);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ *major_opcode = rep.major_opcode;
+ *first_event = rep.first_event;
+ *first_error = rep.first_error;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.present);
+}
+
diff --git a/src/QuKeybd.c b/src/QuKeybd.c
new file mode 100644
index 00000000..238881ce
--- /dev/null
+++ b/src/QuKeybd.c
@@ -0,0 +1,52 @@
+/* $Xorg: QuKeybd.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+struct kmap {
+ char map[32];
+};
+
+XQueryKeymap(dpy, keys)
+ register Display *dpy;
+ char keys[32];
+
+{
+ xQueryKeymapReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(QueryKeymap, req);
+ (void) _XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xQueryKeymapReply) - SIZEOF(xReply)) >> 2, xTrue);
+ *(struct kmap *) keys = *(struct kmap *)rep.map; /* faster than memcpy */
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuPntr.c b/src/QuPntr.c
new file mode 100644
index 00000000..d0b04c1b
--- /dev/null
+++ b/src/QuPntr.c
@@ -0,0 +1,60 @@
+/* $Xorg: QuPntr.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Bool XQueryPointer(dpy, w, root, child, root_x, root_y, win_x, win_y, mask)
+ register Display *dpy;
+ Window w, *root, *child;
+ int *root_x, *root_y, *win_x, *win_y;
+ unsigned int *mask;
+
+{
+ xQueryPointerReply rep;
+ xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(QueryPointer, w, req);
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(False);
+ }
+
+ *root = rep.root;
+ *child = rep.child;
+ *root_x = cvtINT16toInt (rep.rootX);
+ *root_y = cvtINT16toInt (rep.rootY);
+ *win_x = cvtINT16toInt (rep.winX);
+ *win_y = cvtINT16toInt (rep.winY);
+ *mask = rep.mask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (rep.sameScreen);
+}
+
diff --git a/src/QuStipShp.c b/src/QuStipShp.c
new file mode 100644
index 00000000..81996fc4
--- /dev/null
+++ b/src/QuStipShp.c
@@ -0,0 +1,57 @@
+/* $Xorg: QuStipShp.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XQueryBestStipple(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = StippleShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuTextE16.c b/src/QuTextE16.c
new file mode 100644
index 00000000..66b3149f
--- /dev/null
+++ b/src/QuTextE16.c
@@ -0,0 +1,91 @@
+/* $Xorg: QuTextE16.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XQueryTextExtents16 (
+ register Display *dpy,
+ Font fid,
+ _Xconst XChar2b *string,
+ register int nchars,
+ int *dir,
+ int *font_ascent,
+ int *font_descent,
+ register XCharStruct *overall)
+#else
+XQueryTextExtents16 (dpy, fid, string, nchars, dir, font_ascent, font_descent,
+ overall)
+ register Display *dpy;
+ Font fid;
+ XChar2b *string;
+ register int nchars;
+ int *dir;
+ int *font_ascent, *font_descent;
+ register XCharStruct *overall;
+#endif
+{
+ register long i;
+ register unsigned char *ptr;
+ char *buf;
+ xQueryTextExtentsReply rep;
+ long nbytes;
+ register xQueryTextExtentsReq *req;
+
+ LockDisplay(dpy);
+ nbytes = nchars << 1;
+ GetReq(QueryTextExtents, req);
+ req->fid = fid;
+ if ((buf = _XAllocScratch (dpy, (unsigned long) nbytes))) {
+ req->length += (nbytes + 3)>>2;
+ req->oddLength = nchars & 1;
+ for (ptr = (unsigned char *)buf, i = nchars; --i >= 0; string++) {
+ *ptr++ = string->byte1;
+ *ptr++ = string->byte2;
+ }
+ Data (dpy, buf, nbytes);
+ }
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue) || !buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *dir = rep.drawDirection;
+ *font_ascent = cvtINT16toInt (rep.fontAscent);
+ *font_descent = cvtINT16toInt (rep.fontDescent);
+ overall->ascent = (short) cvtINT16toShort (rep.overallAscent);
+ overall->descent = (short) cvtINT16toShort (rep.overallDescent);
+ /* XXX bogus - we're throwing away information!!! */
+ overall->width = (short) cvtINT32toInt (rep.overallWidth);
+ overall->lbearing = (short) cvtINT32toInt (rep.overallLeft);
+ overall->rbearing = (short) cvtINT32toInt (rep.overallRight);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuTextExt.c b/src/QuTextExt.c
new file mode 100644
index 00000000..bcf8ee17
--- /dev/null
+++ b/src/QuTextExt.c
@@ -0,0 +1,90 @@
+/* $Xorg: QuTextExt.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XQueryTextExtents (
+ register Display *dpy,
+ Font fid,
+ register _Xconst char *string,
+ register int nchars,
+ int *dir,
+ int *font_ascent,
+ int *font_descent,
+ register XCharStruct *overall)
+#else
+XQueryTextExtents (dpy, fid, string, nchars, dir, font_ascent, font_descent,
+ overall)
+ register Display *dpy;
+ Font fid;
+ register char *string;
+ register int nchars;
+ int *dir;
+ int *font_ascent, *font_descent;
+ register XCharStruct *overall;
+#endif
+{
+ register int i;
+ register char *ptr;
+ char *buf;
+ xQueryTextExtentsReply rep;
+ long nbytes;
+ register xQueryTextExtentsReq *req;
+
+ LockDisplay(dpy);
+ nbytes = nchars << 1;
+ GetReq(QueryTextExtents, req);
+ req->fid = fid;
+ if ((buf = _XAllocScratch (dpy, (unsigned long) nbytes))) {
+ req->length += (nbytes + 3)>>2;
+ req->oddLength = nchars & 1;
+ for (ptr = buf, i = nchars; --i >= 0;) {
+ *ptr++ = 0;
+ *ptr++ = *string++;
+ }
+ Data (dpy, buf, nbytes);
+ }
+ if (!_XReply (dpy, (xReply *)&rep, 0, xTrue) || !buf) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+ *dir = rep.drawDirection;
+ *font_ascent = cvtINT16toInt (rep.fontAscent);
+ *font_descent = cvtINT16toInt (rep.fontDescent);
+ overall->ascent = (short) cvtINT16toShort (rep.overallAscent);
+ overall->descent = (short) cvtINT16toShort (rep.overallDescent);
+ /* XXX bogus - we're throwing away information!!! */
+ overall->width = (short) cvtINT32toInt (rep.overallWidth);
+ overall->lbearing = (short) cvtINT32toInt (rep.overallLeft);
+ overall->rbearing = (short) cvtINT32toInt (rep.overallRight);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/QuTileShp.c b/src/QuTileShp.c
new file mode 100644
index 00000000..1c15d17b
--- /dev/null
+++ b/src/QuTileShp.c
@@ -0,0 +1,58 @@
+/* $Xorg: QuTileShp.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XQueryBestTile(dpy, drawable, width, height, ret_width, ret_height)
+ register Display *dpy;
+ Drawable drawable;
+ unsigned int width, height;
+ unsigned int *ret_width, *ret_height;
+{
+ xQueryBestSizeReply rep;
+ register xQueryBestSizeReq *req;
+
+ LockDisplay(dpy);
+ GetReq(QueryBestSize, req);
+ req->class = TileShape;
+ req->drawable = drawable;
+ req->width = width;
+ req->height = height;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(0);
+ }
+
+ *ret_width = rep.width;
+ *ret_height = rep.height;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/QuTree.c b/src/QuTree.c
new file mode 100644
index 00000000..8c6fcc7a
--- /dev/null
+++ b/src/QuTree.c
@@ -0,0 +1,71 @@
+/* $Xorg: QuTree.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Status XQueryTree (dpy, w, root, parent, children, nchildren)
+ register Display *dpy;
+ Window w;
+ Window *root; /* RETURN */
+ Window *parent; /* RETURN */
+ Window **children; /* RETURN */
+ unsigned int *nchildren; /* RETURN */
+{
+ long nbytes;
+ xQueryTreeReply rep;
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(QueryTree, w, req);
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ *children = (Window *) NULL;
+ if (rep.nChildren != 0) {
+ nbytes = rep.nChildren * sizeof(Window);
+ *children = (Window *) Xmalloc((unsigned) nbytes);
+ nbytes = rep.nChildren << 2;
+ if (! *children) {
+ _XEatData(dpy, (unsigned long) nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+ _XRead32 (dpy, (char *) *children, nbytes);
+ }
+ *parent = rep.parent;
+ *root = rep.root;
+ *nchildren = rep.nChildren;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (1);
+}
+
diff --git a/src/Quarks.c b/src/Quarks.c
new file mode 100644
index 00000000..98b1b761
--- /dev/null
+++ b/src/Quarks.c
@@ -0,0 +1,431 @@
+/* $Xorg: Quarks.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard,
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1987, 1988, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+
+/* Not cost effective, at least for vanilla MIT clients */
+/* #define PERMQ */
+
+typedef unsigned long Signature;
+typedef unsigned long Entry;
+#ifdef PERMQ
+typedef unsigned char Bits;
+#endif
+
+static XrmQuark nextQuark = 1; /* next available quark number */
+static unsigned long quarkMask = 0;
+static Entry zero = 0;
+static Entry *quarkTable = &zero; /* crock */
+static unsigned long quarkRehash;
+static XrmString **stringTable = NULL;
+#ifdef PERMQ
+static Bits **permTable = NULL;
+#endif
+static XrmQuark nextUniq = -1; /* next quark from XrmUniqueQuark */
+
+#define QUANTUMSHIFT 8
+#define QUANTUMMASK ((1 << QUANTUMSHIFT) - 1)
+#define CHUNKPER 8
+#define CHUNKMASK ((CHUNKPER << QUANTUMSHIFT) - 1)
+
+#define LARGEQUARK ((Entry)0x80000000L)
+#define QUARKSHIFT 18
+#define QUARKMASK ((LARGEQUARK - 1) >> QUARKSHIFT)
+#define XSIGMASK ((1L << QUARKSHIFT) - 1)
+
+#define STRQUANTSIZE (sizeof(XrmString) * (QUANTUMMASK + 1))
+#ifdef PERMQ
+#define QUANTSIZE (STRQUANTSIZE + \
+ (sizeof(Bits) * ((QUANTUMMASK + 1) >> 3))
+#else
+#define QUANTSIZE STRQUANTSIZE
+#endif
+
+#define HASH(sig) ((sig) & quarkMask)
+#define REHASHVAL(sig) ((((sig) % quarkRehash) + 2) | 1)
+#define REHASH(idx,rehash) ((idx + rehash) & quarkMask)
+#define NAME(q) stringTable[(q) >> QUANTUMSHIFT][(q) & QUANTUMMASK]
+#ifdef PERMQ
+#define BYTEREF(q) permTable[(q) >> QUANTUMSHIFT][((q) & QUANTUMMASK) >> 3]
+#define ISPERM(q) (BYTEREF(q) & (1 << ((q) & 7)))
+#define SETPERM(q) BYTEREF(q) |= (1 << ((q) & 7))
+#define CLEARPERM(q) BYTEREF(q) &= ~(1 << ((q) & 7))
+#endif
+
+/* Permanent memory allocation */
+
+#define WALIGN sizeof(unsigned long)
+#define DALIGN sizeof(double)
+
+#define NEVERFREETABLESIZE ((8192-12) & ~(DALIGN-1))
+static char *neverFreeTable = NULL;
+static int neverFreeTableSize = 0;
+
+static char *permalloc(length)
+ register unsigned int length;
+{
+ char *ret;
+
+ if (neverFreeTableSize < length) {
+ if (length >= NEVERFREETABLESIZE)
+ return Xmalloc(length);
+ if (! (ret = Xmalloc(NEVERFREETABLESIZE)))
+ return (char *) NULL;
+ neverFreeTableSize = NEVERFREETABLESIZE;
+ neverFreeTable = ret;
+ }
+ ret = neverFreeTable;
+ neverFreeTable += length;
+ neverFreeTableSize -= length;
+ return(ret);
+}
+
+#ifndef WORD64
+typedef struct {char a; double b;} TestType1;
+typedef struct {char a; unsigned long b;} TestType2;
+#endif
+
+#ifdef XTHREADS
+static char *_Xpermalloc();
+
+char *Xpermalloc(length)
+ unsigned int length;
+{
+ char *p;
+
+ _XLockMutex(_Xglobal_lock);
+ p = _Xpermalloc(length);
+ _XUnlockMutex(_Xglobal_lock);
+ return p;
+}
+#define Xpermalloc _Xpermalloc
+
+static
+#endif /* XTHREADS */
+char *Xpermalloc(length)
+ unsigned int length;
+{
+ int i;
+
+ if (neverFreeTableSize && length < NEVERFREETABLESIZE) {
+#ifndef WORD64
+ if ((sizeof(TestType1) !=
+ (sizeof(TestType2) - sizeof(unsigned long) + sizeof(double))) &&
+ !(length & (DALIGN-1)) &&
+ ((i = (NEVERFREETABLESIZE - neverFreeTableSize) & (DALIGN-1)))) {
+ neverFreeTableSize -= DALIGN - i;
+ neverFreeTable += DALIGN - i;
+ } else
+#endif
+ if ((i = (NEVERFREETABLESIZE - neverFreeTableSize) & (WALIGN-1))) {
+ neverFreeTableSize -= WALIGN - i;
+ neverFreeTable += WALIGN - i;
+ }
+ }
+ return permalloc(length);
+}
+
+static Bool
+ExpandQuarkTable()
+{
+ unsigned long oldmask, newmask;
+ register char c, *s;
+ register Entry *oldentries, *entries;
+ register Entry entry;
+ register int oldidx, newidx, rehash;
+ Signature sig;
+ XrmQuark q;
+
+ oldentries = quarkTable;
+ if ((oldmask = quarkMask))
+ newmask = (oldmask << 1) + 1;
+ else {
+ if (!stringTable) {
+ stringTable = (XrmString **)Xmalloc(sizeof(XrmString *) *
+ CHUNKPER);
+ if (!stringTable)
+ return False;
+ stringTable[0] = (XrmString *)NULL;
+ }
+#ifdef PERMQ
+ if (!permTable)
+ permTable = (Bits **)Xmalloc(sizeof(Bits *) * CHUNKPER);
+ if (!permTable)
+ return False;
+#endif
+ stringTable[0] = (XrmString *)Xpermalloc(QUANTSIZE);
+ if (!stringTable[0])
+ return False;
+#ifdef PERMQ
+ permTable[0] = (Bits *)((char *)stringTable[0] + STRQUANTSIZE);
+#endif
+ newmask = 0x1ff;
+ }
+ entries = (Entry *)Xmalloc(sizeof(Entry) * (newmask + 1));
+ if (!entries)
+ return False;
+ bzero((char *)entries, sizeof(Entry) * (newmask + 1));
+ quarkTable = entries;
+ quarkMask = newmask;
+ quarkRehash = quarkMask - 2;
+ for (oldidx = 0; oldidx <= oldmask; oldidx++) {
+ if ((entry = oldentries[oldidx])) {
+ if (entry & LARGEQUARK)
+ q = entry & (LARGEQUARK-1);
+ else
+ q = (entry >> QUARKSHIFT) & QUARKMASK;
+ for (sig = 0, s = NAME(q); (c = *s++); )
+ sig = (sig << 1) + c;
+ newidx = HASH(sig);
+ if (entries[newidx]) {
+ rehash = REHASHVAL(sig);
+ do {
+ newidx = REHASH(newidx, rehash);
+ } while (entries[newidx]);
+ }
+ entries[newidx] = entry;
+ }
+ }
+ if (oldmask)
+ Xfree((char *)oldentries);
+ return True;
+}
+
+#if NeedFunctionPrototypes
+XrmQuark _XrmInternalStringToQuark(
+ register _Xconst char *name, register int len, register Signature sig,
+ Bool permstring)
+#else
+XrmQuark _XrmInternalStringToQuark(name, len, sig, permstring)
+ register XrmString name;
+ register int len;
+ register Signature sig;
+ Bool permstring;
+#endif
+{
+ register XrmQuark q;
+ register Entry entry;
+ register int idx, rehash;
+ register int i;
+ register char *s1, *s2;
+ char *new;
+
+ rehash = 0;
+ idx = HASH(sig);
+ _XLockMutex(_Xglobal_lock);
+ while ((entry = quarkTable[idx])) {
+ if (entry & LARGEQUARK)
+ q = entry & (LARGEQUARK-1);
+ else {
+ if ((entry - sig) & XSIGMASK)
+ goto nomatch;
+ q = (entry >> QUARKSHIFT) & QUARKMASK;
+ }
+ for (i = len, s1 = (char *)name, s2 = NAME(q); --i >= 0; ) {
+ if (*s1++ != *s2++)
+ goto nomatch;
+ }
+ if (*s2) {
+nomatch: if (!rehash)
+ rehash = REHASHVAL(sig);
+ idx = REHASH(idx, rehash);
+ continue;
+ }
+#ifdef PERMQ
+ if (permstring && !ISPERM(q)) {
+ Xfree(NAME(q));
+ NAME(q) = (char *)name;
+ SETPERM(q);
+ }
+#endif
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+ }
+ if (nextUniq == nextQuark)
+ goto fail;
+ if ((nextQuark + (nextQuark >> 2)) > quarkMask) {
+ if (!ExpandQuarkTable())
+ goto fail;
+ _XUnlockMutex(_Xglobal_lock);
+ return _XrmInternalStringToQuark(name, len, sig, permstring);
+ }
+ q = nextQuark;
+ if (!(q & QUANTUMMASK)) {
+ if (!(q & CHUNKMASK)) {
+ if (!(new = Xrealloc((char *)stringTable,
+ sizeof(XrmString *) *
+ ((q >> QUANTUMSHIFT) + CHUNKPER))))
+ goto fail;
+ stringTable = (XrmString **)new;
+#ifdef PERMQ
+ if (!(new = Xrealloc((char *)permTable,
+ sizeof(Bits *) *
+ ((q >> QUANTUMSHIFT) + CHUNKPER))))
+ goto fail;
+ permTable = (Bits **)new;
+#endif
+ }
+ new = Xpermalloc(QUANTSIZE);
+ if (!new)
+ goto fail;
+ stringTable[q >> QUANTUMSHIFT] = (XrmString *)new;
+#ifdef PERMQ
+ permTable[q >> QUANTUMSHIFT] = (Bits *)(new + STRQUANTSIZE);
+#endif
+ }
+ if (!permstring) {
+ s2 = (char *)name;
+#ifdef PERMQ
+ name = Xmalloc(len+1);
+#else
+ name = permalloc(len+1);
+#endif
+ if (!name)
+ goto fail;
+ for (i = len, s1 = (char *)name; --i >= 0; )
+ *s1++ = *s2++;
+ *s1++ = '\0';
+#ifdef PERMQ
+ CLEARPERM(q);
+ }
+ else {
+ SETPERM(q);
+#endif
+ }
+ NAME(q) = (char *)name;
+ if (q <= QUARKMASK)
+ entry = (q << QUARKSHIFT) | (sig & XSIGMASK);
+ else
+ entry = q | LARGEQUARK;
+ quarkTable[idx] = entry;
+ nextQuark++;
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+ fail:
+ _XUnlockMutex(_Xglobal_lock);
+ return NULLQUARK;
+}
+
+#if NeedFunctionPrototypes
+XrmQuark XrmStringToQuark(
+ _Xconst char *name)
+#else
+XrmQuark XrmStringToQuark(name)
+ XrmString name;
+#endif
+{
+ register char c, *tname;
+ register Signature sig = 0;
+
+ if (!name)
+ return (NULLQUARK);
+
+ for (tname = (char *)name; (c = *tname++); )
+ sig = (sig << 1) + c;
+
+ return _XrmInternalStringToQuark(name, tname-(char *)name-1, sig, False);
+}
+
+#if NeedFunctionPrototypes
+XrmQuark XrmPermStringToQuark(
+ _Xconst char *name)
+#else
+XrmQuark XrmPermStringToQuark(name)
+ XrmString name;
+#endif
+{
+ register char c, *tname;
+ register Signature sig = 0;
+
+ if (!name)
+ return (NULLQUARK);
+
+ for (tname = (char *)name; (c = *tname++); )
+ sig = (sig << 1) + c;
+
+ return _XrmInternalStringToQuark(name, tname-(char *)name-1, sig, True);
+}
+
+XrmQuark XrmUniqueQuark()
+{
+ XrmQuark q;
+
+ _XLockMutex(_Xglobal_lock);
+ if (nextUniq == nextQuark)
+ q = NULLQUARK;
+ else
+ q = nextUniq--;
+ _XUnlockMutex(_Xglobal_lock);
+ return q;
+}
+
+XrmString XrmQuarkToString(quark)
+ register XrmQuark quark;
+{
+ XrmString s;
+
+ _XLockMutex(_Xglobal_lock);
+ if (quark <= 0 || quark >= nextQuark)
+ s = NULLSTRING;
+ else {
+#ifdef PERMQ
+ /* We have to mark the quark as permanent, since the caller might hold
+ * onto the string pointer forver.
+ */
+ SETPERM(quark);
+#endif
+ s = NAME(quark);
+ }
+ _XUnlockMutex(_Xglobal_lock);
+ return s;
+}
diff --git a/src/RaiseWin.c b/src/RaiseWin.c
new file mode 100644
index 00000000..7524a5ae
--- /dev/null
+++ b/src/RaiseWin.c
@@ -0,0 +1,46 @@
+/* $Xorg: RaiseWin.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XRaiseWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xConfigureWindowReq *req;
+ unsigned long val = Above; /* needed for macro below */
+
+ LockDisplay(dpy);
+ GetReqExtra(ConfigureWindow, 4, req);
+ req->window = w;
+ req->mask = CWStackMode;
+ OneDataCard32 (dpy, NEXTPTR(req,xConfigureWindowReq), val);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/RdBitF.c b/src/RdBitF.c
new file mode 100644
index 00000000..2b7b3966
--- /dev/null
+++ b/src/RdBitF.c
@@ -0,0 +1,289 @@
+/* $Xorg: RdBitF.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Code to read bitmaps from disk files. Interprets
+ * data from X10 and X11 bitmap files and creates
+ * Pixmap representations of files. Returns Pixmap
+ * ID and specifics about image.
+ *
+ * Modified for speedup by Jim Becker, changed image
+ * data parsing logic (removed some fscanf()s).
+ * Aug 5, 1988
+ *
+ * Note that this file and ../Xmu/RdBitF.c look very similar.... Keep them
+ * that way (but don't use common source code so that people can have one
+ * without the other).
+ */
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xutil.h"
+#include <stdio.h>
+#include <ctype.h>
+
+
+#define MAX_SIZE 255
+
+/* shared data for the image read/parse logic */
+static short hexTable[256]; /* conversion value */
+static Bool initialized = False; /* easier to fill in at run time */
+
+
+/*
+ * Table index for the hex values. Initialized once, first time.
+ * Used for translation value or delimiter significance lookup.
+ */
+static void initHexTable()
+{
+ /*
+ * We build the table at run time for several reasons:
+ *
+ * 1. portable to non-ASCII machines.
+ * 2. still reentrant since we set the init flag after setting table.
+ * 3. easier to extend.
+ * 4. less prone to bugs.
+ */
+ hexTable['0'] = 0; hexTable['1'] = 1;
+ hexTable['2'] = 2; hexTable['3'] = 3;
+ hexTable['4'] = 4; hexTable['5'] = 5;
+ hexTable['6'] = 6; hexTable['7'] = 7;
+ hexTable['8'] = 8; hexTable['9'] = 9;
+ hexTable['A'] = 10; hexTable['B'] = 11;
+ hexTable['C'] = 12; hexTable['D'] = 13;
+ hexTable['E'] = 14; hexTable['F'] = 15;
+ hexTable['a'] = 10; hexTable['b'] = 11;
+ hexTable['c'] = 12; hexTable['d'] = 13;
+ hexTable['e'] = 14; hexTable['f'] = 15;
+
+ /* delimiters of significance are flagged w/ negative value */
+ hexTable[' '] = -1; hexTable[','] = -1;
+ hexTable['}'] = -1; hexTable['\n'] = -1;
+ hexTable['\t'] = -1;
+
+ initialized = True;
+}
+
+/*
+ * read next hex value in the input stream, return -1 if EOF
+ */
+static NextInt (fstream)
+ FILE *fstream;
+{
+ int ch;
+ int value = 0;
+ int gotone = 0;
+ int done = 0;
+
+ /* loop, accumulate hex value until find delimiter */
+ /* skip any initial delimiters found in read stream */
+
+ while (!done) {
+ ch = getc(fstream);
+ if (ch == EOF) {
+ value = -1;
+ done++;
+ } else {
+ /* trim high bits, check type and accumulate */
+ ch &= 0xff;
+ if (isascii(ch) && isxdigit(ch)) {
+ value = (value << 4) + hexTable[ch];
+ gotone++;
+ } else if ((hexTable[ch]) < 0 && gotone)
+ done++;
+ }
+ }
+ return value;
+}
+
+#if NeedFunctionPrototypes
+int XReadBitmapFileData (
+ _Xconst char *filename,
+ unsigned int *width, /* RETURNED */
+ unsigned int *height, /* RETURNED */
+ unsigned char **data, /* RETURNED */
+ int *x_hot, /* RETURNED */
+ int *y_hot) /* RETURNED */
+#else
+int XReadBitmapFileData (filename, width, height, data, x_hot, y_hot)
+ char *filename;
+ unsigned int *width, *height; /* RETURNED */
+ unsigned char **data; /* RETURNED */
+ int *x_hot, *y_hot; /* RETURNED */
+#endif
+{
+ FILE *fstream; /* handle on file */
+ unsigned char *bits = NULL; /* working variable */
+ char line[MAX_SIZE]; /* input line from file */
+ int size; /* number of bytes of data */
+ char name_and_type[MAX_SIZE]; /* an input line */
+ char *type; /* for parsing */
+ int value; /* from an input line */
+ int version10p; /* boolean, old format */
+ int padding; /* to handle alignment */
+ int bytes_per_line; /* per scanline of data */
+ unsigned int ww = 0; /* width */
+ unsigned int hh = 0; /* height */
+ int hx = -1; /* x hotspot */
+ int hy = -1; /* y hotspot */
+
+ /* first time initialization */
+ if (initialized == False) initHexTable();
+
+ if (!(fstream = fopen(filename, "r")))
+ return BitmapOpenFailed;
+
+ /* error cleanup and return macro */
+#define RETURN(code) \
+{ if (bits) Xfree ((char *)bits); fclose (fstream); return code; }
+
+ while (fgets(line, MAX_SIZE, fstream)) {
+ if (strlen(line) == MAX_SIZE-1)
+ RETURN (BitmapFileInvalid);
+ if (sscanf(line,"#define %s %d",name_and_type,&value) == 2) {
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (!strcmp("width", type))
+ ww = (unsigned int) value;
+ if (!strcmp("height", type))
+ hh = (unsigned int) value;
+ if (!strcmp("hot", type)) {
+ if (type-- == name_and_type || type-- == name_and_type)
+ continue;
+ if (!strcmp("x_hot", type))
+ hx = value;
+ if (!strcmp("y_hot", type))
+ hy = value;
+ }
+ continue;
+ }
+
+ if (sscanf(line, "static short %s = {", name_and_type) == 1)
+ version10p = 1;
+ else if (sscanf(line,"static unsigned char %s = {",name_and_type) == 1)
+ version10p = 0;
+ else if (sscanf(line, "static char %s = {", name_and_type) == 1)
+ version10p = 0;
+ else
+ continue;
+
+ if (!(type = strrchr(name_and_type, '_')))
+ type = name_and_type;
+ else
+ type++;
+
+ if (strcmp("bits[]", type))
+ continue;
+
+ if (!ww || !hh)
+ RETURN (BitmapFileInvalid);
+
+ if ((ww % 16) && ((ww % 16) < 9) && version10p)
+ padding = 1;
+ else
+ padding = 0;
+
+ bytes_per_line = (ww+7)/8 + padding;
+
+ size = bytes_per_line * hh;
+ bits = (unsigned char *) Xmalloc ((unsigned int) size);
+ if (!bits)
+ RETURN (BitmapNoMemory);
+
+ if (version10p) {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=bits; bytes<size; (bytes += 2)) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *(ptr++) = value;
+ if (!padding || ((bytes+2) % bytes_per_line))
+ *(ptr++) = value >> 8;
+ }
+ } else {
+ unsigned char *ptr;
+ int bytes;
+
+ for (bytes=0, ptr=bits; bytes<size; bytes++, ptr++) {
+ if ((value = NextInt(fstream)) < 0)
+ RETURN (BitmapFileInvalid);
+ *ptr=value;
+ }
+ }
+ } /* end while */
+
+ fclose(fstream);
+ if (!bits)
+ return (BitmapFileInvalid);
+
+ *data = bits;
+ *width = ww;
+ *height = hh;
+ if (x_hot) *x_hot = hx;
+ if (y_hot) *y_hot = hy;
+
+ return (BitmapSuccess);
+}
+
+#if NeedFunctionPrototypes
+int XReadBitmapFile (
+ Display *display,
+ Drawable d,
+ _Xconst char *filename,
+ unsigned int *width, /* RETURNED */
+ unsigned int *height, /* RETURNED */
+ Pixmap *pixmap, /* RETURNED */
+ int *x_hot, /* RETURNED */
+ int *y_hot) /* RETURNED */
+#else
+int XReadBitmapFile (display, d, filename, width, height, pixmap, x_hot, y_hot)
+ Display *display;
+ Drawable d;
+ char *filename;
+ unsigned int *width, *height; /* RETURNED */
+ Pixmap *pixmap; /* RETURNED */
+ int *x_hot, *y_hot; /* RETURNED */
+#endif
+{
+ unsigned char *data;
+ int res;
+
+ res = XReadBitmapFileData(filename, width, height, &data, x_hot, y_hot);
+ if (res != BitmapSuccess)
+ return res;
+ *pixmap = XCreateBitmapFromData(display, d, (char *)data, *width, *height);
+ Xfree((char *)data);
+ if (*pixmap == None)
+ return (BitmapNoMemory);
+ return (BitmapSuccess);
+}
diff --git a/src/RecolorC.c b/src/RecolorC.c
new file mode 100644
index 00000000..06cf31ce
--- /dev/null
+++ b/src/RecolorC.c
@@ -0,0 +1,50 @@
+/* $Xorg: RecolorC.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XRecolorCursor(dpy, cursor, foreground, background)
+ register Display *dpy;
+ Cursor cursor;
+ XColor *foreground, *background;
+{
+ register xRecolorCursorReq *req;
+
+ LockDisplay(dpy);
+ GetReq(RecolorCursor, req);
+ req->cursor = cursor;
+ req->foreRed = foreground->red;
+ req->foreGreen = foreground->green;
+ req->foreBlue = foreground->blue;
+ req->backRed = background->red;
+ req->backGreen = background->green;
+ req->backBlue = background->blue;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/ReconfWM.c b/src/ReconfWM.c
new file mode 100644
index 00000000..c1a6cfb6
--- /dev/null
+++ b/src/ReconfWM.c
@@ -0,0 +1,139 @@
+/* $Xorg: ReconfWM.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+#define AllMaskBits (CWX|CWY|CWWidth|CWHeight|\
+ CWBorderWidth|CWSibling|CWStackMode)
+
+Status XReconfigureWMWindow (dpy, w, screen, mask, changes)
+ register Display *dpy;
+ Window w;
+ int screen;
+ unsigned int mask;
+ XWindowChanges *changes;
+{
+ XConfigureRequestEvent ev;
+ Window root = RootWindow (dpy, screen);
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ /*
+ * Only need to go through the trouble if we are actually changing the
+ * stacking mode.
+ */
+ if (!(mask & CWStackMode)) {
+ XConfigureWindow (dpy, w, mask, changes);
+ return True;
+ }
+
+
+ /*
+ * We need to inline XConfigureWindow and XSync so that everything is done
+ * while the display is locked.
+ */
+
+ LockDisplay(dpy);
+
+ /*
+ * XConfigureWindow (dpy, w, mask, changes);
+ */
+ {
+ unsigned long values[7];
+ register unsigned long *value = values;
+ long nvalues;
+ register xConfigureWindowReq *req;
+
+ GetReq(ConfigureWindow, req);
+
+ async_state.min_sequence_number = dpy->request;
+ async_state.max_sequence_number = dpy->request;
+ async_state.error_code = BadMatch;
+ async_state.major_opcode = X_ConfigureWindow;
+ async_state.minor_opcode = 0;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+
+ req->window = w;
+ mask &= AllMaskBits;
+ req->mask = mask;
+
+ if (mask & CWX) *value++ = changes->x;
+ if (mask & CWY) *value++ = changes->y;
+ if (mask & CWWidth) *value++ = changes->width;
+ if (mask & CWHeight) *value++ = changes->height;
+ if (mask & CWBorderWidth) *value++ = changes->border_width;
+ if (mask & CWSibling) *value++ = changes->sibling;
+ if (mask & CWStackMode) *value++ = changes->stack_mode;
+ req->length += (nvalues = value - values);
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, nvalues);
+ }
+
+ /*
+ * XSync (dpy, 0)
+ */
+ {
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+
+ /*
+ * If the request succeeded, then everything is okay; otherwise, send event
+ */
+ if (!async_state.error_count) return True;
+
+ ev.type = ConfigureRequest;
+ ev.window = w;
+ ev.parent = root;
+ ev.value_mask = (mask & AllMaskBits);
+ ev.x = changes->x;
+ ev.y = changes->y;
+ ev.width = changes->width;
+ ev.height = changes->height;
+ ev.border_width = changes->border_width;
+ ev.above = changes->sibling;
+ ev.detail = changes->stack_mode;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/src/ReconfWin.c b/src/ReconfWin.c
new file mode 100644
index 00000000..e1e2fe59
--- /dev/null
+++ b/src/ReconfWin.c
@@ -0,0 +1,78 @@
+/* $Xorg: ReconfWin.c,v 1.4 2001/02/09 02:03:35 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define AllMaskBits (CWX|CWY|CWWidth|CWHeight|\
+ CWBorderWidth|CWSibling|CWStackMode)
+
+XConfigureWindow(dpy, w, mask, changes)
+ register Display *dpy;
+ Window w;
+ unsigned int mask;
+ XWindowChanges *changes;
+ {
+ unsigned long values[7];
+ register unsigned long *value = values;
+ long nvalues;
+ register xConfigureWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ConfigureWindow, req);
+ req->window = w;
+ mask &= AllMaskBits;
+ req->mask = mask;
+
+ if (mask & CWX)
+ *value++ = changes->x;
+
+ if (mask & CWY)
+ *value++ = changes->y;
+
+ if (mask & CWWidth)
+ *value++ = changes->width;
+
+ if (mask & CWHeight)
+ *value++ = changes->height;
+
+ if (mask & CWBorderWidth)
+ *value++ = changes->border_width;
+
+ if (mask & CWSibling)
+ *value++ = changes->sibling;
+
+ if (mask & CWStackMode)
+ *value++ = changes->stack_mode;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, nvalues);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
diff --git a/src/Region.c b/src/Region.c
new file mode 100644
index 00000000..c8eeabd6
--- /dev/null
+++ b/src/Region.c
@@ -0,0 +1,1672 @@
+/* $Xorg: Region.c,v 1.6 2001/02/09 02:03:35 xorgcvs Exp $ */
+/************************************************************************
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987, 1988 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+************************************************************************/
+/*
+ * The functions in this file implement the Region abstraction, similar to one
+ * used in the X11 sample server. A Region is simply an area, as the name
+ * implies, and is implemented as a "y-x-banded" array of rectangles. To
+ * explain: Each Region is made up of a certain number of rectangles sorted
+ * by y coordinate first, and then by x coordinate.
+ *
+ * Furthermore, the rectangles are banded such that every rectangle with a
+ * given upper-left y coordinate (y1) will have the same lower-right y
+ * coordinate (y2) and vice versa. If a rectangle has scanlines in a band, it
+ * will span the entire vertical distance of the band. This means that some
+ * areas that could be merged into a taller rectangle will be represented as
+ * several shorter rectangles to account for shorter rectangles to its left
+ * or right but within its "vertical scope".
+ *
+ * An added constraint on the rectangles is that they must cover as much
+ * horizontal area as possible. E.g. no two rectangles in a band are allowed
+ * to touch.
+ *
+ * Whenever possible, bands will be merged together to cover a greater vertical
+ * distance (and thus reduce the number of rectangles). Two bands can be merged
+ * only if the bottom of one touches the top of the other and they have
+ * rectangles in the same places (of the same width, of course). This maintains
+ * the y-x-banding that's so nice to have...
+ */
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#include "region.h"
+#include "poly.h"
+
+#ifdef DEBUG
+#include <stdio.h>
+#define assert(expr) {if (!(expr)) fprintf(stderr,\
+"Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__); }
+#else
+#define assert(expr)
+#endif
+
+typedef void (*voidProcp)();
+
+static void miRegionOp();
+/* Create a new empty region */
+Region
+XCreateRegion()
+{
+ Region temp;
+
+ if (! (temp = ( Region )Xmalloc( (unsigned) sizeof( REGION ))))
+ return (Region) NULL;
+ if (! (temp->rects = ( BOX * )Xmalloc( (unsigned) sizeof( BOX )))) {
+ Xfree((char *) temp);
+ return (Region) NULL;
+ }
+ temp->numRects = 0;
+ temp->extents.x1 = 0;
+ temp->extents.y1 = 0;
+ temp->extents.x2 = 0;
+ temp->extents.y2 = 0;
+ temp->size = 1;
+ return( temp );
+}
+
+XClipBox( r, rect )
+ Region r;
+ XRectangle *rect;
+{
+ rect->x = r->extents.x1;
+ rect->y = r->extents.y1;
+ rect->width = r->extents.x2 - r->extents.x1;
+ rect->height = r->extents.y2 - r->extents.y1;
+ return 1;
+}
+
+XUnionRectWithRegion(rect, source, dest)
+ register XRectangle *rect;
+ Region source, dest;
+{
+ REGION region;
+
+ if (!rect->width || !rect->height)
+ return 0;
+ region.rects = &region.extents;
+ region.numRects = 1;
+ region.extents.x1 = rect->x;
+ region.extents.y1 = rect->y;
+ region.extents.x2 = rect->x + rect->width;
+ region.extents.y2 = rect->y + rect->height;
+ region.size = 1;
+
+ return XUnionRegion(&region, source, dest);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSetExtents --
+ * Reset the extents of a region to what they should be. Called by
+ * miSubtract and miIntersect b/c they can't figure it out along the
+ * way or do so easily, as miUnion can.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The region's 'extents' structure is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+static void
+miSetExtents (pReg)
+ Region pReg;
+{
+ register BoxPtr pBox,
+ pBoxEnd,
+ pExtents;
+
+ if (pReg->numRects == 0)
+ {
+ pReg->extents.x1 = 0;
+ pReg->extents.y1 = 0;
+ pReg->extents.x2 = 0;
+ pReg->extents.y2 = 0;
+ return;
+ }
+
+ pExtents = &pReg->extents;
+ pBox = pReg->rects;
+ pBoxEnd = &pBox[pReg->numRects - 1];
+
+ /*
+ * Since pBox is the first rectangle in the region, it must have the
+ * smallest y1 and since pBoxEnd is the last rectangle in the region,
+ * it must have the largest y2, because of banding. Initialize x1 and
+ * x2 from pBox and pBoxEnd, resp., as good things to initialize them
+ * to...
+ */
+ pExtents->x1 = pBox->x1;
+ pExtents->y1 = pBox->y1;
+ pExtents->x2 = pBoxEnd->x2;
+ pExtents->y2 = pBoxEnd->y2;
+
+ assert(pExtents->y1 < pExtents->y2);
+ while (pBox <= pBoxEnd)
+ {
+ if (pBox->x1 < pExtents->x1)
+ {
+ pExtents->x1 = pBox->x1;
+ }
+ if (pBox->x2 > pExtents->x2)
+ {
+ pExtents->x2 = pBox->x2;
+ }
+ pBox++;
+ }
+ assert(pExtents->x1 < pExtents->x2);
+}
+
+XSetRegion( dpy, gc, r )
+ Display *dpy;
+ GC gc;
+ register Region r;
+{
+ register int i;
+ register XRectangle *xr, *pr;
+ register BOX *pb;
+ unsigned long total;
+ extern void _XSetClipRectangles();
+
+ LockDisplay (dpy);
+ total = r->numRects * sizeof (XRectangle);
+ if ((xr = (XRectangle *) _XAllocTemp(dpy, total))) {
+ for (pr = xr, pb = r->rects, i = r->numRects; --i >= 0; pr++, pb++) {
+ pr->x = pb->x1;
+ pr->y = pb->y1;
+ pr->width = pb->x2 - pb->x1;
+ pr->height = pb->y2 - pb->y1;
+ }
+ }
+ if (xr || !r->numRects)
+ _XSetClipRectangles(dpy, gc, 0, 0, xr, r->numRects, YXBanded);
+ if (xr)
+ _XFreeTemp(dpy, (char *)xr, total);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+XDestroyRegion( r )
+ Region r;
+{
+ Xfree( (char *) r->rects );
+ Xfree( (char *) r );
+ return 1;
+}
+
+
+/* TranslateRegion(pRegion, x, y)
+ translates in place
+ added by raymond
+*/
+
+XOffsetRegion(pRegion, x, y)
+ register Region pRegion;
+ register int x;
+ register int y;
+{
+ register int nbox;
+ register BOX *pbox;
+
+ pbox = pRegion->rects;
+ nbox = pRegion->numRects;
+
+ while(nbox--)
+ {
+ pbox->x1 += x;
+ pbox->x2 += x;
+ pbox->y1 += y;
+ pbox->y2 += y;
+ pbox++;
+ }
+ pRegion->extents.x1 += x;
+ pRegion->extents.x2 += x;
+ pRegion->extents.y1 += y;
+ pRegion->extents.y2 += y;
+ return 1;
+}
+
+/*
+ Utility procedure Compress:
+ Replace r by the region r', where
+ p in r' iff (Quantifer m <= dx) (p + m in r), and
+ Quantifier is Exists if grow is TRUE, For all if grow is FALSE, and
+ (x,y) + m = (x+m,y) if xdir is TRUE; (x,y+m) if xdir is FALSE.
+
+ Thus, if xdir is TRUE and grow is FALSE, r is replaced by the region
+ of all points p such that p and the next dx points on the same
+ horizontal scan line are all in r. We do this using by noting
+ that p is the head of a run of length 2^i + k iff p is the head
+ of a run of length 2^i and p+2^i is the head of a run of length
+ k. Thus, the loop invariant: s contains the region corresponding
+ to the runs of length shift. r contains the region corresponding
+ to the runs of length 1 + dxo & (shift-1), where dxo is the original
+ value of dx. dx = dxo & ~(shift-1). As parameters, s and t are
+ scratch regions, so that we don't have to allocate them on every
+ call.
+*/
+
+#define ZOpRegion(a,b,c) if (grow) XUnionRegion(a,b,c); \
+ else XIntersectRegion(a,b,c)
+#define ZShiftRegion(a,b) if (xdir) XOffsetRegion(a,b,0); \
+ else XOffsetRegion(a,0,b)
+#define ZCopyRegion(a,b) XUnionRegion(a,a,b)
+
+static void
+Compress(r, s, t, dx, xdir, grow)
+ Region r, s, t;
+ register unsigned dx;
+ register int xdir, grow;
+{
+ register unsigned shift = 1;
+
+ ZCopyRegion(r, s);
+ while (dx) {
+ if (dx & shift) {
+ ZShiftRegion(r, -(int)shift);
+ ZOpRegion(r, s, r);
+ dx -= shift;
+ if (!dx) break;
+ }
+ ZCopyRegion(s, t);
+ ZShiftRegion(s, -(int)shift);
+ ZOpRegion(s, t, s);
+ shift <<= 1;
+ }
+}
+
+#undef ZOpRegion
+#undef ZShiftRegion
+#undef ZCopyRegion
+
+XShrinkRegion(r, dx, dy)
+ Region r;
+ int dx, dy;
+{
+ Region s, t;
+ int grow;
+
+ if (!dx && !dy) return 0;
+ if ((! (s = XCreateRegion())) || (! (t = XCreateRegion()))) return 0;
+ if ((grow = (dx < 0))) dx = -dx;
+ if (dx) Compress(r, s, t, (unsigned) 2*dx, TRUE, grow);
+ if ((grow = (dy < 0))) dy = -dy;
+ if (dy) Compress(r, s, t, (unsigned) 2*dy, FALSE, grow);
+ XOffsetRegion(r, dx, dy);
+ XDestroyRegion(s);
+ XDestroyRegion(t);
+ return 0;
+}
+
+#ifdef notdef
+/***********************************************************
+ * Bop down the array of rects until we have passed
+ * scanline y. numRects is the size of the array.
+ ***********************************************************/
+
+static BOX
+*IndexRects(rects, numRects, y)
+ register BOX *rects;
+ register int numRects;
+ register int y;
+{
+ while ((numRects--) && (rects->y2 <= y))
+ rects++;
+ return(rects);
+}
+#endif
+
+/*======================================================================
+ * Region Intersection
+ *====================================================================*/
+/*-
+ *-----------------------------------------------------------------------
+ * miIntersectO --
+ * Handle an overlapping band for miIntersect.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Rectangles may be added to the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static
+miIntersectO (pReg, r1, r1End, r2, r2End, y1, y2)
+ register Region pReg;
+ register BoxPtr r1;
+ BoxPtr r1End;
+ register BoxPtr r2;
+ BoxPtr r2End;
+ short y1;
+ short y2;
+{
+ register short x1;
+ register short x2;
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ x1 = max(r1->x1,r2->x1);
+ x2 = min(r1->x2,r2->x2);
+
+ /*
+ * If there's any overlap between the two rectangles, add that
+ * overlap to the new region.
+ * There's no need to check for subsumption because the only way
+ * such a need could arise is if some region has two rectangles
+ * right next to each other. Since that should never happen...
+ */
+ if (x1 < x2)
+ {
+ assert(y1<y2);
+
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+ assert(pReg->numRects <= pReg->size);
+ }
+
+ /*
+ * Need to advance the pointers. Shift the one that extends
+ * to the right the least, since the other still has a chance to
+ * overlap with that region's next rectangle, if you see what I mean.
+ */
+ if (r1->x2 < r2->x2)
+ {
+ r1++;
+ }
+ else if (r2->x2 < r1->x2)
+ {
+ r2++;
+ }
+ else
+ {
+ r1++;
+ r2++;
+ }
+ }
+ return 0; /* lint */
+}
+
+XIntersectRegion(reg1, reg2, newReg)
+ Region reg1;
+ Region reg2; /* source regions */
+ register Region newReg; /* destination Region */
+{
+ /* check for trivial reject */
+ if ( (!(reg1->numRects)) || (!(reg2->numRects)) ||
+ (!EXTENTCHECK(&reg1->extents, &reg2->extents)))
+ newReg->numRects = 0;
+ else
+ miRegionOp (newReg, reg1, reg2,
+ (voidProcp) miIntersectO, (voidProcp) NULL, (voidProcp) NULL);
+
+ /*
+ * Can't alter newReg's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being the same. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents(newReg);
+ return 1;
+}
+
+static void
+miRegionCopy(dstrgn, rgn)
+ register Region dstrgn;
+ register Region rgn;
+
+{
+ if (dstrgn != rgn) /* don't want to copy to itself */
+ {
+ if (dstrgn->size < rgn->numRects)
+ {
+ if (dstrgn->rects)
+ {
+ BOX *prevRects = dstrgn->rects;
+
+ if (! (dstrgn->rects = (BOX *)
+ Xrealloc((char *) dstrgn->rects,
+ (unsigned) rgn->numRects * (sizeof(BOX))))) {
+ Xfree(prevRects);
+ return;
+ }
+ }
+ dstrgn->size = rgn->numRects;
+ }
+ dstrgn->numRects = rgn->numRects;
+ dstrgn->extents.x1 = rgn->extents.x1;
+ dstrgn->extents.y1 = rgn->extents.y1;
+ dstrgn->extents.x2 = rgn->extents.x2;
+ dstrgn->extents.y2 = rgn->extents.y2;
+
+ memcpy((char *) dstrgn->rects, (char *) rgn->rects,
+ (int) (rgn->numRects * sizeof(BOX)));
+ }
+}
+
+#ifdef notdef
+
+/*
+ * combinRegs(newReg, reg1, reg2)
+ * if one region is above or below the other.
+*/
+
+static void
+combineRegs(newReg, reg1, reg2)
+ register Region newReg;
+ Region reg1;
+ Region reg2;
+{
+ register Region tempReg;
+ register BOX *rects;
+ register BOX *rects1;
+ register BOX *rects2;
+ register int total;
+
+ rects1 = reg1->rects;
+ rects2 = reg2->rects;
+
+ total = reg1->numRects + reg2->numRects;
+ if (! (tempReg = XCreateRegion()))
+ return;
+ tempReg->size = total;
+ /* region 1 is below region 2 */
+ if (reg1->extents.y1 > reg2->extents.y1)
+ {
+ miRegionCopy(tempReg, reg2);
+ rects = &tempReg->rects[tempReg->numRects];
+ total -= tempReg->numRects;
+ while (total--)
+ *rects++ = *rects1++;
+ }
+ else
+ {
+ miRegionCopy(tempReg, reg1);
+ rects = &tempReg->rects[tempReg->numRects];
+ total -= tempReg->numRects;
+ while (total--)
+ *rects++ = *rects2++;
+ }
+ tempReg->extents = reg1->extents;
+ tempReg->numRects = reg1->numRects + reg2->numRects;
+ EXTENTS(&reg2->extents, tempReg);
+ miRegionCopy(newReg, tempReg);
+ Xfree((char *)tempReg);
+}
+
+/*
+ * QuickCheck checks to see if it does not have to go through all the
+ * the ugly code for the region call. It returns 1 if it did all
+ * the work for Union, otherwise 0 - still work to be done.
+*/
+
+static int
+QuickCheck(newReg, reg1, reg2)
+ Region newReg, reg1, reg2;
+{
+
+ /* if unioning with itself or no rects to union with */
+ if ( (reg1 == reg2) || (!(reg1->numRects)) )
+ {
+ miRegionCopy(newReg, reg2);
+ return TRUE;
+ }
+
+ /* if nothing to union */
+ if (!(reg2->numRects))
+ {
+ miRegionCopy(newReg, reg1);
+ return TRUE;
+ }
+
+ /* could put an extent check to see if add above or below */
+
+ if ((reg1->extents.y1 >= reg2->extents.y2) ||
+ (reg2->extents.y1 >= reg1->extents.y2) )
+ {
+ combineRegs(newReg, reg1, reg2);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+/* TopRects(rects, reg1, reg2)
+ * N.B. We now assume that reg1 and reg2 intersect. Therefore we are
+ * NOT checking in the two while loops for stepping off the end of the
+ * region.
+ */
+
+static int
+TopRects(newReg, rects, reg1, reg2, FirstRect)
+ register Region newReg;
+ register BOX *rects;
+ register Region reg1;
+ register Region reg2;
+ BOX *FirstRect;
+{
+ register BOX *tempRects;
+
+ /* need to add some rects from region 1 */
+ if (reg1->extents.y1 < reg2->extents.y1)
+ {
+ tempRects = reg1->rects;
+ while(tempRects->y1 < reg2->extents.y1)
+ {
+ MEMCHECK(newReg, rects, FirstRect);
+ ADDRECTNOX(newReg,rects, tempRects->x1, tempRects->y1,
+ tempRects->x2, MIN(tempRects->y2, reg2->extents.y1));
+ tempRects++;
+ }
+ }
+ /* need to add some rects from region 2 */
+ if (reg2->extents.y1 < reg1->extents.y1)
+ {
+ tempRects = reg2->rects;
+ while (tempRects->y1 < reg1->extents.y1)
+ {
+ MEMCHECK(newReg, rects, FirstRect);
+ ADDRECTNOX(newReg, rects, tempRects->x1,tempRects->y1,
+ tempRects->x2, MIN(tempRects->y2, reg1->extents.y1));
+ tempRects++;
+ }
+ }
+ return 1;
+}
+#endif
+
+/*======================================================================
+ * Generic Region Operator
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miCoalesce --
+ * Attempt to merge the boxes in the current band with those in the
+ * previous one. Used only by miRegionOp.
+ *
+ * Results:
+ * The new index for the previous band.
+ *
+ * Side Effects:
+ * If coalescing takes place:
+ * - rectangles in the previous band will have their y2 fields
+ * altered.
+ * - pReg->numRects will be decreased.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static int*/
+static
+miCoalesce (pReg, prevStart, curStart)
+ register Region pReg; /* Region to coalesce */
+ int prevStart; /* Index of start of previous band */
+ int curStart; /* Index of start of current band */
+{
+ register BoxPtr pPrevBox; /* Current box in previous band */
+ register BoxPtr pCurBox; /* Current box in current band */
+ register BoxPtr pRegEnd; /* End of region */
+ int curNumRects; /* Number of rectangles in current
+ * band */
+ int prevNumRects; /* Number of rectangles in previous
+ * band */
+ int bandY1; /* Y1 coordinate for current band */
+
+ pRegEnd = &pReg->rects[pReg->numRects];
+
+ pPrevBox = &pReg->rects[prevStart];
+ prevNumRects = curStart - prevStart;
+
+ /*
+ * Figure out how many rectangles are in the current band. Have to do
+ * this because multiple bands could have been added in miRegionOp
+ * at the end when one region has been exhausted.
+ */
+ pCurBox = &pReg->rects[curStart];
+ bandY1 = pCurBox->y1;
+ for (curNumRects = 0;
+ (pCurBox != pRegEnd) && (pCurBox->y1 == bandY1);
+ curNumRects++)
+ {
+ pCurBox++;
+ }
+
+ if (pCurBox != pRegEnd)
+ {
+ /*
+ * If more than one band was added, we have to find the start
+ * of the last band added so the next coalescing job can start
+ * at the right place... (given when multiple bands are added,
+ * this may be pointless -- see above).
+ */
+ pRegEnd--;
+ while (pRegEnd[-1].y1 == pRegEnd->y1)
+ {
+ pRegEnd--;
+ }
+ curStart = pRegEnd - pReg->rects;
+ pRegEnd = pReg->rects + pReg->numRects;
+ }
+
+ if ((curNumRects == prevNumRects) && (curNumRects != 0)) {
+ pCurBox -= curNumRects;
+ /*
+ * The bands may only be coalesced if the bottom of the previous
+ * matches the top scanline of the current.
+ */
+ if (pPrevBox->y2 == pCurBox->y1)
+ {
+ /*
+ * Make sure the bands have boxes in the same places. This
+ * assumes that boxes have been added in such a way that they
+ * cover the most area possible. I.e. two boxes in a band must
+ * have some horizontal space between them.
+ */
+ do
+ {
+ if ((pPrevBox->x1 != pCurBox->x1) ||
+ (pPrevBox->x2 != pCurBox->x2))
+ {
+ /*
+ * The bands don't line up so they can't be coalesced.
+ */
+ return (curStart);
+ }
+ pPrevBox++;
+ pCurBox++;
+ prevNumRects -= 1;
+ } while (prevNumRects != 0);
+
+ pReg->numRects -= curNumRects;
+ pCurBox -= curNumRects;
+ pPrevBox -= curNumRects;
+
+ /*
+ * The bands may be merged, so set the bottom y of each box
+ * in the previous band to that of the corresponding box in
+ * the current band.
+ */
+ do
+ {
+ pPrevBox->y2 = pCurBox->y2;
+ pPrevBox++;
+ pCurBox++;
+ curNumRects -= 1;
+ } while (curNumRects != 0);
+
+ /*
+ * If only one band was added to the region, we have to backup
+ * curStart to the start of the previous band.
+ *
+ * If more than one band was added to the region, copy the
+ * other bands down. The assumption here is that the other bands
+ * came from the same region as the current one and no further
+ * coalescing can be done on them since it's all been done
+ * already... curStart is already in the right place.
+ */
+ if (pCurBox == pRegEnd)
+ {
+ curStart = prevStart;
+ }
+ else
+ {
+ do
+ {
+ *pPrevBox++ = *pCurBox++;
+ } while (pCurBox != pRegEnd);
+ }
+
+ }
+ }
+ return (curStart);
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miRegionOp --
+ * Apply an operation to two regions. Called by miUnion, miInverse,
+ * miSubtract, miIntersect...
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * The new region is overwritten.
+ *
+ * Notes:
+ * The idea behind this function is to view the two regions as sets.
+ * Together they cover a rectangle of area that this function divides
+ * into horizontal bands where points are covered only by one region
+ * or by both. For the first case, the nonOverlapFunc is called with
+ * each the band and the band's upper and lower extents. For the
+ * second, the overlapFunc is called to process the entire band. It
+ * is responsible for clipping the rectangles in the band, though
+ * this function provides the boundaries.
+ * At the end of each band, the new region is coalesced, if possible,
+ * to reduce the number of rectangles in the region.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static void
+miRegionOp(newReg, reg1, reg2, overlapFunc, nonOverlap1Func, nonOverlap2Func)
+ register Region newReg; /* Place to store result */
+ Region reg1; /* First region in operation */
+ Region reg2; /* 2d region in operation */
+ void (*overlapFunc)(); /* Function to call for over-
+ * lapping bands */
+ void (*nonOverlap1Func)(); /* Function to call for non-
+ * overlapping bands in region
+ * 1 */
+ void (*nonOverlap2Func)(); /* Function to call for non-
+ * overlapping bands in region
+ * 2 */
+{
+ register BoxPtr r1; /* Pointer into first region */
+ register BoxPtr r2; /* Pointer into 2d region */
+ BoxPtr r1End; /* End of 1st region */
+ BoxPtr r2End; /* End of 2d region */
+ register short ybot; /* Bottom of intersection */
+ register short ytop; /* Top of intersection */
+ BoxPtr oldRects; /* Old rects for newReg */
+ int prevBand; /* Index of start of
+ * previous band in newReg */
+ int curBand; /* Index of start of current
+ * band in newReg */
+ register BoxPtr r1BandEnd; /* End of current band in r1 */
+ register BoxPtr r2BandEnd; /* End of current band in r2 */
+ short top; /* Top of non-overlapping
+ * band */
+ short bot; /* Bottom of non-overlapping
+ * band */
+
+ /*
+ * Initialization:
+ * set r1, r2, r1End and r2End appropriately, preserve the important
+ * parts of the destination region until the end in case it's one of
+ * the two source regions, then mark the "new" region empty, allocating
+ * another array of rectangles for it to use.
+ */
+ r1 = reg1->rects;
+ r2 = reg2->rects;
+ r1End = r1 + reg1->numRects;
+ r2End = r2 + reg2->numRects;
+
+ oldRects = newReg->rects;
+
+ EMPTY_REGION(newReg);
+
+ /*
+ * Allocate a reasonable number of rectangles for the new region. The idea
+ * is to allocate enough so the individual functions don't need to
+ * reallocate and copy the array, which is time consuming, yet we don't
+ * have to worry about using too much memory. I hope to be able to
+ * nuke the Xrealloc() at the end of this function eventually.
+ */
+ newReg->size = max(reg1->numRects,reg2->numRects) * 2;
+
+ if (! (newReg->rects = (BoxPtr)
+ Xmalloc ((unsigned) (sizeof(BoxRec) * newReg->size)))) {
+ newReg->size = 0;
+ return;
+ }
+
+ /*
+ * Initialize ybot and ytop.
+ * In the upcoming loop, ybot and ytop serve different functions depending
+ * on whether the band being handled is an overlapping or non-overlapping
+ * band.
+ * In the case of a non-overlapping band (only one of the regions
+ * has points in the band), ybot is the bottom of the most recent
+ * intersection and thus clips the top of the rectangles in that band.
+ * ytop is the top of the next intersection between the two regions and
+ * serves to clip the bottom of the rectangles in the current band.
+ * For an overlapping band (where the two regions intersect), ytop clips
+ * the top of the rectangles of both regions and ybot clips the bottoms.
+ */
+ if (reg1->extents.y1 < reg2->extents.y1)
+ ybot = reg1->extents.y1;
+ else
+ ybot = reg2->extents.y1;
+
+ /*
+ * prevBand serves to mark the start of the previous band so rectangles
+ * can be coalesced into larger rectangles. qv. miCoalesce, above.
+ * In the beginning, there is no previous band, so prevBand == curBand
+ * (curBand is set later on, of course, but the first band will always
+ * start at index 0). prevBand and curBand must be indices because of
+ * the possible expansion, and resultant moving, of the new region's
+ * array of rectangles.
+ */
+ prevBand = 0;
+
+ do
+ {
+ curBand = newReg->numRects;
+
+ /*
+ * This algorithm proceeds one source-band (as opposed to a
+ * destination band, which is determined by where the two regions
+ * intersect) at a time. r1BandEnd and r2BandEnd serve to mark the
+ * rectangle after the last one in the current band for their
+ * respective regions.
+ */
+ r1BandEnd = r1;
+ while ((r1BandEnd != r1End) && (r1BandEnd->y1 == r1->y1))
+ {
+ r1BandEnd++;
+ }
+
+ r2BandEnd = r2;
+ while ((r2BandEnd != r2End) && (r2BandEnd->y1 == r2->y1))
+ {
+ r2BandEnd++;
+ }
+
+ /*
+ * First handle the band that doesn't intersect, if any.
+ *
+ * Note that attention is restricted to one band in the
+ * non-intersecting region at once, so if a region has n
+ * bands between the current position and the next place it overlaps
+ * the other, this entire loop will be passed through n times.
+ */
+ if (r1->y1 < r2->y1)
+ {
+ top = max(r1->y1,ybot);
+ bot = min(r1->y2,r2->y1);
+
+ if ((top != bot) && (nonOverlap1Func != (void (*)())NULL))
+ {
+ (* nonOverlap1Func) (newReg, r1, r1BandEnd, top, bot);
+ }
+
+ ytop = r2->y1;
+ }
+ else if (r2->y1 < r1->y1)
+ {
+ top = max(r2->y1,ybot);
+ bot = min(r2->y2,r1->y1);
+
+ if ((top != bot) && (nonOverlap2Func != (void (*)())NULL))
+ {
+ (* nonOverlap2Func) (newReg, r2, r2BandEnd, top, bot);
+ }
+
+ ytop = r1->y1;
+ }
+ else
+ {
+ ytop = r1->y1;
+ }
+
+ /*
+ * If any rectangles got added to the region, try and coalesce them
+ * with rectangles from the previous band. Note we could just do
+ * this test in miCoalesce, but some machines incur a not
+ * inconsiderable cost for function calls, so...
+ */
+ if (newReg->numRects != curBand)
+ {
+ prevBand = miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * Now see if we've hit an intersecting band. The two bands only
+ * intersect if ybot > ytop
+ */
+ ybot = min(r1->y2, r2->y2);
+ curBand = newReg->numRects;
+ if (ybot > ytop)
+ {
+ (* overlapFunc) (newReg, r1, r1BandEnd, r2, r2BandEnd, ytop, ybot);
+
+ }
+
+ if (newReg->numRects != curBand)
+ {
+ prevBand = miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * If we've finished with a band (y2 == ybot) we skip forward
+ * in the region to the next band.
+ */
+ if (r1->y2 == ybot)
+ {
+ r1 = r1BandEnd;
+ }
+ if (r2->y2 == ybot)
+ {
+ r2 = r2BandEnd;
+ }
+ } while ((r1 != r1End) && (r2 != r2End));
+
+ /*
+ * Deal with whichever region still has rectangles left.
+ */
+ curBand = newReg->numRects;
+ if (r1 != r1End)
+ {
+ if (nonOverlap1Func != (void (*)())NULL)
+ {
+ do
+ {
+ r1BandEnd = r1;
+ while ((r1BandEnd < r1End) && (r1BandEnd->y1 == r1->y1))
+ {
+ r1BandEnd++;
+ }
+ (* nonOverlap1Func) (newReg, r1, r1BandEnd,
+ max(r1->y1,ybot), r1->y2);
+ r1 = r1BandEnd;
+ } while (r1 != r1End);
+ }
+ }
+ else if ((r2 != r2End) && (nonOverlap2Func != (void (*)())NULL))
+ {
+ do
+ {
+ r2BandEnd = r2;
+ while ((r2BandEnd < r2End) && (r2BandEnd->y1 == r2->y1))
+ {
+ r2BandEnd++;
+ }
+ (* nonOverlap2Func) (newReg, r2, r2BandEnd,
+ max(r2->y1,ybot), r2->y2);
+ r2 = r2BandEnd;
+ } while (r2 != r2End);
+ }
+
+ if (newReg->numRects != curBand)
+ {
+ (void) miCoalesce (newReg, prevBand, curBand);
+ }
+
+ /*
+ * A bit of cleanup. To keep regions from growing without bound,
+ * we shrink the array of rectangles to match the new number of
+ * rectangles in the region. This never goes to 0, however...
+ *
+ * Only do this stuff if the number of rectangles allocated is more than
+ * twice the number of rectangles in the region (a simple optimization...).
+ */
+ if (newReg->numRects < (newReg->size >> 1))
+ {
+ if (REGION_NOT_EMPTY(newReg))
+ {
+ BoxPtr prev_rects = newReg->rects;
+ newReg->size = newReg->numRects;
+ newReg->rects = (BoxPtr) Xrealloc ((char *) newReg->rects,
+ (unsigned) (sizeof(BoxRec) * newReg->size));
+ if (! newReg->rects)
+ newReg->rects = prev_rects;
+ }
+ else
+ {
+ /*
+ * No point in doing the extra work involved in an Xrealloc if
+ * the region is empty
+ */
+ newReg->size = 1;
+ Xfree((char *) newReg->rects);
+ newReg->rects = (BoxPtr) Xmalloc(sizeof(BoxRec));
+ }
+ }
+ Xfree ((char *) oldRects);
+ return;
+}
+
+
+/*======================================================================
+ * Region Union
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miUnionNonO --
+ * Handle a non-overlapping band for the union operation. Just
+ * Adds the rectangles into the region. Doesn't have to check for
+ * subsumption or anything.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg->numRects is incremented and the final rectangles overwritten
+ * with the rectangles we're passed.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static
+miUnionNonO (pReg, r, rEnd, y1, y2)
+ register Region pReg;
+ register BoxPtr r;
+ BoxPtr rEnd;
+ register short y1;
+ register short y2;
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ assert(y1 < y2);
+
+ while (r != rEnd)
+ {
+ assert(r->x1 < r->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = r->x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+ r++;
+ }
+ return 0; /* lint */
+}
+
+
+/*-
+ *-----------------------------------------------------------------------
+ * miUnionO --
+ * Handle an overlapping band for the union operation. Picks the
+ * left-most rectangle each time and merges it into the region.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * Rectangles are overwritten in pReg->rects and pReg->numRects will
+ * be changed.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+/* static void*/
+static
+miUnionO (pReg, r1, r1End, r2, r2End, y1, y2)
+ register Region pReg;
+ register BoxPtr r1;
+ BoxPtr r1End;
+ register BoxPtr r2;
+ BoxPtr r2End;
+ register short y1;
+ register short y2;
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+#define MERGERECT(r) \
+ if ((pReg->numRects != 0) && \
+ (pNextRect[-1].y1 == y1) && \
+ (pNextRect[-1].y2 == y2) && \
+ (pNextRect[-1].x2 >= r->x1)) \
+ { \
+ if (pNextRect[-1].x2 < r->x2) \
+ { \
+ pNextRect[-1].x2 = r->x2; \
+ assert(pNextRect[-1].x1<pNextRect[-1].x2); \
+ } \
+ } \
+ else \
+ { \
+ MEMCHECK(pReg, pNextRect, pReg->rects); \
+ pNextRect->y1 = y1; \
+ pNextRect->y2 = y2; \
+ pNextRect->x1 = r->x1; \
+ pNextRect->x2 = r->x2; \
+ pReg->numRects += 1; \
+ pNextRect += 1; \
+ } \
+ assert(pReg->numRects<=pReg->size);\
+ r++;
+
+ assert (y1<y2);
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ if (r1->x1 < r2->x1)
+ {
+ MERGERECT(r1);
+ }
+ else
+ {
+ MERGERECT(r2);
+ }
+ }
+
+ if (r1 != r1End)
+ {
+ do
+ {
+ MERGERECT(r1);
+ } while (r1 != r1End);
+ }
+ else while (r2 != r2End)
+ {
+ MERGERECT(r2);
+ }
+ return 0; /* lint */
+}
+
+XUnionRegion(reg1, reg2, newReg)
+ Region reg1;
+ Region reg2; /* source regions */
+ Region newReg; /* destination Region */
+{
+ /* checks all the simple cases */
+
+ /*
+ * Region 1 and 2 are the same or region 1 is empty
+ */
+ if ( (reg1 == reg2) || (!(reg1->numRects)) )
+ {
+ if (newReg != reg2)
+ miRegionCopy(newReg, reg2);
+ return 1;
+ }
+
+ /*
+ * if nothing to union (region 2 empty)
+ */
+ if (!(reg2->numRects))
+ {
+ if (newReg != reg1)
+ miRegionCopy(newReg, reg1);
+ return 1;
+ }
+
+ /*
+ * Region 1 completely subsumes region 2
+ */
+ if ((reg1->numRects == 1) &&
+ (reg1->extents.x1 <= reg2->extents.x1) &&
+ (reg1->extents.y1 <= reg2->extents.y1) &&
+ (reg1->extents.x2 >= reg2->extents.x2) &&
+ (reg1->extents.y2 >= reg2->extents.y2))
+ {
+ if (newReg != reg1)
+ miRegionCopy(newReg, reg1);
+ return 1;
+ }
+
+ /*
+ * Region 2 completely subsumes region 1
+ */
+ if ((reg2->numRects == 1) &&
+ (reg2->extents.x1 <= reg1->extents.x1) &&
+ (reg2->extents.y1 <= reg1->extents.y1) &&
+ (reg2->extents.x2 >= reg1->extents.x2) &&
+ (reg2->extents.y2 >= reg1->extents.y2))
+ {
+ if (newReg != reg2)
+ miRegionCopy(newReg, reg2);
+ return 1;
+ }
+
+ miRegionOp (newReg, reg1, reg2, (voidProcp) miUnionO,
+ (voidProcp) miUnionNonO, (voidProcp) miUnionNonO);
+
+ newReg->extents.x1 = min(reg1->extents.x1, reg2->extents.x1);
+ newReg->extents.y1 = min(reg1->extents.y1, reg2->extents.y1);
+ newReg->extents.x2 = max(reg1->extents.x2, reg2->extents.x2);
+ newReg->extents.y2 = max(reg1->extents.y2, reg2->extents.y2);
+
+ return 1;
+}
+
+
+/*======================================================================
+ * Region Subtraction
+ *====================================================================*/
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtractNonO --
+ * Deal with non-overlapping band for subtraction. Any parts from
+ * region 2 we discard. Anything from region 1 we add to the region.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg may be affected.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static
+miSubtractNonO1 (pReg, r, rEnd, y1, y2)
+ register Region pReg;
+ register BoxPtr r;
+ BoxPtr rEnd;
+ register short y1;
+ register short y2;
+{
+ register BoxPtr pNextRect;
+
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ assert(y1<y2);
+
+ while (r != rEnd)
+ {
+ assert(r->x1<r->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = r->x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects <= pReg->size);
+
+ r++;
+ }
+ return 0; /* lint */
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtractO --
+ * Overlapping band subtraction. x1 is the left-most point not yet
+ * checked.
+ *
+ * Results:
+ * None.
+ *
+ * Side Effects:
+ * pReg may have rectangles added to it.
+ *
+ *-----------------------------------------------------------------------
+ */
+/* static void*/
+static
+miSubtractO (pReg, r1, r1End, r2, r2End, y1, y2)
+ register Region pReg;
+ register BoxPtr r1;
+ BoxPtr r1End;
+ register BoxPtr r2;
+ BoxPtr r2End;
+ register short y1;
+ register short y2;
+{
+ register BoxPtr pNextRect;
+ register int x1;
+
+ x1 = r1->x1;
+
+ assert(y1<y2);
+ pNextRect = &pReg->rects[pReg->numRects];
+
+ while ((r1 != r1End) && (r2 != r2End))
+ {
+ if (r2->x2 <= x1)
+ {
+ /*
+ * Subtrahend missed the boat: go to next subtrahend.
+ */
+ r2++;
+ }
+ else if (r2->x1 <= x1)
+ {
+ /*
+ * Subtrahend preceeds minuend: nuke left edge of minuend.
+ */
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend completely covered: advance to next minuend and
+ * reset left fence to edge of new minuend.
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend now used up since it doesn't extend beyond
+ * minuend
+ */
+ r2++;
+ }
+ }
+ else if (r2->x1 < r1->x2)
+ {
+ /*
+ * Left part of subtrahend covers part of minuend: add uncovered
+ * part of minuend to region and skip to next subtrahend.
+ */
+ assert(x1<r2->x1);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r2->x1;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+
+ x1 = r2->x2;
+ if (x1 >= r1->x2)
+ {
+ /*
+ * Minuend used up: advance to new...
+ */
+ r1++;
+ if (r1 != r1End)
+ x1 = r1->x1;
+ }
+ else
+ {
+ /*
+ * Subtrahend used up
+ */
+ r2++;
+ }
+ }
+ else
+ {
+ /*
+ * Minuend used up: add any remaining piece before advancing.
+ */
+ if (r1->x2 > x1)
+ {
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r1->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+ assert(pReg->numRects<=pReg->size);
+ }
+ r1++;
+ x1 = r1->x1;
+ }
+ }
+
+ /*
+ * Add remaining minuend rectangles to region.
+ */
+ while (r1 != r1End)
+ {
+ assert(x1<r1->x2);
+ MEMCHECK(pReg, pNextRect, pReg->rects);
+ pNextRect->x1 = x1;
+ pNextRect->y1 = y1;
+ pNextRect->x2 = r1->x2;
+ pNextRect->y2 = y2;
+ pReg->numRects += 1;
+ pNextRect++;
+
+ assert(pReg->numRects<=pReg->size);
+
+ r1++;
+ if (r1 != r1End)
+ {
+ x1 = r1->x1;
+ }
+ }
+ return 0; /* lint */
+}
+
+/*-
+ *-----------------------------------------------------------------------
+ * miSubtract --
+ * Subtract regS from regM and leave the result in regD.
+ * S stands for subtrahend, M for minuend and D for difference.
+ *
+ * Results:
+ * TRUE.
+ *
+ * Side Effects:
+ * regD is overwritten.
+ *
+ *-----------------------------------------------------------------------
+ */
+
+XSubtractRegion(regM, regS, regD)
+ Region regM;
+ Region regS;
+ register Region regD;
+{
+ /* check for trivial reject */
+ if ( (!(regM->numRects)) || (!(regS->numRects)) ||
+ (!EXTENTCHECK(&regM->extents, &regS->extents)) )
+ {
+ miRegionCopy(regD, regM);
+ return 1;
+ }
+
+ miRegionOp (regD, regM, regS, (voidProcp) miSubtractO,
+ (voidProcp) miSubtractNonO1, (voidProcp) NULL);
+
+ /*
+ * Can't alter newReg's extents before we call miRegionOp because
+ * it might be one of the source regions and miRegionOp depends
+ * on the extents of those regions being the unaltered. Besides, this
+ * way there's no checking against rectangles that will be nuked
+ * due to coalescing, so we have to examine fewer rectangles.
+ */
+ miSetExtents (regD);
+ return 1;
+}
+
+int
+XXorRegion( sra, srb, dr )
+ Region sra, srb, dr;
+{
+ Region tra, trb;
+
+ if ((! (tra = XCreateRegion())) || (! (trb = XCreateRegion())))
+ return 0;
+ (void) XSubtractRegion(sra,srb,tra);
+ (void) XSubtractRegion(srb,sra,trb);
+ (void) XUnionRegion(tra,trb,dr);
+ XDestroyRegion(tra);
+ XDestroyRegion(trb);
+ return 0;
+}
+
+/*
+ * Check to see if the region is empty. Assumes a region is passed
+ * as a parameter
+ */
+int
+XEmptyRegion( r )
+ Region r;
+{
+ if( r->numRects == 0 ) return TRUE;
+ else return FALSE;
+}
+
+/*
+ * Check to see if two regions are equal
+ */
+int
+XEqualRegion( r1, r2 )
+ Region r1, r2;
+{
+ int i;
+
+ if( r1->numRects != r2->numRects ) return FALSE;
+ else if( r1->numRects == 0 ) return TRUE;
+ else if ( r1->extents.x1 != r2->extents.x1 ) return FALSE;
+ else if ( r1->extents.x2 != r2->extents.x2 ) return FALSE;
+ else if ( r1->extents.y1 != r2->extents.y1 ) return FALSE;
+ else if ( r1->extents.y2 != r2->extents.y2 ) return FALSE;
+ else for( i=0; i < r1->numRects; i++ ) {
+ if ( r1->rects[i].x1 != r2->rects[i].x1 ) return FALSE;
+ else if ( r1->rects[i].x2 != r2->rects[i].x2 ) return FALSE;
+ else if ( r1->rects[i].y1 != r2->rects[i].y1 ) return FALSE;
+ else if ( r1->rects[i].y2 != r2->rects[i].y2 ) return FALSE;
+ }
+ return TRUE;
+}
+
+int
+XPointInRegion( pRegion, x, y )
+ Region pRegion;
+ int x, y;
+{
+ int i;
+
+ if (pRegion->numRects == 0)
+ return FALSE;
+ if (!INBOX(pRegion->extents, x, y))
+ return FALSE;
+ for (i=0; i<pRegion->numRects; i++)
+ {
+ if (INBOX (pRegion->rects[i], x, y))
+ return TRUE;
+ }
+ return FALSE;
+}
+
+int
+XRectInRegion(region, rx, ry, rwidth, rheight)
+ register Region region;
+ int rx, ry;
+ unsigned int rwidth, rheight;
+{
+ register BoxPtr pbox;
+ register BoxPtr pboxEnd;
+ Box rect;
+ register BoxPtr prect = &rect;
+ int partIn, partOut;
+
+ prect->x1 = rx;
+ prect->y1 = ry;
+ prect->x2 = rwidth + rx;
+ prect->y2 = rheight + ry;
+
+ /* this is (just) a useful optimization */
+ if ((region->numRects == 0) || !EXTENTCHECK(&region->extents, prect))
+ return(RectangleOut);
+
+ partOut = FALSE;
+ partIn = FALSE;
+
+ /* can stop when both partOut and partIn are TRUE, or we reach prect->y2 */
+ for (pbox = region->rects, pboxEnd = pbox + region->numRects;
+ pbox < pboxEnd;
+ pbox++)
+ {
+
+ if (pbox->y2 <= ry)
+ continue; /* getting up to speed or skipping remainder of band */
+
+ if (pbox->y1 > ry)
+ {
+ partOut = TRUE; /* missed part of rectangle above */
+ if (partIn || (pbox->y1 >= prect->y2))
+ break;
+ ry = pbox->y1; /* x guaranteed to be == prect->x1 */
+ }
+
+ if (pbox->x2 <= rx)
+ continue; /* not far enough over yet */
+
+ if (pbox->x1 > rx)
+ {
+ partOut = TRUE; /* missed part of rectangle to left */
+ if (partIn)
+ break;
+ }
+
+ if (pbox->x1 < prect->x2)
+ {
+ partIn = TRUE; /* definitely overlap */
+ if (partOut)
+ break;
+ }
+
+ if (pbox->x2 >= prect->x2)
+ {
+ ry = pbox->y2; /* finished with this band */
+ if (ry >= prect->y2)
+ break;
+ rx = prect->x1; /* reset x out to left again */
+ } else
+ {
+ /*
+ * Because boxes in a band are maximal width, if the first box
+ * to overlap the rectangle doesn't completely cover it in that
+ * band, the rectangle must be partially out, since some of it
+ * will be uncovered in that band. partIn will have been set true
+ * by now...
+ */
+ break;
+ }
+
+ }
+
+ return(partIn ? ((ry < prect->y2) ? RectanglePart : RectangleIn) :
+ RectangleOut);
+}
diff --git a/src/RegstFlt.c b/src/RegstFlt.c
new file mode 100644
index 00000000..901e5f30
--- /dev/null
+++ b/src/RegstFlt.c
@@ -0,0 +1,160 @@
+/* $Xorg: RegstFlt.c,v 1.5 2001/02/09 02:03:35 xorgcvs Exp $ */
+
+ /*
+ * Copyright 1990, 1991 by OMRON Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 OMRON not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission. OMRON makes no representations
+ * about the suitability of this software for any purpose. It is provided
+ * "as is" without express or implied warranty.
+ *
+ * OMRON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL OMRON 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
+ * TORTUOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ *
+ * Author: Seiji Kuwari OMRON Corporation
+ * kuwa@omron.co.jp
+ * kuwa%omron.co.jp@uunet.uu.net
+ */
+/*
+
+Copyright 1990, 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+static void
+_XFreeIMFilters(display)
+ Display *display;
+{
+ register XFilterEventList fl;
+
+ while ((fl = display->im_filters)) {
+ display->im_filters = fl->next;
+ Xfree((char *)fl);
+ }
+}
+
+/*
+ * Register a filter with the filter machinery by event mask.
+ */
+void
+_XRegisterFilterByMask(display, window, event_mask, filter, client_data)
+ Display *display;
+ Window window;
+ unsigned long event_mask;
+ Bool (*filter)(
+#if NeedNestedPrototypes
+ Display*, Window, XEvent*, XPointer
+#endif
+ );
+ XPointer client_data;
+{
+ XFilterEventRec *rec;
+
+ rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ if (!rec)
+ return;
+ rec->window = window;
+ rec->event_mask = event_mask;
+ rec->start_type = 0;
+ rec->end_type = 0;
+ rec->filter = filter;
+ rec->client_data = client_data;
+ LockDisplay(display);
+ rec->next = display->im_filters;
+ display->im_filters = rec;
+ display->free_funcs->im_filters = _XFreeIMFilters;
+ UnlockDisplay(display);
+}
+
+/*
+ * Register a filter with the filter machinery by type code.
+ */
+void
+_XRegisterFilterByType(display, window, start_type, end_type,
+ filter, client_data)
+ Display *display;
+ Window window;
+ int start_type;
+ int end_type;
+ Bool (*filter)(
+#if NeedNestedPrototypes
+ Display*, Window, XEvent*, XPointer
+#endif
+ );
+ XPointer client_data;
+{
+ XFilterEventRec *rec;
+
+ rec = (XFilterEventList)Xmalloc(sizeof(XFilterEventRec));
+ if (!rec)
+ return;
+ rec->window = window;
+ rec->event_mask = 0;
+ rec->start_type = start_type;
+ rec->end_type = end_type;
+ rec->filter = filter;
+ rec->client_data = client_data;
+ LockDisplay(display);
+ rec->next = display->im_filters;
+ display->im_filters = rec;
+ display->free_funcs->im_filters = _XFreeIMFilters;
+ UnlockDisplay(display);
+}
+
+void
+_XUnregisterFilter(display, window, filter, client_data)
+ Display *display;
+ Window window;
+ Bool (*filter)(
+#if NeedNestedPrototypes
+ Display*, Window, XEvent*, XPointer
+#endif
+ );
+ XPointer client_data;
+{
+ register XFilterEventList *prev, fl;
+
+ for (prev = &display->im_filters; (fl = *prev); ) {
+ if (fl->window == window &&
+ fl->filter == filter && fl->client_data == client_data) {
+ *prev = fl->next;
+ Xfree((char *)fl);
+ } else
+ prev = &fl->next;
+ }
+}
diff --git a/src/RepWindow.c b/src/RepWindow.c
new file mode 100644
index 00000000..ca1f6315
--- /dev/null
+++ b/src/RepWindow.c
@@ -0,0 +1,47 @@
+/* $Xorg: RepWindow.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XReparentWindow(dpy, w, p, x, y)
+ register Display *dpy;
+ Window w, p;
+ int x, y;
+{
+ register xReparentWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(ReparentWindow, req);
+ req->window = w;
+ req->parent = p;
+ req->x = x;
+ req->y = y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/RestackWs.c b/src/RestackWs.c
new file mode 100644
index 00000000..1051fde6
--- /dev/null
+++ b/src/RestackWs.c
@@ -0,0 +1,67 @@
+/* $Xorg: RestackWs.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XRestackWindows (dpy, windows, n)
+ register Display *dpy;
+ register Window *windows;
+ int n;
+ {
+ int i = 0;
+#ifdef MUSTCOPY
+ unsigned long val = Below; /* needed for macro below */
+#endif
+
+ LockDisplay(dpy);
+ while (windows++, ++i < n) {
+ register xConfigureWindowReq *req;
+
+ GetReqExtra (ConfigureWindow, 8, req);
+ req->window = *windows;
+ req->mask = CWSibling | CWStackMode;
+#ifdef MUSTCOPY
+ dpy->bufptr -= 8;
+ Data32 (dpy, (long *)(windows-1), 4);
+ Data32 (dpy, (long *)&val, 4);
+#else
+ {
+ register CARD32 *values = (CARD32 *)
+ NEXTPTR(req,xConfigureWindowReq);
+ *values++ = *(windows-1);
+ *values = Below;
+ }
+#endif /* MUSTCOPY */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
diff --git a/src/RotProp.c b/src/RotProp.c
new file mode 100644
index 00000000..36c3c1df
--- /dev/null
+++ b/src/RotProp.c
@@ -0,0 +1,60 @@
+/* $Xorg: RotProp.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XRotateWindowProperties(dpy, w, properties, nprops, npositions)
+ register Display *dpy;
+ Window w;
+ Atom *properties;
+ register int nprops;
+ int npositions;
+ {
+ register long nbytes;
+ register xRotatePropertiesReq *req;
+
+ LockDisplay(dpy);
+ GetReq (RotateProperties, req);
+ req->window = w;
+ req->nAtoms = nprops;
+ req->nPositions = npositions;
+
+ req->length += nprops;
+ nbytes = nprops << 2;
+/* XXX Cray needs packing here.... */
+ Data32 (dpy, (long *) properties, nbytes);
+
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
+
+
+
+
diff --git a/src/ScrResStr.c b/src/ScrResStr.c
new file mode 100644
index 00000000..bd996871
--- /dev/null
+++ b/src/ScrResStr.c
@@ -0,0 +1,54 @@
+/* $Xorg: ScrResStr.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+char *XScreenResourceString(screen)
+ Screen *screen;
+{
+ Atom prop_name;
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ char *val = NULL;
+
+ prop_name = XInternAtom(screen->display, "SCREEN_RESOURCES", True);
+ if (prop_name &&
+ XGetWindowProperty(screen->display, screen->root, prop_name,
+ 0L, 100000000L, False,
+ XA_STRING, &actual_type, &actual_format,
+ &nitems, &leftover,
+ (unsigned char **) &val) == Success) {
+ if ((actual_type == XA_STRING) && (actual_format == 8))
+ return val;
+ if (val)
+ Xfree(val);
+ }
+ return (char *)NULL;
+}
diff --git a/src/SelInput.c b/src/SelInput.c
new file mode 100644
index 00000000..c42a6674
--- /dev/null
+++ b/src/SelInput.c
@@ -0,0 +1,46 @@
+/* $Xorg: SelInput.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSelectInput (dpy, w, mask)
+ register Display *dpy;
+ Window w;
+ long mask;
+{
+ register xChangeWindowAttributesReq *req;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWEventMask;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), mask);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/SendEvent.c b/src/SendEvent.c
new file mode 100644
index 00000000..d853e273
--- /dev/null
+++ b/src/SendEvent.c
@@ -0,0 +1,73 @@
+/* $Xorg: SendEvent.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+extern Status _XEventToWire();
+/*
+ * In order to avoid all images requiring _XEventToWire, we install the
+ * event converter here if it has never been installed.
+ */
+Status
+XSendEvent(dpy, w, propagate, event_mask, event)
+ register Display *dpy;
+ Window w;
+ Bool propagate;
+ long event_mask;
+ XEvent *event;
+{
+ register xSendEventReq *req;
+ xEvent ev;
+ register Status (**fp)();
+ Status status;
+
+ LockDisplay (dpy);
+
+ /* call through display to find proper conversion routine */
+
+ fp = &dpy->wire_vec[event->type & 0177];
+ if (*fp == NULL) *fp = _XEventToWire;
+ status = (**fp)(dpy, event, &ev);
+
+ if (status) {
+ GetReq(SendEvent, req);
+ req->destination = w;
+ req->propagate = propagate;
+ req->eventMask = event_mask;
+#ifdef WORD64
+ /* avoid quad-alignment problems */
+ memcpy ((char *) req->eventdata, (char *) &ev, SIZEOF(xEvent));
+#else
+ req->event = ev;
+#endif /* WORD64 */
+ }
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(status);
+}
diff --git a/src/SetBack.c b/src/SetBack.c
new file mode 100644
index 00000000..aea142c9
--- /dev/null
+++ b/src/SetBack.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetBack.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetBackground (dpy, gc, background)
+register Display *dpy;
+GC gc;
+unsigned long background; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.background != background) {
+ gc->values.background = background;
+ gc->dirty |= GCBackground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetCRects.c b/src/SetCRects.c
new file mode 100644
index 00000000..8f03b7de
--- /dev/null
+++ b/src/SetCRects.c
@@ -0,0 +1,79 @@
+/* $Xorg: SetCRects.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+/* can only call when display is locked. */
+void _XSetClipRectangles (dpy, gc, clip_x_origin, clip_y_origin, rectangles, n,
+ ordering)
+ register Display *dpy;
+ GC gc;
+ int clip_x_origin, clip_y_origin;
+ XRectangle *rectangles;
+ int n;
+ int ordering;
+{
+ register xSetClipRectanglesReq *req;
+ register long len;
+ unsigned long dirty;
+ register _XExtension *ext;
+
+ GetReq (SetClipRectangles, req);
+ req->gc = gc->gid;
+ req->xOrigin = gc->values.clip_x_origin = clip_x_origin;
+ req->yOrigin = gc->values.clip_y_origin = clip_y_origin;
+ req->ordering = ordering;
+ len = ((long)n) << 1;
+ SetReqLen(req, len, 1);
+ len <<= 2;
+ Data16 (dpy, (short *) rectangles, len);
+ gc->rects = 1;
+ dirty = gc->dirty & ~(GCClipMask | GCClipXOrigin | GCClipYOrigin);
+ gc->dirty = GCClipMask | GCClipXOrigin | GCClipYOrigin;
+ /* call out to any extensions interested */
+ for (ext = dpy->ext_procs; ext; ext = ext->next)
+ if (ext->flush_GC) (*ext->flush_GC)(dpy, gc, &ext->codes);
+ gc->dirty = dirty;
+}
+
+XSetClipRectangles (dpy, gc, clip_x_origin, clip_y_origin, rectangles, n,
+ ordering)
+ register Display *dpy;
+ GC gc;
+ int clip_x_origin, clip_y_origin;
+ XRectangle *rectangles;
+ int n;
+ int ordering;
+{
+ LockDisplay(dpy);
+ _XSetClipRectangles (dpy, gc, clip_x_origin, clip_y_origin, rectangles, n,
+ ordering);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/SetClMask.c b/src/SetClMask.c
new file mode 100644
index 00000000..75d97ab4
--- /dev/null
+++ b/src/SetClMask.c
@@ -0,0 +1,44 @@
+/* $Xorg: SetClMask.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetClipMask (dpy, gc, mask)
+register Display *dpy;
+GC gc;
+Pixmap mask;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.clip_mask = mask;
+ gc->dirty |= GCClipMask;
+ gc->rects = 0;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetClOrig.c b/src/SetClOrig.c
new file mode 100644
index 00000000..c471234e
--- /dev/null
+++ b/src/SetClOrig.c
@@ -0,0 +1,49 @@
+/* $Xorg: SetClOrig.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetClipOrigin (dpy, gc, xorig, yorig)
+register Display *dpy;
+GC gc;
+int xorig, yorig;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (xorig != gv->clip_x_origin) {
+ gv->clip_x_origin = xorig;
+ gc->dirty |= GCClipXOrigin;
+ }
+ if (yorig != gv->clip_y_origin) {
+ gv->clip_y_origin = yorig;
+ gc->dirty |= GCClipYOrigin;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetDashes.c b/src/SetDashes.c
new file mode 100644
index 00000000..ce3a5e60
--- /dev/null
+++ b/src/SetDashes.c
@@ -0,0 +1,61 @@
+/* $Xorg: SetDashes.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XSetDashes (
+ register Display *dpy,
+ GC gc,
+ int dash_offset,
+ _Xconst char *list,
+ int n)
+#else
+XSetDashes (dpy, gc, dash_offset, list, n)
+ register Display *dpy;
+ GC gc;
+ int dash_offset;
+ char *list;
+ int n;
+#endif
+ {
+ register xSetDashesReq *req;
+
+ LockDisplay(dpy);
+ GetReq (SetDashes,req);
+ req->gc = gc->gid;
+ req->dashOffset = gc->values.dash_offset = dash_offset;
+ req->nDashes = n;
+ req->length += (n+3)>>2;
+ gc->dashes = 1;
+ gc->dirty &= ~(GCDashList | GCDashOffset);
+ Data (dpy, list, (long)n);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+ }
+
diff --git a/src/SetFPath.c b/src/SetFPath.c
new file mode 100644
index 00000000..acf0a1d0
--- /dev/null
+++ b/src/SetFPath.c
@@ -0,0 +1,75 @@
+/* $Xorg: SetFPath.c,v 1.5 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#define safestrlen(s) ((s) ? strlen(s) : 0)
+
+int
+XSetFontPath (dpy, directories, ndirs)
+register Display *dpy;
+char **directories;
+int ndirs;
+{
+ register int n = 0;
+ register int i;
+ register int nbytes;
+ char *p;
+ register xSetFontPathReq *req;
+ int retCode;
+
+ LockDisplay(dpy);
+ GetReq (SetFontPath, req);
+ req->nFonts = ndirs;
+ for (i = 0; i < ndirs; i++) {
+ n += safestrlen (directories[i]) + 1;
+ }
+ nbytes = (n + 3) & ~3;
+ req->length += nbytes >> 2;
+ if ((p = (char *) Xmalloc ((unsigned) nbytes))) {
+ /*
+ * pack into counted strings.
+ */
+ char *tmp = p;
+
+ for (i = 0; i < ndirs; i++) {
+ register int length = safestrlen (directories[i]);
+ *p = length;
+ memcpy (p + 1, directories[i], length);
+ p += length + 1;
+ }
+ Data (dpy, tmp, nbytes);
+ Xfree ((char *) tmp);
+ retCode = 1;
+ }
+ else
+ retCode = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (retCode);
+}
diff --git a/src/SetFont.c b/src/SetFont.c
new file mode 100644
index 00000000..57f7294f
--- /dev/null
+++ b/src/SetFont.c
@@ -0,0 +1,44 @@
+/* $Xorg: SetFont.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetFont (dpy, gc, font)
+register Display *dpy;
+GC gc;
+Font font;
+{
+ LockDisplay(dpy);
+ if (gc->values.font != font) {
+ gc->values.font = font;
+ gc->dirty |= GCFont;
+ _XFlushGCCache(dpy, gc);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetFore.c b/src/SetFore.c
new file mode 100644
index 00000000..d8773494
--- /dev/null
+++ b/src/SetFore.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetFore.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetForeground (dpy, gc, foreground)
+register Display *dpy;
+GC gc;
+unsigned long foreground; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.foreground != foreground) {
+ gc->values.foreground = foreground;
+ gc->dirty |= GCForeground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetFunc.c b/src/SetFunc.c
new file mode 100644
index 00000000..b4154672
--- /dev/null
+++ b/src/SetFunc.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetFunc.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetFunction (dpy, gc, function)
+register Display *dpy;
+GC gc;
+int function;
+{
+ LockDisplay(dpy);
+ if (gc->values.function != function) {
+ gc->values.function = function;
+ gc->dirty |= GCFunction;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetHints.c b/src/SetHints.c
new file mode 100644
index 00000000..f8201921
--- /dev/null
+++ b/src/SetHints.c
@@ -0,0 +1,296 @@
+/* $Xorg: SetHints.c,v 1.5 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+
+#define safestrlen(s) ((s) ? strlen(s) : 0)
+
+XSetSizeHints(dpy, w, hints, property) /* old routine */
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom property;
+{
+ xPropSizeHints prop;
+ prop.flags = (hints->flags & (USPosition|USSize|PAllHints));
+ prop.x = hints->x;
+ prop.y = hints->y;
+ prop.width = hints->width;
+ prop.height = hints->height;
+ prop.minWidth = hints->min_width;
+ prop.minHeight = hints->min_height;
+ prop.maxWidth = hints->max_width;
+ prop.maxHeight = hints->max_height;
+ prop.widthInc = hints->width_inc;
+ prop.heightInc = hints->height_inc;
+ prop.minAspectX = hints->min_aspect.x;
+ prop.minAspectY = hints->min_aspect.y;
+ prop.maxAspectX = hints->max_aspect.x;
+ prop.maxAspectY = hints->max_aspect.y;
+ return XChangeProperty (dpy, w, property, XA_WM_SIZE_HINTS, 32,
+ PropModeReplace, (unsigned char *) &prop,
+ OldNumPropSizeElements);
+}
+
+/*
+ * XSetWMHints sets the property
+ * WM_HINTS type: WM_HINTS format:32
+ */
+
+XSetWMHints (dpy, w, wmhints)
+ Display *dpy;
+ Window w;
+ XWMHints *wmhints;
+{
+ xPropWMHints prop;
+ prop.flags = wmhints->flags;
+ prop.input = (wmhints->input == True ? 1 : 0);
+ prop.initialState = wmhints->initial_state;
+ prop.iconPixmap = wmhints->icon_pixmap;
+ prop.iconWindow = wmhints->icon_window;
+ prop.iconX = wmhints->icon_x;
+ prop.iconY = wmhints->icon_y;
+ prop.iconMask = wmhints->icon_mask;
+ prop.windowGroup = wmhints->window_group;
+ return XChangeProperty (dpy, w, XA_WM_HINTS, XA_WM_HINTS, 32,
+ PropModeReplace, (unsigned char *) &prop,
+ NumPropWMHintsElements);
+}
+
+
+
+/*
+ * XSetZoomHints sets the property
+ * WM_ZOOM_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+XSetZoomHints (dpy, w, zhints)
+ Display *dpy;
+ Window w;
+ XSizeHints *zhints;
+{
+ return XSetSizeHints (dpy, w, zhints, XA_WM_ZOOM_HINTS);
+}
+
+
+/*
+ * XSetNormalHints sets the property
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+XSetNormalHints (dpy, w, hints) /* old routine */
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ return XSetSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
+}
+
+
+
+/*
+ * Note, the following is one of the few cases were we really do want sizeof
+ * when examining a protocol structure. This is because the XChangeProperty
+ * routine will take care of converting to host to network data structures.
+ */
+
+XSetIconSizes (dpy, w, list, count)
+ Display *dpy;
+ Window w; /* typically, root */
+ XIconSize *list;
+ int count; /* number of items on the list */
+{
+ register int i;
+ xPropIconSize *pp, *prop;
+#define size_of_the_real_thing sizeof /* avoid grepping screwups */
+ unsigned nbytes = count * size_of_the_real_thing(xPropIconSize);
+#undef size_of_the_real_thing
+ if ((prop = pp = (xPropIconSize *) Xmalloc (nbytes))) {
+ for (i = 0; i < count; i++) {
+ pp->minWidth = list->min_width;
+ pp->minHeight = list->min_height;
+ pp->maxWidth = list->max_width;
+ pp->maxHeight = list->max_height;
+ pp->widthInc = list->width_inc;
+ pp->heightInc = list->height_inc;
+ pp += 1;
+ list += 1;
+ }
+ XChangeProperty (dpy, w, XA_WM_ICON_SIZE, XA_WM_ICON_SIZE, 32,
+ PropModeReplace, (unsigned char *) prop,
+ count * NumPropIconSizeElements);
+ Xfree ((char *)prop);
+ }
+ return 1;
+}
+
+XSetCommand (dpy, w, argv, argc)
+ Display *dpy;
+ Window w;
+ char **argv;
+ int argc;
+{
+ register int i;
+ register int nbytes;
+ register char *buf, *bp;
+ for (i = 0, nbytes = 0; i < argc; i++) {
+ nbytes += safestrlen(argv[i]) + 1;
+ }
+ if ((bp = buf = Xmalloc((unsigned) nbytes))) {
+ /* copy arguments into single buffer */
+ for (i = 0; i < argc; i++) {
+ if (argv[i]) {
+ (void) strcpy(bp, argv[i]);
+ bp += strlen(argv[i]) + 1;
+ }
+ else
+ *bp++ = '\0';
+ }
+ XChangeProperty (dpy, w, XA_WM_COMMAND, XA_STRING, 8,
+ PropModeReplace, (unsigned char *)buf, nbytes);
+ Xfree(buf);
+ }
+ return 1;
+}
+/*
+ * XSetStandardProperties sets the following properties:
+ * WM_NAME type: STRING format: 8
+ * WM_ICON_NAME type: STRING format: 8
+ * WM_HINTS type: WM_HINTS format: 32
+ * WM_COMMAND type: STRING
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ */
+
+#if NeedFunctionPrototypes
+XSetStandardProperties (
+ Display *dpy,
+ Window w, /* window to decorate */
+ _Xconst char *name, /* name of application */
+ _Xconst char *icon_string,/* name string for icon */
+ Pixmap icon_pixmap, /* pixmap to use as icon, or None */
+ char **argv, /* command to be used to restart application */
+ int argc, /* count of arguments */
+ XSizeHints *hints) /* size hints for window in its normal state */
+#else
+XSetStandardProperties (dpy, w, name, icon_string, icon_pixmap, argv, argc, hints)
+ Display *dpy;
+ Window w; /* window to decorate */
+ char *name; /* name of application */
+ char *icon_string; /* name string for icon */
+ Pixmap icon_pixmap; /* pixmap to use as icon, or None */
+ char **argv; /* command to be used to restart application */
+ int argc; /* count of arguments */
+ XSizeHints *hints; /* size hints for window in its normal state */
+#endif
+{
+ XWMHints phints;
+ phints.flags = 0;
+
+ if (name != NULL) XStoreName (dpy, w, name);
+
+ if (icon_string != NULL) {
+ XChangeProperty (dpy, w, XA_WM_ICON_NAME, XA_STRING, 8,
+ PropModeReplace, (unsigned char *)icon_string, safestrlen(icon_string));
+ }
+
+ if (icon_pixmap != None) {
+ phints.icon_pixmap = icon_pixmap;
+ phints.flags |= IconPixmapHint;
+ }
+ if (argv != NULL) XSetCommand(dpy, w, argv, argc);
+
+ if (hints != NULL) XSetNormalHints(dpy, w, hints);
+
+ if (phints.flags != 0) XSetWMHints(dpy, w, &phints);
+
+ return 1;
+}
+
+XSetTransientForHint(dpy, w, propWindow)
+ Display *dpy;
+ Window w;
+ Window propWindow;
+{
+ return XChangeProperty(dpy, w, XA_WM_TRANSIENT_FOR, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) &propWindow, 1);
+}
+
+XSetClassHint(dpy, w, classhint)
+ Display *dpy;
+ Window w;
+ XClassHint *classhint;
+{
+ char *class_string;
+ char *s;
+ int len_nm, len_cl;
+
+ len_nm = safestrlen(classhint->res_name);
+ len_cl = safestrlen(classhint->res_class);
+ if ((class_string = s = Xmalloc((unsigned) (len_nm + len_cl + 2)))) {
+ if (len_nm) {
+ strcpy(s, classhint->res_name);
+ s += len_nm + 1;
+ }
+ else
+ *s++ = '\0';
+ if (len_cl)
+ strcpy(s, classhint->res_class);
+ else
+ *s = '\0';
+ XChangeProperty(dpy, w, XA_WM_CLASS, XA_STRING, 8,
+ PropModeReplace, (unsigned char *) class_string,
+ len_nm+len_cl+2);
+ Xfree(class_string);
+ }
+ return 1;
+}
diff --git a/src/SetIFocus.c b/src/SetIFocus.c
new file mode 100644
index 00000000..550a8cba
--- /dev/null
+++ b/src/SetIFocus.c
@@ -0,0 +1,47 @@
+/* $Xorg: SetIFocus.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetInputFocus(dpy, focus, revert_to, time)
+ register Display *dpy;
+ Window focus;
+ int revert_to;
+ Time time;
+{
+ register xSetInputFocusReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetInputFocus, req);
+ req->focus = focus;
+ req->revertTo = revert_to;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/SetLStyle.c b/src/SetLStyle.c
new file mode 100644
index 00000000..a0352407
--- /dev/null
+++ b/src/SetLStyle.c
@@ -0,0 +1,60 @@
+/* $Xorg: SetLStyle.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetLineAttributes(dpy, gc, linewidth, linestyle, capstyle, joinstyle)
+register Display *dpy;
+GC gc;
+unsigned int linewidth; /* CARD16 */
+int linestyle;
+int capstyle;
+int joinstyle;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (linewidth != gv->line_width) {
+ gv->line_width = linewidth;
+ gc->dirty |= GCLineWidth;
+ }
+ if (linestyle != gv->line_style) {
+ gv->line_style = linestyle;
+ gc->dirty |= GCLineStyle;
+ }
+ if (capstyle != gv->cap_style) {
+ gv->cap_style = capstyle;
+ gc->dirty |= GCCapStyle;
+ }
+ if (joinstyle != gv->join_style) {
+ gv->join_style = joinstyle;
+ gc->dirty |= GCJoinStyle;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetLocale.c b/src/SetLocale.c
new file mode 100644
index 00000000..faa72941
--- /dev/null
+++ b/src/SetLocale.c
@@ -0,0 +1,230 @@
+/* $Xorg: SetLocale.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 names of OMRON, NTT Software, and NTT
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. OMRON, NTT Software,
+ * and NTT make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, AND NTT, DISCLAIM ALL WARRANTIES WITH REGARD
+ * TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS, IN NO EVENT SHALL OMRON, NTT SOFTWARE, OR NTT, 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tetsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Corporation
+ *
+ */
+/*
+
+Copyright 1987,1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <X11/Xlocale.h>
+#include <X11/Xos.h>
+
+#ifdef X_LOCALE
+
+/* alternative setlocale() for when the OS does not provide one */
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+#if NeedFunctionPrototypes
+char *
+_Xsetlocale(
+ int category,
+ _Xconst char *name
+)
+#else
+char *
+_Xsetlocale(category, name)
+ int category;
+ char *name;
+#endif
+{
+ static char *xsl_name;
+ char *old_name;
+ XrmMethods methods;
+ XPointer state;
+
+ if (category != LC_CTYPE && category != LC_ALL)
+ return NULL;
+ if (!name) {
+ if (xsl_name)
+ return xsl_name;
+ return "C";
+ }
+ if (!*name)
+ name = getenv("LC_CTYPE");
+ if (!name || !*name)
+ name = getenv("LANG");
+ if (!name || !*name || !_XOpenLC(name))
+ name = "C";
+ old_name = xsl_name;
+ xsl_name = (char *)name;
+ methods = _XrmInitParseInfo(&state);
+ xsl_name = old_name;
+ if (!methods)
+ return NULL;
+ name = (*methods->lcname)(state);
+ xsl_name = Xmalloc(strlen(name) + 1);
+ if (!xsl_name) {
+ xsl_name = old_name;
+ (*methods->destroy)(state);
+ return NULL;
+ }
+ strcpy(xsl_name, name);
+ if (old_name)
+ Xfree(old_name);
+ (*methods->destroy)(state);
+ return xsl_name;
+}
+
+#else /* X_LOCALE */
+
+/*
+ * _XlcMapOSLocaleName is an implementation dependent routine that derives
+ * the LC_CTYPE locale name as used in the sample implementation from that
+ * returned by setlocale.
+ *
+ * Should match the code in Xt ExtractLocaleName.
+ *
+ * This function name is a bit of a misnomer. Even the siname parameter
+ * name is a misnomer. On most modern operating systems this function is
+ * a no-op, simply returning the osname; but on older operating systems
+ * like Ultrix, or HPUX 9.x and earlier, when you set LANG=german.88591
+ * then the string returned by setlocale(LC_ALL, "") will look something
+ * like: "german.88591 german.88591 ... german.88591". Then this function
+ * will pick out the LC_CTYPE component and return a pointer to that.
+ */
+
+char *
+_XlcMapOSLocaleName(osname, siname)
+ char *osname;
+ char *siname;
+{
+#if defined(hpux) || defined(CSRG_BASED) || defined(sun) || defined(SVR4) || defined(sgi) || defined(__osf__) || defined(AIXV3) || defined(ultrix) || defined(WIN32)
+#ifdef hpux
+#ifndef _LastCategory
+/* HPUX 9 and earlier */
+#define SKIPCOUNT 2
+#define STARTCHAR ':'
+#define ENDCHAR ';'
+#else
+/* HPUX 10 */
+#define ENDCHAR ' '
+#endif
+#else
+#ifdef ultrix
+#define SKIPCOUNT 2
+#define STARTCHAR '\001'
+#define ENDCHAR '\001'
+#else
+#ifdef WIN32
+#define SKIPCOUNT 1
+#define STARTCHAR '='
+#define ENDCHAR ';'
+#define WHITEFILL
+#else
+#if defined(__osf__) || (defined(AIXV3) && !defined(AIXV4))
+#define STARTCHAR ' '
+#define ENDCHAR ' '
+#else
+#if !defined(sun) || defined(SVR4)
+#define STARTCHAR '/'
+#endif
+#define ENDCHAR '/'
+#endif
+#endif
+#endif
+#endif
+
+ char *start;
+ char *end;
+ int len;
+#ifdef SKIPCOUNT
+ int n;
+#endif
+
+ start = osname;
+#ifdef SKIPCOUNT
+ for (n = SKIPCOUNT;
+ --n >= 0 && start && (start = strchr (start, STARTCHAR));
+ start++)
+ ;
+ if (!start)
+ start = osname;
+#endif
+#ifdef STARTCHAR
+ if (start && (start = strchr (start, STARTCHAR))) {
+ start++;
+#endif
+ if (end = strchr (start, ENDCHAR)) {
+ len = end - start;
+ strncpy(siname, start, len);
+ *(siname + len) = '\0';
+#ifdef WHITEFILL
+ for (start = siname; start = strchr(start, ' '); )
+ *start++ = '-';
+#endif
+ return siname;
+#ifdef STARTCHAR
+ }
+#endif
+ }
+#ifdef WHITEFILL
+ if (strchr(osname, ' ')) {
+ strcpy(siname, osname);
+ for (start = siname; start = strchr(start, ' '); )
+ *start++ = '-';
+ return siname;
+ }
+#endif
+#undef STARTCHAR
+#undef ENDCHAR
+#undef WHITEFILL
+#endif
+ return osname;
+}
+
+#endif /* X_LOCALE */
diff --git a/src/SetNrmHint.c b/src/SetNrmHint.c
new file mode 100644
index 00000000..d8511a6f
--- /dev/null
+++ b/src/SetNrmHint.c
@@ -0,0 +1,108 @@
+/* $Xorg: SetNrmHint.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca,
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL AND WYSE DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL DIGITAL OR WYSE 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.
+
+******************************************************************/
+/*
+
+Copyright 1987, 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+
+void XSetWMSizeHints (dpy, w, hints, prop)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+ Atom prop;
+{
+ xPropSizeHints data;
+
+ data.flags = (hints->flags &
+ (USPosition|USSize|PPosition|PSize|PMinSize|PMaxSize|
+ PResizeInc|PAspect|PBaseSize|PWinGravity));
+
+ /*
+ * The x, y, width, and height fields are obsolete; but, applications
+ * that want to work with old window managers might set them.
+ */
+ data.x = hints->x;
+ data.y = hints->y;
+ data.width = hints->width;
+ data.height = hints->height;
+
+ data.minWidth = hints->min_width;
+ data.minHeight = hints->min_height;
+ data.maxWidth = hints->max_width;
+ data.maxHeight = hints->max_height;
+ data.widthInc = hints->width_inc;
+ data.heightInc = hints->height_inc;
+ data.minAspectX = hints->min_aspect.x;
+ data.minAspectY = hints->min_aspect.y;
+ data.maxAspectX = hints->max_aspect.x;
+ data.maxAspectY = hints->max_aspect.y;
+ data.baseWidth = hints->base_width;
+ data.baseHeight = hints->base_height;
+ data.winGravity = hints->win_gravity;
+
+ XChangeProperty (dpy, w, prop, XA_WM_SIZE_HINTS, 32,
+ PropModeReplace, (unsigned char *) &data,
+ NumPropSizeElements);
+}
+
+
+void XSetWMNormalHints (dpy, w, hints)
+ Display *dpy;
+ Window w;
+ XSizeHints *hints;
+{
+ XSetWMSizeHints (dpy, w, hints, XA_WM_NORMAL_HINTS);
+}
+
diff --git a/src/SetPMask.c b/src/SetPMask.c
new file mode 100644
index 00000000..d712c12b
--- /dev/null
+++ b/src/SetPMask.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetPMask.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetPlaneMask (dpy, gc, planemask)
+register Display *dpy;
+GC gc;
+unsigned long planemask; /* CARD32 */
+{
+ LockDisplay(dpy);
+ if (gc->values.plane_mask != planemask) {
+ gc->values.plane_mask = planemask;
+ gc->dirty |= GCPlaneMask;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetPntMap.c b/src/SetPntMap.c
new file mode 100644
index 00000000..52971616
--- /dev/null
+++ b/src/SetPntMap.c
@@ -0,0 +1,84 @@
+/* $Xorg: SetPntMap.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+
+#include "Xlibint.h"
+/* returns either DeviceMappingSuccess or DeviceMappingBusy */
+
+#if NeedFunctionPrototypes
+int XSetPointerMapping (
+ register Display *dpy,
+ _Xconst unsigned char *map,
+ int nmaps)
+#else
+int XSetPointerMapping (dpy, map, nmaps)
+ register Display *dpy;
+ unsigned char *map;
+ int nmaps;
+#endif
+ {
+ register xSetPointerMappingReq *req;
+ xSetPointerMappingReply rep;
+
+ LockDisplay(dpy);
+ GetReq (SetPointerMapping, req);
+ req->nElts = nmaps;
+ req->length += (nmaps + 3)>>2;
+ Data (dpy, (char *)map, (long) nmaps);
+ if (_XReply (dpy, (xReply *)&rep, 0, xFalse) == 0)
+ rep.success = MappingSuccess;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int) rep.success);
+ }
+
+XChangeKeyboardMapping (dpy, first_keycode, keysyms_per_keycode,
+ keysyms, nkeycodes)
+ register Display *dpy;
+ int first_keycode;
+ int keysyms_per_keycode;
+ KeySym *keysyms;
+ int nkeycodes;
+ {
+ register long nbytes;
+ register xChangeKeyboardMappingReq *req;
+
+ LockDisplay(dpy);
+ GetReq (ChangeKeyboardMapping, req);
+ req->firstKeyCode = first_keycode;
+ req->keyCodes = nkeycodes;
+ req->keySymsPerKeyCode = keysyms_per_keycode;
+ req->firstKeyCode = first_keycode;
+ req->length += nkeycodes * keysyms_per_keycode;
+ nbytes = keysyms_per_keycode * nkeycodes * 4;
+ Data32 (dpy, (long *)keysyms, nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+ }
+
diff --git a/src/SetRGBCMap.c b/src/SetRGBCMap.c
new file mode 100644
index 00000000..0523f0ba
--- /dev/null
+++ b/src/SetRGBCMap.c
@@ -0,0 +1,98 @@
+/* $Xorg: SetRGBCMap.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+void XSetRGBColormaps (dpy, w, cmaps, count, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmaps;
+ int count;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ register int i; /* iterator variable */
+ register xPropStandardColormap *map; /* tmp variable, data in prop */
+ register XStandardColormap *cmap; /* tmp variable, user data */
+ xPropStandardColormap *data, tmpdata; /* scratch data */
+ int mode = PropModeReplace; /* for partial writes */
+ Bool alloced_scratch_space; /* do we need to free? */
+
+
+ if (count < 1) return;
+
+ /*
+ * if doing more than one, allocate scratch space for it
+ */
+ if ((count > 1) && ((data = ((xPropStandardColormap *)
+ Xmalloc(count*sizeof(xPropStandardColormap))))
+ != NULL)) {
+ alloced_scratch_space = True;
+ } else {
+ data = &tmpdata;
+ alloced_scratch_space = False;
+ }
+
+
+ /*
+ * Do the iteration. If using temp space put out each part of the prop;
+ * otherwise, wait until the end and blast it all at once.
+ */
+ for (i = count, map = data, cmap = cmaps; i > 0; i--, cmap++) {
+ map->colormap = cmap->colormap;
+ map->red_max = cmap->red_max;
+ map->red_mult = cmap->red_mult;
+ map->green_max = cmap->green_max;
+ map->green_mult = cmap->green_mult;
+ map->blue_max = cmap->blue_max;
+ map->blue_mult = cmap->blue_mult;
+ map->base_pixel = cmap->base_pixel;
+ map->visualid = cmap->visualid;
+ map->killid = cmap->killid;
+
+ if (alloced_scratch_space) {
+ map++;
+ } else {
+ XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32, mode,
+ (unsigned char *) data,
+ NumPropStandardColormapElements);
+ mode = PropModeAppend;
+ }
+ }
+
+ if (alloced_scratch_space) {
+ XChangeProperty (dpy, w, property, XA_RGB_COLOR_MAP, 32,
+ PropModeReplace, (unsigned char *) data,
+ (int) (count * NumPropStandardColormapElements));
+ Xfree ((char *) data);
+ }
+}
diff --git a/src/SetSOwner.c b/src/SetSOwner.c
new file mode 100644
index 00000000..67fc6ba2
--- /dev/null
+++ b/src/SetSOwner.c
@@ -0,0 +1,46 @@
+/* $Xorg: SetSOwner.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetSelectionOwner(dpy, selection, owner, time)
+register Display *dpy;
+Atom selection;
+Window owner;
+Time time;
+{
+ register xSetSelectionOwnerReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetSelectionOwner,req);
+ req->selection = selection;
+ req->window = owner;
+ req->time = time;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetSSaver.c b/src/SetSSaver.c
new file mode 100644
index 00000000..42ca05b0
--- /dev/null
+++ b/src/SetSSaver.c
@@ -0,0 +1,47 @@
+/* $Xorg: SetSSaver.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetScreenSaver(dpy, timeout, interval, prefer_blank, allow_exp)
+ register Display *dpy;
+ int timeout, interval, prefer_blank, allow_exp;
+
+{
+ register xSetScreenSaverReq *req;
+
+ LockDisplay(dpy);
+ GetReq(SetScreenSaver, req);
+ req->timeout = timeout;
+ req->interval = interval;
+ req->preferBlank = prefer_blank;
+ req->allowExpose = allow_exp;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/SetStCmap.c b/src/SetStCmap.c
new file mode 100644
index 00000000..86ff4c8e
--- /dev/null
+++ b/src/SetStCmap.c
@@ -0,0 +1,90 @@
+/* $Xorg: SetStCmap.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include "Xatomtype.h"
+#include <X11/Xatom.h>
+
+/*
+ * WARNING
+ *
+ * This is a pre-ICCCM routine. It must not reference any of the new fields
+ * in the XStandardColormap structure.
+ */
+
+void XSetStandardColormap(dpy, w, cmap, property)
+ Display *dpy;
+ Window w;
+ XStandardColormap *cmap;
+ Atom property; /* XA_RGB_BEST_MAP, etc. */
+{
+ Screen *sp;
+ XStandardColormap stdcmap;
+
+ sp = _XScreenOfWindow (dpy, w);
+ if (!sp) {
+ /* already caught the XGetGeometry error in _XScreenOfWindow */
+ return;
+ }
+
+ stdcmap.colormap = cmap->colormap;
+ stdcmap.red_max = cmap->red_max;
+ stdcmap.red_mult = cmap->red_mult;
+ stdcmap.green_max = cmap->green_max;
+ stdcmap.green_mult = cmap->green_mult;
+ stdcmap.blue_max = cmap->blue_max;
+ stdcmap.blue_mult = cmap->blue_mult;
+ stdcmap.base_pixel = cmap->base_pixel;
+ stdcmap.visualid = sp->root_visual->visualid;
+ stdcmap.killid = None; /* don't know how to kill this one */
+
+ XSetRGBColormaps (dpy, w, &stdcmap, 1, property);
+ return;
+}
diff --git a/src/SetState.c b/src/SetState.c
new file mode 100644
index 00000000..ad91d8fa
--- /dev/null
+++ b/src/SetState.c
@@ -0,0 +1,60 @@
+/* $Xorg: SetState.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetState(dpy, gc, foreground, background, function, planemask)
+register Display *dpy;
+GC gc;
+int function;
+unsigned long planemask;
+unsigned long foreground, background;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+
+ if (function != gv->function) {
+ gv->function = function;
+ gc->dirty |= GCFunction;
+ }
+ if (planemask != gv->plane_mask) {
+ gv->plane_mask = planemask;
+ gc->dirty |= GCPlaneMask;
+ }
+ if (foreground != gv->foreground) {
+ gv->foreground = foreground;
+ gc->dirty |= GCForeground;
+ }
+ if (background != gv->background) {
+ gv->background = background;
+ gc->dirty |= GCBackground;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetStip.c b/src/SetStip.c
new file mode 100644
index 00000000..3c6948f3
--- /dev/null
+++ b/src/SetStip.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetStip.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetStipple (dpy, gc, stipple)
+register Display *dpy;
+GC gc;
+Pixmap stipple;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.stipple = stipple;
+ gc->dirty |= GCStipple;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetTSOrig.c b/src/SetTSOrig.c
new file mode 100644
index 00000000..6f6a2bad
--- /dev/null
+++ b/src/SetTSOrig.c
@@ -0,0 +1,49 @@
+/* $Xorg: SetTSOrig.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetTSOrigin (dpy, gc, x, y)
+register Display *dpy;
+GC gc;
+int x, y;
+{
+ XGCValues *gv = &gc->values;
+
+ LockDisplay(dpy);
+ if (x != gv->ts_x_origin) {
+ gv->ts_x_origin = x;
+ gc->dirty |= GCTileStipXOrigin;
+ }
+ if (y != gv->ts_y_origin) {
+ gv->ts_y_origin = y;
+ gc->dirty |= GCTileStipYOrigin;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetTile.c b/src/SetTile.c
new file mode 100644
index 00000000..296e74aa
--- /dev/null
+++ b/src/SetTile.c
@@ -0,0 +1,43 @@
+/* $Xorg: SetTile.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XSetTile (dpy, gc, tile)
+register Display *dpy;
+GC gc;
+Pixmap tile;
+{
+ LockDisplay(dpy);
+ /* always update, since client may have changed pixmap contents */
+ gc->values.tile = tile;
+ gc->dirty |= GCTile;
+ _XFlushGCCache(dpy, gc);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/SetTxtProp.c b/src/SetTxtProp.c
new file mode 100644
index 00000000..73bee7e1
--- /dev/null
+++ b/src/SetTxtProp.c
@@ -0,0 +1,91 @@
+/* $Xorg: SetTxtProp.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.
+
+ All Rights Reserved
+
+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 Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+#include <stdio.h>
+
+void XSetTextProperty (dpy, w, tp, property)
+ Display *dpy;
+ Window w;
+ Atom property;
+ XTextProperty *tp;
+{
+ XChangeProperty (dpy, w, property, tp->encoding, tp->format,
+ PropModeReplace, tp->value, tp->nitems);
+}
+
+void XSetWMName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_NAME);
+}
+
+void XSetWMIconName (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_ICON_NAME);
+}
+
+void XSetWMClientMachine (dpy, w, tp)
+ Display *dpy;
+ Window w;
+ XTextProperty *tp;
+{
+ XSetTextProperty (dpy, w, tp, XA_WM_CLIENT_MACHINE);
+}
+
diff --git a/src/SetWMCMapW.c b/src/SetWMCMapW.c
new file mode 100644
index 00000000..bf56a023
--- /dev/null
+++ b/src/SetWMCMapW.c
@@ -0,0 +1,72 @@
+/* $Xorg: SetWMCMapW.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+/*
+ * XSetWMProtocols sets the property
+ * WM_COLORMAP_WINDOWS type: WINDOW format:32
+ */
+
+Status XSetWMColormapWindows (dpy, w, windows, count)
+ Display *dpy;
+ Window w;
+ Window *windows;
+ int count;
+{
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_COLORMAP_WINDOWS", False);
+ if (prop == None) return False;
+
+ XChangeProperty (dpy, w, prop, XA_WINDOW, 32,
+ PropModeReplace, (unsigned char *) windows, count);
+ return True;
+}
diff --git a/src/SetWMProto.c b/src/SetWMProto.c
new file mode 100644
index 00000000..15ebd76a
--- /dev/null
+++ b/src/SetWMProto.c
@@ -0,0 +1,72 @@
+/* $Xorg: SetWMProto.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include "Xlibint.h"
+#include <X11/Xatom.h>
+
+/*
+ * XSetWMProtocols sets the property
+ * WM_PROTOCOLS type: ATOM format: 32
+ */
+
+Status XSetWMProtocols (dpy, w, protocols, count)
+ Display *dpy;
+ Window w;
+ Atom *protocols;
+ int count;
+{
+ Atom prop;
+
+ prop = XInternAtom (dpy, "WM_PROTOCOLS", False);
+ if (prop == None) return False;
+
+ XChangeProperty (dpy, w, prop, XA_ATOM, 32,
+ PropModeReplace, (unsigned char *) protocols, count);
+ return True;
+}
diff --git a/src/StBytes.c b/src/StBytes.c
new file mode 100644
index 00000000..880745f3
--- /dev/null
+++ b/src/StBytes.c
@@ -0,0 +1,114 @@
+/* $Xorg: StBytes.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+
+/* insulate predefined atom numbers from cut routines */
+static Atom n_to_atom[8] = {
+ XA_CUT_BUFFER0,
+ XA_CUT_BUFFER1,
+ XA_CUT_BUFFER2,
+ XA_CUT_BUFFER3,
+ XA_CUT_BUFFER4,
+ XA_CUT_BUFFER5,
+ XA_CUT_BUFFER6,
+ XA_CUT_BUFFER7};
+
+XRotateBuffers (dpy, rotate)
+ register Display *dpy;
+ int rotate;
+{
+ return XRotateWindowProperties(dpy, RootWindow(dpy, 0), n_to_atom, 8, rotate);
+}
+
+char *XFetchBuffer (dpy, nbytes, buffer)
+ register Display *dpy;
+ int *nbytes;
+ register int buffer;
+{
+ Atom actual_type;
+ int actual_format;
+ unsigned long nitems;
+ unsigned long leftover;
+ unsigned char *data;
+ *nbytes = 0;
+ if ((buffer < 0) || (buffer > 7)) return (NULL);
+/* XXX should be (sizeof (maxint) - 1)/4 */
+ if (XGetWindowProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
+ 0L, 10000000L, False, XA_STRING,
+ &actual_type, &actual_format, &nitems, &leftover, &data) != Success) {
+ return (NULL);
+ }
+ if ( (actual_type == XA_STRING) && (actual_format != 32) ) {
+ *nbytes = nitems;
+ return((char *)data);
+ }
+ if ((char *) data != NULL) Xfree ((char *)data);
+ return(NULL);
+}
+
+char *XFetchBytes (dpy, nbytes)
+ register Display *dpy;
+ int *nbytes;
+{
+ return (XFetchBuffer (dpy, nbytes, 0));
+}
+
+#if NeedFunctionPrototypes
+XStoreBuffer (
+ register Display *dpy,
+ _Xconst char *bytes,
+ int nbytes,
+ register int buffer)
+#else
+XStoreBuffer (dpy, bytes, nbytes, buffer)
+ register Display *dpy;
+ char *bytes;
+ int nbytes;
+ register int buffer;
+#endif
+{
+ if ((buffer < 0) || (buffer > 7)) return 0;
+ return XChangeProperty(dpy, RootWindow(dpy, 0), n_to_atom[buffer],
+ XA_STRING, 8, PropModeReplace, (unsigned char *) bytes, nbytes);
+}
+
+#if NeedFunctionPrototypes
+XStoreBytes (
+ register Display *dpy,
+ _Xconst char *bytes,
+ int nbytes)
+#else
+XStoreBytes (dpy, bytes, nbytes)
+ register Display *dpy;
+ char *bytes;
+ int nbytes;
+#endif
+{
+ return XStoreBuffer (dpy, bytes, nbytes, 0);
+}
diff --git a/src/StColor.c b/src/StColor.c
new file mode 100644
index 00000000..332fdf49
--- /dev/null
+++ b/src/StColor.c
@@ -0,0 +1,67 @@
+/* $Xorg: StColor.c,v 1.4 2001/02/09 02:03:36 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XStoreColor(dpy, cmap, def)
+register Display *dpy;
+Colormap cmap;
+XColor *def;
+{
+ xColorItem *citem;
+ register xStoreColorsReq *req;
+#ifdef MUSTCOPY
+ xColorItem citemdata;
+ long len = SIZEOF(xColorItem);
+
+ citem = &citemdata;
+#endif /* MUSTCOPY */
+
+ LockDisplay(dpy);
+ GetReqExtra(StoreColors, SIZEOF(xColorItem), req); /* assume size is 4*n */
+
+ req->cmap = cmap;
+
+#ifndef MUSTCOPY
+ citem = (xColorItem *) NEXTPTR(req,xStoreColorsReq);
+#endif /* not MUSTCOPY */
+
+ citem->pixel = def->pixel;
+ citem->red = def->red;
+ citem->green = def->green;
+ citem->blue = def->blue;
+ citem->flags = def->flags; /* do_red, do_green, do_blue */
+
+#ifdef MUSTCOPY
+ dpy->bufptr -= SIZEOF(xColorItem); /* adjust for GetReqExtra */
+ Data (dpy, (char *) citem, len);
+#endif /* MUSTCOPY */
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/StColors.c b/src/StColors.c
new file mode 100644
index 00000000..cf970950
--- /dev/null
+++ b/src/StColors.c
@@ -0,0 +1,62 @@
+/* $Xorg: StColors.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XStoreColors(dpy, cmap, defs, ncolors)
+register Display *dpy;
+Colormap cmap;
+XColor *defs;
+int ncolors;
+{
+ register int i;
+ xColorItem citem;
+ register xStoreColorsReq *req;
+
+ LockDisplay(dpy);
+ GetReq(StoreColors, req);
+
+ req->cmap = cmap;
+
+ req->length += (ncolors * SIZEOF(xColorItem)) >> 2; /* assume size is 4*n */
+
+ for (i = 0; i < ncolors; i++) {
+ citem.pixel = defs[i].pixel;
+ citem.red = defs[i].red;
+ citem.green = defs[i].green;
+ citem.blue = defs[i].blue;
+ citem.flags = defs[i].flags;
+
+ /* note that xColorItem doesn't contain all 16-bit quantities, so
+ we can't use Data16 */
+ Data(dpy, (char *)&citem, (long) SIZEOF(xColorItem));
+ /* assume size is 4*n */
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/StNColor.c b/src/StNColor.c
new file mode 100644
index 00000000..04d27d87
--- /dev/null
+++ b/src/StNColor.c
@@ -0,0 +1,92 @@
+/* $Xorg: StNColor.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern void _XcmsRGB_to_XColor();
+
+#if NeedFunctionPrototypes
+XStoreNamedColor(
+register Display *dpy,
+Colormap cmap,
+_Xconst char *name, /* STRING8 */
+unsigned long pixel, /* CARD32 */
+int flags) /* DoRed, DoGreen, DoBlue */
+#else
+XStoreNamedColor(dpy, cmap, name, pixel, flags)
+register Display *dpy;
+Colormap cmap;
+char *name; /* STRING8 */
+unsigned long pixel; /* CARD32 */
+int flags; /* DoRed, DoGreen, DoBlue */
+#endif
+{
+ unsigned int nbytes;
+ register xStoreNamedColorReq *req;
+ XcmsCCC ccc;
+ XcmsColor cmsColor_exact;
+ XColor scr_def;
+
+ /*
+ * Let's Attempt to use Xcms approach to Parse Color
+ */
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) != (XcmsCCC)NULL) {
+ if (_XcmsResolveColorString(ccc, &name, &cmsColor_exact,
+ XcmsRGBFormat) >= XcmsSuccess) {
+ _XcmsRGB_to_XColor(&cmsColor_exact, &scr_def, 1);
+ scr_def.pixel = pixel;
+ scr_def.flags = flags;
+ return XStoreColor(dpy, cmap, &scr_def);
+ }
+ /*
+ * Otherwise we failed; or name was changed with yet another
+ * name. Thus pass name to the X Server.
+ */
+ }
+
+ /*
+ * The Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ LockDisplay(dpy);
+ GetReq(StoreNamedColor, req);
+
+ req->cmap = cmap;
+ req->flags = flags;
+ req->pixel = pixel;
+ req->nbytes = nbytes = strlen(name);
+ req->length += (nbytes + 3) >> 2; /* round up to multiple of 4 */
+ Data(dpy, name, (long)nbytes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+
diff --git a/src/StName.c b/src/StName.c
new file mode 100644
index 00000000..80fc2dcf
--- /dev/null
+++ b/src/StName.c
@@ -0,0 +1,63 @@
+/* $Xorg: StName.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+
+#if NeedFunctionPrototypes
+XStoreName (
+ register Display *dpy,
+ Window w,
+ _Xconst char *name)
+#else
+XStoreName (dpy, w, name)
+ register Display *dpy;
+ Window w;
+ char *name;
+#endif
+{
+ return XChangeProperty(dpy, w, XA_WM_NAME, XA_STRING,
+ 8, PropModeReplace, (unsigned char *)name,
+ name ? strlen(name) : 0);
+}
+
+#if NeedFunctionPrototypes
+XSetIconName (
+ register Display *dpy,
+ Window w,
+ _Xconst char *icon_name)
+#else
+XSetIconName (dpy, w, icon_name)
+ register Display *dpy;
+ Window w;
+ char *icon_name;
+#endif
+{
+ return XChangeProperty(dpy, w, XA_WM_ICON_NAME, XA_STRING,
+ 8, PropModeReplace, (unsigned char *)icon_name,
+ icon_name ? strlen(icon_name) : 0);
+}
diff --git a/src/StrKeysym.c b/src/StrKeysym.c
new file mode 100644
index 00000000..e378f93b
--- /dev/null
+++ b/src/StrKeysym.c
@@ -0,0 +1,148 @@
+/* $Xorg: StrKeysym.c,v 1.5 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include <X11/keysymdef.h>
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+extern XrmQuark _XrmInternalStringToQuark();
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+typedef unsigned long Signature;
+
+#define NEEDKTABLE
+#include "ks_tables.h"
+
+#ifndef KEYSYMDB
+#define KEYSYMDB "/usr/lib/X11/XKeysymDB"
+#endif
+
+static Bool initialized;
+static XrmDatabase keysymdb;
+static XrmQuark Qkeysym[2];
+
+XrmDatabase
+_XInitKeysymDB()
+{
+ if (!initialized)
+ {
+ char *dbname;
+
+ XrmInitialize();
+ /* use and name of this env var is not part of the standard */
+ /* implementation-dependent feature */
+ dbname = getenv("XKEYSYMDB");
+ if (!dbname)
+ dbname = KEYSYMDB;
+ keysymdb = XrmGetFileDatabase(dbname);
+ if (keysymdb)
+ Qkeysym[0] = XrmStringToQuark("Keysym");
+ initialized = True;
+ }
+ return keysymdb;
+}
+
+#if NeedFunctionPrototypes
+KeySym XStringToKeysym(s)
+ _Xconst char *s;
+#else
+KeySym XStringToKeysym(s)
+ char *s;
+#endif
+{
+ register int i, n;
+ int h;
+ register Signature sig = 0;
+ register Const char *p = s;
+ register int c;
+ register int idx;
+ Const unsigned char *entry;
+ unsigned char sig1, sig2;
+ KeySym val;
+
+ while ((c = *p++))
+ sig = (sig << 1) + c;
+ i = sig % KTABLESIZE;
+ h = i + 1;
+ sig1 = (sig >> 8) & 0xff;
+ sig2 = sig & 0xff;
+ n = KMAXHASH;
+ while ((idx = hashString[i]))
+ {
+ entry = &_XkeyTable[idx];
+ if ((entry[0] == sig1) && (entry[1] == sig2) &&
+ !strcmp(s, (char *)entry + 4))
+ {
+ val = (entry[2] << 8) | entry[3];
+ if (!val)
+ val = XK_VoidSymbol;
+ return val;
+ }
+ if (!--n)
+ break;
+ i += h;
+ if (i >= KTABLESIZE)
+ i -= KTABLESIZE;
+ }
+
+ if (!initialized)
+ (void)_XInitKeysymDB();
+ if (keysymdb)
+ {
+ XrmValue result;
+ XrmRepresentation from_type;
+ char c;
+ KeySym val;
+ XrmQuark names[2];
+
+ names[0] = _XrmInternalStringToQuark(s, p - s - 1, sig, False);
+ names[1] = NULLQUARK;
+ (void)XrmQGetResource(keysymdb, names, Qkeysym, &from_type, &result);
+ if (result.addr && (result.size > 1))
+ {
+ val = 0;
+ for (i = 0; i < result.size - 1; i++)
+ {
+ c = ((char *)result.addr)[i];
+ if ('0' <= c && c <= '9') val = (val<<4)+c-'0';
+ else if ('a' <= c && c <= 'z') val = (val<<4)+c-'a'+10;
+ else if ('A' <= c && c <= 'Z') val = (val<<4)+c-'A'+10;
+ else return NoSymbol;
+ }
+ return val;
+ }
+ }
+ return (NoSymbol);
+}
diff --git a/src/StrToText.c b/src/StrToText.c
new file mode 100644
index 00000000..c84c0714
--- /dev/null
+++ b/src/StrToText.c
@@ -0,0 +1,88 @@
+/* $Xorg: StrToText.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+/*
+ * XStringListToTextProperty - fill in TextProperty structure with
+ * concatenated list of null-separated strings. Return True if successful
+ * else False. Allocate room on end for trailing NULL, but don't include in
+ * count.
+ */
+
+Status XStringListToTextProperty (argv, argc, textprop)
+ char **argv;
+ int argc;
+ XTextProperty *textprop;
+{
+ register int i;
+ register unsigned int nbytes;
+ XTextProperty proto;
+
+ /* figure out how much space we'll need for this list */
+ for (i = 0, nbytes = 0; i < argc; i++) {
+ nbytes += (unsigned) ((argv[i] ? strlen (argv[i]) : 0) + 1);
+ }
+
+ /* fill in a prototype containing results so far */
+ proto.encoding = XA_STRING;
+ proto.format = 8;
+ if (nbytes)
+ proto.nitems = nbytes - 1; /* subtract one for trailing <NUL> */
+ else
+ proto.nitems = 0;
+ proto.value = NULL;
+
+ /* build concatenated list of strings */
+ if (nbytes > 0) {
+ register char *buf = Xmalloc (nbytes);
+ if (!buf) return False;
+
+ proto.value = (unsigned char *) buf;
+ for (i = 0; i < argc; i++) {
+ char *arg = argv[i];
+
+ if (arg) {
+ (void) strcpy (buf, arg);
+ buf += (strlen (arg) + 1);
+ } else {
+ *buf++ = '\0';
+ }
+ }
+ } else {
+ proto.value = (unsigned char *) Xmalloc (1); /* easier for client */
+ if (!proto.value) return False;
+
+ proto.value[0] = '\0';
+ }
+
+ /* we were successful, so set return value */
+ *textprop = proto;
+ return True;
+}
diff --git a/src/Sync.c b/src/Sync.c
new file mode 100644
index 00000000..98b5463b
--- /dev/null
+++ b/src/Sync.c
@@ -0,0 +1,59 @@
+/* $Xorg: Sync.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+/* Synchronize with errors and events, optionally discarding pending events */
+
+XSync (dpy, discard)
+ register Display *dpy;
+ Bool discard;
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+
+ if (discard && dpy->head) {
+ _XQEvent *qelt;
+
+ for (qelt=dpy->head; qelt; qelt=qelt->next)
+ qelt->qserial_num = 0;
+
+ ((_XQEvent *)dpy->tail)->next = dpy->qfree;
+ dpy->qfree = (_XQEvent *)dpy->head;
+ dpy->head = dpy->tail = NULL;
+ dpy->qlen = 0;
+ }
+ UnlockDisplay(dpy);
+ return 1;
+}
+
diff --git a/src/Synchro.c b/src/Synchro.c
new file mode 100644
index 00000000..9e9d50ad
--- /dev/null
+++ b/src/Synchro.c
@@ -0,0 +1,96 @@
+/* $Xorg: Synchro.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+
+int _XSyncFunction(dpy)
+register Display *dpy;
+{
+ XSync(dpy,0);
+ return 0;
+}
+
+#if NeedFunctionPrototypes
+int (*XSynchronize(Display *dpy, int onoff))()
+#else
+int (*XSynchronize(dpy,onoff))()
+ register Display *dpy;
+ int onoff;
+#endif
+{
+ int (*temp)();
+ int (*func)() = NULL;
+
+ if (onoff)
+ func = _XSyncFunction;
+
+ LockDisplay(dpy);
+ if (dpy->flags & XlibDisplayPrivSync) {
+ temp = dpy->savedsynchandler;
+ dpy->savedsynchandler = func;
+ } else {
+ temp = dpy->synchandler;
+ dpy->synchandler = func;
+ }
+ UnlockDisplay(dpy);
+ return (temp);
+}
+
+#if NeedFunctionPrototypes
+int (*XSetAfterFunction(
+ Display *dpy,
+ int (*func)(
+#if NeedNestedPrototypes
+ Display*
+#endif
+ )
+))()
+#else
+int (*XSetAfterFunction(dpy,func))()
+ register Display *dpy;
+ int (*func)(
+#if NeedNestedPrototypes
+ Display*
+#endif
+ );
+#endif
+{
+ int (*temp)();
+
+ LockDisplay(dpy);
+ if (dpy->flags & XlibDisplayPrivSync) {
+ temp = dpy->savedsynchandler;
+ dpy->savedsynchandler = func;
+ } else {
+ temp = dpy->synchandler;
+ dpy->synchandler = func;
+ }
+ UnlockDisplay(dpy);
+ return (temp);
+}
+
diff --git a/src/Text.c b/src/Text.c
new file mode 100644
index 00000000..e8d3df45
--- /dev/null
+++ b/src/Text.c
@@ -0,0 +1,146 @@
+/* $Xorg: Text.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawString(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *string,
+ int length)
+#else
+XDrawString(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ char *string;
+ int length;
+#endif
+{
+ int Datalength = 0;
+ register xPolyText8Req *req;
+
+ if (length <= 0)
+ return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText8, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+
+ Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + length;
+
+
+ req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + Datalength > dpy->bufmax)
+ _XFlush (dpy);
+
+ {
+ int nbytes;
+ int PartialNChars = length;
+ /* register xTextElt *elt; */
+ char *CharacterOffset = (char *)string;
+ unsigned char *tbuf;
+
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 + SIZEOF(xTextElt);
+ BufAlloc (unsigned char *, tbuf, nbytes);
+/* elt->delta = 0;
+ * elt->len = 254;
+ */
+ *(unsigned char *)tbuf = 254;
+ *(tbuf+1) = 0;
+/* memcpy ((char *) (elt + 1), CharacterOffset, 254);
+ */
+ memcpy ((char *)tbuf+2, CharacterOffset, 254);
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+ }
+
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars + SIZEOF(xTextElt);
+ BufAlloc (unsigned char *, tbuf, nbytes);
+/* elt->delta = 0;
+ * elt->len = PartialNChars;
+ */
+ *(unsigned char *)tbuf = PartialNChars;
+ *(tbuf+1) = 0;
+/* memcpy ((char *) (elt + 1), CharacterOffset, PartialNChars);
+ */
+ memcpy ((char *)tbuf+2, CharacterOffset, PartialNChars);
+ }
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (Datalength &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - Datalength;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
diff --git a/src/Text16.c b/src/Text16.c
new file mode 100644
index 00000000..f8714459
--- /dev/null
+++ b/src/Text16.c
@@ -0,0 +1,159 @@
+/* $Xorg: Text16.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+#if NeedFunctionPrototypes
+XDrawString16(
+ register Display *dpy,
+ Drawable d,
+ GC gc,
+ int x,
+ int y,
+ _Xconst XChar2b *string,
+ int length)
+#else
+XDrawString16(dpy, d, gc, x, y, string, length)
+ register Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XChar2b *string;
+ int length;
+#endif
+{
+ int Datalength = 0;
+ register xPolyText16Req *req;
+
+ if (length <= 0)
+ return 0;
+
+ LockDisplay(dpy);
+ FlushGC(dpy, gc);
+ GetReq (PolyText16, req);
+ req->drawable = d;
+ req->gc = gc->gid;
+ req->x = x;
+ req->y = y;
+
+
+ Datalength += SIZEOF(xTextElt) * ((length + 253) / 254) + (length << 1);
+
+
+ req->length += (Datalength + 3)>>2; /* convert to number of 32-bit words */
+
+
+ /*
+ * If the entire request does not fit into the remaining space in the
+ * buffer, flush the buffer first. If the request does fit into the
+ * empty buffer, then we won't have to flush it at the end to keep
+ * the buffer 32-bit aligned.
+ */
+
+ if (dpy->bufptr + Datalength > dpy->bufmax)
+ _XFlush (dpy);
+
+ {
+ int nbytes;
+ int PartialNChars = length;
+ register xTextElt *elt;
+ XChar2b *CharacterOffset = (XChar2b *)string;
+
+ while(PartialNChars > 254)
+ {
+ nbytes = 254 * 2 + SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ elt->len = 254;
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < 254; i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy ((char *) (elt + 1), (char *)CharacterOffset, 254 * 2);
+#endif
+ PartialNChars = PartialNChars - 254;
+ CharacterOffset += 254;
+ }
+
+ if (PartialNChars)
+ {
+ nbytes = PartialNChars * 2 + SIZEOF(xTextElt);
+ BufAlloc (xTextElt *, elt, nbytes);
+ elt->delta = 0;
+ elt->len = PartialNChars;
+#if defined(MUSTCOPY) || defined(MUSTCOPY2B)
+ {
+ register int i;
+ register unsigned char *cp;
+ for (i = 0, cp = ((unsigned char *)elt) + 2; i < PartialNChars;
+ i++) {
+ *cp++ = CharacterOffset[i].byte1;
+ *cp++ = CharacterOffset[i].byte2;
+ }
+ }
+#else
+ memcpy((char *)(elt + 1), (char *)CharacterOffset, PartialNChars * 2);
+#endif
+ }
+ }
+
+ /* Pad request out to a 32-bit boundary */
+
+ if (Datalength &= 3) {
+ char *pad;
+ /*
+ * BufAlloc is a macro that uses its last argument more than
+ * once, otherwise I'd write "BufAlloc (char *, pad, 4-length)"
+ */
+ length = 4 - Datalength;
+ BufAlloc (char *, pad, length);
+ /*
+ * if there are 3 bytes of padding, the first byte MUST be 0
+ * so the pad bytes aren't mistaken for a final xTextElt
+ */
+ *pad = 0;
+ }
+
+ /*
+ * If the buffer pointer is not now pointing to a 32-bit boundary,
+ * we must flush the buffer so that it does point to a 32-bit boundary
+ * at the end of this routine.
+ */
+
+ if ((dpy->bufptr - dpy->buffer) & 3)
+ _XFlush (dpy);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
diff --git a/src/TextExt.c b/src/TextExt.c
new file mode 100644
index 00000000..d7f4ff8a
--- /dev/null
+++ b/src/TextExt.c
@@ -0,0 +1,252 @@
+/* $Xorg: TextExt.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+
+#include "Xlibint.h"
+
+#define min_byte2 min_char_or_byte2
+#define max_byte2 max_char_or_byte2
+
+
+/*
+ * CI_GET_ROWZERO_CHAR_INFO_2D - do the same thing as CI_GET_CHAR_INFO_1D,
+ * except that the font has more than one row. This is special case of more
+ * general version used in XTextExt16.c since row == 0. This is used when
+ * max_byte2 is not zero. A further optimization would do the check for
+ * min_byte1 being zero ahead of time.
+ */
+
+#define CI_GET_ROWZERO_CHAR_INFO_2D(fs,col,def,cs) \
+{ \
+ cs = def; \
+ if (fs->min_byte1 == 0 && \
+ col >= fs->min_byte2 && col <= fs->max_byte2) { \
+ if (fs->per_char == NULL) { \
+ cs = &fs->min_bounds; \
+ } else { \
+ cs = &fs->per_char[(col - fs->min_byte2)]; \
+ if (CI_NONEXISTCHAR(cs)) cs = def; \
+ } \
+ } \
+}
+
+
+/*
+ * XTextExtents - compute the extents of string given as a sequences of eight
+ * bit bytes. Since we know that the input characters will always be from the
+ * first row of the font (i.e. byte1 == 0), we can do some optimizations beyond
+ * what is done in XTextExtents16.
+ */
+#if NeedFunctionPrototypes
+XTextExtents (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int nchars,
+ int *dir, /* RETURN font information */
+ int *font_ascent, /* RETURN font information */
+ int *font_descent, /* RETURN font information */
+ register XCharStruct *overall) /* RETURN character information */
+#else
+XTextExtents (fs, string, nchars, dir, font_ascent, font_descent, overall)
+ XFontStruct *fs;
+ char *string;
+ int nchars;
+ int *dir, *font_ascent, *font_descent; /* RETURN font information */
+ register XCharStruct *overall; /* RETURN character information */
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ int nfound = 0; /* number of characters found */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ *dir = fs->direction;
+ *font_ascent = fs->ascent;
+ *font_descent = fs->descent;
+
+ /*
+ * Iterate over the input string getting the appropriate * char struct.
+ * The default (which may be null if there is no def_char) will be returned
+ * if the character doesn't exist. On the first time * through the loop,
+ * assign the values to overall; otherwise, compute * the new values.
+ */
+
+ for (i = 0, us = (unsigned char *) string; i < nchars; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) {
+ if (nfound++ == 0) {
+ *overall = *cs;
+ } else {
+ overall->ascent = max (overall->ascent, cs->ascent);
+ overall->descent = max (overall->descent, cs->descent);
+ overall->lbearing = min (overall->lbearing,
+ overall->width + cs->lbearing);
+ overall->rbearing = max (overall->rbearing,
+ overall->width + cs->rbearing);
+ overall->width += cs->width;
+ }
+ }
+ }
+
+ /*
+ * if there were no characters, then set everything to 0
+ */
+ if (nfound == 0) {
+ overall->width = overall->ascent = overall->descent =
+ overall->lbearing = overall->rbearing = 0;
+ }
+
+ return 0;
+}
+
+
+/*
+ * XTextWidth - compute the width of a string of eightbit bytes. This is a
+ * subset of XTextExtents.
+ */
+#if NeedFunctionPrototypes
+int XTextWidth (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int count)
+#else
+int XTextWidth (fs, string, count)
+ XFontStruct *fs;
+ char *string;
+ int count;
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+ int width = 0; /* RETURN value */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && fs->min_bounds.width == fs->max_bounds.width)
+ return (fs->min_bounds.width * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0, us = (unsigned char *) string; i < count; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) width += cs->width;
+ }
+
+ return width;
+}
+
+
+
+/*
+ * _XTextHeight - compute the height of a string of eightbit bytes.
+ */
+#if NeedFunctionPrototypes
+int _XTextHeight (
+ XFontStruct *fs,
+ _Xconst char *string,
+ int count)
+#else
+int _XTextHeight (fs, string, count)
+ XFontStruct *fs;
+ char *string;
+ int count;
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ unsigned char *us; /* be 8bit clean */
+ int height = 0; /* RETURN value */
+
+ if (singlerow) { /* optimization */
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && (fs->min_bounds.ascent == fs->max_bounds.ascent)
+ && (fs->min_bounds.descent == fs->max_bounds.descent))
+ return ((fs->min_bounds.ascent + fs->min_bounds.descent) * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0, us = (unsigned char *) string; i < count; i++, us++) {
+ register unsigned uc = (unsigned) *us; /* since about to do macro */
+ register XCharStruct *cs;
+
+ if (singlerow) { /* optimization */
+ CI_GET_CHAR_INFO_1D (fs, uc, def, cs);
+ } else {
+ CI_GET_ROWZERO_CHAR_INFO_2D (fs, uc, def, cs);
+ }
+
+ if (cs) height += (cs->ascent + cs->descent);
+ }
+
+ return height;
+}
+
diff --git a/src/TextExt16.c b/src/TextExt16.c
new file mode 100644
index 00000000..24f888ec
--- /dev/null
+++ b/src/TextExt16.c
@@ -0,0 +1,228 @@
+/* $Xorg: TextExt16.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+
+#include "Xlibint.h"
+
+#define min_byte2 min_char_or_byte2
+#define max_byte2 max_char_or_byte2
+
+/*
+ * XTextExtents16 - compute the extents of string given as a sequence of
+ * XChar2bs.
+ */
+#if NeedFunctionPrototypes
+XTextExtents16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int nchars,
+ int *dir, /* RETURN font information */
+ int *font_ascent, /* RETURN font information */
+ int *font_descent, /* RETURN font information */
+ register XCharStruct *overall) /* RETURN character information */
+#else
+XTextExtents16 (fs, string, nchars, dir, font_ascent, font_descent, overall)
+ XFontStruct *fs;
+ XChar2b *string;
+ int nchars;
+ int *dir, *font_ascent, *font_descent; /* RETURN font information */
+ register XCharStruct *overall; /* RETURN character information */
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ int nfound = 0; /* number of characters found */
+ XCharStruct *def; /* info about default char */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ *dir = fs->direction;
+ *font_ascent = fs->ascent;
+ *font_descent = fs->descent;
+
+ /*
+ * Iterate over the input string getting the appropriate * char struct.
+ * The default (which may be null if there is no def_char) will be returned
+ * if the character doesn't exist. On the first time * through the loop,
+ * assign the values to overall; otherwise, compute * the new values.
+ */
+
+ for (i = 0; i < nchars; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) {
+ if (nfound++ == 0) {
+ *overall = *cs;
+ } else {
+ overall->ascent = max (overall->ascent, cs->ascent);
+ overall->descent = max (overall->descent, cs->descent);
+ overall->lbearing = min (overall->lbearing,
+ overall->width + cs->lbearing);
+ overall->rbearing = max (overall->rbearing,
+ overall->width + cs->rbearing);
+ overall->width += cs->width;
+ }
+ }
+ }
+
+ /*
+ * if there were no characters, then set everything to 0
+ */
+ if (nfound == 0) {
+ overall->width = overall->ascent = overall->descent =
+ overall->lbearing = overall->rbearing = 0;
+ }
+
+ return 0;
+}
+
+
+/*
+ * XTextWidth16 - compute the width of sequence of XChar2bs. This is a
+ * subset of XTextExtents16.
+ */
+#if NeedFunctionPrototypes
+int XTextWidth16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int count)
+#else
+int XTextWidth16 (fs, string, count)
+ XFontStruct *fs;
+ XChar2b *string;
+ int count;
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ int width = 0; /* RETURN value */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && fs->min_bounds.width == fs->max_bounds.width)
+ return (fs->min_bounds.width * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0; i < count; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) width += cs->width;
+ }
+
+ return width;
+}
+
+
+/*
+ * _XTextHeight16 - compute the height of sequence of XChar2bs.
+ */
+#if NeedFunctionPrototypes
+int _XTextHeight16 (
+ XFontStruct *fs,
+ _Xconst XChar2b *string,
+ int count)
+#else
+int _XTextHeight16 (fs, string, count)
+ XFontStruct *fs;
+ XChar2b *string;
+ int count;
+#endif
+{
+ int i; /* iterator */
+ Bool singlerow = (fs->max_byte1 == 0); /* optimization */
+ XCharStruct *def; /* info about default char */
+ int height = 0; /* RETURN value */
+
+ if (singlerow) {
+ CI_GET_DEFAULT_INFO_1D (fs, def);
+ } else {
+ CI_GET_DEFAULT_INFO_2D (fs, def);
+ }
+
+ if (def && (fs->min_bounds.ascent == fs->max_bounds.ascent)
+ && (fs->min_bounds.descent == fs->max_bounds.descent))
+ return ((fs->min_bounds.ascent + fs->min_bounds.descent) * count);
+
+ /*
+ * Iterate over all character in the input string; only consider characters
+ * that exist.
+ */
+ for (i = 0; i < count; i++, string++) {
+ register XCharStruct *cs;
+ unsigned int r = (unsigned int) string->byte1; /* watch for macros */
+ unsigned int c = (unsigned int) string->byte2; /* watch for macros */
+
+ if (singlerow) {
+ unsigned int ind = ((r << 8) | c); /* watch for macros */
+ CI_GET_CHAR_INFO_1D (fs, ind, def, cs);
+ } else {
+ CI_GET_CHAR_INFO_2D (fs, r, c, def, cs);
+ }
+
+ if (cs) height += (cs->ascent + cs->descent);
+ }
+
+ return height;
+}
+
diff --git a/src/TextToStr.c b/src/TextToStr.c
new file mode 100644
index 00000000..2ac934c2
--- /dev/null
+++ b/src/TextToStr.c
@@ -0,0 +1,115 @@
+/* $Xorg: TextToStr.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+
+/*
+ * XTextPropertyToStringList - set list and count to contain data stored in
+ * null-separated STRING property.
+ */
+
+Status XTextPropertyToStringList (tp, list_return, count_return)
+ XTextProperty *tp;
+ char ***list_return;
+ int *count_return;
+{
+ char **list; /* return value */
+ int nelements; /* return value */
+ register char *cp; /* temp variable */
+ char *start; /* start of thing to copy */
+ int i, j; /* iterator variables */
+ int datalen = (int) tp->nitems; /* for convenience */
+
+ /*
+ * make sure we understand how to do it
+ */
+ if (tp->encoding != XA_STRING || tp->format != 8) return False;
+
+ if (datalen == 0) {
+ *list_return = NULL;
+ *count_return = 0;
+ return True;
+ }
+
+ /*
+ * walk the list to figure out how many elements there are
+ */
+ nelements = 1; /* since null-separated */
+ for (cp = (char *) tp->value, i = datalen; i > 0; cp++, i--) {
+ if (*cp == '\0') nelements++;
+ }
+
+ /*
+ * allocate list and duplicate
+ */
+ list = (char **) Xmalloc (nelements * sizeof (char *));
+ if (!list) return False;
+
+ start = (char *) Xmalloc ((datalen + 1) * sizeof (char)); /* for <NUL> */
+ if (!start) {
+ Xfree ((char *) list);
+ return False;
+ }
+
+ /*
+ * copy data
+ */
+ memcpy (start, (char *) tp->value, tp->nitems);
+ start[datalen] = '\0';
+
+ /*
+ * walk down list setting value
+ */
+ for (cp = start, i = datalen + 1, j = 0; i > 0; cp++, i--) {
+ if (*cp == '\0') {
+ list[j] = start;
+ start = (cp + 1);
+ j++;
+ }
+ }
+
+ /*
+ * append final null pointer and then return data
+ */
+ *list_return = list;
+ *count_return = nelements;
+ return True;
+}
+
+
+void XFreeStringList (list)
+ char **list;
+{
+ if (list) {
+ if (list[0]) Xfree (list[0]);
+ Xfree ((char *) list);
+ }
+}
+
diff --git a/src/TrCoords.c b/src/TrCoords.c
new file mode 100644
index 00000000..2363248d
--- /dev/null
+++ b/src/TrCoords.c
@@ -0,0 +1,61 @@
+/* $Xorg: TrCoords.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include "Xlibint.h"
+
+Bool XTranslateCoordinates(dpy, src_win, dest_win, src_x, src_y,
+ dst_x, dst_y, child)
+ register Display *dpy;
+ Window src_win, dest_win;
+ int src_x, src_y;
+ int *dst_x, *dst_y;
+ Window *child;
+{
+ register xTranslateCoordsReq *req;
+ xTranslateCoordsReply rep;
+
+ LockDisplay(dpy);
+ GetReq(TranslateCoords, req);
+ req->srcWid = src_win;
+ req->dstWid = dest_win;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ if (_XReply (dpy, (xReply *)&rep, 0, xTrue) == 0) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return(False);
+ }
+
+ *child = rep.child;
+ *dst_x = cvtINT16toInt (rep.dstX);
+ *dst_y = cvtINT16toInt (rep.dstY);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ((int)rep.sameScreen);
+}
+
diff --git a/src/UndefCurs.c b/src/UndefCurs.c
new file mode 100644
index 00000000..46236ea4
--- /dev/null
+++ b/src/UndefCurs.c
@@ -0,0 +1,46 @@
+/* $Xorg: UndefCurs.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUndefineCursor (dpy,w)
+ register Display *dpy;
+ Window w;
+{
+ register xChangeWindowAttributesReq *req;
+ unsigned long defcurs = None;
+
+ LockDisplay(dpy);
+ GetReqExtra (ChangeWindowAttributes, 4, req);
+ req->window = w;
+ req->valueMask = CWCursor;
+ OneDataCard32 (dpy, NEXTPTR(req,xChangeWindowAttributesReq), defcurs);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/UngrabBut.c b/src/UngrabBut.c
new file mode 100644
index 00000000..e0e28a3a
--- /dev/null
+++ b/src/UngrabBut.c
@@ -0,0 +1,46 @@
+/* $Xorg: UngrabBut.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUngrabButton(dpy, button, modifiers, grab_window)
+register Display *dpy;
+unsigned int button; /* CARD8 */
+unsigned int modifiers; /* CARD16 */
+Window grab_window;
+{
+ register xUngrabButtonReq *req;
+
+ LockDisplay(dpy);
+ GetReq(UngrabButton, req);
+ req->button = button;
+ req->modifiers = modifiers;
+ req->grabWindow = grab_window;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/UngrabKbd.c b/src/UngrabKbd.c
new file mode 100644
index 00000000..5a9d7562
--- /dev/null
+++ b/src/UngrabKbd.c
@@ -0,0 +1,42 @@
+/* $Xorg: UngrabKbd.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUngrabKeyboard (dpy, time)
+ register Display *dpy;
+ Time time;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UngrabKeyboard, time, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/UngrabKey.c b/src/UngrabKey.c
new file mode 100644
index 00000000..bfd28c0f
--- /dev/null
+++ b/src/UngrabKey.c
@@ -0,0 +1,50 @@
+/* $Xorg: UngrabKey.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUngrabKey(dpy, key, modifiers, grab_window)
+ register Display *dpy;
+ int key;
+ unsigned int modifiers;
+ Window grab_window;
+
+{
+ register xUngrabKeyReq *req;
+
+ LockDisplay(dpy);
+ GetReq(UngrabKey, req);
+ req->grabWindow = grab_window;
+ req->modifiers = modifiers;
+ req->key = key;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
+
+
diff --git a/src/UngrabPtr.c b/src/UngrabPtr.c
new file mode 100644
index 00000000..4cf09cf1
--- /dev/null
+++ b/src/UngrabPtr.c
@@ -0,0 +1,41 @@
+/* $Xorg: UngrabPtr.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUngrabPointer(dpy, time)
+register Display *dpy;
+Time time;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UngrabPointer, time, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/UngrabSvr.c b/src/UngrabSvr.c
new file mode 100644
index 00000000..e5267e18
--- /dev/null
+++ b/src/UngrabSvr.c
@@ -0,0 +1,41 @@
+/* $Xorg: UngrabSvr.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUngrabServer (dpy)
+register Display *dpy;
+{
+ register xReq *req;
+
+ LockDisplay(dpy);
+ GetEmptyReq(UngrabServer, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/UninsCmap.c b/src/UninsCmap.c
new file mode 100644
index 00000000..6b06c670
--- /dev/null
+++ b/src/UninsCmap.c
@@ -0,0 +1,41 @@
+/* $Xorg: UninsCmap.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUninstallColormap(dpy, cmap)
+register Display *dpy;
+Colormap cmap;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UninstallColormap, cmap, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/UnldFont.c b/src/UnldFont.c
new file mode 100644
index 00000000..66f31a96
--- /dev/null
+++ b/src/UnldFont.c
@@ -0,0 +1,42 @@
+ /* $Xorg: UnldFont.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUnloadFont(dpy, font)
+ register Display *dpy;
+ Font font;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(CloseFont, font, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/UnmapSubs.c b/src/UnmapSubs.c
new file mode 100644
index 00000000..bb7158ea
--- /dev/null
+++ b/src/UnmapSubs.c
@@ -0,0 +1,41 @@
+/* $Xorg: UnmapSubs.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUnmapSubwindows(dpy, win)
+register Display *dpy;
+Window win;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UnmapSubwindows,win, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
diff --git a/src/UnmapWin.c b/src/UnmapWin.c
new file mode 100644
index 00000000..d536ecb0
--- /dev/null
+++ b/src/UnmapWin.c
@@ -0,0 +1,42 @@
+/* $Xorg: UnmapWin.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XUnmapWindow (dpy, w)
+ register Display *dpy;
+ Window w;
+{
+ register xResourceReq *req;
+
+ LockDisplay(dpy);
+ GetResReq(UnmapWindow, w, req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/VisUtil.c b/src/VisUtil.c
new file mode 100644
index 00000000..92cdd93f
--- /dev/null
+++ b/src/VisUtil.c
@@ -0,0 +1,253 @@
+/* $Xorg: VisUtil.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+#include <stdio.h>
+/*
+ * This procedure returns a list of visual information structures
+ * that match the specified attributes given in the visual information
+ * template.
+ *
+ * If no visuals exist that match the specified attributes, a NULL is
+ * returned.
+ *
+ * The choices for visual_info_mask are:
+ *
+ * VisualNoMask
+ * VisualIDMask
+ * VisualScreenMask
+ * VisualDepthMask
+ * VisualClassMask
+ * VisualRedMaskMask
+ * VisualGreenMaskMask
+ * VisualBlueMaskMask
+ * VisualColormapSizeMask
+ * VisualBitsPerRGBMask
+ * VisualAllMask
+ */
+
+XVisualInfo *XGetVisualInfo( dpy, visual_info_mask,
+ visual_info_template, nitems)
+Display *dpy;
+register long visual_info_mask;
+register XVisualInfo *visual_info_template;
+int *nitems; /* RETURN */
+{
+
+ register Visual *vp;
+ register Depth *dp;
+ Screen *sp;
+ int ii,screen_s,screen_e,total,count;
+ register XVisualInfo *vip,*vip_base;
+
+ /* NOTE: NO HIGH PERFORMING CODE TO BE FOUND HERE */
+
+ LockDisplay(dpy);
+
+ /* ALLOCATE THE ORIGINAL BUFFER; REALLOCED LATER IF OVERFLOW OCCURS;
+ FREED AT END IF NO VISUALS ARE FOUND */
+
+ count = 0;
+ total = 10;
+ if (! (vip_base = vip = (XVisualInfo *)
+ Xmalloc((unsigned) (sizeof(XVisualInfo) * total)))) {
+ UnlockDisplay(dpy);
+ return (XVisualInfo *) NULL;
+ }
+
+ /* DETERMINE IF WE DO ALL SCREENS OR ONLY ONE */
+
+ screen_s = 0;
+ screen_e = dpy->nscreens;
+ if (visual_info_mask & VisualScreenMask)
+ {
+ screen_s = visual_info_template->screen;
+ if (screen_s < 0 || screen_s >= screen_e)
+ screen_e = screen_s;
+ else
+ screen_e = screen_s + 1;
+ }
+
+ /* LOOP THROUGH SCREENS */
+
+ for (ii=screen_s; ii<screen_e; ii++)
+ {
+ sp = (Screen *)(&dpy->screens[ii]);
+
+ /* LOOP THROUGH DEPTHS */
+
+ for (dp=sp->depths; dp < (sp->depths + sp->ndepths); dp++)
+ {
+ if ((visual_info_mask & VisualDepthMask) &&
+ (dp->depth != visual_info_template->depth)) continue;
+
+ /* LOOP THROUGH VISUALS */
+
+ if (dp->visuals) {
+ for (vp=dp->visuals; vp<(dp->visuals + dp->nvisuals); vp++) {
+ if ((visual_info_mask & VisualIDMask) &&
+ (vp->visualid != visual_info_template->visualid)) continue;
+ if ((visual_info_mask & VisualClassMask) &&
+ (vp->class != visual_info_template->class)) continue;
+ if ((visual_info_mask & VisualRedMaskMask) &&
+ (vp->red_mask != visual_info_template->red_mask)) continue;
+ if ((visual_info_mask & VisualGreenMaskMask) &&
+ (vp->green_mask != visual_info_template->green_mask)) continue;
+ if ((visual_info_mask & VisualBlueMaskMask) &&
+ (vp->blue_mask != visual_info_template->blue_mask)) continue;
+ if ((visual_info_mask & VisualColormapSizeMask) &&
+ (vp->map_entries != visual_info_template->colormap_size)) continue;
+ if ((visual_info_mask & VisualBitsPerRGBMask) &&
+ (vp->bits_per_rgb != visual_info_template->bits_per_rgb)) continue;
+
+ /* YEA!!! WE FOUND A GOOD ONE */
+
+ if (count+1 > total)
+ {
+ XVisualInfo *old_vip_base = vip_base;
+ total += 10;
+ if (! (vip_base = (XVisualInfo *)
+ Xrealloc((char *) vip_base,
+ (unsigned) (sizeof(XVisualInfo) * total)))) {
+ Xfree((char *) old_vip_base);
+ UnlockDisplay(dpy);
+ return (XVisualInfo *) NULL;
+ }
+ vip = &vip_base[count];
+ }
+
+ count++;
+
+ vip->visual = _XVIDtoVisual(dpy, vp->visualid);
+ vip->visualid = vp->visualid;
+ vip->screen = ii;
+ vip->depth = dp->depth;
+ vip->class = vp->class;
+ vip->red_mask = vp->red_mask;
+ vip->green_mask = vp->green_mask;
+ vip->blue_mask = vp->blue_mask;
+ vip->colormap_size = vp->map_entries;
+ vip->bits_per_rgb = vp->bits_per_rgb;
+
+ vip++;
+
+ } /* END OF LOOP ON VISUALS */
+ } /* END OF IF THERE ARE ANY VISUALS AT THIS DEPTH */
+
+ } /* END OF LOOP ON DEPTHS */
+
+ } /* END OF LOOP ON SCREENS */
+
+ UnlockDisplay(dpy);
+
+ if (count)
+ {
+ *nitems = count;
+ return vip_base;
+ }
+
+ Xfree((char *) vip_base);
+ *nitems = 0;
+ return NULL;
+}
+
+
+/*
+ * This procedure will return the visual information for a visual
+ * that matches the specified depth and class for a screen. Since
+ * multiple visuals may exist that match the specified depth and
+ * class, which visual chosen is undefined.
+ *
+ * If a visual is found, True is returned as the function value,
+ * otherwise False is returned.
+ */
+
+Status XMatchVisualInfo( dpy, screen, depth, class, visual_info)
+ Display *dpy;
+ int screen;
+ int depth;
+ int class;
+ XVisualInfo *visual_info; /* RETURNED */
+{
+
+ Visual *vp;
+ Depth *dp;
+ Screen *sp;
+ int ii,jj;
+
+ if (screen < 0 || screen >= dpy->nscreens)
+ return False;
+
+ LockDisplay(dpy);
+
+ sp = (Screen *)(&dpy->screens[screen]);
+
+ dp = sp->depths;
+
+ for (ii=0; ii < sp->ndepths; ii++)
+ {
+
+ /* LOOK THROUGH DEPTHS FOR THE WANTED DEPTH */
+
+ if (dp->depth == depth)
+ {
+ vp = dp->visuals;
+
+ /* LOOK THROUGH VISUALS FOR THE WANTED CLASS */
+
+ /* if nvisuals == 0 then vp will be NULL */
+ for (jj=0; jj<dp->nvisuals; jj++)
+ {
+ if (vp->class == class)
+ {
+ visual_info->visual = _XVIDtoVisual(dpy, vp->visualid);
+ visual_info->visualid = vp->visualid;
+ visual_info->screen = screen;
+ visual_info->depth = depth;
+ visual_info->class = vp->class;
+ visual_info->red_mask = vp->red_mask;
+ visual_info->green_mask = vp->green_mask;
+ visual_info->blue_mask = vp->blue_mask;
+ visual_info->colormap_size = vp->map_entries;
+ visual_info->bits_per_rgb = vp->bits_per_rgb;
+ UnlockDisplay(dpy);
+ return True;
+ }
+ vp++;
+ }
+ }
+
+ dp++;
+
+ }
+
+ UnlockDisplay(dpy);
+
+ return False;
+
+}
diff --git a/src/WMGeom.c b/src/WMGeom.c
new file mode 100644
index 00000000..96b9b536
--- /dev/null
+++ b/src/WMGeom.c
@@ -0,0 +1,195 @@
+/* $Xorg: WMGeom.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xutil.h"
+
+static int _GeometryMaskToGravity();
+
+
+/*
+ * This routine given a user supplied positional argument and a default
+ * argument (fully qualified) will return the position the window should take
+ * as well as the gravity to be set in the WM_NORMAL_HINTS size hints.
+ * Always sets all return values and returns a mask describing which fields
+ * were set by the user or'ed with whether or not the x and y values should
+ * be considered "negative".
+ */
+
+#if NeedFunctionPrototypes
+int XWMGeometry (
+ Display *dpy, /* user's display connection */
+ int screen, /* screen on which to do computation */
+ _Xconst char *user_geom, /* user provided geometry spec */
+ _Xconst char *def_geom, /* default geometry spec for window */
+ unsigned int bwidth, /* border width */
+ XSizeHints *hints, /* usually WM_NORMAL_HINTS */
+ int *x_return, /* location of window */
+ int *y_return, /* location of window */
+ int *width_return, /* size of window */
+ int *height_return, /* size of window */
+ int *gravity_return) /* gravity of window */
+#else
+int XWMGeometry (dpy, screen, user_geom, def_geom, bwidth, hints,
+ x_return, y_return, width_return, height_return,
+ gravity_return)
+ Display *dpy; /* user's display connection */
+ int screen; /* screen on which to do computation */
+ char *user_geom; /* user provided geometry spec */
+ char *def_geom; /* default geometry spec for window */
+ unsigned int bwidth; /* border width */
+ XSizeHints *hints; /* usually WM_NORMAL_HINTS */
+ int *x_return, *y_return; /* location of window */
+ int *width_return, *height_return; /* size of window */
+ int *gravity_return; /* gravity of window */
+#endif
+{
+ int ux, uy; /* returned values from parse */
+ unsigned int uwidth, uheight; /* returned values from parse */
+ int umask; /* parse mask of returned values */
+ int dx, dy; /* default values from parse */
+ unsigned int dwidth, dheight; /* default values from parse */
+ int dmask; /* parse mask of returned values */
+ int base_width, base_height; /* valid amounts */
+ int min_width, min_height; /* valid amounts */
+ int width_inc, height_inc; /* valid amounts */
+ int rx, ry, rwidth, rheight; /* return values */
+ int rmask; /* return mask */
+
+ /*
+ * Get the base sizes and increments. Section 4.1.2.3 of the ICCCM
+ * states that the base and minimum sizes are defaults for each other.
+ * If neither is given, then the base sizes should be 0. These parameters
+ * control the sets of sizes that window managers should allow for the
+ * window according to the following formulae:
+ *
+ * width = base_width + (i * width_inc)
+ * height = base_height + (j * height_inc)
+ */
+ base_width = ((hints->flags & PBaseSize) ? hints->base_width :
+ ((hints->flags & PMinSize) ? hints->min_width : 0));
+ base_height = ((hints->flags & PBaseSize) ? hints->base_height :
+ ((hints->flags & PMinSize) ? hints->min_height : 0));
+ min_width = ((hints->flags & PMinSize) ? hints->min_width : base_width);
+ min_height = ((hints->flags & PMinSize) ? hints->min_height : base_height);
+ width_inc = (hints->flags & PResizeInc) ? hints->width_inc : 1;
+ height_inc = (hints->flags & PResizeInc) ? hints->height_inc : 1;
+
+
+ /*
+ * parse the two geometry masks
+ */
+ rmask = umask = XParseGeometry (user_geom, &ux, &uy, &uwidth, &uheight);
+ dmask = XParseGeometry (def_geom, &dx, &dy, &dwidth, &dheight);
+
+
+ /*
+ * get the width and height:
+ * 1. if user-specified, then take that value
+ * 2. else, if program-specified, then take that value
+ * 3. else, take 1
+ * 4. multiply by the size increment
+ * 5. and add to the base size
+ */
+ rwidth = ((((umask & WidthValue) ? uwidth :
+ ((dmask & WidthValue) ? dwidth : 1)) * width_inc) +
+ base_width);
+ rheight = ((((umask & HeightValue) ? uheight :
+ ((dmask & HeightValue) ? dheight : 1)) * height_inc) +
+ base_height);
+
+ /*
+ * Make sure computed size is within limits. Note that we always do the
+ * lower bounds check since the base size (which defaults to 0) should
+ * be used if a minimum size isn't specified.
+ */
+ if (rwidth < min_width) rwidth = min_width;
+ if (rheight < min_height) rheight = min_height;
+
+ if (hints->flags & PMaxSize) {
+ if (rwidth > hints->max_width) rwidth = hints->max_width;
+ if (rheight > hints->max_height) rheight = hints->max_height;
+ }
+
+
+ /*
+ * Compute the location. Set the negative flags in the return mask
+ * (and watch out for borders), if necessary.
+ */
+ if (umask & XValue) {
+ rx = ((umask & XNegative) ?
+ (DisplayWidth (dpy, screen) + ux - rwidth - 2 * bwidth) : ux);
+ } else if (dmask & XValue) {
+ if (dmask & XNegative) {
+ rx = (DisplayWidth (dpy, screen) + dx - rwidth - 2 * bwidth);
+ rmask |= XNegative;
+ } else
+ rx = dx;
+ } else {
+ rx = 0; /* gotta choose something... */
+ }
+
+ if (umask & YValue) {
+ ry = ((umask & YNegative) ?
+ (DisplayHeight(dpy, screen) + uy - rheight - 2 * bwidth) : uy);
+ } else if (dmask & YValue) {
+ if (dmask & YNegative) {
+ ry = (DisplayHeight(dpy, screen) + dy - rheight - 2 * bwidth);
+ rmask |= YNegative;
+ } else
+ ry = dy;
+ } else {
+ ry = 0; /* gotta choose something... */
+ }
+
+
+ /*
+ * All finished, so set the return variables.
+ */
+ *x_return = rx;
+ *y_return = ry;
+ *width_return = rwidth;
+ *height_return = rheight;
+ *gravity_return = _GeometryMaskToGravity (rmask);
+ return rmask;
+}
+
+
+static int _GeometryMaskToGravity (mask)
+ int mask;
+{
+ switch (mask & (XNegative|YNegative)) {
+ case 0:
+ return NorthWestGravity;
+ case XNegative:
+ return NorthEastGravity;
+ case YNegative:
+ return SouthWestGravity;
+ default:
+ return SouthEastGravity;
+ }
+}
diff --git a/src/WMProps.c b/src/WMProps.c
new file mode 100644
index 00000000..c1ed9a9d
--- /dev/null
+++ b/src/WMProps.c
@@ -0,0 +1,132 @@
+/* $Xorg: WMProps.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1988, 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
+
+ All Rights Reserved
+
+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 Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+#include <X11/Xos.h>
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+/*
+ * XSetWMProperties sets the following properties:
+ * WM_NAME type: TEXT format: varies?
+ * WM_ICON_NAME type: TEXT format: varies?
+ * WM_HINTS type: WM_HINTS format: 32
+ * WM_COMMAND type: TEXT format: varies?
+ * WM_CLIENT_MACHINE type: TEXT format: varies?
+ * WM_NORMAL_HINTS type: WM_SIZE_HINTS format: 32
+ * WM_CLASS type: STRING/STRING format: 8
+ */
+
+void XSetWMProperties (dpy, w, windowName, iconName, argv, argc, sizeHints,
+ wmHints, classHints)
+ Display *dpy;
+ Window w; /* window to decorate */
+ XTextProperty *windowName; /* name of application */
+ XTextProperty *iconName; /* name string for icon */
+ char **argv; /* command line */
+ int argc; /* size of command line */
+ XSizeHints *sizeHints; /* size hints for window in its normal state */
+ XWMHints *wmHints; /* miscelaneous window manager hints */
+ XClassHint *classHints; /* resource name and class */
+{
+ XTextProperty textprop;
+ char hostName[256];
+ int len = _XGetHostname (hostName, sizeof hostName);
+
+ /* set names of window and icon */
+ if (windowName) XSetWMName (dpy, w, windowName);
+ if (iconName) XSetWMIconName (dpy, w, iconName);
+
+ /* set the command if given */
+ if (argv) {
+ /*
+ * for UNIX and other operating systems which use nul-terminated
+ * arrays of STRINGs.
+ */
+ XSetCommand (dpy, w, argv, argc);
+ }
+
+ /* set the name of the machine on which this application is running */
+ textprop.value = (unsigned char *) hostName;
+ textprop.encoding = XA_STRING;
+ textprop.format = 8;
+ textprop.nitems = len;
+ XSetWMClientMachine (dpy, w, &textprop);
+
+ /* set hints about how geometry and window manager interaction */
+ if (sizeHints) XSetWMNormalHints (dpy, w, sizeHints);
+ if (wmHints) XSetWMHints (dpy, w, wmHints);
+ if (classHints) {
+ XClassHint tmp;
+
+ if (!classHints->res_name) {
+ tmp.res_name = getenv ("RESOURCE_NAME");
+ if (!tmp.res_name && argv && argv[0]) {
+ /*
+ * UNIX uses /dir/subdir/.../basename; other operating
+ * systems will have to change this.
+ */
+ char *cp = strrchr (argv[0], '/');
+ tmp.res_name = (cp ? cp + 1 : argv[0]);
+ }
+ tmp.res_class = classHints->res_class;
+ classHints = &tmp;
+ }
+ XSetClassHint (dpy, w, classHints);
+ }
+}
+
diff --git a/src/WarpPtr.c b/src/WarpPtr.c
new file mode 100644
index 00000000..e3dfc8da
--- /dev/null
+++ b/src/WarpPtr.c
@@ -0,0 +1,54 @@
+/* $Xorg: WarpPtr.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+XWarpPointer(dpy, src_win, dest_win, src_x, src_y, src_width, src_height,
+ dest_x, dest_y)
+ register Display *dpy;
+ Window src_win, dest_win;
+ int src_x, src_y;
+ unsigned int src_width, src_height;
+ int dest_x, dest_y;
+{
+ register xWarpPointerReq *req;
+
+ LockDisplay(dpy);
+ GetReq(WarpPointer, req);
+ req->srcWid = src_win;
+ req->dstWid = dest_win;
+ req->srcX = src_x;
+ req->srcY = src_y;
+ req->srcWidth = src_width;
+ req->srcHeight = src_height;
+ req->dstX = dest_x;
+ req->dstY = dest_y;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 1;
+}
+
diff --git a/src/WinEvent.c b/src/WinEvent.c
new file mode 100644
index 00000000..726c7729
--- /dev/null
+++ b/src/WinEvent.c
@@ -0,0 +1,84 @@
+/* $Xorg: WinEvent.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+extern long Const _Xevent_to_mask[];
+#define AllPointers (PointerMotionMask|PointerMotionHintMask|ButtonMotionMask)
+#define AllButtons (Button1MotionMask|Button2MotionMask|Button3MotionMask|\
+ Button4MotionMask|Button5MotionMask)
+
+/*
+ * Return the next event in the queue
+ * for the given window matching one of the events in the mask.
+ * Events earlier in the queue are not discarded.
+ * If none found, flush, and then wait until an event arrives which
+ * matches.
+ */
+
+XWindowEvent (dpy, w, mask, event)
+ register Display *dpy;
+ Window w; /* Selected window. */
+ long mask; /* Selected event mask. */
+ register XEvent *event; /* XEvent to be filled in. */
+{
+ register _XQEvent *prev, *qelt;
+ unsigned long qe_serial;
+
+ LockDisplay(dpy);
+ prev = NULL;
+ while (1) {
+ for (qelt = prev ? prev->next : dpy->head;
+ qelt;
+ prev = qelt, qelt = qelt->next) {
+ if ((qelt->event.xany.window == w) &&
+ (qelt->event.type < LASTEvent) &&
+ (_Xevent_to_mask[qelt->event.type] & mask) &&
+ ((qelt->event.type != MotionNotify) ||
+ (mask & AllPointers) ||
+ (mask & AllButtons & qelt->event.xmotion.state))) {
+ *event = qelt->event;
+ _XDeq(dpy, prev, qelt);
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ }
+ if (prev)
+ qe_serial = prev->qserial_num;
+ _XReadEvents(dpy);
+ if (prev && prev->qserial_num != qe_serial)
+ /* another thread has snatched this event */
+ prev = NULL;
+ }
+}
diff --git a/src/Window.c b/src/Window.c
new file mode 100644
index 00000000..5d1f0afe
--- /dev/null
+++ b/src/Window.c
@@ -0,0 +1,136 @@
+/* $Xorg: Window.c,v 1.5 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1986, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+
+void _XProcessWindowAttributes (dpy, req, valuemask, attributes)
+ register Display *dpy;
+ xChangeWindowAttributesReq *req;
+ register unsigned long valuemask;
+ register XSetWindowAttributes *attributes;
+{
+ unsigned long values[32];
+ register unsigned long *value = values;
+ unsigned int nvalues;
+
+ if (valuemask & CWBackPixmap)
+ *value++ = attributes->background_pixmap;
+
+ if (valuemask & CWBackPixel)
+ *value++ = attributes->background_pixel;
+
+ if (valuemask & CWBorderPixmap)
+ *value++ = attributes->border_pixmap;
+
+ if (valuemask & CWBorderPixel)
+ *value++ = attributes->border_pixel;
+
+ if (valuemask & CWBitGravity)
+ *value++ = attributes->bit_gravity;
+
+ if (valuemask & CWWinGravity)
+ *value++ = attributes->win_gravity;
+
+ if (valuemask & CWBackingStore)
+ *value++ = attributes->backing_store;
+
+ if (valuemask & CWBackingPlanes)
+ *value++ = attributes->backing_planes;
+
+ if (valuemask & CWBackingPixel)
+ *value++ = attributes->backing_pixel;
+
+ if (valuemask & CWOverrideRedirect)
+ *value++ = attributes->override_redirect;
+
+ if (valuemask & CWSaveUnder)
+ *value++ = attributes->save_under;
+
+ if (valuemask & CWEventMask)
+ *value++ = attributes->event_mask;
+
+ if (valuemask & CWDontPropagate)
+ *value++ = attributes->do_not_propagate_mask;
+
+ if (valuemask & CWColormap)
+ *value++ = attributes->colormap;
+
+ if (valuemask & CWCursor)
+ *value++ = attributes->cursor;
+
+ req->length += (nvalues = value - values);
+
+ nvalues <<= 2; /* watch out for macros... */
+ Data32 (dpy, (long *) values, (long)nvalues);
+
+}
+
+#define AllMaskBits (CWBackPixmap|CWBackPixel|CWBorderPixmap|\
+ CWBorderPixel|CWBitGravity|CWWinGravity|\
+ CWBackingStore|CWBackingPlanes|CWBackingPixel|\
+ CWOverrideRedirect|CWSaveUnder|CWEventMask|\
+ CWDontPropagate|CWColormap|CWCursor)
+
+Window XCreateWindow(dpy, parent, x, y, width, height,
+ borderWidth, depth, class, visual, valuemask, attributes)
+ register Display *dpy;
+ Window parent;
+ int x, y;
+ unsigned int width, height, borderWidth;
+ int depth;
+ unsigned int class;
+ Visual *visual;
+ unsigned long valuemask;
+ XSetWindowAttributes *attributes;
+{
+ Window wid;
+ register xCreateWindowReq *req;
+
+ LockDisplay(dpy);
+ GetReq(CreateWindow, req);
+ req->parent = parent;
+ req->x = x;
+ req->y = y;
+ req->width = width;
+ req->height = height;
+ req->borderWidth = borderWidth;
+ req->depth = depth;
+ req->class = class;
+ if (visual == CopyFromParent)
+ req->visual = CopyFromParent;
+ else
+ req->visual = visual->visualid;
+ wid = req->wid = XAllocID(dpy);
+ valuemask &= AllMaskBits;
+ if ((req->mask = valuemask))
+ _XProcessWindowAttributes (dpy, (xChangeWindowAttributesReq *)req,
+ valuemask, attributes);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (wid);
+ }
+
diff --git a/src/Withdraw.c b/src/Withdraw.c
new file mode 100644
index 00000000..e9735a9b
--- /dev/null
+++ b/src/Withdraw.c
@@ -0,0 +1,81 @@
+/* $Xorg: Withdraw.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1988 by Wyse Technology, Inc., San Jose, Ca.,
+
+ All Rights Reserved
+
+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 Wyse not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+WYSE DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1988, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#include <X11/Xos.h>
+#include <X11/Xutil.h>
+#include <stdio.h>
+
+/*
+ * This function instructs the window manager to change this window from
+ * NormalState or IconicState to Withdrawn.
+ */
+Status XWithdrawWindow (dpy, w, screen)
+ Display *dpy;
+ Window w;
+ int screen;
+{
+ XUnmapEvent ev;
+ Window root = RootWindow (dpy, screen);
+
+ XUnmapWindow (dpy, w);
+
+ ev.type = UnmapNotify;
+ ev.event = root;
+ ev.window = w;
+ ev.from_configure = False;
+ return (XSendEvent (dpy, root, False,
+ SubstructureRedirectMask|SubstructureNotifyMask,
+ (XEvent *)&ev));
+}
diff --git a/src/WrBitF.c b/src/WrBitF.c
new file mode 100644
index 00000000..e8fad11d
--- /dev/null
+++ b/src/WrBitF.c
@@ -0,0 +1,159 @@
+/* $Xorg: WrBitF.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include <X11/Xos.h>
+#include "Xutil.h"
+#include <stdio.h>
+
+#define ERR_RETURN 0
+
+static char *Format_Image(image, resultsize)
+XImage *image;
+int *resultsize;
+{
+ register int x, c, b;
+ register char *ptr;
+ int y;
+ char *data;
+ int width, height;
+ int bytes_per_line;
+
+ width = image->width;
+ height = image->height;
+
+ bytes_per_line = (width+7)/8;
+ *resultsize = bytes_per_line * height; /* Calculate size of data */
+
+ data = (char *) Xmalloc( *resultsize ); /* Get space for data */
+ if (!data)
+ return(ERR_RETURN);
+
+ /*
+ * The slow but robust brute force method of converting the image:
+ */
+ ptr = data;
+ c = 0; b=1;
+ for (y=0; y<height; y++) {
+ for (x=0; x<width;) {
+ if (XGetPixel(image, x, y))
+ c |= b;
+ b <<= 1;
+ if (!(++x & 7)) {
+ *(ptr++)=c;
+ c=0; b=1;
+ }
+ }
+ if (x & 7) {
+ *(ptr++)=c;
+ c=0; b=1;
+ }
+ }
+
+ return(data);
+}
+
+#define BYTES_PER_OUTPUT_LINE 12
+
+#if NeedFunctionPrototypes
+int XWriteBitmapFile(
+ Display *display,
+ _Xconst char *filename,
+ Pixmap bitmap,
+ unsigned int width,
+ unsigned int height,
+ int x_hot,
+ int y_hot)
+#else
+int XWriteBitmapFile(display, filename, bitmap, width, height, x_hot, y_hot)
+ Display *display;
+ char *filename;
+ Pixmap bitmap;
+ unsigned int width, height;
+ int x_hot, y_hot;
+#endif
+{
+ char *data, *ptr;
+ int size, byte;
+ int c;
+ XImage *image;
+ FILE *stream;
+ char *name;
+
+ if (!(name = strrchr(filename, '/')))
+ name = (char *)filename;
+ else
+ name++;
+
+ if (!(stream = fopen(filename, "w")))
+ return(BitmapOpenFailed);
+
+ /* Convert bitmap to an image */
+ image = XGetImage(display, bitmap, 0,0,width, height, 1L, XYPixmap);
+ if (!image) {
+ fclose(stream);
+ return(4); /* XXX spec does not say what to return */
+ }
+
+ /* Get standard format for data */
+ data = Format_Image(image, &size);
+ XDestroyImage(image);
+ if (!data) {
+ fclose(stream);
+ return(BitmapNoMemory);
+ }
+
+ /* Write out standard header */
+ fprintf(stream, "#define %s_width %d\n", name, width);
+ fprintf(stream, "#define %s_height %d\n", name, height);
+ if (x_hot != -1) {
+ fprintf(stream, "#define %s_x_hot %d\n", name, x_hot);
+ fprintf(stream, "#define %s_y_hot %d\n", name, y_hot);
+ }
+
+ /* Print out the data itself */
+ fprintf(stream, "static unsigned char %s_bits[] = {", name);
+ for (byte=0, ptr=data; byte<size; byte++, ptr++) {
+ if (!byte)
+ fprintf(stream, "\n ");
+ else if (!(byte % BYTES_PER_OUTPUT_LINE))
+ fprintf(stream, ",\n ");
+ else
+ fprintf(stream, ", ");
+ c = *ptr;
+ if (c<0)
+ c += 256;
+ fprintf(stream, "0x%02x", c);
+ }
+ fprintf(stream, "};\n");
+
+ Xfree(data);
+ fclose(stream);
+ return(BitmapSuccess);
+}
diff --git a/src/XErrorDB b/src/XErrorDB
new file mode 100644
index 00000000..5996026c
--- /dev/null
+++ b/src/XErrorDB
@@ -0,0 +1,737 @@
+! $Xorg: XErrorDB,v 1.3 2000/08/17 19:44:59 cpqbld Exp $
+! Copyright 1993, 1995, 1998 The Open Group
+
+! All Rights Reserved.
+!
+! The above copyright notice and this permission notice shall be
+! included in all copies or substantial portions of the Software.
+!
+! THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+! EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+! MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+! IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+! OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+! ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+! OTHER DEALINGS IN THE SOFTWARE.
+!
+! Except as contained in this notice, the name of The Open Group shall
+! not be used in advertising or otherwise to promote the sale, use or
+! other dealings in this Software without prior written authorization
+! from The Open Group.
+!
+! these are used in XGetErrorMessage.
+XlibMessage.XError: X Error of failed request
+XlibMessage.MajorCode: Major opcode of failed request: %d
+XlibMessage.MinorCode: Minor opcode of failed request: %d
+XlibMessage.ResourceID: Resource id in failed request: 0x%lx
+XlibMessage.Value: Value in failed request: 0x%lx
+XlibMessage.AtomID: Atom id in failed request: 0x%lx
+XlibMessage.ErrorSerial: Serial number of failed request: %lu
+XlibMessage.CurrentSerial: Current serial number in output stream: %lu
+! X request codes.
+XRequest.1:X_CreateWindow
+XRequest.2:X_ChangeWindowAttributes
+XRequest.3:X_GetWindowAttributes
+XRequest.4:X_DestroyWindow
+XRequest.5:X_DestroySubwindows
+XRequest.6:X_ChangeSaveSet
+XRequest.7:X_ReparentWindow
+XRequest.8:X_MapWindow
+XRequest.9:X_MapSubwindows
+XRequest.10:X_UnmapWindow
+XRequest.11:X_UnmapSubwindows
+XRequest.12:X_ConfigureWindow
+XRequest.13:X_CirculateWindow
+XRequest.14:X_GetGeometry
+XRequest.15:X_QueryTree
+XRequest.16:X_InternAtom
+XRequest.17:X_GetAtomName
+XRequest.18:X_ChangeProperty
+XRequest.19:X_DeleteProperty
+XRequest.20:X_GetProperty
+XRequest.21:X_ListProperties
+XRequest.22:X_SetSelectionOwner
+XRequest.23:X_GetSelectionOwner
+XRequest.24:X_ConvertSelection
+XRequest.25:X_SendEvent
+XRequest.26:X_GrabPointer
+XRequest.27:X_UngrabPointer
+XRequest.28:X_GrabButton
+XRequest.29:X_UngrabButton
+XRequest.30:X_ChangeActivePointerGrab
+XRequest.31:X_GrabKeyboard
+XRequest.32:X_UngrabKeyboard
+XRequest.33:X_GrabKey
+XRequest.34:X_UngrabKey
+XRequest.35:X_AllowEvents
+XRequest.36:X_GrabServer
+XRequest.37:X_UngrabServer
+XRequest.38:X_QueryPointer
+XRequest.39:X_GetMotionEvents
+XRequest.40:X_TranslateCoords
+XRequest.41:X_WarpPointer
+XRequest.42:X_SetInputFocus
+XRequest.43:X_GetInputFocus
+XRequest.44:X_QueryKeymap
+XRequest.45:X_OpenFont
+XRequest.46:X_CloseFont
+XRequest.47:X_QueryFont
+XRequest.48:X_QueryTextExtents
+XRequest.49:X_ListFonts
+XRequest.50:X_ListFontsWithInfo
+XRequest.51:X_SetFontPath
+XRequest.52:X_GetFontPath
+XRequest.53:X_CreatePixmap
+XRequest.54:X_FreePixmap
+XRequest.55:X_CreateGC
+XRequest.56:X_ChangeGC
+XRequest.57:X_CopyGC
+XRequest.58:X_SetDashes
+XRequest.59:X_SetClipRectangles
+XRequest.60:X_FreeGC
+XRequest.61:X_ClearArea
+XRequest.62:X_CopyArea
+XRequest.63:X_CopyPlane
+XRequest.64:X_PolyPoint
+XRequest.65:X_PolyLine
+XRequest.66:X_PolySegment
+XRequest.67:X_PolyRectangle
+XRequest.68:X_PolyArc
+XRequest.69:X_FillPoly
+XRequest.70:X_PolyFillRectangle
+XRequest.71:X_PolyFillArc
+XRequest.72:X_PutImage
+XRequest.73:X_GetImage
+XRequest.74:X_PolyText8
+XRequest.75:X_PolyText16
+XRequest.76:X_ImageText8
+XRequest.77:X_ImageText16
+XRequest.78:X_CreateColormap
+XRequest.79:X_FreeColormap
+XRequest.80:X_CopyColormapAndFree
+XRequest.81:X_InstallColormap
+XRequest.82:X_UninstallColormap
+XRequest.83:X_ListInstalledColormaps
+XRequest.84:X_AllocColor
+XRequest.85:X_AllocNamedColor
+XRequest.86:X_AllocColorCells
+XRequest.87:X_AllocColorPlanes
+XRequest.88:X_FreeColors
+XRequest.89:X_StoreColors
+XRequest.90:X_StoreNamedColor
+XRequest.91:X_QueryColors
+XRequest.92:X_LookupColor
+XRequest.93:X_CreateCursor
+XRequest.94:X_CreateGlyphCursor
+XRequest.95:X_FreeCursor
+XRequest.96:X_RecolorCursor
+XRequest.97:X_QueryBestSize
+XRequest.98:X_QueryExtension
+XRequest.99:X_ListExtensions
+XRequest.100:X_ChangeKeyboardMapping
+XRequest.101:X_GetKeyboardMapping
+XRequest.102:X_ChangeKeyboardControl
+XRequest.103:X_GetKeyboardControl
+XRequest.104:X_Bell
+XRequest.105:X_ChangePointerControl
+XRequest.106:X_GetPointerControl
+XRequest.107:X_SetScreenSaver
+XRequest.108:X_GetScreenSaver
+XRequest.109:X_ChangeHosts
+XRequest.110:X_ListHosts
+XRequest.111:X_SetAccessControl
+XRequest.112:X_SetCloseDownMode
+XRequest.113:X_KillClient
+XRequest.114:X_RotateProperties
+XRequest.115:X_ForceScreenSaver
+XRequest.116:X_SetPointerMapping
+XRequest.117:X_GetPointerMapping
+XRequest.118:X_SetModifierMapping
+XRequest.119:X_GetModifierMapping
+XRequest.127:X_NoOperation
+! X Error Codes
+XProtoError.0: unknown error code 0
+XProtoError.1: BadRequest (invalid request code or no such operation)
+XProtoError.2: BadValue (integer parameter out of range for operation)
+XProtoError.3: BadWindow (invalid Window parameter)
+XProtoError.4: BadPixmap (invalid Pixmap parameter)
+XProtoError.5: BadAtom (invalid Atom parameter)
+XProtoError.6: BadCursor (invalid Cursor parameter)
+XProtoError.7: BadFont (invalid Font parameter)
+XProtoError.8: BadMatch (invalid parameter attributes)
+XProtoError.9: BadDrawable (invalid Pixmap or Window parameter)
+XProtoError.10: BadAccess (attempt to access private resource denied)
+XProtoError.11: BadAlloc (insufficient resources for operation)
+XProtoError.12: BadColor (invalid Colormap parameter)
+XProtoError.13: BadGC (invalid GC parameter)
+XProtoError.14: BadIDChoice (invalid resource ID chosen for this connection)
+XProtoError.15: BadName (named color or font does not exist)
+XProtoError.16: BadLength (poly request too large or internal Xlib length error)
+XProtoError.17: BadImplementation (server does not implement operation)
+! Multi-Buffering extension, not an X Consortium standard
+XRequest.Multi-Buffering.0: X_MbufGetBufferVersion
+XRequest.Multi-Buffering.1: X_MbufCreateImageBuffers
+XRequest.Multi-Buffering.2: X_MbufDestroyImageBuffers
+XRequest.Multi-Buffering.3: X_MbufDisplayImageBuffers
+XRequest.Multi-Buffering.4: X_MbufSetMultiBufferAttributes
+XRequest.Multi-Buffering.5: X_MbufGetMultiBufferAttributes
+XRequest.Multi-Buffering.6: X_MbufSetBufferAttributes
+XRequest.Multi-Buffering.7: X_MbufGetBufferAttributes
+XRequest.Multi-Buffering.8: X_MbufGetBufferInfo
+XRequest.Multi-Buffering.9: X_MbufCreateStereoWindow
+XProtoError.Multi-Buffering.0: BadBuffer (invalid Buffer parameter)
+XlibMessage.Multi-Buffering.0: Buffer id in failed request: 0x%lx
+! SHAPE extension, an X Consortium standard
+XRequest.SHAPE.0: X_ShapeQueryVersion
+XRequest.SHAPE.1: X_ShapeRectangles
+XRequest.SHAPE.2: X_ShapeMask
+XRequest.SHAPE.3: X_ShapeCombine
+XRequest.SHAPE.4: X_ShapeOffset
+XRequest.SHAPE.5: X_ShapeQueryExtents
+XRequest.SHAPE.6: X_ShapeSelectInput
+XRequest.SHAPE.7: X_ShapeInputSelected
+XRequest.SHAPE.8: X_ShapeGetRectangles
+! Input extension, an X Consortium standard
+XRequest.XInputExtension.1:X_GetExtensionVersion
+XRequest.XInputExtension.2:X_ListInputDevices
+XRequest.XInputExtension.3:X_OpenDevice
+XRequest.XInputExtension.4:X_CloseDevice
+XRequest.XInputExtension.5:X_SetDeviceMode
+XRequest.XInputExtension.6:X_SelectExtensionEvent
+XRequest.XInputExtension.7:X_GetSelectedExtensionEvents
+XRequest.XInputExtension.8:X_ChangeDeviceDontPropagateList
+XRequest.XInputExtension.9:X_GetDeviceDontPropagateList
+XRequest.XInputExtension.10:X_GetDeviceMotionEvents
+XRequest.XInputExtension.11:X_ChangeKeyboardDevice
+XRequest.XInputExtension.12:X_ChangePointerDevice
+XRequest.XInputExtension.13:X_GrabDevice
+XRequest.XInputExtension.14:X_UngrabDevice
+XRequest.XInputExtension.15:X_GrabDeviceKey
+XRequest.XInputExtension.16:X_UngrabDeviceKey
+XRequest.XInputExtension.17:X_GrabDeviceButton
+XRequest.XInputExtension.18:X_UngrabDeviceButton
+XRequest.XInputExtension.19:X_AllowDeviceEvents
+XRequest.XInputExtension.20:X_GetDeviceFocus
+XRequest.XInputExtension.21:X_SetDeviceFocus
+XRequest.XInputExtension.22:X_GetFeedbackControl
+XRequest.XInputExtension.23:X_ChangeFeedbackControl
+XRequest.XInputExtension.24:X_GetDeviceKeyMapping
+XRequest.XInputExtension.25:X_ChangeDeviceKeyMapping
+XRequest.XInputExtension.26:X_GetDeviceModifierMapping
+XRequest.XInputExtension.27:X_SetDeviceModifierMapping
+XRequest.XInputExtension.28:X_GetDeviceButtonMapping
+XRequest.XInputExtension.29:X_SetDeviceButtonMapping
+XRequest.XInputExtension.30:X_QueryDeviceState
+XRequest.XInputExtension.31:X_SendExtensionEvent
+XRequest.XInputExtension.32:X_DeviceBell
+XRequest.XInputExtension.33:X_SetDeviceValuators
+XRequest.XInputExtension.34:X_GetDeviceControl
+XRequest.XInputExtension.35:X_ChangeDeviceControl
+! MIT-SHM extension, experimental, not an X Consortium standard
+XRequest.MIT-SHM.0: X_ShmQueryVersion
+XRequest.MIT-SHM.1: X_ShmAttach
+XRequest.MIT-SHM.2: X_ShmDetach
+XRequest.MIT-SHM.3: X_ShmPutImage
+XRequest.MIT-SHM.4: X_ShmGetImage
+XRequest.MIT-SHM.5: X_ShmCreatePixmap
+XProtoError.MIT-SHM.0: BadShmSeg (invalid shared segment parameter)
+XlibMessage.MIT-SHM.0: Segment id in failed request: 0x%lx
+! MIT-SUNDRY-NONSTANDARD extension, definitely not an X Consortium standard
+XRequest.MIT-SUNDRY-NONSTANDARD.0: X_MITSetBugMode
+XRequest.MIT-SUNDRY-NONSTANDARD.1: X_MITGetBugMode
+! X3D-PEX extension
+XRequest.X3D-PEX.1: PEX_GetExtensionInfo
+XRequest.X3D-PEX.2: PEX_GetEnumeratedTypeInfo
+XRequest.X3D-PEX.3: PEX_GetImpDepConstants
+XRequest.X3D-PEX.4: PEX_CreateLookupTable
+XRequest.X3D-PEX.5: PEX_CopyLookupTable
+XRequest.X3D-PEX.6: PEX_FreeLookupTable
+XRequest.X3D-PEX.7: PEX_GetTableInfo
+XRequest.X3D-PEX.8: PEX_GetPredefinedEntries
+XRequest.X3D-PEX.9: PEX_GetDefinedIndices
+XRequest.X3D-PEX.10: PEX_GetTableEntry
+XRequest.X3D-PEX.11: PEX_GetTableEntries
+XRequest.X3D-PEX.12: PEX_SetTableEntries
+XRequest.X3D-PEX.13: PEX_DeleteTableEntries
+XRequest.X3D-PEX.14: PEX_CreatePipelineContext
+XRequest.X3D-PEX.15: PEX_CopyPipelineContext
+XRequest.X3D-PEX.16: PEX_FreePipelineContext
+XRequest.X3D-PEX.17: PEX_GetPipelineContext
+XRequest.X3D-PEX.18: PEX_ChangePipelineContext
+XRequest.X3D-PEX.19: PEX_CreateRenderer
+XRequest.X3D-PEX.20: PEX_FreeRenderer
+XRequest.X3D-PEX.21: PEX_ChangeRenderer
+XRequest.X3D-PEX.22: PEX_GetRendererAttributes
+XRequest.X3D-PEX.23: PEX_GetRendererDynamics
+XRequest.X3D-PEX.24: PEX_BeginRendering
+XRequest.X3D-PEX.25: PEX_EndRendering
+XRequest.X3D-PEX.26: PEX_BeginStructure
+XRequest.X3D-PEX.27: PEX_EndStructure
+XRequest.X3D-PEX.28: PEX_RenderOutputCommands
+XRequest.X3D-PEX.29: PEX_RenderNetwork
+XRequest.X3D-PEX.30: PEX_CreateStructure
+XRequest.X3D-PEX.31: PEX_CopyStructure
+XRequest.X3D-PEX.32: PEX_DestroyStructures
+XRequest.X3D-PEX.33: PEX_GetStructureInfo
+XRequest.X3D-PEX.34: PEX_GetElementInfo
+XRequest.X3D-PEX.35: PEX_GetStructuresInNetwork
+XRequest.X3D-PEX.36: PEX_GetAncestors
+XRequest.X3D-PEX.37: PEX_GetDescendants
+XRequest.X3D-PEX.38: PEX_FetchElements
+XRequest.X3D-PEX.39: PEX_SetEditingMode
+XRequest.X3D-PEX.40: PEX_SetElementPointer
+XRequest.X3D-PEX.41: PEX_SetElementPointerAtLabel
+XRequest.X3D-PEX.42: PEX_ElementSearch
+XRequest.X3D-PEX.43: PEX_StoreElements
+XRequest.X3D-PEX.44: PEX_DeleteElements
+XRequest.X3D-PEX.45: PEX_DeleteElementsToLabel
+XRequest.X3D-PEX.46: PEX_DeleteBetweenLabels
+XRequest.X3D-PEX.47: PEX_CopyElements
+XRequest.X3D-PEX.48: PEX_ChangeStructureRefs
+XRequest.X3D-PEX.49: PEX_CreateNameSet
+XRequest.X3D-PEX.50: PEX_CopyNameSet
+XRequest.X3D-PEX.51: PEX_FreeNameSet
+XRequest.X3D-PEX.52: PEX_GetNameSet
+XRequest.X3D-PEX.53: PEX_ChangeNameSet
+XRequest.X3D-PEX.54: PEX_CreateSearchContext
+XRequest.X3D-PEX.55: PEX_CopySearchContext
+XRequest.X3D-PEX.56: PEX_FreeSearchContext
+XRequest.X3D-PEX.57: PEX_GetSearchContext
+XRequest.X3D-PEX.58: PEX_ChangeSearchContext
+XRequest.X3D-PEX.59: PEX_SearchNetwork
+XRequest.X3D-PEX.60: PEX_CreatePhigsWks
+XRequest.X3D-PEX.61: PEX_FreePhigsWks
+XRequest.X3D-PEX.62: PEX_GetWksInfo
+XRequest.X3D-PEX.63: PEX_GetDynamics
+XRequest.X3D-PEX.64: PEX_GetViewRep
+XRequest.X3D-PEX.65: PEX_RedrawAllStructures
+XRequest.X3D-PEX.66: PEX_UpdateWorkstation
+XRequest.X3D-PEX.67: PEX_RedrawClipRegion
+XRequest.X3D-PEX.68: PEX_ExecuteDeferredActions
+XRequest.X3D-PEX.69: PEX_SetViewPriority
+XRequest.X3D-PEX.70: PEX_SetDisplayUpdateMode
+XRequest.X3D-PEX.71: PEX_MapDCtoWC
+XRequest.X3D-PEX.72: PEX_MapWCtoDC
+XRequest.X3D-PEX.73: PEX_SetViewRep
+XRequest.X3D-PEX.74: PEX_SetWksWindow
+XRequest.X3D-PEX.75: PEX_SetWksViewport
+XRequest.X3D-PEX.76: PEX_SetHlhsrMode
+XRequest.X3D-PEX.77: PEX_SetWksBufferMode
+XRequest.X3D-PEX.78: PEX_PostStructure
+XRequest.X3D-PEX.79: PEX_UnpostStructure
+XRequest.X3D-PEX.80: PEX_UnpostAllStructures
+XRequest.X3D-PEX.81: PEX_GetWksPostings
+XRequest.X3D-PEX.82: PEX_GetPickDevice
+XRequest.X3D-PEX.83: PEX_ChangePickDevice
+XRequest.X3D-PEX.84: PEX_CreatePickMeasure
+XRequest.X3D-PEX.85: PEX_FreePickMeasure
+XRequest.X3D-PEX.86: PEX_GetPickMeasure
+XRequest.X3D-PEX.87: PEX_UpdatePickMeasure
+XRequest.X3D-PEX.88: PEX_OpenFont
+XRequest.X3D-PEX.89: PEX_CloseFont
+XRequest.X3D-PEX.90: PEX_QueryFont
+XRequest.X3D-PEX.91: PEX_ListFonts
+XRequest.X3D-PEX.92: PEX_ListFontsWithInfo
+XRequest.X3D-PEX.93: PEX_QueryTextExtents
+XRequest.X3D-PEX.94: PEX_MatchRenderingTargets
+XRequest.X3D-PEX.95: PEX_Escape
+XRequest.X3D-PEX.96: PEX_EscapeWithReply
+XRequest.X3D-PEX.97: PEX_RenderElements
+XRequest.X3D-PEX.98: PEX_AccumulateState
+XRequest.X3D-PEX.99: PEX_BeginPickOne
+XRequest.X3D-PEX.100: PEX_EndPickOne
+XRequest.X3D-PEX.101: PEX_PickOne
+XRequest.X3D-PEX.102: PEX_BeginPickAll
+XRequest.X3D-PEX.103: PEX_EndPickAll
+XRequest.X3D-PEX.104: PEX_PickAll
+XProtoError.X3D-PEX.0: PEXColorTypeError
+XlibMessage.X3D-PEX.0: Color type in failed request: 0x%lx
+XProtoError.X3D-PEX.1: PEXRendererStateError
+XlibMessage.X3D-PEX.1: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.2: PEXFloatingPointFormatError
+XlibMessage.X3D-PEX.2: Format in failed request: 0x%lx
+XProtoError.X3D-PEX.3: PEXLabelError
+XlibMessage.X3D-PEX.3: Label in failed request: 0x%lx
+XProtoError.X3D-PEX.4: PEXLookupTableError
+XlibMessage.X3D-PEX.4: Table id in failed request: 0x%lx
+XProtoError.X3D-PEX.5: PEXNameSetError
+XlibMessage.X3D-PEX.5: Nameset in failed request: 0x%lx
+XProtoError.X3D-PEX.6: PEXPathError
+XlibMessage.X3D-PEX.6: Path id in failed request: 0x%lx
+XProtoError.X3D-PEX.7: PEXFontError
+XlibMessage.X3D-PEX.7: Font id in failed request: 0x%lx
+XProtoError.X3D-PEX.8: PEXPhigsWksError
+XlibMessage.X3D-PEX.8: Workstation id in failed request: 0x%lx
+XProtoError.X3D-PEX.9: PEXPickMeasureError
+XlibMessage.X3D-PEX.9: Device id in failed request: 0x%lx
+XProtoError.X3D-PEX.10: PEXPipelineContextError
+XlibMessage.X3D-PEX.10: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.11: PEXRendererError
+XlibMessage.X3D-PEX.11: Renderer id in failed request: 0x%lx
+XProtoError.X3D-PEX.12: PEXSearchContextError
+XlibMessage.X3D-PEX.12: Context id in failed request: 0x%lx
+XProtoError.X3D-PEX.13: PEXStructureError
+XlibMessage.X3D-PEX.13: Structure id in failed request: 0x%lx
+XProtoError.X3D-PEX.14: PEXOutputCommandError
+XlibMessage.X3D-PEX.14: Resource id in failed request: 0x%lx
+! XTEST extension, an X Consortium standard
+XRequest.XTEST.0: X_XTestGetVersion
+XRequest.XTEST.1: X_XTestCompareCursor
+XRequest.XTEST.2: X_XTestFakeInput
+! BIG-REQUESTS extension, an X Consortium standard
+XRequest.BIG-REQUESTS.0: X_BigReqEnable
+! XIE extension, an X Consortium standard
+XRequest.XIE.1: XIE_QueryImageExtension
+XRequest.XIE.2: XIE_QueryTechniques
+XRequest.XIE.3: XIE_CreateColorList
+XRequest.XIE.4: XIE_DestroyColorList
+XRequest.XIE.5: XIE_PurgeColorList
+XRequest.XIE.6: XIE_QueryColorList
+XRequest.XIE.7: XIE_CreateLUT
+XRequest.XIE.8: XIE_DestroyLUT
+XRequest.XIE.9: XIE_CreatePhotomap
+XRequest.XIE.10: XIE_DestroyPhotomap
+XRequest.XIE.11: XIE_QueryPhotomap
+XRequest.XIE.12: XIE_CreateROI
+XRequest.XIE.13: XIE_DestroyROI
+XRequest.XIE.14: XIE_CreatePhotospace
+XRequest.XIE.15: XIE_DestroyPhotospace
+XRequest.XIE.16: XIE_ExecuteImmediate
+XRequest.XIE.17: XIE_CreatePhotoflo
+XRequest.XIE.18: XIE_DestroyPhotoflo
+XRequest.XIE.19: XIE_ExecutePhotoflo
+XRequest.XIE.20: XIE_ModifyPhotoflo
+XRequest.XIE.21: XIE_RedefinePhotoflo
+XRequest.XIE.22: XIE_PutClientData
+XRequest.XIE.23: XIE_GetClientData
+XRequest.XIE.24: XIE_QueryPhotoflo
+XRequest.XIE.25: XIE_Await
+XRequest.XIE.26: XIE_Abort
+XProtoError.XIE.0: XIE_ColorListError
+XlibMessage.XIE.0: ColorList in failed request: 0x%lx
+XProtoError.XIE.1: XIE_LUTError
+XlibMessage.XIE.1: LUT in failed request: 0x%lx
+XProtoError.XIE.2: XIE_PhotofloError
+XlibMessage.XIE.2: Photoflo in failed request: 0x%lx
+XProtoError.XIE.3: XIE_PhotomapError
+XlibMessage.XIE.3: Photomap in failed request: 0x%lx
+XProtoError.XIE.4: XIE_PhotospaceError
+XlibMessage.XIE.4: Photospace in failed request: 0x%lx
+XProtoError.XIE.5: XIE_ROIError
+XlibMessage.XIE.5: ROI in failed request: 0x%lx
+XProtoError.XIE.6: XIE_FloError
+XlibMessage.XIE.6: Photoflo in failed request: 0x%lx
+! SYNC extension, an X Consortium standard
+XRequest.SYNC.0: X_SyncInitialize
+XRequest.SYNC.1: X_SyncListSystemCounters
+XRequest.SYNC.2: X_SyncCreateCounter
+XRequest.SYNC.3: X_SyncSetCounter
+XRequest.SYNC.4: X_SyncChangeCounter
+XRequest.SYNC.5: X_SyncQueryCounter
+XRequest.SYNC.6: X_SyncDestroyCounter
+XRequest.SYNC.7: X_SyncAwait
+XRequest.SYNC.8: X_SyncCreateAlarm
+XRequest.SYNC.9: X_SyncChangeAlarm
+XRequest.SYNC.10: X_SyncQueryAlarm
+XRequest.SYNC.11: X_SyncDestroyAlarm
+XRequest.SYNC.12: X_SyncSetPriority
+XRequest.SYNC.13: X_SyncGetPriority
+XProtoError.SYNC.0: XSyncBadCounter
+XlibMessage.SYNC.0: Counter in failed request: 0x%lx
+XProtoError.SYNC.1: XSyncBadAlarm
+XlibMessage.SYNC.1: Alarm in failed request: 0x%lx
+! XKB extension
+XRequest.XKEYBOARD.0: XkbUseExtension
+XRequest.XKEYBOARD.1: XkbSelectEvents
+XRequest.XKEYBOARD.2: OBSOLETE
+XRequest.XKEYBOARD.3: XkbBell
+XRequest.XKEYBOARD.4: XkbGetState
+XRequest.XKEYBOARD.5: XkbLatchLockState
+XRequest.XKEYBOARD.6: XkbGetControls
+XRequest.XKEYBOARD.7: XkbSetControls
+XRequest.XKEYBOARD.8: XkbGetMap
+XRequest.XKEYBOARD.9: XkbSetMap
+XRequest.XKEYBOARD.10: XkbGetCompatMap
+XRequest.XKEYBOARD.11: XkbSetCompatMap
+XRequest.XKEYBOARD.12: XkbGetIndicatorState
+XRequest.XKEYBOARD.13: XkbGetIndicatorMap
+XRequest.XKEYBOARD.14: XkbSetIndicatorMap
+XRequest.XKEYBOARD.15: XkbGetNamedIndicator
+XRequest.XKEYBOARD.16: XkbSetNamedIndicator
+XRequest.XKEYBOARD.17: XkbGetNames
+XRequest.XKEYBOARD.18: XkbSetNames
+XRequest.XKEYBOARD.19: XkbGetGeometry
+XRequest.XKEYBOARD.20: XkbSetGeometry
+XRequest.XKEYBOARD.21: XkbPerClientFlags
+XRequest.XKEYBOARD.22: XkbListComponents
+XRequest.XKEYBOARD.23: XkbGetKbdByName
+XRequest.XKEYBOARD.24: XkbGetDeviceInfo
+XRequest.XKEYBOARD.25: XkbSetDeviceInfo
+XRequest.XKEYBOARD.101: XkbSetDebuggingFlags
+XProtoError.XKEYBOARD.0: XkbBadKeyboard
+XlibMessage.XKEYBOARD.0: Device id in failed request: 0x%lx
+! GLX extension for OpenGL, an OpenGL Architectural Review Board standard
+! GLX Commands
+XRequest.GLX.7: X_GLXQueryVersion
+XRequest.GLX.3: X_GLXCreateContext
+XRequest.GLX.4: X_GLXDestroyContext
+XRequest.GLX.5: X_GLXMakeCurrent
+XRequest.GLX.6: X_GLXIsDirect
+XRequest.GLX.10: X_GLXCopyContext
+XRequest.GLX.8: X_GLXWaitGL
+XRequest.GLX.9: X_GLXWaitX
+XRequest.GLX.11: X_GLXSwapBuffers
+XRequest.GLX.12: X_GLXUseXFont
+XRequest.GLX.13: X_GLXCreateGLXPixmap
+XRequest.GLX.15: X_GLXDestroyGLXPixmap
+XRequest.GLX.14: X_GLXGetVisualConfigs
+XRequest.GLX.16: X_GLXVendorPrivate
+XRequest.GLX.17: X_GLXVendorPrivateWithReply
+XRequest.GLX.18: X_GLXQueryExtensionsString
+XRequest.GLX.19: X_GLXQueryServerString
+XRequest.GLX.20: X_GLXClientInfo
+! GL Non-rendering Commands
+XRequest.GLX.103: X_GLXDeleteLists
+XRequest.GLX.102: X_GLXEndList
+XRequest.GLX.105: X_GLXFeedbackBuffer
+XRequest.GLX.108: X_GLXFinish
+XRequest.GLX.142: X_GLXFlush
+XRequest.GLX.104: X_GLXGenLists
+XRequest.GLX.112: X_GLXGetBooleanv
+XRequest.GLX.113: X_GLXGetClipPlane
+XRequest.GLX.114: X_GLXGetDoublev
+XRequest.GLX.115: X_GLXGetError
+XRequest.GLX.116: X_GLXGetFloatv
+XRequest.GLX.117: X_GLXGetIntegerv
+XRequest.GLX.118: X_GLXGetLightfv
+XRequest.GLX.119: X_GLXGetLightiv
+XRequest.GLX.120: X_GLXGetMapdv
+XRequest.GLX.121: X_GLXGetMapfv
+XRequest.GLX.122: X_GLXGetMapiv
+XRequest.GLX.123: X_GLXGetMaterialfv
+XRequest.GLX.124: X_GLXGetMaterialiv
+XRequest.GLX.125: X_GLXGetPixelfv
+XRequest.GLX.126: X_GLXGetPixelMapuiv
+XRequest.GLX.127: X_GLXGetPixelMapusv
+XRequest.GLX.129: X_GLXGetString
+XRequest.GLX.130: X_GLXGetTexEnvfv
+XRequest.GLX.131: X_GLXGetTexEnviv
+XRequest.GLX.132: X_GLXGetTexGendv
+XRequest.GLX.133: X_GLXGetTexGenfv
+XRequest.GLX.134: X_GLXGetTexGeniv
+XRequest.GLX.138: X_GLXGetTexLevelParameterfv
+XRequest.GLX.139: X_GLXGetTexLevelParameteriv
+XRequest.GLX.136: X_GLXGetTexParameterfv
+XRequest.GLX.137: X_GLXGetTexParameteriv
+XRequest.GLX.140: X_GLXIsEnabled
+XRequest.GLX.141: X_GLXIsList
+XRequest.GLX.101: X_GLXNewList
+XRequest.GLX.109: X_GLXPixelStoref
+XRequest.GLX.110: X_GLXPixelStorei
+XRequest.GLX.107: X_GLXRenderMode
+XRequest.GLX.106: X_GLXSelectBuffer
+! GL Non-rendering Commands That Return Pixel Data
+XRequest.GLX.128: X_GLXGetPolygonStipple
+XRequest.GLX.135: X_GLXGetTexImage
+XRequest.GLX.111: X_GLXReadPixels
+! GL Rendering Commands
+XRequest.GLX.1: X_GLXRender
+XRequest.GLX.2: X_GLXRenderLarge
+! GLX Errors
+XProtoError.GLX.0: GLXBadContext
+XProtoError.GLX.1: GLXBadContextState
+XProtoError.GLX.2: GLXBadDrawable
+XProtoError.GLX.3: GLXBadPixmap
+XProtoError.GLX.4: GLXBadContextTag
+XProtoError.GLX.5: GLXBadCurrentWindow
+XProtoError.GLX.6: GLXBadRenderRequest
+XProtoError.GLX.7: GLXBadLargeRequest
+XProtoError.GLX.8: GLXUnsupportedPrivateRequest
+! XC-MISC extension, an X Consortium standard
+XRequest.XC-MISC.0: XCMiscGetVersion
+XRequest.XC-MISC.1: XCMiscGetXIDRange
+! RECORD extension
+XRequest.RECORD.0: XRecordQueryVersion
+XRequest.RECORD.1: XRecordCreateContext
+XRequest.RECORD.2: XRecordRegisterClients
+XRequest.RECORD.3: XRecordUnregisterClients
+XRequest.RECORD.4: XRecordGetContext
+XRequest.RECORD.5: XRecordEnableContext
+XRequest.RECORD.6: XRecordDisableContext
+XRequest.RECORD.7: XRecordFreeContext
+XProtoError.RECORD.0: XRecordBadContext
+XlibMessage.RECORD.0: Context in failed request: 0x%lx
+! XFree86-VidModeExtension -- not an X Consortium standard
+XRequest.XFree86-VidModeExtension.0: XF86VidModeQueryVersion
+XRequest.XFree86-VidModeExtension.1: XF86VidModeGetModeLine
+XRequest.XFree86-VidModeExtension.2: XF86VidModeModModeLine
+XRequest.XFree86-VidModeExtension.3: XF86VidModeSwitchMode
+XRequest.XFree86-VidModeExtension.4: XF86VidModeGetMonitor
+XRequest.XFree86-VidModeExtension.5: XF86VidModeLockModeSwitch
+XRequest.XFree86-VidModeExtension.6: XF86VidModeGetAllModeLines
+XRequest.XFree86-VidModeExtension.7: XF86VidModeAddModeLine
+XRequest.XFree86-VidModeExtension.8: XF86VidModeDeleteModeLine
+XRequest.XFree86-VidModeExtension.9: XF86VidModeValidateModeLine
+XRequest.XFree86-VidModeExtension.10: XF86VidModeSwitchToMode
+XRequest.XFree86-VidModeExtension.11: XF86VidModeGetViewPort
+XRequest.XFree86-VidModeExtension.12: XF86VidModeSetViewPort
+XProtoError.XFree86-VidModeExtension.0: XF86VidModeBadClock
+XProtoError.XFree86-VidModeExtension.1: XF86VidModeBadHTimings
+XProtoError.XFree86-VidModeExtension.2: XF86VidModeBadVTimings
+XProtoError.XFree86-VidModeExtension.3: XF86VidModeModeUnsuitable
+XProtoError.XFree86-VidModeExtension.4: XF86VidModeClientNotLocal
+XProtoError.XFree86-VidModeExtension.5: XF86VidModeExtensionDisabled
+XProtoError.XFree86-VidModeExtension.6: XF86VidModeZoomLocked
+! XFree86-Misc -- not an X Consortium standard
+XRequest.XFree86-Misc.0: XF86MiscQueryVersion
+XRequest.XFree86-Misc.1: XF86MiscGetSaver
+XRequest.XFree86-Misc.2: XF86MiscSetSaver
+XRequest.XFree86-Misc.3: XF86MiscGetMouseSettings
+XRequest.XFree86-Misc.4: XF86MiscGetKbdSettings
+XRequest.XFree86-Misc.5: XF86MiscSetMouseSettings
+XRequest.XFree86-Misc.6: XF86MiscSetKbdSettings
+XProtoError.XFree86-Misc.0: XF86MiscBadMouseProtocol
+XProtoError.XFree86-Misc.1: XF86MiscBadMouseBaudRate
+XProtoError.XFree86-Misc.2: XF86MiscBadMouseFlags
+XProtoError.XFree86-Misc.3: XF86MiscBadMouseCombo
+XProtoError.XFree86-Misc.4: XF86MiscBadKbdType
+XProtoError.XFree86-Misc.5: XF86MiscModInDevDisabled
+XProtoError.XFree86-Misc.6: XF86MiscModInDevClientNotLocal
+! XFree86-DGA -- not an X Consortium standard
+XRequest.XFree86-DGA.0: XF86DGAQueryVersion
+XRequest.XFree86-DGA.1: XF86DGAGetVideoLL
+XRequest.XFree86-DGA.2: XF86DGADirectVideo
+XRequest.XFree86-DGA.3: XF86DGAGetViewPortSize
+XRequest.XFree86-DGA.4: XF86DGASetViewPort
+XRequest.XFree86-DGA.5: XF86DGAGetVidPage
+XRequest.XFree86-DGA.6: XF86DGASetVidPage
+XRequest.XFree86-DGA.7: XF86DGAInstallColormap
+XRequest.XFree86-DGA.8: XF86DGAQueryDirectVideo
+XRequest.XFree86-DGA.9: XF86DGAViewPortChanged
+XProtoError.XFree86-DGA.0: XF86DGAClientNotLocal
+XProtoError.XFree86-DGA.1: XF86DGANoDirectVideoMode
+XProtoError.XFree86-DGA.2: XF86DGAScreenNotActive
+XProtoError.XFree86-DGA.3: XF86DGADirectNotActivated
+! DOUBLE-BUFFER (DBE), an X Consortium standard
+XRequest.DOUBLE-BUFFER.0: DBEGetVersion
+XRequest.DOUBLE-BUFFER.1: DBEAllocateBackBufferName
+XRequest.DOUBLE-BUFFER.2: DBEDeallocateBackBufferName
+XRequest.DOUBLE-BUFFER.3: DBESwapBuffers
+XRequest.DOUBLE-BUFFER.4: DBEBeginIdiom
+XRequest.DOUBLE-BUFFER.5: DBEEndIdiom
+XRequest.DOUBLE-BUFFER.6: DBEGetVisualInfo
+XRequest.DOUBLE-BUFFER.7: DBEGetBackBufferAttributes
+XProtoError.DOUBLE-BUFFER.0: DBEBadBuffer (invalid BackBuffer parameter)
+XlibMessage.DOUBLE-BUFFER.0: BackBuffer in failed request: 0x%lx
+! SECURITY
+XRequest.SECURITY.0: SecurityQueryVersion
+XRequest.SECURITY.1: SecurityGenerateAuthorization
+XProtoError.SECURITY.0: SecurityBadAuthorization (invalid authorization id)
+XProtoError.SECURITY.1: SecurityBadAuthorizationProtocol (invalid authorization name or data)
+XlibMessage.SECURITY.1: authorization id in failed request: 0x%lx
+! AppGroup
+XRequest.APPGROUP.0: XagQueryVersion
+XRequest.APPGROUP.1: XagCreate
+XRequest.APPGROUP.2: XagDestroy
+XRequest.APPGROUP.3: XagGetAttr
+XRequest.APPGROUP.4: XagQuery
+XRequest.APPGROUP.5: XagCreateAssoc
+XRequest.APPGROUP.6: XagDestroyAssoc
+XProtoError.APPGROUP.0: XagBadAppGroup (invalid AppGroup parameter)
+! LBX
+XRequest.LBX.0: LbxQueryVersion
+XRequest.LBX.1: LbxStartProxy
+XRequest.LBX.2: LbxStopProxy
+XRequest.LBX.3: LbxSwitch
+XRequest.LBX.4: LbxNewClient
+XRequest.LBX.5: LbxCloseClient
+XRequest.LBX.6: LbxModifySequence
+XRequest.LBX.7: LbxAllowMotion
+XRequest.LBX.8: LbxIncrementPixel
+XRequest.LBX.9: LbxDelta
+XRequest.LBX.10: LbxGetModifierMapping
+XRequest.LBX.11: LbxQueryTag
+XRequest.LBX.12: LbxInvalidateTag
+XRequest.LBX.13: LbxPolyPoint
+XRequest.LBX.14: LbxPolyLine
+XRequest.LBX.15: LbxPolySegment
+XRequest.LBX.16: LbxPolyRectangle
+XRequest.LBX.17: LbxPolyArc
+XRequest.LBX.18: LbxFillPoly
+XRequest.LBX.19: LbxPolyFillRectangle
+XRequest.LBX.20: LbxPolyFillArc
+XRequest.LBX.21: LbxGetKeyboardMapping
+XRequest.LBX.22: LbxQueryFont
+XRequest.LBX.23: LbxChangeProperty
+XRequest.LBX.24: LbxGetProperty
+XRequest.LBX.25: LbxTagData
+XRequest.LBX.26: LbxCopyArea
+XRequest.LBX.27: LbxCopyPlane
+XRequest.LBX.28: LbxPolyText8
+XRequest.LBX.29: LbxPolyText16
+XRequest.LBX.30: LbxImageText8
+XRequest.LBX.31: LbxImageText16
+XRequest.LBX.32: LbxQueryExtension
+XRequest.LBX.33: LbxPutImage
+XRequest.LBX.34: LbxGetImage
+XRequest.LBX.35: LbxBeginLargeRequest
+XRequest.LBX.36: LbxLargeRequestData
+XRequest.LBX.37: LbxEndLargeRequest
+XRequest.LBX.38: LbxInternAtoms
+XRequest.LBX.39: LbxGetWinAttrAndGeom
+XRequest.LBX.40: LbxGrabCmap
+XRequest.LBX.41: LbxReleaseCmap
+XRequest.LBX.42: LbxAllocColor
+XRequest.LBX.43: LbxSync
+XProtoError.LBX.0: BadLbxClient
+! XpExtension
+XRequest.XpExtension.0: PrintQueryVersion
+XRequest.XpExtension.1: PrintGetPrinterList
+XRequest.XpExtension.2: PrintCreateContext
+XRequest.XpExtension.3: PrintSetContext
+XRequest.XpExtension.4: PrintGetContext
+XRequest.XpExtension.5: PrintDestroyContext
+XRequest.XpExtension.6: PrintGetContextScreen
+XRequest.XpExtension.7: PrintStartJob
+XRequest.XpExtension.8: PrintEndJob
+XRequest.XpExtension.9: PrintStartDoc
+XRequest.XpExtension.10: PrintEndDoc
+XRequest.XpExtension.11: PrintPutDocumentData
+XRequest.XpExtension.12: PrintGetDocumentData
+XRequest.XpExtension.13: PrintStartPage
+XRequest.XpExtension.14: PrintEndPage
+XRequest.XpExtension.15: PrintSelectInput
+XRequest.XpExtension.16: PrintInputSelected
+XRequest.XpExtension.17: PrintGetAttributes
+XRequest.XpExtension.18: PrintSetAttributes
+XRequest.XpExtension.19: PrintGetOneAttribute
+XRequest.XpExtension.20: PrintRehashPrinterList
+XRequest.XpExtension.21: PrintGetPageDimensions
+XRequest.XpExtension.22: PrintQueryScreens
+XRequest.XpExtension.23: PrintSetImageResolution
+XRequest.XpExtension.24: PrintGetImageResolution
+XProtoError.XpExtension.0: XPBadContext (Print Context invalid or missing)
+XlibMessage.XpExtension.0: Context in failed request: 0x%lx
+XProtoError.XpExtension.1: XPBadSequence (Illegal sequence of XP operations)
+XProtoError.XpExtension.2: XPBadResourceID (X resource not valid)
+! TOG-CUP, an X Project Team specification
+XRequest.TOG-CUP.0: CUPQueryVersion
+XRequest.TOG-CUP.1: CUPGetReservedColormapEntries
+XRequest.TOG-CUP.2: CUPStoreColors
+! Extended-Visual-Information, an X Project Team specification
+XRequest.Extended-Visual-Information.0: EVIQueryVersion
+XRequest.Extended-Visual-Information.1: EVIGetVisualInfo
+! DPMS (Display Power Management Signaling), an X Project Team specification
+XRequest.DPMS.0: DPMSGetVersion
+XRequest.DPMS.1: DPMSCapable
+XRequest.DPMS.2: DPMSGetTimeouts
+XRequest.DPMS.3: DPMSSetTimeouts
+XRequest.DPMS.4: DPMSEnable
+XRequest.DPMS.5: DPMSDisable
+XRequest.DPMS.6: DPMSForceLevel
+XRequest.DPMS.7: DPMSInfo
+! XINERAMA, not an X Project Team specification
+XRequest.XINERAMA.0: XINERAMAQueryVersion
+XRequest.XINERAMA.1: XINERAMAGetState
+XRequest.XINERAMA.2: XINERAMAGetScreenCount
+XRequest.XINERAMA.3: XINERAMAGetScreenSize
diff --git a/src/XKeysymDB b/src/XKeysymDB
new file mode 100644
index 00000000..70575cec
--- /dev/null
+++ b/src/XKeysymDB
@@ -0,0 +1,206 @@
+! $Xorg: XKeysymDB,v 1.3 2000/08/17 19:45:04 cpqbld Exp $
+! Copyright 1993 Massachusetts Institute of Technology
+!
+! Permission to use, copy, modify, distribute, and sell this software and
+! its documentation for any purpose is hereby granted without fee, 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 M.I.T. not be used in advertising or
+! publicity pertaining to distribution of the software without specific,
+! written prior permission. M.I.T. makes no representations about the
+! suitability of this software for any purpose. It is provided "as is"
+! without express or implied warranty.
+
+hpmute_acute :100000A8
+hpmute_grave :100000A9
+hpmute_asciicircum :100000AA
+hpmute_diaeresis :100000AB
+hpmute_asciitilde :100000AC
+hplira :100000AF
+hpguilder :100000BE
+hpYdiaeresis :100000EE
+hpIO :100000EE
+hplongminus :100000F6
+hpblock :100000FC
+apLineDel :1000FF00
+apCharDel :1000FF01
+apCopy :1000FF02
+apCut :1000FF03
+apPaste :1000FF04
+apMove :1000FF05
+apGrow :1000FF06
+apCmd :1000FF07
+apShell :1000FF08
+apLeftBar :1000FF09
+apRightBar :1000FF0A
+apLeftBox :1000FF0B
+apRightBox :1000FF0C
+apUpBox :1000FF0D
+apDownBox :1000FF0E
+apPop :1000FF0F
+apRead :1000FF10
+apEdit :1000FF11
+apSave :1000FF12
+apExit :1000FF13
+apRepeat :1000FF14
+hpModelock1 :1000FF48
+hpModelock2 :1000FF49
+hpReset :1000FF6C
+hpSystem :1000FF6D
+hpUser :1000FF6E
+hpClearLine :1000FF6F
+hpInsertLine :1000FF70
+hpDeleteLine :1000FF71
+hpInsertChar :1000FF72
+hpDeleteChar :1000FF73
+hpBackTab :1000FF74
+hpKP_BackTab :1000FF75
+apKP_parenleft :1000FFA8
+apKP_parenright :1000FFA9
+
+I2ND_FUNC_L :10004001
+I2ND_FUNC_R :10004002
+IREMOVE :10004003
+IREPEAT :10004004
+IA1 :10004101
+IA2 :10004102
+IA3 :10004103
+IA4 :10004104
+IA5 :10004105
+IA6 :10004106
+IA7 :10004107
+IA8 :10004108
+IA9 :10004109
+IA10 :1000410A
+IA11 :1000410B
+IA12 :1000410C
+IA13 :1000410D
+IA14 :1000410E
+IA15 :1000410F
+IB1 :10004201
+IB2 :10004202
+IB3 :10004203
+IB4 :10004204
+IB5 :10004205
+IB6 :10004206
+IB7 :10004207
+IB8 :10004208
+IB9 :10004209
+IB10 :1000420A
+IB11 :1000420B
+IB12 :1000420C
+IB13 :1000420D
+IB14 :1000420E
+IB15 :1000420F
+IB16 :10004210
+
+DRemove :1000FF00
+Dring_accent :1000FEB0
+Dcircumflex_accent :1000FE5E
+Dcedilla_accent :1000FE2C
+Dacute_accent :1000FE27
+Dgrave_accent :1000FE60
+Dtilde :1000FE7E
+Ddiaeresis :1000FE22
+
+osfCopy :1004FF02
+osfCut :1004FF03
+osfPaste :1004FF04
+osfBackTab :1004FF07
+osfBackSpace :1004FF08
+osfClear :1004FF0B
+osfEscape :1004FF1B
+osfAddMode :1004FF31
+osfPrimaryPaste :1004FF32
+osfQuickPaste :1004FF33
+osfPageLeft :1004FF40
+osfPageUp :1004FF41
+osfPageDown :1004FF42
+osfPageRight :1004FF43
+osfActivate :1004FF44
+osfMenuBar :1004FF45
+osfLeft :1004FF51
+osfUp :1004FF52
+osfRight :1004FF53
+osfDown :1004FF54
+osfPrior :1004FF55
+osfNext :1004FF56
+osfEndLine :1004FF57
+osfBeginLine :1004FF58
+osfEndData :1004FF59
+osfBeginData :1004FF5A
+osfPrevMenu :1004FF5B
+osfNextMenu :1004FF5C
+osfPrevField :1004FF5D
+osfNextField :1004FF5E
+osfSelect :1004FF60
+osfInsert :1004FF63
+osfUndo :1004FF65
+osfMenu :1004FF67
+osfCancel :1004FF69
+osfHelp :1004FF6A
+osfSelectAll :1004FF71
+osfDeselectAll :1004FF72
+osfReselect :1004FF73
+osfExtend :1004FF74
+osfRestore :1004FF78
+osfSwitchDirection :1004FF7E
+osfPriorMinor :1004FFF5
+osfNextMinor :1004FFF6
+osfRightLine :1004FFF7
+osfLeftLine :1004FFF8
+osfDelete :1004FFFF
+
+SunFA_Grave :1005FF00
+SunFA_Circum :1005FF01
+SunFA_Tilde :1005FF02
+SunFA_Acute :1005FF03
+SunFA_Diaeresis :1005FF04
+SunFA_Cedilla :1005FF05
+SunF36 :1005FF10
+SunF37 :1005FF11
+SunSys_Req :1005FF60
+SunProps :1005FF70
+SunFront :1005FF71
+SunCopy :1005FF72
+SunOpen :1005FF73
+SunPaste :1005FF74
+SunCut :1005FF75
+SunPowerSwitch :1005FF76
+SunAudioLowerVolume :1005FF77
+SunAudioMute :1005FF78
+SunAudioRaiseVolume :1005FF79
+SunVideoDegauss :1005FF7A
+SunVideoLowerBrightness :1005FF7B
+SunVideoRaiseBrightness :1005FF7C
+SunPowerSwitchShift :1005FF7D
+
+SunCompose :FF20
+SunPageUp :FF55
+SunPageDown :FF56
+SunPrint_Screen :FF61
+SunUndo :FF65
+SunAgain :FF66
+SunFind :FF68
+SunStop :FF69
+SunAltGraph :FF7E
+
+WYSetup :1006FF00
+
+ncdSetup :1006FF00
+
+XeroxPointerButton1 :10070001
+XeroxPointerButton2 :10070002
+XeroxPointerButton3 :10070003
+XeroxPointerButton4 :10070004
+XeroxPointerButton5 :10070005
+
+XF86ModeLock :1008FF01
+
+usldead_acute :100000A8
+usldead_grave :100000A9
+usldead_diaeresis :100000AB
+usldead_asciicircum :100000AA
+usldead_asciitilde :100000AC
+usldead_cedilla :1000FE2C
+usldead_ring :1000FEB0
diff --git a/src/Xatomtype.h b/src/Xatomtype.h
new file mode 100644
index 00000000..7ab7e5a0
--- /dev/null
+++ b/src/Xatomtype.h
@@ -0,0 +1,134 @@
+/* $Xorg: Xatomtype.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+
+/***********************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+#ifndef _XATOMTYPE_H_
+#define _XATOMTYPE_H_
+
+/*
+ * This files defines crock C structures for calling XGetWindowProperty and
+ * XChangeProperty. All fields must be longs as the semantics of property
+ * routines will handle conversion to and from actual 32 bit objects. If your
+ * compiler doesn't treat &structoflongs the same as &arrayoflongs[0], you
+ * will have some work to do.
+ */
+
+#define BOOL long
+#define SIGNEDINT long
+#define UNSIGNEDINT unsigned long
+#define RESOURCEID unsigned long
+
+
+/* this structure may be extended, but do not change the order */
+typedef struct {
+ UNSIGNEDINT flags;
+ SIGNEDINT x, y, width, height; /* need to cvt; only for pre-ICCCM */
+ SIGNEDINT minWidth, minHeight; /* need to cvt */
+ SIGNEDINT maxWidth, maxHeight; /* need to cvt */
+ SIGNEDINT widthInc, heightInc; /* need to cvt */
+ SIGNEDINT minAspectX, minAspectY; /* need to cvt */
+ SIGNEDINT maxAspectX, maxAspectY; /* need to cvt */
+ SIGNEDINT baseWidth,baseHeight; /* need to cvt; ICCCM version 1 */
+ SIGNEDINT winGravity; /* need to cvt; ICCCM version 1 */
+} xPropSizeHints;
+#define OldNumPropSizeElements 15 /* pre-ICCCM */
+#define NumPropSizeElements 18 /* ICCCM version 1 */
+
+/* this structure may be extended, but do not change the order */
+/* RGB properties */
+typedef struct {
+ RESOURCEID colormap;
+ UNSIGNEDINT red_max;
+ UNSIGNEDINT red_mult;
+ UNSIGNEDINT green_max;
+ UNSIGNEDINT green_mult;
+ UNSIGNEDINT blue_max;
+ UNSIGNEDINT blue_mult;
+ UNSIGNEDINT base_pixel;
+ RESOURCEID visualid; /* ICCCM version 1 */
+ RESOURCEID killid; /* ICCCM version 1 */
+} xPropStandardColormap;
+#define OldNumPropStandardColormapElements 8 /* pre-ICCCM */
+#define NumPropStandardColormapElements 10 /* ICCCM version 1 */
+
+
+/* this structure may be extended, but do not change the order */
+typedef struct {
+ UNSIGNEDINT flags;
+ BOOL input; /* need to convert */
+ SIGNEDINT initialState; /* need to cvt */
+ RESOURCEID iconPixmap;
+ RESOURCEID iconWindow;
+ SIGNEDINT iconX; /* need to cvt */
+ SIGNEDINT iconY; /* need to cvt */
+ RESOURCEID iconMask;
+ UNSIGNEDINT windowGroup;
+ } xPropWMHints;
+#define NumPropWMHintsElements 9 /* number of elements in this structure */
+
+/* this structure defines the icon size hints information */
+typedef struct {
+ SIGNEDINT minWidth, minHeight; /* need to cvt */
+ SIGNEDINT maxWidth, maxHeight; /* need to cvt */
+ SIGNEDINT widthInc, heightInc; /* need to cvt */
+ } xPropIconSize;
+#define NumPropIconSizeElements 6 /* number of elements in this structure */
+
+/* this structure defines the window manager state information */
+typedef struct {
+ SIGNEDINT state; /* need to cvt */
+ RESOURCEID iconWindow;
+} xPropWMState;
+#define NumPropWMStateElements 2 /* number of elements in struct */
+
+#undef BOOL
+#undef SIGNEDINT
+#undef UNSIGNEDINT
+#undef RESOURCEID
+
+#endif /* _XATOMTYPE_H_ */
diff --git a/src/XlibAsync.c b/src/XlibAsync.c
new file mode 100644
index 00000000..066e12e7
--- /dev/null
+++ b/src/XlibAsync.c
@@ -0,0 +1,153 @@
+/* $Xorg: XlibAsync.c,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_REPLIES
+#include <X11/Xlibint.h>
+#include <X11/Xos.h>
+
+/*ARGSUSED*/
+Bool
+_XAsyncErrorHandler(dpy, rep, buf, len, data)
+ register Display *dpy;
+ register xReply *rep;
+ char *buf;
+ int len;
+ XPointer data;
+{
+ register _XAsyncErrorState *state;
+
+ state = (_XAsyncErrorState *)data;
+ if (rep->generic.type == X_Error &&
+ (!state->error_code ||
+ rep->error.errorCode == state->error_code) &&
+ (!state->major_opcode ||
+ rep->error.majorCode == state->major_opcode) &&
+ (!state->minor_opcode ||
+ rep->error.minorCode == state->minor_opcode) &&
+ (!state->min_sequence_number ||
+ (state->min_sequence_number <= dpy->last_request_read)) &&
+ (!state->max_sequence_number ||
+ (state->max_sequence_number >= dpy->last_request_read))) {
+ state->last_error_received = rep->error.errorCode;
+ state->error_count++;
+ return True;
+ }
+ return False;
+}
+
+void _XDeqAsyncHandler(dpy, handler)
+ Display *dpy;
+ register _XAsyncHandler *handler;
+{
+ register _XAsyncHandler **prev;
+ register _XAsyncHandler *async;
+
+ for (prev = &dpy->async_handlers;
+ (async = *prev) && (async != handler);
+ prev = &async->next)
+ ;
+ if (async)
+ *prev = async->next;
+}
+
+char *
+_XGetAsyncReply(dpy, replbuf, rep, buf, len, extra, discard)
+ register Display *dpy;
+ register char *replbuf; /* data is read into this buffer */
+ register xReply *rep; /* value passed to calling handler */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int extra; /* extra words to read, ala _XReply */
+ Bool discard; /* discard after extra?, ala _XReply */
+{
+ if (extra == 0) {
+ if (discard && (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ return (char *)rep;
+ }
+
+ if (extra <= rep->generic.length) {
+ int size = SIZEOF(xReply) + (extra << 2);
+ if (size > len) {
+ memcpy(replbuf, buf, len);
+ _XRead(dpy, replbuf + len, size - len);
+ buf = replbuf;
+ len = size;
+#ifdef MUSTCOPY
+ } else {
+ memcpy(replbuf, buf, size);
+ buf = replbuf;
+#endif
+ }
+
+ if (discard && rep->generic.length > extra &&
+ (rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+
+ return buf;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ if ((rep->generic.length << 2) > len)
+ _XEatData (dpy, (rep->generic.length << 2) - len);
+ _XIOError (dpy);
+ return (char *)rep;
+}
+
+void
+_XGetAsyncData(dpy, data, buf, len, skip, datalen, discardtotal)
+ Display *dpy;
+ char *data; /* data is read into this buffer */
+ char *buf; /* value passed to calling handler */
+ int len; /* value passed to calling handler */
+ int skip; /* number of bytes already read in previous
+ _XGetAsyncReply or _XGetAsyncData calls */
+ int datalen; /* size of data buffer in bytes */
+ int discardtotal; /* min. bytes to consume (after skip) */
+{
+ buf += skip;
+ len -= skip;
+ if (!data) {
+ if (datalen > len)
+ _XEatData(dpy, datalen - len);
+ } else if (datalen <= len) {
+ memcpy(data, buf, datalen);
+ } else {
+ memcpy(data, buf, len);
+ _XRead(dpy, data + len, datalen - len);
+ }
+ if (discardtotal > len) {
+ if (datalen > len)
+ len = datalen;
+ _XEatData(dpy, discardtotal - len);
+ }
+}
diff --git a/src/XlibInt.c b/src/XlibInt.c
new file mode 100644
index 00000000..a14cb333
--- /dev/null
+++ b/src/XlibInt.c
@@ -0,0 +1,3424 @@
+/* $Xorg: XlibInt.c,v 1.10 2001/02/20 02:13:26 coskrey Exp $ */
+/*
+
+Copyright 1985, 1986, 1987, 1998, 2001 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * XlibInt.c - Internal support routines for the C subroutine
+ * interface library (Xlib) to the X Window System Protocol V11.0.
+ */
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#define GENERIC_LENGTH_LIMIT (1 << 29)
+
+#include "Xlibint.h"
+#include <X11/Xpoll.h>
+#include <X11/Xtrans.h>
+#include "xcmiscstr.h"
+#include <stdio.h>
+
+#ifdef XTHREADS
+#include "locking.h"
+
+/* these pointers get initialized by XInitThreads */
+LockInfoPtr _Xglobal_lock = NULL;
+void (*_XCreateMutex_fn)() = NULL;
+struct _XCVList *(*_XCreateCVL_fn)() = NULL;
+void (*_XFreeMutex_fn)() = NULL;
+void (*_XLockMutex_fn)() = NULL;
+void (*_XUnlockMutex_fn)() = NULL;
+xthread_t (*_Xthread_self_fn)() = NULL;
+
+#define XThread_Self() ((*_Xthread_self_fn)())
+
+#define UnlockNextReplyReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->reply_awaiters,&(d)->lock->reply_awaiters_tail)
+
+#define QueueReplyReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->reply_awaiters_tail) : NULL)
+#define QueueEventReaderLock(d) ((d)->lock ? \
+ (*(d)->lock->push_reader)(d,&(d)->lock->event_awaiters_tail) : NULL)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip,__FILE__,__LINE__)
+#else
+#define InternalLockDisplay(d,wskip) if ((d)->lock) \
+ (*(d)->lock->internal_lock_display)(d,wskip)
+#endif
+
+#else /* XTHREADS else */
+
+#define UnlockNextReplyReader(d)
+#define UnlockNextEventReader(d)
+#define InternalLockDisplay(d,wskip)
+
+#endif /* XTHREADS else */
+
+/* check for both EAGAIN and EWOULDBLOCK, because some supposedly POSIX
+ * systems are broken and return EWOULDBLOCK when they should return EAGAIN
+ */
+#ifdef WIN32
+#define ETEST() (WSAGetLastError() == WSAEWOULDBLOCK)
+#else
+#if defined(EAGAIN) && defined(EWOULDBLOCK)
+#define ETEST() (errno == EAGAIN || errno == EWOULDBLOCK)
+#else
+#ifdef EAGAIN
+#define ETEST() (errno == EAGAIN)
+#else
+#define ETEST() (errno == EWOULDBLOCK)
+#endif
+#endif
+#endif
+#ifdef WIN32
+#define ECHECK(err) (WSAGetLastError() == err)
+#define ESET(val) WSASetLastError(val)
+#else
+#define ECHECK(err) (errno == err)
+#define ESET(val) errno = val
+#endif
+
+#if defined(LOCALCONN) || defined(LACHMAN)
+#ifdef EMSGSIZE
+#define ESZTEST() (ECHECK(EMSGSIZE) || ECHECK(ERANGE))
+#else
+#define ESZTEST() ECHECK(ERANGE)
+#endif
+#else
+#ifdef EMSGSIZE
+#define ESZTEST() ECHECK(EMSGSIZE)
+#endif
+#endif
+
+#ifdef MUSTCOPY
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ { register char *cpvar; \
+ for (cpvar = (char *) (start); endcond; ) { \
+ type dummy; memcpy ((char *) &dummy, cpvar, SIZEOF(type)); \
+ tpvar = &dummy;
+#define ITERPTR(tpvar) cpvar
+#define RESETITERPTR(tpvar,type,start) cpvar = start
+#define INCITERPTR(tpvar,type) cpvar += SIZEOF(type)
+#define ENDITERATE }}
+
+#else
+
+#define STARTITERATE(tpvar,type,start,endcond) \
+ for (tpvar = (type *) (start); endcond; )
+#define ITERPTR(tpvar) (char *)tpvar
+#define RESETITERPTR(tpvar,type,start) tpvar = (type *) (start)
+#define INCITERPTR(tpvar,type) tpvar++
+#define ENDITERATE
+
+#endif /* MUSTCOPY */
+
+typedef union {
+ xReply rep;
+ char buf[BUFSIZE];
+} _XAlignedBuffer;
+
+static char *_XAsyncReply();
+static void _XProcessInternalConnection();
+#define SEQLIMIT (65535 - (BUFSIZE / SIZEOF(xReq)) - 10)
+
+/*
+ * The following routines are internal routines used by Xlib for protocol
+ * packet transmission and reception.
+ *
+ * _XIOError(Display *) will be called if any sort of system call error occurs.
+ * This is assumed to be a fatal condition, i.e., XIOError should not return.
+ *
+ * _XError(Display *, xError *) will be called whenever an X_Error event is
+ * received. This is not assumed to be a fatal condition, i.e., it is
+ * acceptable for this procedure to return. However, XError should NOT
+ * perform any operations (directly or indirectly) on the DISPLAY.
+ *
+ * Routines declared with a return type of 'Status' return 0 on failure,
+ * and non 0 on success. Routines with no declared return type don't
+ * return anything. Whenever possible routines that create objects return
+ * the object they have created.
+ */
+
+static int padlength[4] = {0, 3, 2, 1};
+ /* lookup table for adding padding bytes to data that is read from
+ or written to the X socket. */
+
+static xReq _dummy_request = {
+ 0, 0, 0
+};
+
+/*
+ * This is an OS dependent routine which:
+ * 1) returns as soon as the connection can be written on....
+ * 2) if the connection can be read, must enqueue events and handle errors,
+ * until the connection is writable.
+ */
+static void
+_XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ )
+ Display *dpy;
+#ifdef XTHREADS
+ xcondition_t cv; /* our reading condition variable */
+#endif
+{
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ fd_set w_mask;
+#endif
+ int nfound;
+
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = 0;
+#else
+ FD_ZERO(&r_mask);
+ FD_ZERO(&w_mask);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* We allow only one thread at a time to read, to minimize
+ passing of read data between threads.
+ Now, who is it? If there is a non-NULL reply_awaiters and
+ we (i.e., our cv) are not at the head of it, then whoever
+ is at the head is the reader, and we don't read.
+ Otherwise there is no reply_awaiters or we are at the
+ head, having just appended ourselves.
+ In this case, if there is a event_awaiters, then whoever
+ is at the head of it got there before we did, and they are the
+ reader.
+
+ Last cases: no event_awaiters and we are at the head of
+ reply_awaiters or reply_awaiters is NULL: we are the reader,
+ since there is obviously no one else involved.
+
+ XXX - what if cv is NULL and someone else comes along after
+ us while we are waiting?
+ */
+
+ if (!dpy->lock ||
+ (!dpy->lock->event_awaiters &&
+ (!dpy->lock->reply_awaiters ||
+ dpy->lock->reply_awaiters->cv == cv)))
+#endif
+#ifdef USE_POLL
+ filedes.events = POLLIN;
+ filedes.events |= POLLOUT;
+#else
+ FD_SET(dpy->fd, &r_mask);
+ FD_SET(dpy->fd, &w_mask);
+#endif
+
+ do {
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ nfound = poll (&filedes, 1, -1);
+#else
+ nfound = Select (dpy->fd + 1, &r_mask, &w_mask, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, cv != NULL);
+ if (nfound < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+ } while (nfound <= 0);
+
+ if (
+#ifdef USE_POLL
+ filedes.revents & POLLIN
+#else
+ FD_ISSET(dpy->fd, &r_mask)
+#endif
+ )
+ {
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register BytesReadable_t len;
+ register xReply *rep;
+
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just block waiting for it */
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE) len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+
+ (void) _XRead (dpy, buf.buf, (long) len);
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ pend = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &pend, True));
+ len = pend;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ }
+#ifdef USE_POLL
+ if (filedes.revents & (POLLOUT|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(dpy->fd, &w_mask))
+#endif
+ {
+#ifdef XTHREADS
+ if (dpy->lock) {
+ ConditionBroadcast(dpy, dpy->lock->writers);
+ }
+#endif
+ return;
+ }
+ }
+}
+
+
+#define POLLFD_CACHE_SIZE 5
+
+/* initialize the struct array passed to poll() below */
+Bool _XPollfdCacheInit(dpy)
+ Display *dpy;
+{
+#ifdef USE_POLL
+ struct pollfd *pfp;
+
+ pfp = (struct pollfd *)Xmalloc(POLLFD_CACHE_SIZE * sizeof(struct pollfd));
+ if (!pfp)
+ return False;
+ pfp[0].fd = dpy->fd;
+ pfp[0].events = POLLIN;
+
+ dpy->filedes = (XPointer)pfp;
+#endif
+ return True;
+}
+
+void _XPollfdCacheAdd(dpy, fd)
+ Display *dpy;
+ int fd;
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ pfp[dpy->im_fd_length].fd = fd;
+ pfp[dpy->im_fd_length].events = POLLIN;
+ }
+#endif
+}
+
+/* ARGSUSED */
+void _XPollfdCacheDel(dpy, fd)
+ Display *dpy;
+ int fd; /* not used */
+{
+#ifdef USE_POLL
+ struct pollfd *pfp = (struct pollfd *)dpy->filedes;
+ struct _XConnectionInfo *conni;
+
+ /* just recalculate whole list */
+ if (dpy->im_fd_length <= POLLFD_CACHE_SIZE) {
+ int loc = 1;
+ for (conni = dpy->im_fd_info; conni; conni=conni->next) {
+ pfp[loc].fd = conni->fd;
+ pfp[loc].events = POLLIN;
+ loc++;
+ }
+ }
+#endif
+}
+
+/* returns True iff there is an event in the queue newer than serial_num */
+
+static Bool
+_XNewerQueuedEvent(dpy, serial_num)
+ Display *dpy;
+ int serial_num;
+{
+ _XQEvent *qev;
+
+ if (dpy->next_event_serial_num == serial_num)
+ return False;
+
+ qev = dpy->head;
+ while (qev) {
+ if (qev->qserial_num >= serial_num) {
+ return True;
+ }
+ qev = qev->next;
+ }
+ return False;
+}
+
+static int
+_XWaitForReadable(dpy)
+ Display *dpy;
+{
+ int result;
+ int fd = dpy->fd;
+ struct _XConnectionInfo *ilist;
+ register int saved_event_serial;
+ int in_read_events;
+ register Bool did_proc_conni = False;
+#ifdef USE_POLL
+ struct pollfd *filedes;
+#else
+ fd_set r_mask;
+ int highest_fd = fd;
+#endif
+
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE
+ && !(dpy->flags & XlibDisplayProcConni)) {
+ /* XXX - this fallback is gross */
+ int i;
+
+ filedes = (struct pollfd *)Xmalloc(dpy->im_fd_length * sizeof(struct pollfd));
+ filedes[0].fd = fd;
+ filedes[0].events = POLLIN;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+ filedes[i].fd = ilist->fd;
+ filedes[i].events = POLLIN;
+ }
+ } else {
+ filedes = (struct pollfd *)dpy->filedes;
+ }
+#else
+ FD_ZERO(&r_mask);
+#endif
+ for (;;) {
+#ifndef USE_POLL
+ FD_SET(fd, &r_mask);
+ if (!(dpy->flags & XlibDisplayProcConni))
+ for (ilist=dpy->im_fd_info; ilist; ilist=ilist->next) {
+ FD_SET(ilist->fd, &r_mask);
+ if (ilist->fd > highest_fd)
+ highest_fd = ilist->fd;
+ }
+#endif
+ UnlockDisplay(dpy);
+#ifdef USE_POLL
+ result = poll(filedes,
+ (dpy->flags & XlibDisplayProcConni) ? 1 : 1+dpy->im_fd_length,
+ -1);
+#else
+ result = Select(highest_fd + 1, &r_mask, NULL, NULL, NULL);
+#endif
+ InternalLockDisplay(dpy, dpy->flags & XlibDisplayReply);
+ if (result == -1 && !ECHECK(EINTR)) _XIOError(dpy);
+ if (result <= 0)
+ continue;
+#ifdef USE_POLL
+ if (filedes[0].revents & (POLLIN|POLLHUP|POLLERR))
+#else
+ if (FD_ISSET(fd, &r_mask))
+#endif
+ break;
+ if (!(dpy->flags & XlibDisplayProcConni)) {
+ int i;
+
+ saved_event_serial = dpy->next_event_serial_num;
+ /* dpy flags can be clobbered by internal connection callback */
+ in_read_events = dpy->flags & XlibDisplayReadEvents;
+ for (ilist=dpy->im_fd_info, i=1; ilist; ilist=ilist->next, i++) {
+#ifdef USE_POLL
+ if (filedes[i].revents & POLLIN)
+#else
+ if (FD_ISSET(ilist->fd, &r_mask))
+#endif
+ {
+ _XProcessInternalConnection(dpy, ilist);
+ did_proc_conni = True;
+ }
+ }
+#ifdef USE_POLL
+ if (dpy->im_fd_length + 1 > POLLFD_CACHE_SIZE)
+ Xfree(filedes);
+#endif
+ }
+ if (did_proc_conni) {
+ /* some internal connection callback might have done an
+ XPutBackEvent. We notice it here and if we needed an event,
+ we can return all the way. */
+ if (_XNewerQueuedEvent(dpy, saved_event_serial)
+ && (in_read_events
+#ifdef XTHREADS
+ || (dpy->lock && dpy->lock->event_awaiters)
+#endif
+ ))
+ return -2;
+ did_proc_conni = False;
+ }
+ }
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x _XWaitForReadable returning\n", XThread_Self());
+#endif
+#endif
+ return 0;
+}
+
+static
+int _XSeqSyncFunction(dpy)
+ register Display *dpy;
+{
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ LockDisplay(dpy);
+ if ((dpy->request - dpy->last_request_read) >= (BUFSIZE / SIZEOF(xReq))) {
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ /* could get XID handler while waiting for reply in MT env */
+ if (dpy->synchandler == _XSeqSyncFunction) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+#ifdef XTHREADS
+static void _XFlushInt();
+#endif
+
+/*
+ * _XFlush - Flush the X request buffer. If the buffer is empty, no
+ * action is taken. This routine correctly handles incremental writes.
+ * This routine may have to be reworked if int < long.
+ */
+void _XFlush (dpy)
+ register Display *dpy;
+{
+#ifdef XTHREADS
+ /* With multi-threading we introduce an internal routine to which
+ we can pass a condition variable to do locking correctly. */
+
+ _XFlushInt(dpy, NULL);
+}
+
+/* _XFlushInt - Internal version of _XFlush used to do multi-threaded
+ * locking correctly.
+ */
+
+static void _XFlushInt (dpy, cv)
+ register Display *dpy;
+ register xcondition_t cv;
+{
+ char *nextindex;
+#endif /* XTHREADS*/
+ register long size, todo;
+ register int write_stat;
+ register char *bufindex;
+ _XExtension *ext;
+
+ /* This fix resets the bufptr to the front of the buffer so
+ * additional appends to the bufptr will not corrupt memory. Since
+ * the server is down, these appends are no-op's anyway but
+ * callers of _XFlush() are not verifying this before they call it.
+ */
+ if (dpy->flags & XlibDisplayIOError)
+ {
+ dpy->bufptr = dpy->buffer;
+ dpy->last_req = (char *)&_dummy_request;
+ return;
+ }
+
+#ifdef XTHREADS
+ while (dpy->flags & XlibDisplayWriting) {
+ ConditionWait(dpy, dpy->lock->writers);
+ }
+#endif
+ size = todo = dpy->bufptr - dpy->buffer;
+ if (!size) return;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ for (ext = dpy->flushes; ext; ext = ext->next_flush)
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, size);
+ bufindex = dpy->buffer;
+ /*
+ * While write has not written the entire buffer, keep looping
+ * until the entire buffer is written. bufindex will be
+ * incremented and size decremented as buffer is written out.
+ */
+ while (size) {
+ ESET(0);
+ write_stat = _X11TransWrite(dpy->trans_conn,
+ bufindex, (int) todo);
+ if (write_stat >= 0) {
+ size -= write_stat;
+ todo = size;
+ bufindex += write_stat;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , cv
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ /* Write failed! */
+ /* errno set by write system call. */
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *)&_dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+}
+
+int
+_XEventsQueued (dpy, mode)
+ register Display *dpy;
+ int mode;
+{
+ register BytesReadable_t len;
+ BytesReadable_t pend;
+ _XAlignedBuffer buf;
+ register xReply *rep;
+ char *read_buf;
+#ifdef XTHREADS
+ int entry_event_serial_num;
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XEventsQueued called in thread %x\n", XThread_Self());
+#endif
+#endif /* XTHREADS*/
+
+ if (mode == QueuedAfterFlush)
+ {
+ _XFlush(dpy);
+ if (dpy->qlen)
+ return(dpy->qlen);
+ }
+ if (dpy->flags & XlibDisplayIOError) return(dpy->qlen);
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread))) {
+ /* In the multi-threaded case, if there is someone else
+ reading events, then there aren't any available, so
+ we just return. If we waited we would block.
+ */
+ if (dpy->lock && dpy->lock->event_awaiters)
+ return dpy->qlen;
+ /* nobody here but us, so lock out any newcomers */
+ cvl = QueueEventReaderLock(dpy);
+ }
+
+ while (dpy->lock && cvl && dpy->lock->reply_first) {
+ /* note which events we have already seen so we'll know
+ if _XReply (in another thread) reads one */
+ entry_event_serial_num = dpy->next_event_serial_num;
+ ConditionWait(dpy, cvl->cv);
+ /* did _XReply read an event we can return? */
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num))
+ {
+ UnlockNextEventReader(dpy);
+ return 0;
+ }
+ }
+#endif /* XTHREADS*/
+
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+#ifdef XCONN_CHECK_FREQ
+ /* This is a crock, required because FIONREAD or equivalent is
+ * not guaranteed to detect a broken connection.
+ */
+ if (!pend && !dpy->qlen && ++dpy->conn_checker >= XCONN_CHECK_FREQ)
+ {
+#ifdef USE_POLL
+ struct pollfd filedes;
+#else
+ fd_set r_mask;
+ static struct timeval zero_time;
+#endif
+
+ dpy->conn_checker = 0;
+#ifdef USE_POLL
+ filedes.fd = dpy->fd;
+ filedes.events = POLLIN;
+ if ((pend = poll(&filedes, 1, 0)))
+#else
+ FD_ZERO(&r_mask);
+ FD_SET(dpy->fd, &r_mask);
+ if ((pend = Select(dpy->fd + 1, &r_mask, NULL, NULL, &zero_time)))
+#endif
+ {
+ if (pend > 0)
+ {
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ /* we should not get zero, if we do, force a read */
+ if (!pend)
+ pend = SIZEOF(xReply);
+ }
+ else if (pend < 0 && !ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#endif /* XCONN_CHECK_FREQ */
+ if (!(len = pend)) {
+ /* _XFlush can enqueue events */
+ UnlockNextEventReader(dpy);
+ return(dpy->qlen);
+ }
+ /* Force a read if there is not enough data. Otherwise,
+ * a select() loop at a higher-level will spin undesirably,
+ * and we've seen at least one OS that appears to not update
+ * the result from FIONREAD once it has returned nonzero.
+ */
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ if (len < SIZEOF(xReply)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ )
+ len = SIZEOF(xReply);
+ else if (len > BUFSIZE)
+ len = BUFSIZE;
+ len = (len / SIZEOF(xReply)) * SIZEOF(xReply);
+ }
+#ifdef XCONN_CHECK_FREQ
+ dpy->conn_checker = 0;
+#endif
+
+ (void) _XRead (dpy, read_buf, (long) len);
+
+#ifdef XTHREADS
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf, read_buf,
+ len);
+ UnlockNextEventReader(dpy);
+ return(dpy->qlen); /* we read, so we can return */
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS*/
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ pend = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &pend, True));
+ len = pend;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *)rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE
+
+ UnlockNextEventReader(dpy);
+ return(dpy->qlen);
+}
+
+/* _XReadEvents - Flush the output queue,
+ * then read as many events as possible (but at least 1) and enqueue them
+ */
+void _XReadEvents(dpy)
+ register Display *dpy;
+{
+ _XAlignedBuffer buf;
+ BytesReadable_t pend;
+ register BytesReadable_t len;
+ register xReply *rep;
+ Bool not_yet_flushed = True;
+ char *read_buf;
+ int i;
+ int entry_event_serial_num = dpy->next_event_serial_num;
+#ifdef XTHREADS
+ struct _XCVList *cvl = NULL;
+ xthread_t self;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReadEvents called in thread %x\n",
+ XThread_Self());
+#endif
+ /* create our condition variable and append to list,
+ * unless we were called from within XProcessInternalConnection
+ * or XLockDisplay
+ */
+ xthread_clear_id(self);
+ if (dpy->lock && (xthread_have_id (dpy->lock->conni_thread)
+ || xthread_have_id (dpy->lock->locking_thread)))
+ /* some thread is in XProcessInternalConnection or XLockDisplay
+ so we have to see if we are it */
+ self = XThread_Self();
+ if (!xthread_have_id(self)
+ || (!xthread_equal(self, dpy->lock->conni_thread)
+ && !xthread_equal(self, dpy->lock->locking_thread)))
+ cvl = QueueEventReaderLock(dpy);
+#endif /* XTHREADS */
+
+ do {
+#ifdef XTHREADS
+ /* if it is not our turn to read an event off the wire,
+ wait til we're at head of list */
+ if (dpy->lock && cvl &&
+ (dpy->lock->event_awaiters != cvl ||
+ dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ continue;
+ }
+#endif /* XTHREADS */
+ /* find out how much data can be read */
+ if (_X11TransBytesReadable(dpy->trans_conn, &pend) < 0)
+ _XIOError(dpy);
+ len = pend;
+
+ /* must read at least one xEvent; if none is pending, then
+ we'll just flush and block waiting for it */
+ if (len < SIZEOF(xEvent)
+#ifdef XTHREADS
+ || dpy->async_handlers
+#endif
+ ) {
+ len = SIZEOF(xEvent);
+ /* don't flush until the first time we would block */
+ if (not_yet_flushed) {
+ _XFlush (dpy);
+ if (_XNewerQueuedEvent(dpy, entry_event_serial_num)) {
+ /* _XReply has read an event for us */
+ goto got_event;
+ }
+ not_yet_flushed = False;
+ }
+ }
+
+#ifdef XTHREADS
+ /* If someone is waiting for a reply, gamble that
+ the reply will be the next thing on the wire
+ and read it into their buffer. */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ read_buf = (char *)dpy->lock->reply_awaiters->buf;
+ len = SIZEOF(xReply);
+ } else
+#endif /* XTHREADS*/
+ {
+ read_buf = buf.buf;
+
+ /* but we won't read more than the max buffer size */
+ if (len > BUFSIZE)
+ len = BUFSIZE;
+
+ /* round down to an integral number of XReps */
+ len = (len / SIZEOF(xEvent)) * SIZEOF(xEvent);
+ }
+
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ /* save value we may have to stick in conni_thread */
+ dpy->lock->reading_thread = self;
+#endif /* XTHREADS */
+ dpy->flags |= XlibDisplayReadEvents;
+ i = _XRead (dpy, read_buf, (long) len);
+ dpy->flags &= ~XlibDisplayReadEvents;
+ if (i == -2) {
+ /* special flag from _XRead to say that internal connection has
+ done XPutBackEvent. Which we can use so we're done. */
+ got_event:
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->lock_wait) {
+ if (dpy->lock->event_awaiters != cvl)
+ /* since it is not us, must be user lock thread */
+ ConditionSignal(dpy,
+ dpy->lock->event_awaiters->cv);
+ (*dpy->lock->lock_wait)(dpy);
+ continue;
+ }
+#endif
+ break;
+ }
+#ifdef XTHREADS
+ if (xthread_have_id(self))
+ xthread_clear_id(dpy->lock->reading_thread);
+
+ /* what did we actually read: reply or event? */
+ if (dpy->lock && dpy->lock->reply_awaiters) {
+ if (((xReply *)read_buf)->generic.type == X_Reply ||
+ ((xReply *)read_buf)->generic.type == X_Error)
+ {
+ dpy->lock->reply_was_read = True;
+ dpy->lock->reply_first = True;
+ if (read_buf != (char *)dpy->lock->reply_awaiters->buf)
+ memcpy(dpy->lock->reply_awaiters->buf,
+ read_buf, len);
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ continue;
+ } else if (read_buf != buf.buf)
+ memcpy(buf.buf, read_buf, len);
+ }
+#endif /* XTHREADS */
+
+ STARTITERATE(rep,xReply,buf.buf,len > 0) {
+ if (rep->generic.type == X_Reply) {
+ pend = len;
+ RESETITERPTR(rep,xReply,
+ _XAsyncReply (dpy, rep,
+ ITERPTR(rep), &pend, True));
+ len = pend;
+ } else {
+ if (rep->generic.type == X_Error)
+ _XError (dpy, (xError *) rep);
+ else /* must be an event packet */
+ _XEnq (dpy, (xEvent *)rep);
+ INCITERPTR(rep,xReply);
+ len -= SIZEOF(xReply);
+ }
+ } ENDITERATE;
+ } while (!_XNewerQueuedEvent(dpy, entry_event_serial_num));
+
+ UnlockNextEventReader(dpy);
+}
+
+/*
+ * _XRead - Read bytes from the socket taking into account incomplete
+ * reads. This routine may have to be reworked if int < long.
+ */
+int _XRead (dpy, data, size)
+ register Display *dpy;
+ register char *data;
+ register long size;
+{
+ register long bytes_read;
+#ifdef XTHREADS
+ int original_size = size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0)
+ return 0;
+ ESET(0);
+ while ((bytes_read = _X11TransRead(dpy->trans_conn, data, (int)size))
+ != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ data += bytes_read;
+ }
+ else if (ETEST()) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ if (_XWaitForReadable(dpy) == -2)
+ return -2; /* internal connection did XPutBackEvent */
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+ return 0;
+}
+
+#ifdef LONG64
+void _XRead32 (dpy, data, len)
+ Display *dpy;
+ register long *data;
+ long len;
+{
+ register int *buf;
+ register long i;
+
+ if (len) {
+ (void) _XRead(dpy, (char *)data, len);
+ i = len >> 2;
+ buf = (int *)data + i;
+ data += i;
+ while (--i >= 0)
+ *--data = *--buf;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this....
+ * PACKBUFFERSIZE must be a multiple of 4.
+ */
+
+#define PACKBUFFERSIZE 4096
+
+
+/*
+ * _XRead32 - Read bytes from the socket unpacking each 32 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static void _doXRead32 (dpy, data, size, packbuffer)
+ register Display *dpy;
+ register long *data;
+ register long size;
+ register char *packbuffer;
+{
+ long *lpack,*lp;
+ long mask32 = 0x00000000ffffffff;
+ long maskw, nwords, i, bits;
+
+ _XReadPad (dpy, packbuffer, size);
+
+ lp = data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ maskw = mask32 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits = bits ^32;
+ if(bits){
+ lpack++;
+ }
+ }
+}
+
+void _XRead32 (dpy, data, len)
+ Display *dpy;
+ long *data;
+ long len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead32 (dpy, data, len, packbuffer);
+}
+
+
+
+/*
+ * _XRead16 - Read bytes from the socket unpacking each 16 bits
+ * into a long (64 bits on a CRAY computer).
+ *
+ */
+static _doXRead16 (dpy, data, size, packbuffer)
+ register Display *dpy;
+ register short *data;
+ register long size;
+ char *packbuffer;
+{
+ long *lpack,*lp;
+ long mask16 = 0x000000000000ffff;
+ long maskw, nwords, i, bits;
+
+ (void) _XRead(dpy,packbuffer,size); /* don't do a padded read... */
+
+ lp = (long *) data;
+ lpack = (long *) packbuffer;
+ nwords = size >> 1; /* number of 16 bit words to be unpacked */
+ bits = 48;
+ for(i=0;i<nwords;i++){
+ maskw = mask16 << bits;
+ *lp++ = ( *lpack & maskw ) >> bits;
+ bits -= 16;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+}
+
+void _XRead16 (dpy, data, len)
+ Display *dpy;
+ short *data;
+ long len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ _doXRead16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) _doXRead16 (dpy, data, len, packbuffer);
+}
+
+void _XRead16Pad (dpy, data, size)
+ Display *dpy;
+ short *data;
+ long size;
+{
+ int slop = (size & 3);
+ short slopbuf[3];
+
+ _XRead16 (dpy, data, size);
+ if (slop > 0) {
+ _XRead16 (dpy, slopbuf, 4 - slop);
+ }
+}
+#endif /* WORD64 */
+
+
+/*
+ * _XReadPad - Read bytes from the socket taking into account incomplete
+ * reads. If the number of bytes is not 0 mod 4, read additional pad
+ * bytes. This routine may have to be reworked if int < long.
+ */
+void _XReadPad (dpy, data, size)
+ register Display *dpy;
+ register char *data;
+ register long size;
+{
+ register long bytes_read;
+ struct iovec iov[2];
+ char pad[3];
+#ifdef XTHREADS
+ int original_size;
+#endif
+
+ if ((dpy->flags & XlibDisplayIOError) || size == 0) return;
+ iov[0].iov_len = (int)size;
+ iov[0].iov_base = data;
+ /*
+ * The following hack is used to provide 32 bit long-word
+ * aligned padding. The [1] vector is of length 0, 1, 2, or 3,
+ * whatever is needed.
+ */
+
+ iov[1].iov_len = padlength[size & 3];
+ iov[1].iov_base = pad;
+ size += iov[1].iov_len;
+#ifdef XTHREADS
+ original_size = size;
+#endif
+ ESET(0);
+ while ((bytes_read = _X11TransReadv (dpy->trans_conn, iov, 2)) != size) {
+
+ if (bytes_read > 0) {
+ size -= bytes_read;
+ if ((iov[0].iov_len -= bytes_read) < 0) {
+ iov[1].iov_len += iov[0].iov_len;
+ iov[1].iov_base = (char *)iov[1].iov_base - iov[0].iov_len;
+ iov[0].iov_len = 0;
+ }
+ else
+ iov[0].iov_base = (char *)iov[0].iov_base + bytes_read;
+ }
+ else if (ETEST()) {
+ _XWaitForReadable(dpy);
+ ESET(0);
+ }
+#ifdef SUNSYSV
+ else if (ECHECK(0)) {
+ _XWaitForReadable(dpy);
+ }
+#endif
+ else if (bytes_read == 0) {
+ /* Read failed because of end of file! */
+ ESET(EPIPE);
+ _XIOError(dpy);
+ }
+
+ else /* bytes_read is less than 0; presumably -1 */ {
+ /* If it's a system call interrupt, it's not an error. */
+ if (!ECHECK(EINTR))
+ _XIOError(dpy);
+ }
+ }
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->reply_bytes_left > 0)
+ {
+ dpy->lock->reply_bytes_left -= original_size;
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ }
+#endif /* XTHREADS*/
+}
+
+/*
+ * _XSend - Flush the buffer and send the client data. 32 bit word aligned
+ * transmission is used, if size is not 0 mod 4, extra bytes are transmitted.
+ * This routine may have to be reworked if int < long;
+ */
+void
+#if NeedFunctionPrototypes
+_XSend (
+ register Display *dpy,
+ _Xconst char *data,
+ register long size)
+#else
+_XSend (dpy, data, size)
+ register Display *dpy;
+ char *data;
+ register long size;
+#endif
+{
+ struct iovec iov[3];
+ static char pad[3] = {0, 0, 0};
+ /* XText8 and XText16 require that the padding bytes be zero! */
+
+ long skip, dbufsize, padsize, total, todo;
+ _XExtension *ext;
+
+ if (!size || (dpy->flags & XlibDisplayIOError)) return;
+ dbufsize = dpy->bufptr - dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags |= XlibDisplayWriting;
+ /* make sure no one else can put in data */
+ dpy->bufptr = dpy->bufmax;
+#endif
+ padsize = padlength[size & 3];
+ for (ext = dpy->flushes; ext; ext = ext->next_flush) {
+ (*ext->before_flush)(dpy, &ext->codes, dpy->buffer, dbufsize);
+ (*ext->before_flush)(dpy, &ext->codes, (char *)data, size);
+ if (padsize)
+ (*ext->before_flush)(dpy, &ext->codes, pad, padsize);
+ }
+ skip = 0;
+ todo = total = dbufsize + size + padsize;
+
+ /*
+ * There are 3 pieces that may need to be written out:
+ *
+ * o whatever is in the display buffer
+ * o the data passed in by the user
+ * o any padding needed to 32bit align the whole mess
+ *
+ * This loop looks at all 3 pieces each time through. It uses skip
+ * to figure out whether or not a given piece is needed.
+ */
+ while (total) {
+ long before = skip; /* amount of whole thing written */
+ long remain = todo; /* amount to try this time, <= total */
+ int i = 0;
+ long len;
+
+ /* You could be very general here and have "in" and "out" iovecs
+ * and write a loop without using a macro, but what the heck. This
+ * translates to:
+ *
+ * how much of this piece is new?
+ * if more new then we are trying this time, clamp
+ * if nothing new
+ * then bump down amount already written, for next piece
+ * else put new stuff in iovec, will need all of next piece
+ *
+ * Note that todo had better be at least 1 or else we'll end up
+ * writing 0 iovecs.
+ */
+#define InsertIOV(pointer, length) \
+ len = (length) - before; \
+ if (len > remain) \
+ len = remain; \
+ if (len <= 0) { \
+ before = (-len); \
+ } else { \
+ iov[i].iov_len = len; \
+ iov[i].iov_base = (pointer) + before; \
+ i++; \
+ remain -= len; \
+ before = 0; \
+ }
+
+ InsertIOV (dpy->buffer, dbufsize)
+ InsertIOV ((char *)data, size)
+ InsertIOV (pad, padsize)
+
+ ESET(0);
+ if ((len = _X11TransWritev(dpy->trans_conn, iov, i)) >= 0) {
+ skip += len;
+ total -= len;
+ todo = total;
+ } else if (ETEST()) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#ifdef SUNSYSV
+ } else if (ECHECK(0)) {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+#endif
+#ifdef ESZTEST
+ } else if (ESZTEST()) {
+ if (todo > 1)
+ todo >>= 1;
+ else {
+ _XWaitForWritable(dpy
+#ifdef XTHREADS
+ , NULL
+#endif
+ );
+ }
+#endif
+ } else if (!ECHECK(EINTR)) {
+ _XIOError(dpy);
+ }
+ }
+ dpy->last_req = (char *) & _dummy_request;
+ if ((dpy->request - dpy->last_request_read) >= SEQLIMIT &&
+ !(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->synchandler = _XSeqSyncFunction;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->bufptr = dpy->buffer;
+#ifdef XTHREADS
+ dpy->flags &= ~XlibDisplayWriting;
+#endif
+ return;
+}
+
+static void
+_XGetMiscCode(dpy)
+ register Display *dpy;
+{
+ xQueryExtensionReply qrep;
+ register xQueryExtensionReq *qreq;
+ xXCMiscGetVersionReply vrep;
+ register xXCMiscGetVersionReq *vreq;
+
+ if (dpy->xcmisc_opcode)
+ return;
+ GetReq(QueryExtension, qreq);
+ qreq->nbytes = sizeof(XCMiscExtensionName) - 1;
+ qreq->length += (qreq->nbytes+(unsigned)3)>>2;
+ _XSend(dpy, XCMiscExtensionName, (long)qreq->nbytes);
+ if (!_XReply (dpy, (xReply *)&qrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else {
+ GetReq(XCMiscGetVersion, vreq);
+ vreq->reqType = qrep.major_opcode;
+ vreq->miscReqType = X_XCMiscGetVersion;
+ vreq->majorVersion = XCMiscMajorVersion;
+ vreq->minorVersion = XCMiscMinorVersion;
+ if (!_XReply (dpy, (xReply *)&vrep, 0, xTrue))
+ dpy->xcmisc_opcode = -1;
+ else
+ dpy->xcmisc_opcode = qrep.major_opcode;
+ }
+}
+
+static int
+_XIDHandler(dpy)
+ register Display *dpy;
+{
+ xXCMiscGetXIDRangeReply grep;
+ register xXCMiscGetXIDRangeReq *greq;
+
+ LockDisplay(dpy);
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDRange, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDRange;
+ if (_XReply (dpy, (xReply *)&grep, 0, xTrue) && grep.count) {
+ dpy->resource_id = ((grep.start_id - dpy->resource_base) >>
+ dpy->resource_shift);
+ dpy->resource_max = dpy->resource_id;
+ if (grep.count > 5)
+ dpy->resource_max += grep.count - 6;
+ dpy->resource_max <<= dpy->resource_shift;
+ }
+ }
+ if (dpy->flags & XlibDisplayPrivSync) {
+ dpy->synchandler = dpy->savedsynchandler;
+ dpy->flags &= ~XlibDisplayPrivSync;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return 0;
+}
+
+/*
+ * _XAllocID - resource ID allocation routine.
+ */
+XID _XAllocID(dpy)
+ register Display *dpy;
+{
+ XID id;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ if (id <= dpy->resource_mask) {
+ dpy->resource_id++;
+ return (dpy->resource_base + id);
+ }
+ if (id != 0x10000000) {
+ (void) fprintf(stderr,
+ "Xlib: resource ID allocation space exhausted!\n");
+ id = 0x10000000;
+ dpy->resource_id = id >> dpy->resource_shift;
+ }
+ return id;
+}
+
+/*
+ * _XAllocIDs - multiple resource ID allocation routine.
+ */
+void _XAllocIDs(dpy, ids, count)
+ register Display *dpy;
+ XID *ids;
+ int count;
+{
+ XID id;
+ int i;
+ xXCMiscGetXIDListReply grep;
+ register xXCMiscGetXIDListReq *greq;
+
+ id = dpy->resource_id << dpy->resource_shift;
+ if (dpy->resource_max <= dpy->resource_mask &&
+ id <= dpy->resource_mask &&
+ (dpy->resource_max - id) > ((count - 1) << dpy->resource_shift)) {
+ id += dpy->resource_base;
+ for (i = 0; i < count; i++) {
+ ids[i] = id;
+ id += (1 << dpy->resource_shift);
+ dpy->resource_id++;
+ }
+ return;
+ }
+ grep.count = 0;
+ _XGetMiscCode(dpy);
+ if (dpy->xcmisc_opcode > 0) {
+ GetReq(XCMiscGetXIDList, greq);
+ greq->reqType = dpy->xcmisc_opcode;
+ greq->miscReqType = X_XCMiscGetXIDList;
+ greq->count = count;
+ if (_XReply(dpy, (xReply *)&grep, 0, xFalse) && grep.count) {
+ _XRead32(dpy, (long *) ids, 4L * (long) (grep.count));
+ for (i = 0; i < grep.count; i++) {
+ id = (ids[i] - dpy->resource_base) >> dpy->resource_shift;
+ if (id >= dpy->resource_id)
+ dpy->resource_id = id;
+ }
+ if (id >= dpy->resource_max) {
+ if (!(dpy->flags & XlibDisplayPrivSync)) {
+ dpy->savedsynchandler = dpy->synchandler;
+ dpy->flags |= XlibDisplayPrivSync;
+ }
+ dpy->synchandler = _XIDHandler;
+ dpy->resource_max = dpy->resource_mask + 1;
+ }
+ }
+ }
+ for (i = grep.count; i < count; i++)
+ ids[i] = XAllocID(dpy);
+}
+
+/*
+ * The hard part about this is that we only get 16 bits from a reply.
+ * We have three values that will march along, with the following invariant:
+ * dpy->last_request_read <= rep->sequenceNumber <= dpy->request
+ * We have to keep
+ * dpy->request - dpy->last_request_read < 2^16
+ * or else we won't know for sure what value to use in events. We do this
+ * by forcing syncs when we get close.
+ */
+
+unsigned long
+_XSetLastRequestRead(dpy, rep)
+ register Display *dpy;
+ register xGenericReply *rep;
+{
+ register unsigned long newseq, lastseq;
+
+ lastseq = dpy->last_request_read;
+ /*
+ * KeymapNotify has no sequence number, but is always guaranteed
+ * to immediately follow another event, except when generated via
+ * SendEvent (hmmm).
+ */
+ if ((rep->type & 0x7f) == KeymapNotify)
+ return(lastseq);
+
+ newseq = (lastseq & ~((unsigned long)0xffff)) | rep->sequenceNumber;
+
+ if (newseq < lastseq) {
+ newseq += 0x10000;
+ if (newseq > dpy->request) {
+ (void) fprintf (stderr,
+ "Xlib: sequence lost (0x%lx > 0x%lx) in reply type 0x%x!\n",
+ newseq, dpy->request,
+ (unsigned int) rep->type);
+ newseq -= 0x10000;
+ }
+ }
+
+ dpy->last_request_read = newseq;
+ return(newseq);
+}
+
+/*
+ * _XReply - Wait for a reply packet and copy its contents into the
+ * specified rep. Meanwhile we must handle error and event packets that
+ * we may encounter.
+ */
+Status
+_XReply (dpy, rep, extra, discard)
+ register Display *dpy;
+ register xReply *rep;
+ int extra; /* number of 32-bit words expected after the reply */
+ Bool discard; /* should I discard data following "extra" words? */
+{
+ /* Pull out the serial number now, so that (currently illegal) requests
+ * generated by an error handler don't confuse us.
+ */
+ unsigned long cur_request = dpy->request;
+#ifdef XTHREADS
+ struct _XCVList *cvl;
+#endif
+
+ if (dpy->flags & XlibDisplayIOError)
+ return 0;
+
+#ifdef XTHREADS
+ /* create our condition variable and append to list */
+ cvl = QueueReplyReaderLock(dpy);
+ if (cvl) {
+ cvl->buf = rep;
+ if (dpy->lock->reply_awaiters == cvl && !dpy->lock->event_awaiters)
+ dpy->lock->reply_first = True;
+ }
+
+#ifdef XTHREADS_DEBUG
+ printf("_XReply called in thread %x, adding %x to cvl\n",
+ XThread_Self(), cvl);
+#endif
+
+ _XFlushInt(dpy, cvl ? cvl->cv : NULL);
+ /* if it is not our turn to read a reply off the wire,
+ * wait til we're at head of list. if there is an event waiter,
+ * and our reply hasn't been read, they'll be in select and will
+ * hand control back to us next.
+ */
+ if(dpy->lock &&
+ (dpy->lock->reply_awaiters != cvl || !dpy->lock->reply_first)) {
+ ConditionWait(dpy, cvl->cv);
+ }
+ dpy->flags |= XlibDisplayReply;
+#else /* XTHREADS else */
+ _XFlush(dpy);
+#endif
+
+ for (;;) {
+#ifdef XTHREADS
+ /* Did another thread's _XReadEvents get our reply by accident? */
+ if (!dpy->lock || !dpy->lock->reply_was_read)
+#endif
+ (void) _XRead(dpy, (char *)rep, (long)SIZEOF(xReply));
+#ifdef XTHREADS
+ if (dpy->lock)
+ dpy->lock->reply_was_read = False;
+#endif
+
+ switch ((int)rep->generic.type) {
+
+ case X_Reply:
+ /* Reply received. Fast update for synchronous replies,
+ * but deal with multiple outstanding replies.
+ */
+ if (rep->generic.sequenceNumber == (cur_request & 0xffff))
+ dpy->last_request_read = cur_request;
+ else {
+ int pend = SIZEOF(xReply);
+ if (_XAsyncReply(dpy, rep, (char *)rep, &pend, False)
+ != (char *)rep)
+ continue;
+ }
+ /*
+ * Don't accept ridiculously large values for
+ * generic.length; doing so could cause stack-scribbling
+ * problems elsewhere.
+ */
+ if (rep->generic.length > GENERIC_LENGTH_LIMIT) {
+ rep->generic.length = GENERIC_LENGTH_LIMIT;
+ (void) fprintf(stderr,
+ "Xlib: suspiciously long reply length %d set to %d",
+ rep->generic.length, GENERIC_LENGTH_LIMIT);
+ }
+ if (extra <= rep->generic.length) {
+ if (extra > 0)
+ /*
+ * Read the extra data into storage immediately
+ * following the GenericReply structure.
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long)extra) << 2);
+ if (discard) {
+ if (extra < rep->generic.length)
+ _XEatData(dpy, (rep->generic.length - extra) << 2);
+ }
+#ifdef XTHREADS
+ if (dpy->lock) {
+ if (discard) {
+ dpy->lock->reply_bytes_left = 0;
+ } else {
+ dpy->lock->reply_bytes_left =
+ (rep->generic.length - extra) << 2;
+ }
+ if (dpy->lock->reply_bytes_left == 0) {
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ }
+ } else
+ dpy->flags &= ~XlibDisplayReply;
+#endif
+ return 1;
+ }
+ /*
+ *if we get here, then extra > rep->generic.length--meaning we
+ * read a reply that's shorter than we expected. This is an
+ * error, but we still need to figure out how to handle it...
+ */
+ (void) _XRead (dpy, (char *) (NEXTPTR(rep,xReply)),
+ ((long) rep->generic.length) << 2);
+ dpy->flags &= ~XlibDisplayReply;
+ UnlockNextReplyReader(dpy);
+ _XIOError (dpy);
+ return (0);
+
+ case X_Error:
+ {
+ register _XExtension *ext;
+ register Bool ret = False;
+ int ret_code;
+ xError *err = (xError *) rep;
+ unsigned long serial;
+
+ dpy->flags &= ~XlibDisplayReply;
+ serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+ if (serial == cur_request)
+ /* do not die on "no such font", "can't allocate",
+ "can't grab" failures */
+ switch ((int)err->errorCode) {
+ case BadName:
+ switch (err->majorCode) {
+ case X_LookupColor:
+ case X_AllocNamedColor:
+ UnlockNextReplyReader(dpy);
+ return(0);
+ }
+ break;
+ case BadFont:
+ if (err->majorCode == X_QueryFont) {
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ break;
+ case BadAlloc:
+ case BadAccess:
+ UnlockNextReplyReader(dpy);
+ return (0);
+ }
+ /*
+ * we better see if there is an extension who may
+ * want to suppress the error.
+ */
+ for (ext = dpy->ext_procs; !ret && ext; ext = ext->next) {
+ if (ext->error)
+ ret = (*ext->error)(dpy, err, &ext->codes, &ret_code);
+ }
+ if (!ret) {
+ _XError(dpy, err);
+ ret_code = 0;
+ }
+ if (serial == cur_request) {
+ UnlockNextReplyReader(dpy);
+ return(ret_code);
+ }
+
+ } /* case X_Error */
+ break;
+ default:
+ _XEnq(dpy, (xEvent *) rep);
+#ifdef XTHREADS
+ if (dpy->lock && dpy->lock->event_awaiters)
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+#endif
+ break;
+ }
+ }
+}
+
+static char *
+_XAsyncReply(dpy, rep, buf, lenp, discard)
+ Display *dpy;
+ register xReply *rep;
+ char *buf;
+ register int *lenp;
+ Bool discard;
+{
+ register _XAsyncHandler *async, *next;
+ register int len;
+ register Bool consumed = False;
+ char *nbuf;
+
+ (void) _XSetLastRequestRead(dpy, &rep->generic);
+ len = SIZEOF(xReply) + (rep->generic.length << 2);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((consumed = (*async->handler)(dpy, rep, buf, *lenp, async->data)))
+ break;
+ }
+ if (!consumed) {
+ if (!discard)
+ return buf;
+ (void) fprintf(stderr,
+ "Xlib: unexpected async reply (sequence 0x%lx)!\n",
+ dpy->last_request_read);
+#ifdef XTHREADS
+#ifdef XTHREADS_DEBUG
+ printf("thread %x, unexpected async reply\n", XThread_Self());
+#endif
+#endif
+ if (len > *lenp)
+ _XEatData(dpy, len - *lenp);
+ }
+ if (len < SIZEOF(xReply))
+ {
+ ESET(EINVAL);
+ _XIOError (dpy);
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ if (len >= *lenp) {
+ buf += *lenp;
+ *lenp = 0;
+ return buf;
+ }
+ *lenp -= len;
+ buf += len;
+ len = *lenp;
+ nbuf = buf;
+ while (len > SIZEOF(xReply)) {
+ if (*buf == X_Reply)
+ return nbuf;
+ buf += SIZEOF(xReply);
+ len -= SIZEOF(xReply);
+ }
+ if (len > 0 && len < SIZEOF(xReply)) {
+ buf = nbuf;
+ len = SIZEOF(xReply) - len;
+ nbuf -= len;
+ memmove(nbuf, buf, *lenp);
+ (void) _XRead(dpy, nbuf + *lenp, (long)len);
+ *lenp += len;
+ }
+ return nbuf;
+}
+
+/*
+ * Support for internal connections, such as an IM might use.
+ * By Stephen Gildea, The Open Group, September 1993
+ */
+
+/* _XRegisterInternalConnection
+ * Each IM (or Xlib extension) that opens a file descriptor that Xlib should
+ * include in its select/poll mask must call this function to register the
+ * fd with Xlib. Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Whenever Xlib detects input available on fd, it will call callback
+ * with call_data to process it. If non-Xlib code calls select/poll
+ * and detects input available, it must call XProcessInternalConnection,
+ * which will call the associated callback.
+ *
+ * Non-Xlib code can learn about these additional fds by calling
+ * XInternalConnectionNumbers or, more typically, by registering
+ * a XConnectionWatchProc with XAddConnectionWatch
+ * to be called when fds are registered or unregistered.
+ *
+ * Returns True if registration succeeded, False if not, typically
+ * because could not allocate memory.
+ * Assumes Display locked when called.
+ */
+#if NeedFunctionPrototypes
+Status _XRegisterInternalConnection(
+ Display* dpy,
+ int fd,
+ _XInternalConnectionProc callback,
+ XPointer call_data
+)
+#else
+Status
+_XRegisterInternalConnection(dpy, fd, callback, call_data)
+ Display *dpy;
+ int fd;
+ _XInternalConnectionProc callback;
+ XPointer call_data;
+#endif
+{
+ struct _XConnectionInfo *new_conni, **iptr;
+ struct _XConnWatchInfo *watchers;
+ XPointer *wd;
+
+ new_conni = (struct _XConnectionInfo*)Xmalloc(sizeof(struct _XConnectionInfo));
+ if (!new_conni)
+ return 0;
+ new_conni->watch_data = (XPointer *)Xmalloc(dpy->watcher_count * sizeof(XPointer));
+ if (!new_conni->watch_data) {
+ Xfree(new_conni);
+ return 0;
+ }
+ new_conni->fd = fd;
+ new_conni->read_callback = callback;
+ new_conni->call_data = call_data;
+ new_conni->next = NULL;
+ /* link new structure onto end of list */
+ for (iptr = &dpy->im_fd_info; *iptr; iptr = &(*iptr)->next)
+ ;
+ *iptr = new_conni;
+ dpy->im_fd_length++;
+ _XPollfdCacheAdd(dpy, fd);
+
+ for (watchers=dpy->conn_watchers, wd=new_conni->watch_data;
+ watchers;
+ watchers=watchers->next, wd++) {
+ *wd = NULL; /* for cleanliness */
+ (*watchers->fn) (dpy, watchers->client_data, fd, True, wd);
+ }
+
+ return 1;
+}
+
+/* _XUnregisterInternalConnection
+ * Each IM (or Xlib extension) that closes a file descriptor previously
+ * registered with _XRegisterInternalConnection must call this function.
+ * Any XConnectionWatchProc registered by XAddConnectionWatch
+ * will also be called.
+ *
+ * Assumes Display locked when called.
+ */
+#if NeedFunctionPrototypes
+void _XUnregisterInternalConnection(
+ Display* dpy,
+ int fd
+)
+#else
+void
+_XUnregisterInternalConnection(dpy, fd)
+ Display *dpy;
+ int fd;
+#endif
+{
+ struct _XConnectionInfo *info_list, **prev;
+ struct _XConnWatchInfo *watch;
+ XPointer *wd;
+
+ for (prev = &dpy->im_fd_info; (info_list = *prev); prev = &info_list->next) {
+ if (info_list->fd == fd) {
+ *prev = info_list->next;
+ dpy->im_fd_length--;
+ for (watch=dpy->conn_watchers, wd=info_list->watch_data;
+ watch;
+ watch=watch->next, wd++) {
+ (*watch->fn) (dpy, watch->client_data, fd, False, wd);
+ }
+ if (info_list->watch_data)
+ Xfree (info_list->watch_data);
+ Xfree (info_list);
+ break;
+ }
+ }
+ _XPollfdCacheDel(dpy, fd);
+}
+
+/* XInternalConnectionNumbers
+ * Returns an array of fds and an array of corresponding call data.
+ * Typically a XConnectionWatchProc registered with XAddConnectionWatch
+ * will be used instead of this function to discover
+ * additional fds to include in the select/poll mask.
+ *
+ * The list is allocated with Xmalloc and should be freed by the caller
+ * with Xfree;
+ */
+#if NeedFunctionPrototypes
+Status XInternalConnectionNumbers(
+ Display *dpy,
+ int **fd_return,
+ int *count_return
+)
+#else
+Status
+XInternalConnectionNumbers(dpy, fd_return, count_return)
+ Display *dpy;
+ int **fd_return;
+ int *count_return;
+#endif
+{
+ int count;
+ struct _XConnectionInfo *info_list;
+ int *fd_list;
+
+ LockDisplay(dpy);
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next)
+ count++;
+ fd_list = (int*) Xmalloc (count * sizeof(int));
+ if (!fd_list) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ count = 0;
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ fd_list[count] = info_list->fd;
+ count++;
+ }
+ UnlockDisplay(dpy);
+
+ *fd_return = fd_list;
+ *count_return = count;
+ return 1;
+}
+
+static void _XProcessInternalConnection(dpy, conn_info)
+ Display *dpy;
+ struct _XConnectionInfo *conn_info;
+{
+ dpy->flags |= XlibDisplayProcConni;
+#ifdef XTHREADS
+ if (dpy->lock) {
+ /* check cache to avoid call to thread_self */
+ if (xthread_have_id(dpy->lock->reading_thread))
+ dpy->lock->conni_thread = dpy->lock->reading_thread;
+ else
+ dpy->lock->conni_thread = XThread_Self();
+ }
+#endif /* XTHREADS */
+ UnlockDisplay(dpy);
+ (*conn_info->read_callback) (dpy, conn_info->fd, conn_info->call_data);
+ LockDisplay(dpy);
+#ifdef XTHREADS
+ if (dpy->lock)
+ xthread_clear_id(dpy->lock->conni_thread);
+#endif /* XTHREADS */
+ dpy->flags &= ~XlibDisplayProcConni;
+}
+
+/* XProcessInternalConnection
+ * Call the _XInternalConnectionProc registered by _XRegisterInternalConnection
+ * for this fd.
+ * The Display is NOT locked during the call.
+ */
+#if NeedFunctionPrototypes
+void XProcessInternalConnection(
+ Display* dpy,
+ int fd
+)
+#else
+void
+XProcessInternalConnection(dpy, fd)
+ Display *dpy;
+ int fd;
+#endif
+{
+ struct _XConnectionInfo *info_list;
+
+ LockDisplay(dpy);
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ if (info_list->fd == fd) {
+ _XProcessInternalConnection(dpy, info_list);
+ break;
+ }
+ }
+ UnlockDisplay(dpy);
+}
+
+/* XAddConnectionWatch
+ * Register a callback to be called whenever _XRegisterInternalConnection
+ * or _XUnregisterInternalConnection is called.
+ * Callbacks are called with the Display locked.
+ * If any connections are already registered, the callback is immediately
+ * called for each of them.
+ */
+#if NeedFunctionPrototypes
+Status XAddConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+#else
+Status
+XAddConnectionWatch(dpy, callback, client_data)
+ Display *dpy;
+ XConnectionWatchProc callback;
+ XPointer client_data;
+#endif
+{
+ struct _XConnWatchInfo *new_watcher, **wptr;
+ struct _XConnectionInfo *info_list;
+ XPointer *wd_array;
+
+ LockDisplay(dpy);
+
+ /* allocate new watch data */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ wd_array = (XPointer *)Xrealloc((char *)info_list->watch_data,
+ (dpy->watcher_count + 1) *
+ sizeof(XPointer));
+ if (!wd_array) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ wd_array[dpy->watcher_count] = NULL; /* for cleanliness */
+ }
+
+ new_watcher = (struct _XConnWatchInfo*)Xmalloc(sizeof(struct _XConnWatchInfo));
+ if (!new_watcher) {
+ UnlockDisplay(dpy);
+ return 0;
+ }
+ new_watcher->fn = callback;
+ new_watcher->client_data = client_data;
+ new_watcher->next = NULL;
+
+ /* link new structure onto end of list */
+ for (wptr = &dpy->conn_watchers; *wptr; wptr = &(*wptr)->next)
+ ;
+ *wptr = new_watcher;
+ dpy->watcher_count++;
+
+ /* call new watcher on all currently registered fds */
+ for (info_list=dpy->im_fd_info; info_list; info_list=info_list->next) {
+ (*callback) (dpy, client_data, info_list->fd, True,
+ info_list->watch_data + dpy->watcher_count - 1);
+ }
+
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+/* XRemoveConnectionWatch
+ * Unregister a callback registered by XAddConnectionWatch.
+ * Both callback and client_data must match what was passed to
+ * XAddConnectionWatch.
+ */
+#if NeedFunctionPrototypes
+void XRemoveConnectionWatch(
+ Display* dpy,
+ XConnectionWatchProc callback,
+ XPointer client_data
+)
+#else
+void
+XRemoveConnectionWatch(dpy, callback, client_data)
+ Display *dpy;
+ XConnectionWatchProc callback;
+ XPointer client_data;
+#endif
+{
+ struct _XConnWatchInfo *watch;
+ struct _XConnWatchInfo *previous = NULL;
+ struct _XConnectionInfo *conni;
+ int counter = 0;
+
+ LockDisplay(dpy);
+ for (watch=dpy->conn_watchers; watch; watch=watch->next) {
+ if (watch->fn == callback && watch->client_data == client_data) {
+ if (previous)
+ previous->next = watch->next;
+ else
+ dpy->conn_watchers = watch->next;
+ Xfree (watch);
+ dpy->watcher_count--;
+ /* remove our watch_data for each connection */
+ for (conni=dpy->im_fd_info; conni; conni=conni->next) {
+ /* don't bother realloc'ing; these arrays are small anyway */
+ /* overlapping */
+ memmove(conni->watch_data+counter,
+ conni->watch_data+counter+1,
+ dpy->watcher_count - counter);
+ }
+ break;
+ }
+ previous = watch;
+ counter++;
+ }
+ UnlockDisplay(dpy);
+}
+
+/* end of internal connections support */
+
+
+/* Read and discard "n" 8-bit bytes of data */
+
+void _XEatData (dpy, n)
+ Display *dpy;
+ register unsigned long n;
+{
+#define SCRATCHSIZE 2048
+ char buf[SCRATCHSIZE];
+
+ while (n > 0) {
+ register long bytes_read = (n > SCRATCHSIZE) ? SCRATCHSIZE : n;
+ (void) _XRead (dpy, buf, bytes_read);
+ n -= bytes_read;
+ }
+#undef SCRATCHSIZE
+}
+
+
+/*
+ * _XEnq - Place event packets on the display's queue.
+ * note that no squishing of move events in V11, since there
+ * is pointer motion hints....
+ */
+void _XEnq (dpy, event)
+ register Display *dpy;
+ register xEvent *event;
+{
+ register _XQEvent *qelt;
+
+ if ((qelt = dpy->qfree)) {
+ /* If dpy->qfree is non-NULL do this, else malloc a new one. */
+ dpy->qfree = qelt->next;
+ }
+ else if ((qelt =
+ (_XQEvent *) Xmalloc((unsigned)sizeof(_XQEvent))) == NULL) {
+ /* Malloc call failed! */
+ ESET(ENOMEM);
+ _XIOError(dpy);
+ }
+ qelt->next = NULL;
+ /* go call through display to find proper event reformatter */
+ if ((*dpy->event_vec[event->u.u.type & 0177])(dpy, &qelt->event, event)) {
+ qelt->qserial_num = dpy->next_event_serial_num++;
+ if (dpy->tail) dpy->tail->next = qelt;
+ else dpy->head = qelt;
+
+ dpy->tail = qelt;
+ dpy->qlen++;
+ } else {
+ /* ignored, or stashed away for many-to-one compression */
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ }
+}
+
+/*
+ * _XDeq - Remove event packet from the display's queue.
+ */
+void _XDeq (dpy, prev, qelt)
+ register Display *dpy;
+ register _XQEvent *prev; /* element before qelt */
+ register _XQEvent *qelt; /* element to be unlinked */
+{
+ if (prev) {
+ if ((prev->next = qelt->next) == NULL)
+ dpy->tail = prev;
+ } else {
+ /* no prev, so removing first elt */
+ if ((dpy->head = qelt->next) == NULL)
+ dpy->tail = NULL;
+ }
+ qelt->qserial_num = 0;
+ qelt->next = dpy->qfree;
+ dpy->qfree = qelt;
+ dpy->qlen--;
+}
+
+/*
+ * EventToWire in separate file in that often not needed.
+ */
+
+/*ARGSUSED*/
+Bool
+_XUnknownWireEvent(dpy, re, event)
+register Display *dpy; /* pointer to display structure */
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled wire event! event number = %d, display = %x\n.",
+ event->u.u.type, dpy);
+#endif
+ return(False);
+}
+
+/*ARGSUSED*/
+Status
+_XUnknownNativeEvent(dpy, re, event)
+register Display *dpy; /* pointer to display structure */
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+{
+#ifdef notdef
+ (void) fprintf(stderr,
+ "Xlib: unhandled native event! event number = %d, display = %x\n.",
+ re->type, dpy);
+#endif
+ return(0);
+}
+/*
+ * reformat a wire event into an XEvent structure of the right type.
+ */
+Bool
+_XWireToEvent(dpy, re, event)
+register Display *dpy; /* pointer to display structure */
+register XEvent *re; /* pointer to where event should be reformatted */
+register xEvent *event; /* wire protocol event */
+{
+
+ re->type = event->u.u.type & 0x7f;
+ ((XAnyEvent *)re)->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ((XAnyEvent *)re)->send_event = ((event->u.u.type & 0x80) != 0);
+ ((XAnyEvent *)re)->display = dpy;
+
+ /* Ignore the leading bit of the event type since it is set when a
+ client sends an event rather than the server. */
+
+ switch (event-> u.u.type & 0177) {
+ case KeyPress:
+ case KeyRelease:
+ {
+ register XKeyEvent *ev = (XKeyEvent*) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->keycode = event->u.u.detail;
+ }
+ break;
+ case ButtonPress:
+ case ButtonRelease:
+ {
+ register XButtonEvent *ev = (XButtonEvent *) re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->button = event->u.u.detail;
+ }
+ break;
+ case MotionNotify:
+ {
+ register XMotionEvent *ev = (XMotionEvent *)re;
+ ev->root = event->u.keyButtonPointer.root;
+ ev->window = event->u.keyButtonPointer.event;
+ ev->subwindow = event->u.keyButtonPointer.child;
+ ev->time = event->u.keyButtonPointer.time;
+ ev->x = cvtINT16toInt(event->u.keyButtonPointer.eventX);
+ ev->y = cvtINT16toInt(event->u.keyButtonPointer.eventY);
+ ev->x_root = cvtINT16toInt(event->u.keyButtonPointer.rootX);
+ ev->y_root = cvtINT16toInt(event->u.keyButtonPointer.rootY);
+ ev->state = event->u.keyButtonPointer.state;
+ ev->same_screen = event->u.keyButtonPointer.sameScreen;
+ ev->is_hint = event->u.u.detail;
+ }
+ break;
+ case EnterNotify:
+ case LeaveNotify:
+ {
+ register XCrossingEvent *ev = (XCrossingEvent *) re;
+ ev->root = event->u.enterLeave.root;
+ ev->window = event->u.enterLeave.event;
+ ev->subwindow = event->u.enterLeave.child;
+ ev->time = event->u.enterLeave.time;
+ ev->x = cvtINT16toInt(event->u.enterLeave.eventX);
+ ev->y = cvtINT16toInt(event->u.enterLeave.eventY);
+ ev->x_root = cvtINT16toInt(event->u.enterLeave.rootX);
+ ev->y_root = cvtINT16toInt(event->u.enterLeave.rootY);
+ ev->state = event->u.enterLeave.state;
+ ev->mode = event->u.enterLeave.mode;
+ ev->same_screen = (event->u.enterLeave.flags &
+ ELFlagSameScreen) && True;
+ ev->focus = (event->u.enterLeave.flags &
+ ELFlagFocus) && True;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case FocusIn:
+ case FocusOut:
+ {
+ register XFocusChangeEvent *ev = (XFocusChangeEvent *) re;
+ ev->window = event->u.focus.window;
+ ev->mode = event->u.focus.mode;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case KeymapNotify:
+ {
+ register XKeymapEvent *ev = (XKeymapEvent *) re;
+ ev->window = None;
+ memcpy(&ev->key_vector[1],
+ (char *)((xKeymapEvent *) event)->map,
+ sizeof (((xKeymapEvent *) event)->map));
+ }
+ break;
+ case Expose:
+ {
+ register XExposeEvent *ev = (XExposeEvent *) re;
+ ev->window = event->u.expose.window;
+ ev->x = event->u.expose.x;
+ ev->y = event->u.expose.y;
+ ev->width = event->u.expose.width;
+ ev->height = event->u.expose.height;
+ ev->count = event->u.expose.count;
+ }
+ break;
+ case GraphicsExpose:
+ {
+ register XGraphicsExposeEvent *ev =
+ (XGraphicsExposeEvent *) re;
+ ev->drawable = event->u.graphicsExposure.drawable;
+ ev->x = event->u.graphicsExposure.x;
+ ev->y = event->u.graphicsExposure.y;
+ ev->width = event->u.graphicsExposure.width;
+ ev->height = event->u.graphicsExposure.height;
+ ev->count = event->u.graphicsExposure.count;
+ ev->major_code = event->u.graphicsExposure.majorEvent;
+ ev->minor_code = event->u.graphicsExposure.minorEvent;
+ }
+ break;
+ case NoExpose:
+ {
+ register XNoExposeEvent *ev = (XNoExposeEvent *) re;
+ ev->drawable = event->u.noExposure.drawable;
+ ev->major_code = event->u.noExposure.majorEvent;
+ ev->minor_code = event->u.noExposure.minorEvent;
+ }
+ break;
+ case VisibilityNotify:
+ {
+ register XVisibilityEvent *ev = (XVisibilityEvent *) re;
+ ev->window = event->u.visibility.window;
+ ev->state = event->u.visibility.state;
+ }
+ break;
+ case CreateNotify:
+ {
+ register XCreateWindowEvent *ev =
+ (XCreateWindowEvent *) re;
+ ev->window = event->u.createNotify.window;
+ ev->parent = event->u.createNotify.parent;
+ ev->x = cvtINT16toInt(event->u.createNotify.x);
+ ev->y = cvtINT16toInt(event->u.createNotify.y);
+ ev->width = event->u.createNotify.width;
+ ev->height = event->u.createNotify.height;
+ ev->border_width = event->u.createNotify.borderWidth;
+ ev->override_redirect = event->u.createNotify.override;
+ }
+ break;
+ case DestroyNotify:
+ {
+ register XDestroyWindowEvent *ev =
+ (XDestroyWindowEvent *) re;
+ ev->window = event->u.destroyNotify.window;
+ ev->event = event->u.destroyNotify.event;
+ }
+ break;
+ case UnmapNotify:
+ {
+ register XUnmapEvent *ev = (XUnmapEvent *) re;
+ ev->window = event->u.unmapNotify.window;
+ ev->event = event->u.unmapNotify.event;
+ ev->from_configure = event->u.unmapNotify.fromConfigure;
+ }
+ break;
+ case MapNotify:
+ {
+ register XMapEvent *ev = (XMapEvent *) re;
+ ev->window = event->u.mapNotify.window;
+ ev->event = event->u.mapNotify.event;
+ ev->override_redirect = event->u.mapNotify.override;
+ }
+ break;
+ case MapRequest:
+ {
+ register XMapRequestEvent *ev = (XMapRequestEvent *) re;
+ ev->window = event->u.mapRequest.window;
+ ev->parent = event->u.mapRequest.parent;
+ }
+ break;
+ case ReparentNotify:
+ {
+ register XReparentEvent *ev = (XReparentEvent *) re;
+ ev->event = event->u.reparent.event;
+ ev->window = event->u.reparent.window;
+ ev->parent = event->u.reparent.parent;
+ ev->x = cvtINT16toInt(event->u.reparent.x);
+ ev->y = cvtINT16toInt(event->u.reparent.y);
+ ev->override_redirect = event->u.reparent.override;
+ }
+ break;
+ case ConfigureNotify:
+ {
+ register XConfigureEvent *ev = (XConfigureEvent *) re;
+ ev->event = event->u.configureNotify.event;
+ ev->window = event->u.configureNotify.window;
+ ev->above = event->u.configureNotify.aboveSibling;
+ ev->x = cvtINT16toInt(event->u.configureNotify.x);
+ ev->y = cvtINT16toInt(event->u.configureNotify.y);
+ ev->width = event->u.configureNotify.width;
+ ev->height = event->u.configureNotify.height;
+ ev->border_width = event->u.configureNotify.borderWidth;
+ ev->override_redirect = event->u.configureNotify.override;
+ }
+ break;
+ case ConfigureRequest:
+ {
+ register XConfigureRequestEvent *ev =
+ (XConfigureRequestEvent *) re;
+ ev->window = event->u.configureRequest.window;
+ ev->parent = event->u.configureRequest.parent;
+ ev->above = event->u.configureRequest.sibling;
+ ev->x = cvtINT16toInt(event->u.configureRequest.x);
+ ev->y = cvtINT16toInt(event->u.configureRequest.y);
+ ev->width = event->u.configureRequest.width;
+ ev->height = event->u.configureRequest.height;
+ ev->border_width = event->u.configureRequest.borderWidth;
+ ev->value_mask = event->u.configureRequest.valueMask;
+ ev->detail = event->u.u.detail;
+ }
+ break;
+ case GravityNotify:
+ {
+ register XGravityEvent *ev = (XGravityEvent *) re;
+ ev->window = event->u.gravity.window;
+ ev->event = event->u.gravity.event;
+ ev->x = cvtINT16toInt(event->u.gravity.x);
+ ev->y = cvtINT16toInt(event->u.gravity.y);
+ }
+ break;
+ case ResizeRequest:
+ {
+ register XResizeRequestEvent *ev =
+ (XResizeRequestEvent *) re;
+ ev->window = event->u.resizeRequest.window;
+ ev->width = event->u.resizeRequest.width;
+ ev->height = event->u.resizeRequest.height;
+ }
+ break;
+ case CirculateNotify:
+ {
+ register XCirculateEvent *ev = (XCirculateEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->event = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case CirculateRequest:
+ {
+ register XCirculateRequestEvent *ev =
+ (XCirculateRequestEvent *) re;
+ ev->window = event->u.circulate.window;
+ ev->parent = event->u.circulate.event;
+ ev->place = event->u.circulate.place;
+ }
+ break;
+ case PropertyNotify:
+ {
+ register XPropertyEvent *ev = (XPropertyEvent *) re;
+ ev->window = event->u.property.window;
+ ev->atom = event->u.property.atom;
+ ev->time = event->u.property.time;
+ ev->state = event->u.property.state;
+ }
+ break;
+ case SelectionClear:
+ {
+ register XSelectionClearEvent *ev =
+ (XSelectionClearEvent *) re;
+ ev->window = event->u.selectionClear.window;
+ ev->selection = event->u.selectionClear.atom;
+ ev->time = event->u.selectionClear.time;
+ }
+ break;
+ case SelectionRequest:
+ {
+ register XSelectionRequestEvent *ev =
+ (XSelectionRequestEvent *) re;
+ ev->owner = event->u.selectionRequest.owner;
+ ev->requestor = event->u.selectionRequest.requestor;
+ ev->selection = event->u.selectionRequest.selection;
+ ev->target = event->u.selectionRequest.target;
+ ev->property = event->u.selectionRequest.property;
+ ev->time = event->u.selectionRequest.time;
+ }
+ break;
+ case SelectionNotify:
+ {
+ register XSelectionEvent *ev = (XSelectionEvent *) re;
+ ev->requestor = event->u.selectionNotify.requestor;
+ ev->selection = event->u.selectionNotify.selection;
+ ev->target = event->u.selectionNotify.target;
+ ev->property = event->u.selectionNotify.property;
+ ev->time = event->u.selectionNotify.time;
+ }
+ break;
+ case ColormapNotify:
+ {
+ register XColormapEvent *ev = (XColormapEvent *) re;
+ ev->window = event->u.colormap.window;
+ ev->colormap = event->u.colormap.colormap;
+ ev->new = event->u.colormap.new;
+ ev->state = event->u.colormap.state;
+ }
+ break;
+ case ClientMessage:
+ {
+ register int i;
+ register XClientMessageEvent *ev
+ = (XClientMessageEvent *) re;
+ ev->window = event->u.clientMessage.window;
+ ev->format = event->u.u.detail;
+ switch (ev->format) {
+ case 8:
+ ev->message_type = event->u.clientMessage.u.b.type;
+ for (i = 0; i < 20; i++)
+ ev->data.b[i] = event->u.clientMessage.u.b.bytes[i];
+ break;
+ case 16:
+ ev->message_type = event->u.clientMessage.u.s.type;
+ ev->data.s[0] = cvtINT16toShort(event->u.clientMessage.u.s.shorts0);
+ ev->data.s[1] = cvtINT16toShort(event->u.clientMessage.u.s.shorts1);
+ ev->data.s[2] = cvtINT16toShort(event->u.clientMessage.u.s.shorts2);
+ ev->data.s[3] = cvtINT16toShort(event->u.clientMessage.u.s.shorts3);
+ ev->data.s[4] = cvtINT16toShort(event->u.clientMessage.u.s.shorts4);
+ ev->data.s[5] = cvtINT16toShort(event->u.clientMessage.u.s.shorts5);
+ ev->data.s[6] = cvtINT16toShort(event->u.clientMessage.u.s.shorts6);
+ ev->data.s[7] = cvtINT16toShort(event->u.clientMessage.u.s.shorts7);
+ ev->data.s[8] = cvtINT16toShort(event->u.clientMessage.u.s.shorts8);
+ ev->data.s[9] = cvtINT16toShort(event->u.clientMessage.u.s.shorts9);
+ break;
+ case 32:
+ ev->message_type = event->u.clientMessage.u.l.type;
+ ev->data.l[0] = cvtINT32toLong(event->u.clientMessage.u.l.longs0);
+ ev->data.l[1] = cvtINT32toLong(event->u.clientMessage.u.l.longs1);
+ ev->data.l[2] = cvtINT32toLong(event->u.clientMessage.u.l.longs2);
+ ev->data.l[3] = cvtINT32toLong(event->u.clientMessage.u.l.longs3);
+ ev->data.l[4] = cvtINT32toLong(event->u.clientMessage.u.l.longs4);
+ break;
+ default: /* XXX should never occur */
+ break;
+ }
+ }
+ break;
+ case MappingNotify:
+ {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->window = 0;
+ ev->first_keycode = event->u.mappingNotify.firstKeyCode;
+ ev->request = event->u.mappingNotify.request;
+ ev->count = event->u.mappingNotify.count;
+ }
+ break;
+ default:
+ return(_XUnknownWireEvent(dpy, re, event));
+ }
+ return(True);
+}
+
+
+#ifndef USL_SHARELIB
+
+static char *_SysErrorMsg (n)
+ int n;
+{
+ char *s = strerror(n);
+
+ return (s ? s : "no such error");
+}
+
+#endif /* USL sharedlibs in don't define for SVR3.2 */
+
+
+/*
+ * _XDefaultIOError - Default fatal system error reporting routine. Called
+ * when an X internal system error is encountered.
+ */
+void _XDefaultIOError (dpy)
+ Display *dpy;
+{
+ if (ECHECK(EPIPE)) {
+ (void) fprintf (stderr,
+ "X connection to %s broken (explicit kill or server shutdown).\r\n",
+ DisplayString (dpy));
+ } else {
+ (void) fprintf (stderr,
+ "XIO: fatal IO error %d (%s) on X server \"%s\"\r\n",
+#ifdef WIN32
+ WSAGetLastError(), strerror(WSAGetLastError()),
+#else
+ errno, _SysErrorMsg (errno),
+#endif
+ DisplayString (dpy));
+ (void) fprintf (stderr,
+ " after %lu requests (%lu known processed) with %d events remaining.\r\n",
+ NextRequest(dpy) - 1, LastKnownRequestProcessed(dpy),
+ QLength(dpy));
+
+ }
+ exit(1);
+}
+
+
+static int _XPrintDefaultError (dpy, event, fp)
+ Display *dpy;
+ XErrorEvent *event;
+ FILE *fp;
+{
+ char buffer[BUFSIZ];
+ char mesg[BUFSIZ];
+ char number[32];
+ char *mtype = "XlibMessage";
+ register _XExtension *ext = (_XExtension *)NULL;
+ _XExtension *bext = (_XExtension *)NULL;
+ XGetErrorText(dpy, event->error_code, buffer, BUFSIZ);
+ XGetErrorDatabaseText(dpy, mtype, "XError", "X Error", mesg, BUFSIZ);
+ (void) fprintf(fp, "%s: %s\n ", mesg, buffer);
+ XGetErrorDatabaseText(dpy, mtype, "MajorCode", "Request Major code %d",
+ mesg, BUFSIZ);
+ (void) fprintf(fp, mesg, event->request_code);
+ if (event->request_code < 128) {
+ sprintf(number, "%d", event->request_code);
+ XGetErrorDatabaseText(dpy, "XRequest", number, "", buffer, BUFSIZ);
+ } else {
+ for (ext = dpy->ext_procs;
+ ext && (ext->codes.major_opcode != event->request_code);
+ ext = ext->next)
+ ;
+ if (ext)
+ strcpy(buffer, ext->name);
+ else
+ buffer[0] = '\0';
+ }
+ (void) fprintf(fp, " (%s)\n", buffer);
+ if (event->request_code >= 128) {
+ XGetErrorDatabaseText(dpy, mtype, "MinorCode", "Request Minor code %d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->minor_code);
+ if (ext) {
+ sprintf(mesg, "%s.%d", ext->name, event->minor_code);
+ XGetErrorDatabaseText(dpy, "XRequest", mesg, "", buffer, BUFSIZ);
+ (void) fprintf(fp, " (%s)", buffer);
+ }
+ fputs("\n", fp);
+ }
+ if (event->error_code >= 128) {
+ /* kludge, try to find the extension that caused it */
+ buffer[0] = '\0';
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_string)
+ (*ext->error_string)(dpy, event->error_code, &ext->codes,
+ buffer, BUFSIZ);
+ if (buffer[0]) {
+ bext = ext;
+ break;
+ }
+ if (ext->codes.first_error &&
+ ext->codes.first_error < (int)event->error_code &&
+ (!bext || ext->codes.first_error > bext->codes.first_error))
+ bext = ext;
+ }
+ if (bext)
+ sprintf(buffer, "%s.%d", bext->name,
+ event->error_code - bext->codes.first_error);
+ else
+ strcpy(buffer, "Value");
+ XGetErrorDatabaseText(dpy, mtype, buffer, "", mesg, BUFSIZ);
+ if (mesg[0]) {
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ /* let extensions try to print the values */
+ for (ext = dpy->ext_procs; ext; ext = ext->next) {
+ if (ext->error_values)
+ (*ext->error_values)(dpy, event, fp);
+ }
+ } else if ((event->error_code == BadWindow) ||
+ (event->error_code == BadPixmap) ||
+ (event->error_code == BadCursor) ||
+ (event->error_code == BadFont) ||
+ (event->error_code == BadDrawable) ||
+ (event->error_code == BadColor) ||
+ (event->error_code == BadGC) ||
+ (event->error_code == BadIDChoice) ||
+ (event->error_code == BadValue) ||
+ (event->error_code == BadAtom)) {
+ if (event->error_code == BadValue)
+ XGetErrorDatabaseText(dpy, mtype, "Value", "Value 0x%x",
+ mesg, BUFSIZ);
+ else if (event->error_code == BadAtom)
+ XGetErrorDatabaseText(dpy, mtype, "AtomID", "AtomID 0x%x",
+ mesg, BUFSIZ);
+ else
+ XGetErrorDatabaseText(dpy, mtype, "ResourceID", "ResourceID 0x%x",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->resourceid);
+ fputs("\n", fp);
+ }
+ XGetErrorDatabaseText(dpy, mtype, "ErrorSerial", "Error Serial #%d",
+ mesg, BUFSIZ);
+ fputs(" ", fp);
+ (void) fprintf(fp, mesg, event->serial);
+ XGetErrorDatabaseText(dpy, mtype, "CurrentSerial", "Current Serial #%d",
+ mesg, BUFSIZ);
+ fputs("\n ", fp);
+ (void) fprintf(fp, mesg, dpy->request);
+ fputs("\n", fp);
+ if (event->error_code == BadImplementation) return 0;
+ return 1;
+}
+
+int _XDefaultError(dpy, event)
+ Display *dpy;
+ XErrorEvent *event;
+{
+ if (_XPrintDefaultError (dpy, event, stderr) == 0) return 0;
+ exit(1);
+ /*NOTREACHED*/
+}
+
+/*ARGSUSED*/
+Bool _XDefaultWireError(display, he, we)
+ Display *display;
+ XErrorEvent *he;
+ xError *we;
+{
+ return True;
+}
+
+/*
+ * _XError - upcall internal or user protocol error handler
+ */
+int _XError (dpy, rep)
+ Display *dpy;
+ register xError *rep;
+{
+ /*
+ * X_Error packet encountered! We need to unpack the error before
+ * giving it to the user.
+ */
+ XEvent event; /* make it a large event */
+ register _XAsyncHandler *async, *next;
+
+ event.xerror.serial = _XSetLastRequestRead(dpy, (xGenericReply *)rep);
+
+ for (async = dpy->async_handlers; async; async = next) {
+ next = async->next;
+ if ((*async->handler)(dpy, (xReply *)rep,
+ (char *)rep, SIZEOF(xError), async->data))
+ return 0;
+ }
+
+ event.xerror.display = dpy;
+ event.xerror.type = X_Error;
+ event.xerror.resourceid = rep->resourceID;
+ event.xerror.error_code = rep->errorCode;
+ event.xerror.request_code = rep->majorCode;
+ event.xerror.minor_code = rep->minorCode;
+ if (dpy->error_vec &&
+ !(*dpy->error_vec[rep->errorCode])(dpy, &event.xerror, rep))
+ return 0;
+ if (_XErrorFunction != NULL) {
+ int rtn_val;
+#ifdef XTHREADS
+ if (dpy->lock)
+ (*dpy->lock->user_lock_display)(dpy);
+ UnlockDisplay(dpy);
+#endif /* XTHREADS */
+ rtn_val = (*_XErrorFunction)(dpy, (XErrorEvent *)&event); /* upcall */
+#ifdef XTHREADS
+ LockDisplay(dpy);
+ if (dpy->lock)
+ (*dpy->lock->user_unlock_display)(dpy);
+#endif /* XTHREADS */
+ return rtn_val;
+ } else {
+ return _XDefaultError(dpy, (XErrorEvent *)&event);
+ }
+}
+
+/*
+ * _XIOError - call user connection error handler and exit
+ */
+_XIOError (dpy)
+ Display *dpy;
+{
+ dpy->flags |= XlibDisplayIOError;
+#ifdef WIN32
+ errno = WSAGetLastError();
+#endif
+
+ if (_XIOErrorFunction != NULL)
+ (*_XIOErrorFunction)(dpy);
+ else
+ _XDefaultIOError(dpy);
+ exit (1);
+}
+
+
+/*
+ * This routine can be used to (cheaply) get some memory within a single
+ * Xlib routine for scratch space. A single buffer is reused each time
+ * if possible. To be MT safe, you can only call this between a call to
+ * GetReq* and a call to Data* or _XSend*, or in a context when the thread
+ * is guaranteed to not unlock the display.
+ */
+char *_XAllocScratch (dpy, nbytes)
+ register Display *dpy;
+ unsigned long nbytes;
+{
+ if (nbytes > dpy->scratch_length) {
+ if (dpy->scratch_buffer) Xfree (dpy->scratch_buffer);
+ if ((dpy->scratch_buffer = Xmalloc((unsigned) nbytes)))
+ dpy->scratch_length = nbytes;
+ else dpy->scratch_length = 0;
+ }
+ return (dpy->scratch_buffer);
+}
+
+/*
+ * Scratch space allocator you can call any time, multiple times, and be
+ * MT safe, but you must hand the buffer back with _XFreeTemp.
+ */
+char *_XAllocTemp (dpy, nbytes)
+ register Display *dpy;
+ unsigned long nbytes;
+{
+ char *buf;
+
+ buf = _XAllocScratch(dpy, nbytes);
+ dpy->scratch_buffer = NULL;
+ dpy->scratch_length = 0;
+ return buf;
+}
+
+void _XFreeTemp (dpy, buf, nbytes)
+ register Display *dpy;
+ char *buf;
+ unsigned long nbytes;
+{
+ if (dpy->scratch_buffer)
+ Xfree(dpy->scratch_buffer);
+ dpy->scratch_buffer = buf;
+ dpy->scratch_length = nbytes;
+}
+
+/*
+ * Given a visual id, find the visual structure for this id on this display.
+ */
+Visual *_XVIDtoVisual (dpy, id)
+ Display *dpy;
+ VisualID id;
+{
+ register int i, j, k;
+ register Screen *sp;
+ register Depth *dp;
+ register Visual *vp;
+ for (i = 0; i < dpy->nscreens; i++) {
+ sp = &dpy->screens[i];
+ for (j = 0; j < sp->ndepths; j++) {
+ dp = &sp->depths[j];
+ /* if nvisuals == 0 then visuals will be NULL */
+ for (k = 0; k < dp->nvisuals; k++) {
+ vp = &dp->visuals[k];
+ if (vp->visualid == id) return (vp);
+ }
+ }
+ }
+ return (NULL);
+}
+
+#if NeedFunctionPrototypes
+XFree (void *data)
+#else
+XFree (data)
+ char *data;
+#endif
+{
+ Xfree (data);
+ return 1;
+}
+
+#ifdef _XNEEDBCOPYFUNC
+void _Xbcopy(b1, b2, length)
+ register char *b1, *b2;
+ register length;
+{
+ if (b1 < b2) {
+ b2 += length;
+ b1 += length;
+ while (length--)
+ *--b2 = *--b1;
+ } else {
+ while (length--)
+ *b2++ = *b1++;
+ }
+}
+#endif
+
+#ifdef DataRoutineIsProcedure
+void Data (dpy, data, len)
+ Display *dpy;
+ char *data;
+ long len;
+{
+ if (dpy->bufptr + (len) <= dpy->bufmax) {
+ memcpy(dpy->bufptr, data, (int)len);
+ dpy->bufptr += ((len) + 3) & ~3;
+ } else {
+ _XSend(dpy, data, len);
+ }
+}
+#endif /* DataRoutineIsProcedure */
+
+
+#ifdef LONG64
+_XData32 (dpy, data, len)
+ Display *dpy;
+ register long *data;
+ unsigned len;
+{
+ register int *buf;
+ register long i;
+
+ while (len) {
+ buf = (int *)dpy->bufptr;
+ i = dpy->bufmax - (char *)buf;
+ if (!i) {
+ _XFlush(dpy);
+ continue;
+ }
+ if (len < i)
+ i = len;
+ dpy->bufptr = (char *)buf + i;
+ len -= i;
+ i >>= 2;
+ while (--i >= 0)
+ *buf++ = *data++;
+ }
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+
+/*
+ * XXX This is a *really* stupid way of doing this. It should just use
+ * dpy->bufptr directly, taking into account where in the word it is.
+ */
+
+/*
+ * Data16 - Place 16 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData16(dpy, data, len, packbuffer)
+ register Display *dpy;
+ short *data;
+ unsigned len;
+ char *packbuffer;
+{
+ long *lp,*lpack;
+ long i, nwords,bits;
+ long mask16 = 0x000000000000ffff;
+
+ lp = (long *)data;
+ lpack = (long *)packbuffer;
+
+/* nwords is the number of 16 bit values to be packed,
+ * the low order 16 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 1;
+ bits = 48;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 48) *lpack = 0;
+ *lpack ^= (*lp & mask16) << bits;
+ bits -= 16 ;
+ lp++;
+ if(bits < 0){
+ lpack++;
+ bits = 48;
+ }
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData16 (dpy, data, len)
+ Display *dpy;
+ short *data;
+ unsigned len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 1;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData16 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData16 (dpy, data, len, packbuffer);
+}
+
+/*
+ * Data32 - Place 32 bit data in the buffer.
+ *
+ * "dpy" is a pointer to a Display.
+ * "data" is a pointer to the data.
+ * "len" is the length in bytes of the data.
+ */
+
+static doData32 (dpy, data, len, packbuffer)
+ register Display *dpy;
+ long *data;
+ unsigned len;
+ char *packbuffer;
+{
+ long *lp,*lpack;
+ long i,bits,nwords;
+ long mask32 = 0x00000000ffffffff;
+
+ lpack = (long *) packbuffer;
+ lp = data;
+
+/* nwords is the number of 32 bit values to be packed
+ * the low order 32 bits of each word will be packed
+ * into 64 bit words
+ */
+ nwords = len >> 2;
+ bits = 32;
+
+ for(i=0;i<nwords;i++){
+ if (bits == 32) *lpack = 0;
+ *lpack ^= (*lp & mask32) << bits;
+ bits = bits ^32;
+ lp++;
+ if(bits)
+ lpack++;
+ }
+ Data(dpy, packbuffer, len);
+}
+
+_XData32 (dpy, data, len)
+ Display *dpy;
+ long *data;
+ unsigned len;
+{
+ char packbuffer[PACKBUFFERSIZE];
+ unsigned nunits = PACKBUFFERSIZE >> 2;
+
+ for (; len > PACKBUFFERSIZE; len -= PACKBUFFERSIZE, data += nunits) {
+ doData32 (dpy, data, PACKBUFFERSIZE, packbuffer);
+ }
+ if (len) doData32 (dpy, data, len, packbuffer);
+}
+
+#endif /* WORD64 */
+
+
+/* Make sure this produces the same string as DefineLocal/DefineSelf in xdm.
+ * Otherwise, Xau will not be able to find your cookies in the Xauthority file.
+ *
+ * Note: POSIX says that the ``nodename'' member of utsname does _not_ have
+ * to have sufficient information for interfacing to the network,
+ * and so, you may be better off using gethostname (if it exists).
+ */
+
+#if (defined(_POSIX_SOURCE) && !defined(AIXV3)) || defined(hpux) || defined(USG) || defined(SVR4)
+#define NEED_UTSNAME
+#include <sys/utsname.h>
+#endif
+
+/*
+ * _XGetHostname - similar to gethostname but allows special processing.
+ */
+int _XGetHostname (buf, maxlen)
+ char *buf;
+ int maxlen;
+{
+ int len;
+
+#ifdef NEED_UTSNAME
+ struct utsname name;
+
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ uname (&name);
+ len = strlen (name.nodename);
+ if (len >= maxlen) len = maxlen - 1;
+ strncpy (buf, name.nodename, len);
+ buf[len] = '\0';
+#else
+ if (maxlen <= 0 || buf == NULL)
+ return 0;
+
+ buf[0] = '\0';
+ (void) gethostname (buf, maxlen);
+ buf [maxlen - 1] = '\0';
+ len = strlen(buf);
+#endif /* NEED_UTSNAME */
+ return len;
+}
+
+
+/*
+ * _XScreenOfWindow - get the Screen of a given window
+ */
+
+Screen *_XScreenOfWindow (dpy, w)
+ Display *dpy;
+ Window w;
+{
+ register int i;
+ Window root;
+ int x, y; /* dummy variables */
+ unsigned int width, height, bw, depth; /* dummy variables */
+
+ if (XGetGeometry (dpy, w, &root, &x, &y, &width, &height,
+ &bw, &depth) == False) {
+ return None;
+ }
+ for (i = 0; i < ScreenCount (dpy); i++) { /* find root from list */
+ if (root == RootWindow (dpy, i)) {
+ return ScreenOfDisplay (dpy, i);
+ }
+ }
+ return NULL;
+}
+
+
+#if (MSKCNT > 4)
+/*
+ * This is a macro if MSKCNT <= 4
+ */
+_XANYSET(src)
+ long *src;
+{
+ int i;
+
+ for (i=0; i<MSKCNT; i++)
+ if (src[ i ])
+ return (1);
+ return (0);
+}
+#endif
+
+#if defined(WIN32) || defined(__EMX__) /* || defined(OS2) */
+
+/*
+ * These functions are intended to be used internally to Xlib only.
+ * These functions will always prefix the path with a DOS drive in the
+ * form "<drive-letter>:". As such, these functions are only suitable
+ * for use by Xlib function that supply a root-based path to some
+ * particular file, e.g. <ProjectRoot>/lib/X11/locale/locale.dir will
+ * be converted to "C:/usr/X11R6.3/lib/X11/locale/locale.dir".
+ */
+
+static int access_file (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ if (access (path, F_OK) == 0) {
+ if (strlen (path) < len_pathbuf)
+ *pathret = pathbuf;
+ else
+ *pathret = Xmalloc (strlen (path) + 1);
+ if (*pathret) {
+ strcpy (*pathret, path);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static int AccessFile (path, pathbuf, len_pathbuf, pathret)
+ char* path;
+ char* pathbuf;
+ int len_pathbuf;
+ char** pathret;
+{
+ unsigned long drives;
+ int i, len;
+ char* drive;
+ char buf[MAX_PATH];
+ char* bufp;
+
+ /* just try the "raw" name first and see if it works */
+ if (access_file (path, pathbuf, len_pathbuf, pathret))
+ return 1;
+
+ /* try the places set in the environment */
+ drive = getenv ("_XBASEDRIVE");
+#ifdef __EMX__
+ if (!drive)
+ drive = getenv ("X11ROOT");
+#endif
+ if (!drive)
+ drive = "C:";
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+
+#ifndef __EMX__
+ /* one last place to look */
+ drive = getenv ("HOMEDRIVE");
+ if (drive) {
+ len = strlen (drive) + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ strcpy (bufp, drive);
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+
+ /* tried everywhere else, go fishing */
+#define C_DRIVE ('C' - 'A')
+#define Z_DRIVE ('Z' - 'A')
+ /* does OS/2 (with or with gcc-emx) have getdrives? */
+ drives = _getdrives ();
+ for (i = C_DRIVE; i <= Z_DRIVE; i++) { /* don't check on A: or B: */
+ if ((1 << i) & drives) {
+ len = 2 + strlen (path);
+ if (len < MAX_PATH) bufp = buf;
+ else bufp = Xmalloc (len + 1);
+ *bufp = 'A' + i;
+ *(bufp + 1) = ':';
+ *(bufp + 2) = '\0';
+ strcat (bufp, path);
+ if (access_file (bufp, pathbuf, len_pathbuf, pathret)) {
+ if (bufp != buf) Xfree (bufp);
+ return 1;
+ }
+ }
+ }
+#endif
+ return 0;
+}
+
+int _XOpenFile(path, flags)
+ char* path;
+ int flags;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = open (bufp, flags);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+void* _XFopenFile(path, mode)
+ char* path;
+ char* mode;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ void* ret = NULL;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ if (AccessFile (path, buf, MAX_PATH, &bufp))
+ ret = fopen (bufp, mode);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+int _XAccessFile(path)
+ char* path;
+{
+ char buf[MAX_PATH];
+ char* bufp;
+ int ret = -1;
+ UINT olderror = SetErrorMode (SEM_FAILCRITICALERRORS);
+
+ ret = AccessFile (path, buf, MAX_PATH, &bufp);
+
+ (void) SetErrorMode (olderror);
+
+ if (bufp != buf) Xfree (bufp);
+
+ return ret;
+}
+
+#endif
+
diff --git a/src/XomGeneric.h b/src/XomGeneric.h
new file mode 100644
index 00000000..10dea3b3
--- /dev/null
+++ b/src/XomGeneric.h
@@ -0,0 +1,181 @@
+/* $Xorg: XomGeneric.h,v 1.3 2000/08/17 19:45:08 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+
+#ifndef _XOMGENERIC_H_
+#define _XOMGENERIC_H_
+
+#include "XlcPublic.h"
+
+#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
+#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
+
+/* For VW/UDC */
+typedef struct _CodeRangeRec {
+ unsigned long start;
+ unsigned long end;
+ unsigned long dmy1;
+ unsigned long dmy2;
+} CodeRangeRec, *CodeRange;
+
+typedef struct _VRotateRec {
+ char *charset_name; /* Charset name */
+ XlcSide side; /* Encoding side */
+ int num_cr;
+ CodeRange code_range;
+ char *xlfd_name;
+ XFontStruct *font;
+} VRotateRec, *VRotate;
+
+typedef enum {
+ XOMMultiByte,
+ XOMWideChar
+} XOMTextType;
+
+typedef struct _FontDataRec {
+ char *name;
+ XlcSide side;
+ /* For VW/UDC */
+ int scopes_num;
+ FontScope scopes;
+ char *xlfd_name;
+ XFontStruct *font;
+} FontDataRec, *FontData;
+
+#define VROTATE_NONE 0
+#define VROTATE_PART 1
+#define VROTATE_ALL 2
+
+typedef struct _OMDataRec {
+ int charset_count;
+ XlcCharSet *charset_list;
+ int font_data_count;
+ FontData font_data;
+ /* For VW/UDC */
+ int substitute_num;
+ FontData substitute;
+ /* Vertical Writing */
+ int vmap_num;
+ FontData vmap;
+ int vrotate_type;
+ int vrotate_num;
+ CodeRange vrotate;
+} OMDataRec, *OMData;
+
+typedef struct _XOMGenericPart {
+ int data_num;
+ OMData data;
+ Bool on_demand_loading;
+ char *object_name;
+} XOMGenericPart;
+
+typedef struct _XOMGenericRec {
+ XOMMethods methods;
+ XOMCoreRec core;
+ XOMGenericPart gen;
+} XOMGenericRec, *XOMGeneric;
+
+/*
+ * XOC dependent data
+ */
+
+typedef struct _FontSetRec {
+ int id;
+ int charset_count;
+ XlcCharSet *charset_list;
+ int font_data_count;
+ FontData font_data;
+ char *font_name;
+ XFontStruct *info;
+ XFontStruct *font;
+ XlcSide side;
+ Bool is_xchar2b;
+ /* For VW/UDC */
+ int substitute_num;
+ FontData substitute;
+ /* Vertical Writing */
+ int vpart_initialize;
+ int vmap_num;
+ FontData vmap;
+ int vrotate_num;
+ VRotate vrotate;
+} FontSetRec, *FontSet;
+
+typedef struct _XOCGenericPart {
+ XlcConv mbs_to_cs;
+ XlcConv wcs_to_cs;
+ int font_set_num;
+ FontSet font_set;
+} XOCGenericPart;
+
+typedef struct _XOCGenericRec {
+ XOCMethods methods;
+ XOCCoreRec core;
+ XOCGenericPart gen;
+} XOCGenericRec, *XOCGeneric;
+
+_XFUNCPROTOBEGIN
+
+extern XOM _XomGenericOpenOM(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ XrmDatabase /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+#endif
+);
+
+extern XlcConv _XomInitConverter(
+#if NeedFunctionPrototypes
+ XOC /* oc */,
+ XOMTextType /* type */
+#endif
+);
+
+extern int _XomConvert(
+#if NeedFunctionPrototypes
+ XOC /* oc */,
+ XlcConv /* conv */,
+ XPointer* /* from */,
+ int* /* from_left */,
+ XPointer* /* to */,
+ int* /* to_left */,
+ XPointer* /* args */,
+ int /* num_args */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XOMGENERIC_H_ */
diff --git a/src/Xrm.c b/src/Xrm.c
new file mode 100644
index 00000000..022dbe60
--- /dev/null
+++ b/src/Xrm.c
@@ -0,0 +1,2667 @@
+/* $Xorg: Xrm.c,v 1.7 2001/02/09 02:03:39 xorgcvs Exp $ */
+
+/***********************************************************
+Copyright 1987, 1988, 1990 by Digital Equipment Corporation, Maynard
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+/*
+
+Copyright 1987, 1988, 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <stdio.h>
+#include <ctype.h>
+#include "Xlibint.h"
+#include <X11/Xresource.h>
+#include "Xlcint.h"
+#ifdef XTHREADS
+#include "locking.h"
+#endif
+#include "XrmI.h"
+#include <X11/Xos.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+#if defined(__STDC__) && !defined(NORCONST)
+#define RConst const
+#else
+#define RConst /**/
+#endif
+
+/*
+
+These Xrm routines allow very fast lookup of resources in the resource
+database. Several usage patterns are exploited:
+
+(1) Widgets get a lot of resources at one time. Rather than look up each from
+scratch, we can precompute the prioritized list of database levels once, then
+search for each resource starting at the beginning of the list.
+
+(2) Many database levels don't contain any leaf resource nodes. There is no
+point in looking for resources on a level that doesn't contain any. This
+information is kept on a per-level basis.
+
+(3) Sometimes the widget instance tree is structured such that you get the same
+class name repeated on the fully qualified widget name. This can result in the
+same database level occuring multiple times on the search list. The code below
+only checks to see if you get two identical search lists in a row, rather than
+look back through all database levels, but in practice this removes all
+duplicates I've ever observed.
+
+Joel McCormack
+
+*/
+
+/*
+
+The Xrm representation has been completely redesigned to substantially reduce
+memory and hopefully improve performance.
+
+The database is structured into two kinds of tables: LTables that contain
+only values, and NTables that contain only other tables.
+
+Some invariants:
+
+The next pointer of the top-level node table points to the top-level leaf
+table, if any.
+
+Within an LTable, for a given name, the tight value always precedes the
+loose value, and if both are present the loose value is always right after
+the tight value.
+
+Within an NTable, all of the entries for a given name are contiguous,
+in the order tight NTable, loose NTable, tight LTable, loose LTable.
+
+Bob Scheifler
+
+*/
+
+typedef unsigned long Signature;
+
+static XrmQuark XrmQString, XrmQANY;
+
+typedef Bool (*DBEnumProc)(
+#if NeedNestedPrototypes /* this is Nested on purpose, to match Xlib.h */
+ XrmDatabase* /* db */,
+ XrmBindingList /* bindings */,
+ XrmQuarkList /* quarks */,
+ XrmRepresentation* /* type */,
+ XrmValue* /* value */,
+ XPointer /* closure */
+#endif
+);
+
+typedef struct _VEntry {
+ struct _VEntry *next; /* next in chain */
+ XrmQuark name; /* name of this entry */
+ unsigned int tight:1; /* 1 if it is a tight binding */
+ unsigned int string:1; /* 1 if type is String */
+ unsigned int size:30; /* size of value */
+} VEntryRec, *VEntry;
+
+
+typedef struct _DEntry {
+ VEntryRec entry; /* entry */
+ XrmRepresentation type; /* representation type */
+} DEntryRec, *DEntry;
+
+/* the value is right after the structure */
+#define StringValue(ve) (XPointer)((ve) + 1)
+#define RepType(ve) ((DEntry)(ve))->type
+/* the value is right after the structure */
+#define DataValue(ve) (XPointer)(((DEntry)(ve)) + 1)
+#define RawValue(ve) (char *)((ve)->string ? StringValue(ve) : DataValue(ve))
+
+typedef struct _NTable {
+ struct _NTable *next; /* next in chain */
+ XrmQuark name; /* name of this entry */
+ unsigned int tight:1; /* 1 if it is a tight binding */
+ unsigned int leaf:1; /* 1 if children are values */
+ unsigned int hasloose:1; /* 1 if has loose children */
+ unsigned int hasany:1; /* 1 if has ANY entry */
+ unsigned int pad:4; /* unused */
+ unsigned int mask:8; /* hash size - 1 */
+ unsigned int entries:16; /* number of children */
+} NTableRec, *NTable;
+
+/* the buckets are right after the structure */
+#define NodeBuckets(ne) ((NTable *)((ne) + 1))
+#define NodeHash(ne,q) NodeBuckets(ne)[(q) & (ne)->mask]
+
+/* leaf tables have an extra level of indirection for the buckets,
+ * so that resizing can be done without invalidating a search list.
+ * This is completely ugly, and wastes some memory, but the Xlib
+ * spec doesn't really specify whether invalidation is OK, and the
+ * old implementation did not invalidate.
+ */
+typedef struct _LTable {
+ NTableRec table;
+ VEntry *buckets;
+} LTableRec, *LTable;
+
+#define LeafHash(le,q) (le)->buckets[(q) & (le)->table.mask]
+
+/* An XrmDatabase just holds a pointer to the first top-level table.
+ * The type name is no longer descriptive, but better to not change
+ * the Xresource.h header file. This type also gets used to define
+ * XrmSearchList, which is a complete crock, but we'll just leave it
+ * and caste types as required.
+ */
+typedef struct _XrmHashBucketRec {
+ NTable table;
+ XPointer mbstate;
+ XrmMethods methods;
+#ifdef XTHREADS
+ LockInfoRec linfo;
+#endif
+} XrmHashBucketRec;
+
+/* closure used in get/put resource */
+typedef struct _VClosure {
+ XrmRepresentation *type; /* type of value */
+ XrmValuePtr value; /* value itself */
+} VClosureRec, *VClosure;
+
+/* closure used in get search list */
+typedef struct _SClosure {
+ LTable *list; /* search list */
+ int idx; /* index of last filled element */
+ int limit; /* maximum index */
+} SClosureRec, *SClosure;
+
+/* placed in XrmSearchList to indicate next table is loose only */
+#define LOOSESEARCH ((LTable)1)
+
+/* closure used in enumerate database */
+typedef struct _EClosure {
+ XrmDatabase db; /* the database */
+ DBEnumProc proc; /* the user proc */
+ XPointer closure; /* the user closure */
+ XrmBindingList bindings; /* binding list */
+ XrmQuarkList quarks; /* quark list */
+ int mode; /* XrmEnum<kind> */
+} EClosureRec, *EClosure;
+
+/* predicate to determine when to resize a hash table */
+#define GrowthPred(n,m) ((unsigned)(n) > (((m) + 1) << 2))
+
+#define GROW(prev) \
+ if (GrowthPred((*prev)->entries, (*prev)->mask)) \
+ GrowTable(prev)
+
+/* pick a reasonable value for maximum depth of resource database */
+#define MAXDBDEPTH 100
+
+/* macro used in get/search functions */
+
+/* find an entry named ename, with leafness given by leaf */
+#define NFIND(ename) \
+ q = ename; \
+ entry = NodeHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (leaf && entry && !entry->leaf) { \
+ entry = entry->next; \
+ if (entry && !entry->leaf) \
+ entry = entry->next; \
+ if (entry && entry->name != q) \
+ entry = (NTable)NULL; \
+ }
+
+/* resourceQuarks keeps track of what quarks have been associated with values
+ * in all LTables. If a quark has never been used in an LTable, we don't need
+ * to bother looking for it.
+ */
+
+static unsigned char *resourceQuarks = (unsigned char *)NULL;
+static XrmQuark maxResourceQuark = -1;
+
+/* determines if a quark has been used for a value in any database */
+#define IsResourceQuark(q) ((q) > 0 && (q) <= maxResourceQuark && \
+ resourceQuarks[(q) >> 3] & (1 << ((q) & 7)))
+
+typedef unsigned char XrmBits;
+
+#define BSLASH ((XrmBits) (1 << 5))
+#define NORMAL ((XrmBits) (1 << 4))
+#define EOQ ((XrmBits) (1 << 3))
+#define SEP ((XrmBits) (1 << 2))
+#define ENDOF ((XrmBits) (1 << 1))
+#define SPACE (NORMAL|EOQ|SEP|(XrmBits)0)
+#define RSEP (NORMAL|EOQ|SEP|(XrmBits)1)
+#define EOS (EOQ|SEP|ENDOF|(XrmBits)0)
+#define EOL (EOQ|SEP|ENDOF|(XrmBits)1)
+#define BINDING (NORMAL|EOQ)
+#define ODIGIT (NORMAL|(XrmBits)1)
+
+#define next_char(ch,str) xrmtypes[(unsigned char)((ch) = *(++(str)))]
+#define next_mbchar(ch,len,str) xrmtypes[(unsigned char)(ch = (*db->methods->mbchar)(db->mbstate, str, &len), str += len, ch)]
+
+#define is_space(bits) ((bits) == SPACE)
+#define is_EOQ(bits) ((bits) & EOQ)
+#define is_EOF(bits) ((bits) == EOS)
+#define is_EOL(bits) ((bits) & ENDOF)
+#define is_binding(bits) ((bits) == BINDING)
+#define is_odigit(bits) ((bits) == ODIGIT)
+#define is_separator(bits) ((bits) & SEP)
+#define is_nonpcs(bits) (!(bits))
+#define is_normal(bits) ((bits) & NORMAL)
+#define is_simple(bits) ((bits) & (NORMAL|BSLASH))
+#define is_special(bits) ((bits) & (ENDOF|BSLASH))
+
+/* parsing types */
+static XrmBits Const xrmtypes[256] = {
+ EOS,0,0,0,0,0,0,0,
+ 0,SPACE,EOL,0,0,
+#if defined(WIN32) || defined(__EMX__) /* || defined(OS2) */
+ EOL, /* treat CR the same as LF, just in case */
+#else
+ 0,
+#endif
+ 0,0,
+ 0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,
+ SPACE,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,BINDING,NORMAL,NORMAL,NORMAL,BINDING,NORMAL,
+ ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,ODIGIT,
+ NORMAL,NORMAL,RSEP,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,BSLASH,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,
+ NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,NORMAL,0
+ /* The rest will be automatically initialized to zero. */
+};
+
+void XrmInitialize()
+{
+ XrmQString = XrmPermStringToQuark("String");
+ XrmQANY = XrmPermStringToQuark("?");
+}
+
+XrmDatabase XrmGetDatabase(display)
+ Display *display;
+{
+ XrmDatabase retval;
+ LockDisplay(display);
+ retval = display->db;
+ UnlockDisplay(display);
+ return retval;
+}
+
+void XrmSetDatabase(display, database)
+ Display *display;
+ XrmDatabase database;
+{
+ LockDisplay(display);
+ display->db = database;
+ UnlockDisplay(display);
+}
+
+#if NeedFunctionPrototypes
+void XrmStringToQuarkList(
+ register _Xconst char *name,
+ register XrmQuarkList quarks) /* RETURN */
+#else
+void XrmStringToQuarkList(name, quarks)
+ register char *name;
+ register XrmQuarkList quarks; /* RETURN */
+#endif
+{
+ register XrmBits bits;
+ register Signature sig = 0;
+ register char ch, *tname;
+ register int i = 0;
+
+ if ((tname = (char *)name)) {
+ tname--;
+ while (!is_EOF(bits = next_char(ch, tname))) {
+ if (is_binding (bits)) {
+ if (i) {
+ /* Found a complete name */
+ *quarks++ = _XrmInternalStringToQuark(name,tname - name,
+ sig, False);
+ i = 0;
+ sig = 0;
+ }
+ name = tname+1;
+ }
+ else {
+ sig = (sig << 1) + ch; /* Compute the signature. */
+ i++;
+ }
+ }
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name, sig, False);
+ }
+ *quarks = NULLQUARK;
+}
+
+#if NeedFunctionPrototypes
+void XrmStringToBindingQuarkList(
+ register _Xconst char *name,
+ register XrmBindingList bindings, /* RETURN */
+ register XrmQuarkList quarks) /* RETURN */
+#else
+void XrmStringToBindingQuarkList(name, bindings, quarks)
+ register char *name;
+ register XrmBindingList bindings; /* RETURN */
+ register XrmQuarkList quarks; /* RETURN */
+#endif
+{
+ register XrmBits bits;
+ register Signature sig = 0;
+ register char ch, *tname;
+ register XrmBinding binding;
+ register int i = 0;
+
+ if ((tname = (char *)name)) {
+ tname--;
+ binding = XrmBindTightly;
+ while (!is_EOF(bits = next_char(ch, tname))) {
+ if (is_binding (bits)) {
+ if (i) {
+ /* Found a complete name */
+ *bindings++ = binding;
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name,
+ sig, False);
+
+ i = 0;
+ sig = 0;
+ binding = XrmBindTightly;
+ }
+ name = tname+1;
+
+ if (ch == '*')
+ binding = XrmBindLoosely;
+ }
+ else {
+ sig = (sig << 1) + ch; /* Compute the signature. */
+ i++;
+ }
+ }
+ *bindings = binding;
+ *quarks++ = _XrmInternalStringToQuark(name, tname - name, sig, False);
+ }
+ *quarks = NULLQUARK;
+}
+
+#ifdef DEBUG
+
+static void PrintQuarkList(quarks, stream)
+ XrmQuarkList quarks;
+ FILE *stream;
+{
+ Bool firstNameSeen;
+
+ for (firstNameSeen = False; *quarks; quarks++) {
+ if (firstNameSeen) {
+ (void) fprintf(stream, ".");
+ }
+ firstNameSeen = True;
+ (void) fputs(XrmQuarkToString(*quarks), stream);
+ }
+} /* PrintQuarkList */
+
+#endif /* DEBUG */
+
+/*ARGSUSED*/
+static void mbnoop(state)
+ XPointer state;
+{
+}
+
+/*ARGSUSED*/
+static char mbchar(state, str, lenp)
+ XPointer state;
+ char *str;
+ int *lenp;
+{
+ *lenp = 1;
+ return *str;
+}
+
+/*ARGSUSED*/
+static char *lcname(state)
+ XPointer state;
+{
+ return "C";
+}
+
+static RConst XrmMethodsRec mb_methods = {
+ mbnoop,
+ mbchar,
+ mbnoop,
+ lcname,
+ mbnoop
+};
+
+static XrmDatabase NewDatabase()
+{
+ register XrmDatabase db;
+
+ db = (XrmDatabase) Xmalloc(sizeof(XrmHashBucketRec));
+ if (db) {
+ _XCreateMutex(&db->linfo);
+ db->table = (NTable)NULL;
+ db->mbstate = (XPointer)NULL;
+ db->methods = _XrmInitParseInfo(&db->mbstate);
+ if (!db->methods)
+ db->methods = (XrmMethods)&mb_methods;
+ }
+ return db;
+}
+
+/* move all values from ftable to ttable, and free ftable's buckets.
+ * ttable is quaranteed empty to start with.
+ */
+static void MoveValues(ftable, ttable)
+ LTable ftable;
+ register LTable ttable;
+{
+ register VEntry fentry, nfentry;
+ register VEntry *prev;
+ register VEntry *bucket;
+ register VEntry tentry;
+ register int i;
+
+ for (i = ftable->table.mask, bucket = ftable->buckets; i >= 0; i--) {
+ for (fentry = *bucket++; fentry; fentry = nfentry) {
+ prev = &LeafHash(ttable, fentry->name);
+ tentry = *prev;
+ *prev = fentry;
+ /* chain on all with same name, to preserve invariant order */
+ while ((nfentry = fentry->next) && nfentry->name == fentry->name)
+ fentry = nfentry;
+ fentry->next = tentry;
+ }
+ }
+ Xfree((char *)ftable->buckets);
+}
+
+/* move all tables from ftable to ttable, and free ftable.
+ * ttable is quaranteed empty to start with.
+ */
+static void MoveTables(ftable, ttable)
+ NTable ftable;
+ register NTable ttable;
+{
+ register NTable fentry, nfentry;
+ register NTable *prev;
+ register NTable *bucket;
+ register NTable tentry;
+ register int i;
+
+ for (i = ftable->mask, bucket = NodeBuckets(ftable); i >= 0; i--) {
+ for (fentry = *bucket++; fentry; fentry = nfentry) {
+ prev = &NodeHash(ttable, fentry->name);
+ tentry = *prev;
+ *prev = fentry;
+ /* chain on all with same name, to preserve invariant order */
+ while ((nfentry = fentry->next) && nfentry->name == fentry->name)
+ fentry = nfentry;
+ fentry->next = tentry;
+ }
+ }
+ Xfree((char *)ftable);
+}
+
+/* grow the table, based on current number of entries */
+static void GrowTable(prev)
+ NTable *prev;
+{
+ register NTable table;
+ register int i;
+
+ table = *prev;
+ i = table->mask;
+ if (i == 255) /* biggest it gets */
+ return;
+ while (i < 255 && GrowthPred(table->entries, i))
+ i = (i << 1) + 1;
+ i++; /* i is now the new size */
+ if (table->leaf) {
+ register LTable ltable;
+ LTableRec otable;
+
+ ltable = (LTable)table;
+ /* cons up a copy to make MoveValues look symmetric */
+ otable = *ltable;
+ ltable->buckets = (VEntry *)Xmalloc(i * sizeof(VEntry));
+ if (!ltable->buckets) {
+ ltable->buckets = otable.buckets;
+ return;
+ }
+ ltable->table.mask = i - 1;
+ bzero((char *)ltable->buckets, i * sizeof(VEntry));
+ MoveValues(&otable, ltable);
+ } else {
+ register NTable ntable;
+
+ ntable = (NTable)Xmalloc(sizeof(NTableRec) + i * sizeof(NTable));
+ if (!ntable)
+ return;
+ *ntable = *table;
+ ntable->mask = i - 1;
+ bzero((char *)NodeBuckets(ntable), i * sizeof(NTable));
+ *prev = ntable;
+ MoveTables(table, ntable);
+ }
+}
+
+/* merge values from ftable into *pprev, destroy ftable in the process */
+static void MergeValues(ftable, pprev, override)
+ LTable ftable;
+ NTable *pprev;
+ Bool override;
+{
+ register VEntry fentry, tentry;
+ register VEntry *prev;
+ register LTable ttable;
+ VEntry *bucket;
+ int i;
+ register XrmQuark q;
+
+ ttable = (LTable)*pprev;
+ if (ftable->table.hasloose)
+ ttable->table.hasloose = 1;
+ for (i = ftable->table.mask, bucket = ftable->buckets;
+ i >= 0;
+ i--, bucket++) {
+ for (fentry = *bucket; fentry; ) {
+ q = fentry->name;
+ prev = &LeafHash(ttable, q);
+ tentry = *prev;
+ while (tentry && tentry->name != q)
+ tentry = *(prev = &tentry->next);
+ /* note: test intentionally uses fentry->name instead of q */
+ /* permits serendipitous inserts */
+ while (tentry && tentry->name == fentry->name) {
+ /* if tentry is earlier, skip it */
+ if (!fentry->tight && tentry->tight) {
+ tentry = *(prev = &tentry->next);
+ continue;
+ }
+ if (fentry->tight != tentry->tight) {
+ /* no match, chain in fentry */
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->table.entries++;
+ } else if (override) {
+ /* match, chain in fentry, splice out and free tentry */
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry->next;
+ /* free the overridden entry */
+ Xfree((char *)tentry);
+ /* get next tentry */
+ tentry = *prev;
+ } else {
+ /* match, discard fentry */
+ prev = &tentry->next;
+ tentry = fentry; /* use as a temp var */
+ fentry = fentry->next;
+ /* free the overpowered entry */
+ Xfree((char *)tentry);
+ /* get next tentry */
+ tentry = *prev;
+ }
+ if (!fentry)
+ break;
+ }
+ /* at this point, tentry cannot match any fentry named q */
+ /* chain in all bindings together, preserve invariant order */
+ while (fentry && fentry->name == q) {
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->table.entries++;
+ }
+ }
+ }
+ Xfree((char *)ftable->buckets);
+ Xfree((char *)ftable);
+ /* resize if necessary, now that we're all done */
+ GROW(pprev);
+}
+
+/* merge tables from ftable into *pprev, destroy ftable in the process */
+static void MergeTables(ftable, pprev, override)
+ NTable ftable;
+ NTable *pprev;
+ Bool override;
+{
+ register NTable fentry, tentry;
+ NTable nfentry;
+ register NTable *prev;
+ register NTable ttable;
+ NTable *bucket;
+ int i;
+ register XrmQuark q;
+
+ ttable = *pprev;
+ if (ftable->hasloose)
+ ttable->hasloose = 1;
+ if (ftable->hasany)
+ ttable->hasany = 1;
+ for (i = ftable->mask, bucket = NodeBuckets(ftable);
+ i >= 0;
+ i--, bucket++) {
+ for (fentry = *bucket; fentry; ) {
+ q = fentry->name;
+ prev = &NodeHash(ttable, q);
+ tentry = *prev;
+ while (tentry && tentry->name != q)
+ tentry = *(prev = &tentry->next);
+ /* note: test intentionally uses fentry->name instead of q */
+ /* permits serendipitous inserts */
+ while (tentry && tentry->name == fentry->name) {
+ /* if tentry is earlier, skip it */
+ if ((fentry->leaf && !tentry->leaf) ||
+ (!fentry->tight && tentry->tight &&
+ (fentry->leaf || !tentry->leaf))) {
+ tentry = *(prev = &tentry->next);
+ continue;
+ }
+ nfentry = fentry->next;
+ if (fentry->leaf != tentry->leaf ||
+ fentry->tight != tentry->tight) {
+ /* no match, just chain in */
+ *prev = fentry;
+ *(prev = &fentry->next) = tentry;
+ ttable->entries++;
+ } else {
+ if (fentry->leaf)
+ MergeValues((LTable)fentry, prev, override);
+ else
+ MergeTables(fentry, prev, override);
+ /* bump to next tentry */
+ tentry = *(prev = &(*prev)->next);
+ }
+ /* bump to next fentry */
+ fentry = nfentry;
+ if (!fentry)
+ break;
+ }
+ /* at this point, tentry cannot match any fentry named q */
+ /* chain in all bindings together, preserve invariant order */
+ while (fentry && fentry->name == q) {
+ *prev = fentry;
+ prev = &fentry->next;
+ fentry = *prev;
+ *prev = tentry;
+ ttable->entries++;
+ }
+ }
+ }
+ Xfree((char *)ftable);
+ /* resize if necessary, now that we're all done */
+ GROW(pprev);
+}
+
+void XrmCombineDatabase(from, into, override)
+ XrmDatabase from, *into;
+ Bool override;
+{
+ register NTable *prev;
+ register NTable ftable, ttable, nftable;
+
+ if (!*into) {
+ *into = from;
+ } else if (from) {
+ _XLockMutex(&from->linfo);
+ _XLockMutex(&(*into)->linfo);
+ if ((ftable = from->table)) {
+ prev = &(*into)->table;
+ ttable = *prev;
+ if (!ftable->leaf) {
+ nftable = ftable->next;
+ if (ttable && !ttable->leaf) {
+ /* both have node tables, merge them */
+ MergeTables(ftable, prev, override);
+ /* bump to into's leaf table, if any */
+ ttable = *(prev = &(*prev)->next);
+ } else {
+ /* into has no node table, link from's in */
+ *prev = ftable;
+ *(prev = &ftable->next) = ttable;
+ }
+ /* bump to from's leaf table, if any */
+ ftable = nftable;
+ } else {
+ /* bump to into's leaf table, if any */
+ if (ttable && !ttable->leaf)
+ ttable = *(prev = &ttable->next);
+ }
+ if (ftable) {
+ /* if into has a leaf, merge, else insert */
+ if (ttable)
+ MergeValues((LTable)ftable, prev, override);
+ else
+ *prev = ftable;
+ }
+ }
+ (from->methods->destroy)(from->mbstate);
+ _XFreeMutex(&from->linfo);
+ Xfree((char *)from);
+ _XUnlockMutex(&(*into)->linfo);
+ }
+}
+
+void XrmMergeDatabases(from, into)
+ XrmDatabase from, *into;
+{
+ XrmCombineDatabase(from, into, True);
+}
+
+/* store a value in the database, overriding any existing entry */
+static void PutEntry(db, bindings, quarks, type, value)
+ XrmDatabase db;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ XrmRepresentation type;
+ XrmValuePtr value;
+{
+ register NTable *pprev, *prev;
+ register NTable table;
+ register XrmQuark q;
+ register VEntry *vprev;
+ register VEntry entry;
+ NTable *nprev, *firstpprev;
+
+#define NEWTABLE(q,i) \
+ table = (NTable)Xmalloc(sizeof(LTableRec)); \
+ if (!table) \
+ return; \
+ table->name = q; \
+ table->hasloose = 0; \
+ table->hasany = 0; \
+ table->mask = 0; \
+ table->entries = 0; \
+ if (quarks[i]) { \
+ table->leaf = 0; \
+ nprev = NodeBuckets(table); \
+ } else { \
+ table->leaf = 1; \
+ if (!(nprev = (NTable *)Xmalloc(sizeof(VEntry *)))) \
+ return; \
+ ((LTable)table)->buckets = (VEntry *)nprev; \
+ } \
+ *nprev = (NTable)NULL; \
+ table->next = *prev; \
+ *prev = table
+
+ if (!db || !*quarks)
+ return;
+ table = *(prev = &db->table);
+ /* if already at leaf, bump to the leaf table */
+ if (!quarks[1] && table && !table->leaf)
+ table = *(prev = &table->next);
+ pprev = prev;
+ if (!table || (quarks[1] && table->leaf)) {
+ /* no top-level node table, create one and chain it in */
+ NEWTABLE(NULLQUARK,1);
+ table->tight = 1; /* arbitrary */
+ prev = nprev;
+ } else {
+ /* search along until we need a value */
+ while (quarks[1]) {
+ q = *quarks;
+ table = *(prev = &NodeHash(table, q));
+ while (table && table->name != q)
+ table = *(prev = &table->next);
+ if (!table)
+ break; /* not found */
+ if (quarks[2]) {
+ if (table->leaf)
+ break; /* not found */
+ } else {
+ if (!table->leaf) {
+ /* bump to leaf table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q)
+ break; /* not found */
+ if (!table->leaf) {
+ /* bump to leaf table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q)
+ break; /* not found */
+ }
+ }
+ }
+ if (*bindings == XrmBindTightly) {
+ if (!table->tight)
+ break; /* not found */
+ } else {
+ if (table->tight) {
+ /* bump to loose table, if any */
+ table = *(prev = &table->next);
+ if (!table || table->name != q ||
+ !quarks[2] != table->leaf)
+ break; /* not found */
+ }
+ }
+ /* found that one, bump to next quark */
+ pprev = prev;
+ quarks++;
+ bindings++;
+ }
+ if (!quarks[1]) {
+ /* found all the way to a leaf */
+ q = *quarks;
+ entry = *(vprev = &LeafHash((LTable)table, q));
+ while (entry && entry->name != q)
+ entry = *(vprev = &entry->next);
+ /* if want loose and have tight, bump to next entry */
+ if (entry && *bindings == XrmBindLoosely && entry->tight)
+ entry = *(vprev = &entry->next);
+ if (entry && entry->name == q &&
+ (*bindings == XrmBindTightly) == entry->tight) {
+ /* match, need to override */
+ if ((type == XrmQString) == entry->string &&
+ entry->size == value->size) {
+ /* update type if not String, can be different */
+ if (!entry->string)
+ RepType(entry) = type;
+ /* identical size, just overwrite value */
+ memcpy(RawValue(entry), (char *)value->addr, value->size);
+ return;
+ }
+ /* splice out and free old entry */
+ *vprev = entry->next;
+ Xfree((char *)entry);
+ (*pprev)->entries--;
+ }
+ /* this is where to insert */
+ prev = (NTable *)vprev;
+ }
+ }
+ /* keep the top table, because we may have to grow it */
+ firstpprev = pprev;
+ /* iterate until we get to the leaf */
+ while (quarks[1]) {
+ /* build a new table and chain it in */
+ NEWTABLE(*quarks,2);
+ if (*quarks++ == XrmQANY)
+ (*pprev)->hasany = 1;
+ if (*bindings++ == XrmBindTightly) {
+ table->tight = 1;
+ } else {
+ table->tight = 0;
+ (*pprev)->hasloose = 1;
+ }
+ (*pprev)->entries++;
+ pprev = prev;
+ prev = nprev;
+ }
+ /* now allocate the value entry */
+ entry = (VEntry)Xmalloc(((type == XrmQString) ?
+ sizeof(VEntryRec) : sizeof(DEntryRec)) +
+ value->size);
+ if (!entry)
+ return;
+ entry->name = q = *quarks;
+ if (*bindings == XrmBindTightly) {
+ entry->tight = 1;
+ } else {
+ entry->tight = 0;
+ (*pprev)->hasloose = 1;
+ }
+ /* chain it in, with a bit of type cast ugliness */
+ entry->next = *((VEntry *)prev);
+ *((VEntry *)prev) = entry;
+ entry->size = value->size;
+ if (type == XrmQString) {
+ entry->string = 1;
+ } else {
+ entry->string = 0;
+ RepType(entry) = type;
+ }
+ /* save a copy of the value */
+ memcpy(RawValue(entry), (char *)value->addr, value->size);
+ (*pprev)->entries++;
+ /* this is a new leaf, need to remember it for search lists */
+ if (q > maxResourceQuark) {
+ unsigned oldsize = (maxResourceQuark + 1) >> 3;
+ unsigned size = ((q | 0x7f) + 1) >> 3; /* reallocate in chunks */
+ if (resourceQuarks) {
+ unsigned char *prevQuarks = resourceQuarks;
+
+ resourceQuarks = (unsigned char *)Xrealloc((char *)resourceQuarks,
+ size);
+ if (!resourceQuarks) {
+ Xfree(prevQuarks);
+ }
+ } else
+ resourceQuarks = (unsigned char *)Xmalloc(size);
+ if (resourceQuarks) {
+ bzero((char *)&resourceQuarks[oldsize], size - oldsize);
+ maxResourceQuark = (size << 3) - 1;
+ } else {
+ maxResourceQuark = -1;
+ }
+ }
+ if (q > 0 && resourceQuarks)
+ resourceQuarks[q >> 3] |= 1 << (q & 0x7);
+ GROW(firstpprev);
+
+#undef NEWTABLE
+}
+
+void XrmQPutResource(pdb, bindings, quarks, type, value)
+ XrmDatabase *pdb;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ XrmRepresentation type;
+ XrmValuePtr value;
+{
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, type, value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+#if NeedFunctionPrototypes
+void XrmPutResource(
+ XrmDatabase *pdb,
+ _Xconst char *specifier,
+ _Xconst char *type,
+ XrmValuePtr value)
+#else
+void XrmPutResource(pdb, specifier, type, value)
+ XrmDatabase *pdb;
+ char *specifier;
+ char *type;
+ XrmValuePtr value;
+#endif
+{
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ XrmStringToBindingQuarkList(specifier, bindings, quarks);
+ PutEntry(*pdb, bindings, quarks, XrmStringToQuark(type), value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+#if NeedFunctionPrototypes
+void XrmQPutStringResource(
+ XrmDatabase *pdb,
+ XrmBindingList bindings,
+ XrmQuarkList quarks,
+ _Xconst char *str)
+#else
+void XrmQPutStringResource(pdb, bindings, quarks, str)
+ XrmDatabase *pdb;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ char *str;
+#endif
+{
+ XrmValue value;
+
+ if (!*pdb) *pdb = NewDatabase();
+ value.addr = (XPointer) str;
+ value.size = strlen(str)+1;
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, XrmQString, &value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+/* Function Name: GetDatabase
+ * Description: Parses a string and stores it as a database.
+ * Arguments: db - the database.
+ * str - a pointer to the string containing the database.
+ * filename - source filename, if any.
+ * doall - whether to do all lines or just one
+ */
+
+/*
+ * This function is highly optimized to inline as much as possible.
+ * Be very careful with modifications, or simplifications, as they
+ * may adversely affect the performance.
+ *
+ * Chris Peterson, MIT X Consortium 5/17/90.
+ */
+
+/*
+ * Xlib spec says max 100 quarks in a lookup, will stop and return if
+ * return if any single production's lhs has more than 100 components.
+ */
+#define QLIST_SIZE 100
+
+/*
+ * This should be big enough to handle things like the XKeysymDB or biggish
+ * ~/.Xdefaults or app-defaults files. Anything bigger will be allocated on
+ * the heap.
+ */
+#define DEF_BUFF_SIZE 8192
+
+static void GetIncludeFile();
+
+static void GetDatabase(db, str, filename, doall)
+ XrmDatabase db;
+ register char *str;
+ char *filename;
+ Bool doall;
+{
+ char *rhs;
+ char *lhs, lhs_s[DEF_BUFF_SIZE];
+ XrmQuark quarks[QLIST_SIZE + 1]; /* allow for a terminal NullQuark */
+ XrmBinding bindings[QLIST_SIZE + 1];
+
+ register char *ptr;
+ register XrmBits bits = 0;
+ register char c;
+ register Signature sig;
+ register char *ptr_max;
+ register int num_quarks;
+ register XrmBindingList t_bindings;
+
+ int len, alloc_chars;
+ unsigned long str_len;
+ XrmValue value;
+ Bool only_pcs;
+ Bool dolines;
+
+ if (!db)
+ return;
+
+ /*
+ * if strlen (str) < DEF_BUFF_SIZE allocate buffers on the stack for
+ * speed otherwise malloc the buffer. From a buffer overflow standpoint
+ * we can be sure that neither: a) a component on the lhs, or b) a
+ * value on the rhs, will be longer than the overall length of str,
+ * i.e. strlen(str).
+ *
+ * This should give good performance when parsing "*foo: bar" type
+ * databases as might be passed with -xrm command line options; but
+ * with larger databases, e.g. .Xdefaults, app-defaults, or KeysymDB
+ * files, the size of the buffers will be overly large. One way
+ * around this would be to double-parse each production with a resulting
+ * performance hit. In any event we can be assured that a lhs component
+ * name or a rhs value won't be longer than str itself.
+ */
+
+ str_len = strlen (str);
+ if (DEF_BUFF_SIZE > str_len) lhs = lhs_s;
+ else if ((lhs = (char*) Xmalloc (str_len)) == NULL)
+ return;
+
+ alloc_chars = DEF_BUFF_SIZE < str_len ? str_len : DEF_BUFF_SIZE;
+ if ((rhs = (char*) Xmalloc (alloc_chars)) == NULL) {
+ if (lhs != lhs_s) Xfree (lhs);
+ return;
+ }
+
+ (*db->methods->mbinit)(db->mbstate);
+ str--;
+ dolines = True;
+ while (!is_EOF(bits) && dolines) {
+ dolines = doall;
+
+ /*
+ * First: Remove extra whitespace.
+ */
+
+ do {
+ bits = next_char(c, str);
+ } while is_space(bits);
+
+ /*
+ * Ignore empty lines.
+ */
+
+ if (is_EOL(bits))
+ continue; /* start a new line. */
+
+ /*
+ * Second: check the first character in a line to see if it is
+ * "!" signifying a comment, or "#" signifying a directive.
+ */
+
+ if (c == '!') { /* Comment, spin to next newline */
+ while (is_simple(bits = next_char(c, str))) {}
+ if (is_EOL(bits))
+ continue;
+ while (!is_EOL(bits = next_mbchar(c, len, str))) {}
+ str--;
+ continue; /* start a new line. */
+ }
+
+ if (c == '#') { /* Directive */
+ /* remove extra whitespace */
+ only_pcs = True;
+ while (is_space(bits = next_char(c, str))) {};
+ /* only "include" directive is currently defined */
+ if (!strncmp(str, "include", 7)) {
+ str += (7-1);
+ /* remove extra whitespace */
+ while (is_space(bits = next_char(c, str))) {};
+ /* must have a starting " */
+ if (c == '"') {
+ char *fname = str+1;
+ len = 0;
+ do {
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ } while (c != '"' && !is_EOL(bits));
+ /* must have an ending " */
+ if (c == '"')
+ GetIncludeFile(db, filename, fname, str - len - fname);
+ }
+ }
+ /* spin to next newline */
+ if (only_pcs) {
+ while (is_simple(bits))
+ bits = next_char(c, str);
+ if (is_EOL(bits))
+ continue;
+ }
+ while (!is_EOL(bits))
+ bits = next_mbchar(c, len, str);
+ str--;
+ continue; /* start a new line. */
+ }
+
+ /*
+ * Third: loop through the LHS of the resource specification
+ * storing characters and converting this to a Quark.
+ */
+
+ num_quarks = 0;
+ t_bindings = bindings;
+
+ sig = 0;
+ ptr = lhs;
+ *t_bindings = XrmBindTightly;
+ for(;;) {
+ if (!is_binding(bits)) {
+ while (!is_EOQ(bits)) {
+ *ptr++ = c;
+ sig = (sig << 1) + c; /* Compute the signature. */
+ bits = next_char(c, str);
+ }
+
+ quarks[num_quarks++] =
+ _XrmInternalStringToQuark(lhs, ptr - lhs, sig, False);
+
+ if (num_quarks > QLIST_SIZE) {
+ Xfree(rhs);
+ if (lhs != lhs_s) Xfree (lhs);
+ (*db->methods->mbfinish)(db->mbstate);
+ return;
+ }
+
+ if (is_separator(bits)) {
+ if (!is_space(bits))
+ break;
+
+ /* Remove white space */
+ do {
+ *ptr++ = c;
+ sig = (sig << 1) + c; /* Compute the signature. */
+ } while (is_space(bits = next_char(c, str)));
+
+ /*
+ * The spec doesn't permit it, but support spaces
+ * internal to resource name/class
+ */
+
+ if (is_separator(bits))
+ break;
+ num_quarks--;
+ continue;
+ }
+
+ if (c == '.')
+ *(++t_bindings) = XrmBindTightly;
+ else
+ *(++t_bindings) = XrmBindLoosely;
+
+ sig = 0;
+ ptr = lhs;
+ }
+ else {
+ /*
+ * Magic unspecified feature #254.
+ *
+ * If two separators appear with no Text between them then
+ * ignore them.
+ *
+ * If anyone of those separators is a '*' then the binding
+ * will be loose, otherwise it will be tight.
+ */
+
+ if (c == '*')
+ *t_bindings = XrmBindLoosely;
+ }
+
+ bits = next_char(c, str);
+ }
+
+ quarks[num_quarks] = NULLQUARK;
+
+ /*
+ * Make sure that there is a ':' in this line.
+ */
+
+ if (c != ':') {
+ char oldc;
+
+ /*
+ * A parsing error has occured, toss everything on the line
+ * a new_line can still be escaped with a '\'.
+ */
+
+ while (is_normal(bits))
+ bits = next_char(c, str);
+ if (is_EOL(bits))
+ continue;
+ bits = next_mbchar(c, len, str);
+ do {
+ oldc = c;
+ bits = next_mbchar(c, len, str);
+ } while (c && (c != '\n' || oldc == '\\'));
+ str--;
+ continue;
+ }
+
+ /*
+ * I now have a quark and binding list for the entire left hand
+ * side. "c" currently points to the ":" separating the left hand
+ * side for the right hand side. It is time to begin processing
+ * the right hand side.
+ */
+
+ /*
+ * Fourth: Remove more whitespace
+ */
+
+ for(;;) {
+ if (is_space(bits = next_char(c, str)))
+ continue;
+ if (c != '\\')
+ break;
+ bits = next_char(c, str);
+ if (c == '\n')
+ continue;
+ str--;
+ bits = BSLASH;
+ c = '\\';
+ break;
+ }
+
+ /*
+ * Fifth: Process the right hand side.
+ */
+
+ ptr = rhs;
+ ptr_max = ptr + alloc_chars - 4;
+ only_pcs = True;
+ len = 1;
+
+ for(;;) {
+
+ /*
+ * Tight loop for the normal case: Non backslash, non-end of value
+ * character that will fit into the allocated buffer.
+ */
+
+ if (only_pcs) {
+ while (is_normal(bits) && ptr < ptr_max) {
+ *ptr++ = c;
+ bits = next_char(c, str);
+ }
+ if (is_EOL(bits))
+ break;
+ if (is_nonpcs(bits)) {
+ only_pcs = False;
+ bits = next_mbchar(c, len, str);
+ }
+ }
+ while (!is_special(bits) && ptr + len <= ptr_max) {
+ len = -len;
+ while (len)
+ *ptr++ = str[len++];
+ if (*str == '\0') {
+ bits = EOS;
+ break;
+ }
+ bits = next_mbchar(c, len, str);
+ }
+
+ if (is_EOL(bits)) {
+ str--;
+ break;
+ }
+
+ if (c == '\\') {
+ /*
+ * We need to do some magic after a backslash.
+ */
+ Bool read_next = True;
+
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+
+ if (is_EOL(bits)) {
+ if (is_EOF(bits))
+ continue;
+ } else if (c == 'n') {
+ /*
+ * "\n" means insert a newline.
+ */
+ *ptr++ = '\n';
+ } else if (c == '\\') {
+ /*
+ * "\\" completes to just one backslash.
+ */
+ *ptr++ = '\\';
+ } else {
+ /*
+ * pick up to three octal digits after the '\'.
+ */
+ char temp[3];
+ int count = 0;
+ while (is_odigit(bits) && count < 3) {
+ temp[count++] = c;
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ }
+
+ /*
+ * If we found three digits then insert that octal code
+ * into the value string as a character.
+ */
+
+ if (count == 3) {
+ *ptr++ = (unsigned char) ((temp[0] - '0') * 0100 +
+ (temp[1] - '0') * 010 +
+ (temp[2] - '0'));
+ }
+ else {
+ int tcount;
+
+ /*
+ * Otherwise just insert those characters into the
+ * string, since no special processing is needed on
+ * numerics we can skip the special processing.
+ */
+
+ for (tcount = 0; tcount < count; tcount++) {
+ *ptr++ = temp[tcount]; /* print them in
+ the correct order */
+ }
+ }
+ read_next = False;
+ }
+ if (read_next) {
+ if (only_pcs) {
+ bits = next_char(c, str);
+ if (is_nonpcs(bits))
+ only_pcs = False;
+ }
+ if (!only_pcs)
+ bits = next_mbchar(c, len, str);
+ }
+ }
+
+ /*
+ * It is important to make sure that there is room for at least
+ * four more characters in the buffer, since I can add that
+ * many characters into the buffer after a backslash has occured.
+ */
+
+ if (ptr + len > ptr_max) {
+ char * temp_str;
+
+ alloc_chars += BUFSIZ/10;
+ temp_str = Xrealloc(rhs, sizeof(char) * alloc_chars);
+
+ if (!temp_str) {
+ Xfree(rhs);
+ if (lhs != lhs_s) Xfree (lhs);
+ (*db->methods->mbfinish)(db->mbstate);
+ return;
+ }
+
+ ptr = temp_str + (ptr - rhs); /* reset pointer. */
+ rhs = temp_str;
+ ptr_max = rhs + alloc_chars - 4;
+ }
+ }
+
+ /*
+ * Lastly: Terminate the value string, and store this entry
+ * into the database.
+ */
+
+ *ptr++ = '\0';
+
+ /* Store it in database */
+ value.size = ptr - rhs;
+ value.addr = (XPointer) rhs;
+
+ PutEntry(db, bindings, quarks, XrmQString, &value);
+ }
+
+ if (lhs != lhs_s) Xfree (lhs);
+ Xfree (rhs);
+
+ (*db->methods->mbfinish)(db->mbstate);
+}
+
+#if NeedFunctionPrototypes
+void XrmPutStringResource(
+ XrmDatabase *pdb,
+ _Xconst char*specifier,
+ _Xconst char*str)
+#else
+void XrmPutStringResource(pdb, specifier, str)
+ XrmDatabase *pdb;
+ char *specifier;
+ char *str;
+#endif
+{
+ XrmValue value;
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+
+ if (!*pdb) *pdb = NewDatabase();
+ XrmStringToBindingQuarkList(specifier, bindings, quarks);
+ value.addr = (XPointer) str;
+ value.size = strlen(str)+1;
+ _XLockMutex(&(*pdb)->linfo);
+ PutEntry(*pdb, bindings, quarks, XrmQString, &value);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+
+#if NeedFunctionPrototypes
+void XrmPutLineResource(
+ XrmDatabase *pdb,
+ _Xconst char*line)
+#else
+void XrmPutLineResource(pdb, line)
+ XrmDatabase *pdb;
+ char *line;
+#endif
+{
+ if (!*pdb) *pdb = NewDatabase();
+ _XLockMutex(&(*pdb)->linfo);
+ GetDatabase(*pdb, line, (char *)NULL, False);
+ _XUnlockMutex(&(*pdb)->linfo);
+}
+
+#if NeedFunctionPrototypes
+XrmDatabase XrmGetStringDatabase(
+ _Xconst char *data)
+#else
+XrmDatabase XrmGetStringDatabase(data)
+ char *data;
+#endif
+{
+ XrmDatabase db;
+
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, data, (char *)NULL, True);
+ _XUnlockMutex(&db->linfo);
+ return db;
+}
+
+/* Function Name: ReadInFile
+ * Description: Reads the file into a buffer.
+ * Arguments: filename - the name of the file.
+ * Returns: An allocated string containing the contents of the file.
+ */
+
+static char *
+ReadInFile(filename)
+char * filename;
+{
+ register int fd, size;
+ char * filebuf;
+
+ /*
+ * MS-Windows and OS/2 note: Default open mode includes O_TEXT
+ */
+ if ( (fd = _XOpenFile (filename, O_RDONLY)) == -1 )
+ return (char *)NULL;
+
+ /*
+ * MS-Windows and OS/2 note: depending on how the sources are
+ * untarred, the newlines in resource files may or may not have
+ * been * expanded to CRLF. Either way the size returned by fstat
+ * is sufficient to read the file into because in text-mode any
+ * CRLFs in a file will be converted to newlines (LF) with the
+ * result that * the number of bytes actually read with be <=
+ * to the size returned by fstat.
+ */
+ GetSizeOfFile(fd, size);
+
+ if (!(filebuf = Xmalloc(size + 1))) { /* leave room for '\0' */
+ close(fd);
+ return (char *)NULL;
+ }
+ size = read (fd, filebuf, size);
+
+ if (size < 0) {
+ close (fd);
+ Xfree(filebuf);
+ return (char *)NULL;
+ }
+ close (fd);
+
+ filebuf[size] = '\0'; /* NULL terminate it. */
+ return filebuf;
+}
+
+static void
+GetIncludeFile(db, base, fname, fnamelen)
+ XrmDatabase db;
+ char *base;
+ char *fname;
+ int fnamelen;
+{
+ int len;
+ char *str;
+ char realfname[BUFSIZ];
+
+ if (fnamelen <= 0 || fnamelen >= BUFSIZ)
+ return;
+ if (*fname != '/' && base && (str = strrchr(base, '/'))) {
+ len = str - base + 1;
+ if (len + fnamelen >= BUFSIZ)
+ return;
+ strncpy(realfname, base, len);
+ strncpy(realfname + len, fname, fnamelen);
+ realfname[len + fnamelen] = '\0';
+ } else {
+ strncpy(realfname, fname, fnamelen);
+ realfname[fnamelen] = '\0';
+ }
+ if (!(str = ReadInFile(realfname)))
+ return;
+ GetDatabase(db, str, realfname, True);
+ Xfree(str);
+}
+
+#if NeedFunctionPrototypes
+XrmDatabase XrmGetFileDatabase(
+ _Xconst char *filename)
+#else
+XrmDatabase XrmGetFileDatabase(filename)
+ char *filename;
+#endif
+{
+ XrmDatabase db;
+ char *str;
+
+ if (!(str = ReadInFile(filename)))
+ return (XrmDatabase)NULL;
+
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, str, filename, True);
+ _XUnlockMutex(&db->linfo);
+ Xfree(str);
+ return db;
+}
+
+#if NeedFunctionPrototypes
+Status XrmCombineFileDatabase(
+ _Xconst char *filename,
+ XrmDatabase *target,
+ Bool override)
+#else
+Status XrmCombineFileDatabase(filename, target, override)
+ char *filename;
+ XrmDatabase *target;
+ Bool override;
+#endif
+{
+ XrmDatabase db;
+ char *str;
+
+ if (!(str = ReadInFile(filename)))
+ return 0;
+ if (override) {
+ db = *target;
+ if (!db)
+ *target = db = NewDatabase();
+ } else
+ db = NewDatabase();
+ _XLockMutex(&db->linfo);
+ GetDatabase(db, str, filename, True);
+ _XUnlockMutex(&db->linfo);
+ Xfree(str);
+ if (!override)
+ XrmCombineDatabase(db, target, False);
+ return 1;
+}
+
+/* call the user proc for every value in the table, arbitrary order.
+ * stop if user proc returns True. level is current depth in database.
+ */
+/*ARGSUSED*/
+static Bool EnumLTable(table, names, classes, level, closure)
+ LTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ register int level;
+ register EClosure closure;
+{
+ register VEntry *bucket;
+ register int i;
+ register VEntry entry;
+ XrmValue value;
+ XrmRepresentation type;
+ Bool tightOk;
+
+ closure->bindings[level] = (table->table.tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = table->table.name;
+ level++;
+ tightOk = !*names;
+ closure->quarks[level + 1] = NULLQUARK;
+ for (i = table->table.mask, bucket = table->buckets;
+ i >= 0;
+ i--, bucket++) {
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (entry->tight && !tightOk)
+ continue;
+ closure->bindings[level] = (entry->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = entry->name;
+ value.size = entry->size;
+ if (entry->string) {
+ type = XrmQString;
+ value.addr = StringValue(entry);
+ } else {
+ type = RepType(entry);
+ value.addr = DataValue(entry);
+ }
+ if ((*closure->proc)(&closure->db, closure->bindings+1,
+ closure->quarks+1, &type, &value,
+ closure->closure))
+ return True;
+ }
+ }
+ return False;
+}
+
+static Bool EnumAllNTable(table, level, closure)
+ NTable table;
+ register int level;
+ register EClosure closure;
+{
+ register NTable *bucket;
+ register int i;
+ register NTable entry;
+ XrmQuark empty = NULLQUARK;
+
+ if (level >= MAXDBDEPTH)
+ return False;
+ for (i = table->mask, bucket = NodeBuckets(table);
+ i >= 0;
+ i--, bucket++) {
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (entry->leaf) {
+ if (EnumLTable((LTable)entry, &empty, &empty, level, closure))
+ return True;
+ } else {
+ closure->bindings[level] = (entry->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = entry->name;
+ if (EnumAllNTable(entry, level+1, closure))
+ return True;
+ }
+ }
+ }
+ return False;
+}
+
+/* recurse on every table in the table, arbitrary order.
+ * stop if user proc returns True. level is current depth in database.
+ */
+static Bool EnumNTable(table, names, classes, level, closure)
+ NTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ register int level;
+ register EClosure closure;
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)();
+ Bool bilevel;
+
+/* find entries named ename, leafness leaf, tight or loose, and call get */
+#define ITIGHTLOOSE(ename) \
+ NFIND(ename); \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if (!leaf && !entry->tight && entry->next && \
+ entry->next->name == q && entry->next->tight && \
+ (bilevel || entry->next->hasloose) && \
+ EnumLTable((LTable)entry->next, names+1, classes+1, \
+ level, closure)) \
+ return True; \
+ if ((*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && leaf == entry->leaf && \
+ (*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ } else if (entry->leaf) { \
+ if ((bilevel || entry->hasloose) && \
+ EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && (bilevel || entry->hasloose) && \
+ EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ } \
+ }
+
+/* find entries named ename, leafness leaf, loose only, and call get */
+#define ILOOSE(ename) \
+ NFIND(ename); \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (NTable)NULL; \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if ((*get)(entry, names+1, classes+1, level, closure)) \
+ return True; \
+ } else if (entry->leaf && (bilevel || entry->hasloose)) { \
+ if (EnumLTable((LTable)entry, names+1, classes+1, level, closure))\
+ return True; \
+ } \
+ }
+
+ if (level >= MAXDBDEPTH)
+ return False;
+ closure->bindings[level] = (table->tight ?
+ XrmBindTightly : XrmBindLoosely);
+ closure->quarks[level] = table->name;
+ level++;
+ if (!*names) {
+ if (EnumAllNTable(table, level, closure))
+ return True;
+ } else {
+ if (names[1] || closure->mode == XrmEnumAllLevels) {
+ get = EnumNTable; /* recurse */
+ leaf = 0;
+ bilevel = !names[1];
+ } else {
+ get = EnumLTable; /* bottom of recursion */
+ leaf = 1;
+ bilevel = False;
+ }
+ if (table->hasloose && closure->mode == XrmEnumAllLevels) {
+ NTable *bucket;
+ int i;
+ XrmQuark empty = NULLQUARK;
+
+ for (i = table->mask, bucket = NodeBuckets(table);
+ i >= 0;
+ i--, bucket++) {
+ q = NULLQUARK;
+ for (entry = *bucket; entry; entry = entry->next) {
+ if (!entry->tight && entry->name != q &&
+ entry->name != *names && entry->name != *classes) {
+ q = entry->name;
+ if (entry->leaf) {
+ if (EnumLTable((LTable)entry, &empty, &empty,
+ level, closure))
+ return True;
+ } else {
+ if (EnumNTable(entry, &empty, &empty,
+ level, closure))
+ return True;
+ }
+ }
+ }
+ }
+ }
+
+ ITIGHTLOOSE(*names); /* do name, tight and loose */
+ ITIGHTLOOSE(*classes); /* do class, tight and loose */
+ if (table->hasany) {
+ ITIGHTLOOSE(XrmQANY); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!*names)
+ break;
+ if (!names[1] && closure->mode != XrmEnumAllLevels) {
+ get = EnumLTable; /* bottom of recursion */
+ leaf = 1;
+ }
+ ILOOSE(*names); /* loose names */
+ ILOOSE(*classes); /* loose classes */
+ if (table->hasany) {
+ ILOOSE(XrmQANY); /* loose ANY */
+ }
+ }
+ names--;
+ classes--;
+ }
+ }
+ /* now look for matching leaf nodes */
+ entry = table->next;
+ if (!entry)
+ return False;
+ if (entry->leaf) {
+ if (entry->tight && !table->tight)
+ entry = entry->next;
+ } else {
+ entry = entry->next;
+ if (!entry || !entry->tight)
+ return False;
+ }
+ if (!entry || entry->name != table->name)
+ return False;
+ /* found one */
+ level--;
+ if ((!*names || entry->hasloose) &&
+ EnumLTable((LTable)entry, names, classes, level, closure))
+ return True;
+ if (entry->tight && entry == table->next && (entry = entry->next) &&
+ entry->name == table->name && (!*names || entry->hasloose))
+ return EnumLTable((LTable)entry, names, classes, level, closure);
+ return False;
+
+#undef ITIGHTLOOSE
+#undef ILOOSE
+}
+
+/* call the proc for every value in the database, arbitrary order.
+ * stop if the proc returns True.
+ */
+Bool XrmEnumerateDatabase(db, names, classes, mode, proc, closure)
+ XrmDatabase db;
+ XrmNameList names;
+ XrmClassList classes;
+ int mode;
+ DBEnumProc proc;
+ XPointer closure;
+{
+ XrmBinding bindings[MAXDBDEPTH+2];
+ XrmQuark quarks[MAXDBDEPTH+2];
+ register NTable table;
+ EClosureRec eclosure;
+ Bool retval = False;
+
+ if (!db)
+ return False;
+ _XLockMutex(&db->linfo);
+ eclosure.db = db;
+ eclosure.proc = proc;
+ eclosure.closure = closure;
+ eclosure.bindings = bindings;
+ eclosure.quarks = quarks;
+ eclosure.mode = mode;
+ table = db->table;
+ if (table && !table->leaf && !*names && mode == XrmEnumOneLevel)
+ table = table->next;
+ if (table) {
+ if (!table->leaf)
+ retval = EnumNTable(table, names, classes, 0, &eclosure);
+ else
+ retval = EnumLTable((LTable)table, names, classes, 0, &eclosure);
+ }
+ _XUnlockMutex(&db->linfo);
+ return retval;
+}
+
+static void PrintBindingQuarkList(bindings, quarks, stream)
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ FILE *stream;
+{
+ Bool firstNameSeen;
+
+ for (firstNameSeen = False; *quarks; bindings++, quarks++) {
+ if (*bindings == XrmBindLoosely) {
+ (void) fprintf(stream, "*");
+ } else if (firstNameSeen) {
+ (void) fprintf(stream, ".");
+ }
+ firstNameSeen = True;
+ (void) fputs(XrmQuarkToString(*quarks), stream);
+ }
+}
+
+/* output out the entry in correct file syntax */
+/*ARGSUSED*/
+static Bool DumpEntry(db, bindings, quarks, type, value, data)
+ XrmDatabase *db;
+ XrmBindingList bindings;
+ XrmQuarkList quarks;
+ XrmRepresentation *type;
+ XrmValuePtr value;
+ XPointer data;
+{
+ FILE *stream = (FILE *)data;
+ register unsigned int i;
+ register char *s;
+ register char c;
+
+ if (*type != XrmQString)
+ (void) putc('!', stream);
+ PrintBindingQuarkList(bindings, quarks, stream);
+ s = value->addr;
+ i = value->size;
+ if (*type == XrmQString) {
+ (void) fputs(":\t", stream);
+ if (i)
+ i--;
+ }
+ else
+ (void) fprintf(stream, "=%s:\t", XrmRepresentationToString(*type));
+ if (i && (*s == ' ' || *s == '\t'))
+ (void) putc('\\', stream); /* preserve leading whitespace */
+ while (i--) {
+ c = *s++;
+ if (c == '\n') {
+ if (i)
+ (void) fputs("\\n\\\n", stream);
+ else
+ (void) fputs("\\n", stream);
+ } else if (c == '\\')
+ (void) fputs("\\\\", stream);
+ else if ((c < ' ' && c != '\t') ||
+ ((unsigned char)c >= 0x7f && (unsigned char)c < 0xa0))
+ (void) fprintf(stream, "\\%03o", (unsigned char)c);
+ else
+ (void) putc(c, stream);
+ }
+ (void) putc('\n', stream);
+ return ferror(stream) != 0;
+}
+
+#ifdef DEBUG
+
+void PrintTable(table, file)
+ NTable table;
+ FILE *file;
+{
+ XrmBinding bindings[MAXDBDEPTH+1];
+ XrmQuark quarks[MAXDBDEPTH+1];
+ EClosureRec closure;
+ XrmQuark empty = NULLQUARK;
+
+ closure.db = (XrmDatabase)NULL;
+ closure.proc = DumpEntry;
+ closure.closure = (XPointer)file;
+ closure.bindings = bindings;
+ closure.quarks = quarks;
+ closure.mode = XrmEnumAllLevels;
+ if (table->leaf)
+ EnumLTable((LTable)table, &empty, &empty, 0, &closure);
+ else
+ EnumNTable(table, &empty, &empty, 0, &closure);
+}
+
+#endif /* DEBUG */
+
+#if NeedFunctionPrototypes
+void XrmPutFileDatabase(
+ XrmDatabase db,
+ _Xconst char *fileName)
+#else
+void XrmPutFileDatabase(db, fileName)
+ XrmDatabase db;
+ char *fileName;
+#endif
+{
+ FILE *file;
+ XrmQuark empty = NULLQUARK;
+
+ if (!db) return;
+ if (!(file = fopen(fileName, "w"))) return;
+ if (XrmEnumerateDatabase(db, &empty, &empty, XrmEnumAllLevels,
+ DumpEntry, (XPointer) file))
+ unlink((char *)fileName);
+ fclose(file);
+}
+
+/* macros used in get/search functions */
+
+/* find entries named ename, leafness leaf, tight or loose, and call get */
+#define GTIGHTLOOSE(ename,looseleaf) \
+ NFIND(ename); \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if (!leaf && !entry->tight && entry->next && \
+ entry->next->name == q && entry->next->tight && \
+ entry->next->hasloose && \
+ looseleaf((LTable)entry->next, names+1, classes+1, closure)) \
+ return True; \
+ if ((*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && leaf == entry->leaf && \
+ (*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ } else if (entry->leaf) { \
+ if (entry->hasloose && \
+ looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ if (entry->tight && (entry = entry->next) && \
+ entry->name == q && entry->hasloose && \
+ looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ } \
+ }
+
+/* find entries named ename, leafness leaf, loose only, and call get */
+#define GLOOSE(ename,looseleaf) \
+ NFIND(ename); \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (NTable)NULL; \
+ if (entry) { \
+ if (leaf == entry->leaf) { \
+ if ((*get)(entry, names+1, classes+1, closure)) \
+ return True; \
+ } else if (entry->leaf && entry->hasloose) { \
+ if (looseleaf((LTable)entry, names+1, classes+1, closure)) \
+ return True; \
+ } \
+ }
+
+/* add tight/loose entry to the search list, return True if list is full */
+/*ARGSUSED*/
+static Bool AppendLEntry(table, names, classes, closure)
+ LTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ register SClosure closure;
+{
+ /* check for duplicate */
+ if (closure->idx >= 0 && closure->list[closure->idx] == table)
+ return False;
+ if (closure->idx == closure->limit)
+ return True;
+ /* append it */
+ closure->idx++;
+ closure->list[closure->idx] = table;
+ return False;
+}
+
+/* add loose entry to the search list, return True if list is full */
+/*ARGSUSED*/
+static Bool AppendLooseLEntry(table, names, classes, closure)
+ LTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ register SClosure closure;
+{
+ /* check for duplicate */
+ if (closure->idx >= 0 && closure->list[closure->idx] == table)
+ return False;
+ if (closure->idx >= closure->limit - 1)
+ return True;
+ /* append it */
+ closure->idx++;
+ closure->list[closure->idx] = LOOSESEARCH;
+ closure->idx++;
+ closure->list[closure->idx] = table;
+ return False;
+}
+
+/* search for a leaf table */
+static Bool SearchNEntry(table, names, classes, closure)
+ NTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ SClosure closure;
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)();
+
+ if (names[1]) {
+ get = SearchNEntry; /* recurse */
+ leaf = 0;
+ } else {
+ get = AppendLEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GTIGHTLOOSE(*names, AppendLooseLEntry); /* do name, tight and loose */
+ GTIGHTLOOSE(*classes, AppendLooseLEntry); /* do class, tight and loose */
+ if (table->hasany) {
+ GTIGHTLOOSE(XrmQANY, AppendLooseLEntry); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!*names)
+ break;
+ if (!names[1]) {
+ get = AppendLEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GLOOSE(*names, AppendLooseLEntry); /* loose names */
+ GLOOSE(*classes, AppendLooseLEntry); /* loose classes */
+ if (table->hasany) {
+ GLOOSE(XrmQANY, AppendLooseLEntry); /* loose ANY */
+ }
+ }
+ }
+ /* now look for matching leaf nodes */
+ entry = table->next;
+ if (!entry)
+ return False;
+ if (entry->leaf) {
+ if (entry->tight && !table->tight)
+ entry = entry->next;
+ } else {
+ entry = entry->next;
+ if (!entry || !entry->tight)
+ return False;
+ }
+ if (!entry || entry->name != table->name)
+ return False;
+ /* found one */
+ if (entry->hasloose &&
+ AppendLooseLEntry((LTable)entry, names, classes, closure))
+ return True;
+ if (entry->tight && entry == table->next && (entry = entry->next) &&
+ entry->name == table->name && entry->hasloose)
+ return AppendLooseLEntry((LTable)entry, names, classes, closure);
+ return False;
+}
+
+Bool XrmQGetSearchList(db, names, classes, searchList, listLength)
+ XrmDatabase db;
+ XrmNameList names;
+ XrmClassList classes;
+ XrmSearchList searchList; /* RETURN */
+ int listLength;
+{
+ register NTable table;
+ SClosureRec closure;
+
+ if (listLength <= 0)
+ return False;
+ closure.list = (LTable *)searchList;
+ closure.idx = -1;
+ closure.limit = listLength - 2;
+ if (db) {
+ _XLockMutex(&db->linfo);
+ table = db->table;
+ if (*names) {
+ if (table && !table->leaf) {
+ if (SearchNEntry(table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ } else if (table && table->hasloose &&
+ AppendLooseLEntry((LTable)table, names, classes,
+ &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ } else {
+ if (table && !table->leaf)
+ table = table->next;
+ if (table &&
+ AppendLEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return False;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ }
+ closure.list[closure.idx + 1] = (LTable)NULL;
+ return True;
+}
+
+Bool XrmQGetSearchResource(searchList, name, class, pType, pValue)
+ XrmSearchList searchList;
+ register XrmName name;
+ register XrmClass class;
+ XrmRepresentation *pType; /* RETURN */
+ XrmValue *pValue; /* RETURN */
+{
+ register LTable *list;
+ register LTable table;
+ register VEntry entry;
+ int flags;
+
+/* find tight or loose entry */
+#define VTIGHTLOOSE(q) \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry) \
+ break
+
+/* find loose entry */
+#define VLOOSE(q) \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry) { \
+ if (!entry->tight) \
+ break; \
+ if ((entry = entry->next) && entry->name == q) \
+ break; \
+ }
+
+ list = (LTable *)searchList;
+ /* figure out which combination of name and class we need to search for */
+ flags = 0;
+ if (IsResourceQuark(name))
+ flags = 2;
+ if (IsResourceQuark(class))
+ flags |= 1;
+ if (!flags) {
+ /* neither name nor class has ever been used to name a resource */
+ table = (LTable)NULL;
+ } else if (flags == 3) {
+ /* both name and class */
+ while ((table = *list++)) {
+ if (table != LOOSESEARCH) {
+ VTIGHTLOOSE(name); /* do name, tight and loose */
+ VTIGHTLOOSE(class); /* do class, tight and loose */
+ } else {
+ table = *list++;
+ VLOOSE(name); /* do name, loose only */
+ VLOOSE(class); /* do class, loose only */
+ }
+ }
+ } else {
+ /* just one of name or class */
+ if (flags == 1)
+ name = class;
+ while ((table = *list++)) {
+ if (table != LOOSESEARCH) {
+ VTIGHTLOOSE(name); /* tight and loose */
+ } else {
+ table = *list++;
+ VLOOSE(name); /* loose only */
+ }
+ }
+ }
+ if (table) {
+ /* found a match */
+ if (entry->string) {
+ *pType = XrmQString;
+ pValue->addr = StringValue(entry);
+ } else {
+ *pType = RepType(entry);
+ pValue->addr = DataValue(entry);
+ }
+ pValue->size = entry->size;
+ return True;
+ }
+ *pType = NULLQUARK;
+ pValue->addr = (XPointer)NULL;
+ pValue->size = 0;
+ return False;
+
+#undef VTIGHTLOOSE
+#undef VLOOSE
+}
+
+/* look for a tight/loose value */
+static Bool GetVEntry(table, names, classes, closure)
+ LTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ VClosure closure;
+{
+ register VEntry entry;
+ register XrmQuark q;
+
+ /* try name first */
+ q = *names;
+ entry = LeafHash(table, q);
+ while (entry && entry->name != q)
+ entry = entry->next;
+ if (!entry) {
+ /* not found, try class */
+ q = *classes;
+ entry = LeafHash(table, q);
+ while (entry && entry->name != q)
+ entry = entry->next;
+ if (!entry)
+ return False;
+ }
+ if (entry->string) {
+ *closure->type = XrmQString;
+ closure->value->addr = StringValue(entry);
+ } else {
+ *closure->type = RepType(entry);
+ closure->value->addr = DataValue(entry);
+ }
+ closure->value->size = entry->size;
+ return True;
+}
+
+/* look for a loose value */
+static Bool GetLooseVEntry(table, names, classes, closure)
+ LTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ VClosure closure;
+{
+ register VEntry entry;
+ register XrmQuark q;
+
+#define VLOOSE(ename) \
+ q = ename; \
+ entry = LeafHash(table, q); \
+ while (entry && entry->name != q) \
+ entry = entry->next; \
+ if (entry && entry->tight && (entry = entry->next) && entry->name != q) \
+ entry = (VEntry)NULL;
+
+ /* bump to last component */
+ while (names[1]) {
+ names++;
+ classes++;
+ }
+ VLOOSE(*names); /* do name, loose only */
+ if (!entry) {
+ VLOOSE(*classes); /* do class, loose only */
+ if (!entry)
+ return False;
+ }
+ if (entry->string) {
+ *closure->type = XrmQString;
+ closure->value->addr = StringValue(entry);
+ } else {
+ *closure->type = RepType(entry);
+ closure->value->addr = DataValue(entry);
+ }
+ closure->value->size = entry->size;
+ return True;
+
+#undef VLOOSE
+}
+
+/* recursive search for a value */
+static Bool GetNEntry(table, names, classes, closure)
+ NTable table;
+ XrmNameList names;
+ XrmClassList classes;
+ VClosure closure;
+{
+ register NTable entry;
+ register XrmQuark q;
+ register unsigned int leaf;
+ Bool (*get)();
+ NTable otable;
+
+ if (names[2]) {
+ get = GetNEntry; /* recurse */
+ leaf = 0;
+ } else {
+ get = GetVEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GTIGHTLOOSE(*names, GetLooseVEntry); /* do name, tight and loose */
+ GTIGHTLOOSE(*classes, GetLooseVEntry); /* do class, tight and loose */
+ if (table->hasany) {
+ GTIGHTLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, tight and loose */
+ }
+ if (table->hasloose) {
+ while (1) {
+ names++;
+ classes++;
+ if (!names[1])
+ break;
+ if (!names[2]) {
+ get = GetVEntry; /* bottom of recursion */
+ leaf = 1;
+ }
+ GLOOSE(*names, GetLooseVEntry); /* do name, loose only */
+ GLOOSE(*classes, GetLooseVEntry); /* do class, loose only */
+ if (table->hasany) {
+ GLOOSE(XrmQANY, GetLooseVEntry); /* do ANY, loose only */
+ }
+ }
+ }
+ /* look for matching leaf tables */
+ otable = table;
+ table = table->next;
+ if (!table)
+ return False;
+ if (table->leaf) {
+ if (table->tight && !otable->tight)
+ table = table->next;
+ } else {
+ table = table->next;
+ if (!table || !table->tight)
+ return False;
+ }
+ if (!table || table->name != otable->name)
+ return False;
+ /* found one */
+ if (table->hasloose &&
+ GetLooseVEntry((LTable)table, names, classes, closure))
+ return True;
+ if (table->tight && table == otable->next) {
+ table = table->next;
+ if (table && table->name == otable->name && table->hasloose)
+ return GetLooseVEntry((LTable)table, names, classes, closure);
+ }
+ return False;
+}
+
+Bool XrmQGetResource(db, names, classes, pType, pValue)
+ XrmDatabase db;
+ XrmNameList names;
+ XrmClassList classes;
+ XrmRepresentation *pType; /* RETURN */
+ XrmValuePtr pValue; /* RETURN */
+{
+ register NTable table;
+ VClosureRec closure;
+
+ if (db && *names) {
+ _XLockMutex(&db->linfo);
+ closure.type = pType;
+ closure.value = pValue;
+ table = db->table;
+ if (names[1]) {
+ if (table && !table->leaf) {
+ if (GetNEntry(table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return True;
+ }
+ } else if (table && table->hasloose &&
+ GetLooseVEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex (&db->linfo);
+ return True;
+ }
+ } else {
+ if (table && !table->leaf)
+ table = table->next;
+ if (table && GetVEntry((LTable)table, names, classes, &closure)) {
+ _XUnlockMutex(&db->linfo);
+ return True;
+ }
+ }
+ _XUnlockMutex(&db->linfo);
+ }
+ *pType = NULLQUARK;
+ pValue->addr = (XPointer)NULL;
+ pValue->size = 0;
+ return False;
+}
+
+#if NeedFunctionPrototypes
+Bool XrmGetResource(db, name_str, class_str, pType_str, pValue)
+ XrmDatabase db;
+ _Xconst char *name_str;
+ _Xconst char *class_str;
+ XrmString *pType_str; /* RETURN */
+ XrmValuePtr pValue; /* RETURN */
+#else
+Bool XrmGetResource(db, name_str, class_str, pType_str, pValue)
+ XrmDatabase db;
+ XrmString name_str;
+ XrmString class_str;
+ XrmString *pType_str; /* RETURN */
+ XrmValuePtr pValue; /* RETURN */
+#endif
+{
+ XrmName names[MAXDBDEPTH+1];
+ XrmClass classes[MAXDBDEPTH+1];
+ XrmRepresentation fromType;
+ Bool result;
+
+ XrmStringToNameList(name_str, names);
+ XrmStringToClassList(class_str, classes);
+ result = XrmQGetResource(db, names, classes, &fromType, pValue);
+ (*pType_str) = XrmQuarkToString(fromType);
+ return result;
+}
+
+/* destroy all values, plus table itself */
+static void DestroyLTable(table)
+ LTable table;
+{
+ register int i;
+ register VEntry *buckets;
+ register VEntry entry, next;
+
+ buckets = table->buckets;
+ for (i = table->table.mask; i >= 0; i--, buckets++) {
+ for (next = *buckets; (entry = next); ) {
+ next = entry->next;
+ Xfree((char *)entry);
+ }
+ }
+ Xfree((char *)table->buckets);
+ Xfree((char *)table);
+}
+
+/* destroy all contained tables, plus table itself */
+static void DestroyNTable(table)
+ NTable table;
+{
+ register int i;
+ register NTable *buckets;
+ register NTable entry, next;
+
+ buckets = NodeBuckets(table);
+ for (i = table->mask; i >= 0; i--, buckets++) {
+ for (next = *buckets; (entry = next); ) {
+ next = entry->next;
+ if (entry->leaf)
+ DestroyLTable((LTable)entry);
+ else
+ DestroyNTable(entry);
+ }
+ }
+ Xfree((char *)table);
+}
+
+char *XrmLocaleOfDatabase(db)
+ XrmDatabase db;
+{
+ char* retval;
+ _XLockMutex(&db->linfo);
+ retval = (*db->methods->lcname)(db->mbstate);
+ _XUnlockMutex(&db->linfo);
+ return retval;
+}
+
+void XrmDestroyDatabase(db)
+ XrmDatabase db;
+{
+ register NTable table, next;
+
+ if (db) {
+ _XLockMutex(&db->linfo);
+ for (next = db->table; (table = next); ) {
+ next = table->next;
+ if (table->leaf)
+ DestroyLTable((LTable)table);
+ else
+ DestroyNTable(table);
+ }
+ _XFreeMutex(&db->linfo);
+ (*db->methods->destroy)(db->mbstate);
+ Xfree((char *)db);
+ }
+}
diff --git a/src/XrmI.h b/src/XrmI.h
new file mode 100644
index 00000000..949bcd6f
--- /dev/null
+++ b/src/XrmI.h
@@ -0,0 +1,47 @@
+/* $Xorg: XrmI.h,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+/*
+ * Macros to abstract out reading the file, and getting its size.
+ *
+ * You may need to redefine these for various other operating systems.
+ */
+
+#include <X11/Xos.h>
+#include <sys/stat.h>
+
+#define GetSizeOfFile(fd,size) \
+{ \
+ struct stat status_buffer; \
+ if ( (fstat((fd), &status_buffer)) == -1 ) \
+ size = -1; \
+ else \
+ size = status_buffer.st_size; \
+}
diff --git a/src/evtomask.c b/src/evtomask.c
new file mode 100644
index 00000000..80047503
--- /dev/null
+++ b/src/evtomask.c
@@ -0,0 +1,78 @@
+/* $Xorg: evtomask.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+#include <X11/X.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * This array can be used given an event type to determine the mask bits
+ * that could have generated it.
+ */
+long Const _Xevent_to_mask [LASTEvent] = {
+ 0, /* no event 0 */
+ 0, /* no event 1 */
+ KeyPressMask, /* KeyPress */
+ KeyReleaseMask, /* KeyRelease */
+ ButtonPressMask, /* ButtonPress */
+ ButtonReleaseMask, /* ButtonRelease */
+ PointerMotionMask|PointerMotionHintMask|Button1MotionMask|
+ Button2MotionMask|Button3MotionMask|Button4MotionMask|
+ Button5MotionMask|ButtonMotionMask, /* MotionNotify */
+ EnterWindowMask, /* EnterNotify */
+ LeaveWindowMask, /* LeaveNotify */
+ FocusChangeMask, /* FocusIn */
+ FocusChangeMask, /* FocusOut */
+ KeymapStateMask, /* KeymapNotify */
+ ExposureMask, /* Expose */
+ ExposureMask, /* GraphicsExpose */
+ ExposureMask, /* NoExpose */
+ VisibilityChangeMask, /* VisibilityNotify */
+ SubstructureNotifyMask, /* CreateNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* DestroyNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* UnmapNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* MapNotify */
+ SubstructureRedirectMask, /* MapRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* ReparentNotify */
+ StructureNotifyMask|SubstructureNotifyMask, /* ConfigureNotify */
+ SubstructureRedirectMask, /* ConfigureRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* GravityNotify */
+ ResizeRedirectMask, /* ResizeRequest */
+ SubstructureNotifyMask|StructureNotifyMask, /* CirculateNotify */
+ SubstructureRedirectMask, /* CirculateRequest */
+ PropertyChangeMask, /* PropertyNotify */
+ 0, /* SelectionClear */
+ 0, /* SelectionRequest */
+ 0, /* SelectionNotify */
+ ColormapChangeMask, /* ColormapNotify */
+ 0, /* ClientMessage */
+ 0, /* MappingNotify */
+};
diff --git a/src/globals.c b/src/globals.c
new file mode 100644
index 00000000..aadfa878
--- /dev/null
+++ b/src/globals.c
@@ -0,0 +1,235 @@
+/* $Xorg: globals.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+Copyright 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+
+/*
+ *
+ * Global data
+ *
+ * This file should contain only those objects which must be predefined.
+ */
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+
+
+/*
+ * If possible, it is useful to have the global data default to a null value.
+ * Some shared library implementations are *much* happier if there isn't any
+ * global initialized data.
+ */
+#ifdef NULL_NOT_ZERO /* then need to initialize */
+#define SetZero(t,var,z) t var = z
+#else
+#define SetZero(t,var,z) t var
+#endif
+
+#ifdef USL_SHAREDLIB /* then need extra variables */
+/*
+ * If we need to define extra variables for each global
+ */
+#if (defined(__STDC__) && !defined(UNIXCPP)) || defined(ANSICPP)
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_##var##Flag, 0); \
+ SetZero (void *, _libX_##var##Ptr, NULL)
+#else /* else pcc concatenation */
+#define ZEROINIT(t,var,val) SetZero(t,var,val); \
+ SetZero (long, _libX_/**/var/**/Flag, 0); \
+ SetZero (void *, _libX_/**/var/**/Ptr, NULL)
+#endif /* concat ANSI C vs. pcc */
+
+#else /* else not USL_SHAREDLIB */
+/*
+ * no extra crud
+ */
+#define ZEROINIT(t,var,val) SetZero (t, var, val)
+
+#endif /* USL_SHAREDLIB */
+
+
+/*
+ * Error handlers; used to be in XlibInt.c
+ */
+ZEROINIT (XErrorHandler, _XErrorFunction, NULL);
+ZEROINIT (XIOErrorHandler, _XIOErrorFunction, NULL);
+ZEROINIT (_XQEvent *, _qfree, NULL);
+
+
+/*
+ * Debugging information and display list; used to be in XOpenDis.c
+ */
+ZEROINIT (int, _Xdebug, 0);
+ZEROINIT (Display *, _XHeadOfDisplayList, NULL);
+
+
+
+#if 0
+#ifdef STREAMSCONN
+
+
+/* The following are how the Xstream connections are used: */
+/* 1) Local connections over pseudo-tty ports. */
+/* 2) SVR4 local connections using named streams or SVR3.2 */
+/* local connections using streams. */
+/* 3) SVR4 stream pipe code. This code is proprietary and */
+/* the actual code is not included in the XC distribution. */
+/* 4) remote connections using tcp */
+/* 5) remote connections using StarLan */
+
+/*
+ * descriptor block for streams connections
+ */
+
+#include "Xstreams.h"
+
+char _XsTypeOfStream[100] = { 0 };
+
+extern int write();
+extern int close();
+#ifdef SVR4
+extern int _XsSetupSpStream();
+extern int _XsSetupNamedStream();
+#endif
+extern int _XsSetupLocalStream();
+extern int _XsConnectLocalClient();
+extern int _XsCallLocalServer();
+extern int _XsReadLocalStream();
+extern int _XsErrorCall();
+extern int _XsWriteLocalStream();
+extern int _XsCloseLocalStream();
+extern int _XsSetupTliStream();
+extern int _XsConnectTliClient();
+extern int _XsCallTliServer();
+extern int _XsReadTliStream();
+extern int _XsWriteTliStream();
+extern int _XsCloseTliStream();
+
+
+Xstream _XsStream[] = {
+
+ {
+ /* local connections using pseudo-ttys */
+
+ _XsSetupLocalStream,
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ {
+#ifdef SVR4
+ /* local connections using named streams */
+
+ _XsSetupNamedStream,
+#else
+ /* local connections using streams */
+ _XsSetupLocalStream,
+#endif
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ /* Enhanced Application Compatibility Support */
+ {
+#ifdef SVR4
+ /* SVR4 stream pipe code */
+ _XsSetupSpStream,
+#else
+ _XsSetupLocalStream,
+#endif
+ _XsConnectLocalClient,
+ _XsCallLocalServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ /* End Enhanced Application Compatibility Support */
+
+ {
+ /* remote connections using tcp */
+ _XsSetupTliStream,
+ _XsConnectTliClient,
+ _XsCallTliServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ },
+ {
+ /* remote connections using StarLan */
+ _XsSetupTliStream,
+ _XsConnectTliClient,
+ _XsCallTliServer,
+ _XsReadLocalStream,
+ _XsErrorCall,
+ write,
+ close,
+ NULL
+ }
+};
+
+
+#endif /* STREAMSCONN */
+#endif
+
+
+#ifdef XTEST1
+/*
+ * Stuff for input synthesis extension:
+ */
+/*
+ * Holds the two event type codes for this extension. The event type codes
+ * for this extension may vary depending on how many extensions are installed
+ * already, so the initial values given below will be added to the base event
+ * code that is aquired when this extension is installed.
+ *
+ * These two variables must be available to programs that use this extension.
+ */
+int XTestInputActionType = 0;
+int XTestFakeAckType = 1;
+#endif
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted BELOW this point!!!
+ */
+
+/*
+ * NOTE: any additional external definition NEED
+ * to be inserted ABOVE this point!!!
+ */
diff --git a/src/imConv.c b/src/imConv.c
new file mode 100644
index 00000000..e16fb4d2
--- /dev/null
+++ b/src/imConv.c
@@ -0,0 +1,897 @@
+/* $Xorg: imConv.c,v 1.5 2000/08/17 19:45:11 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Fuji Xerox Co.,Ltd.
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Fuji Xerox Co.,Ltd.
+, and that the name of FUJITSU LIMITED not be used in advertising or
+publicity pertaining to distribution of the software without specific,
+ written prior permission.
+Fuji Xerox Co.,Ltd. , and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJI XEROX CO.,LTD. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJI XEROX CO.,LTD.
+AND FUJITSU LIMITED 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.
+
+ Auther: Kazunori Nishihara, Fuji Xerox Co.,Ltd.
+ kaz@ssdev.ksp.fujixerox.co.jp
+ Modifier: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#define NEED_EVENTS
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "Ximint.h"
+#include "XlcPubI.h"
+#define XK_PUBLISHING
+#include "X11/keysym.h"
+
+#ifdef XKB
+/*
+ * rather than just call _XLookupString (i.e. the pre-XKB XLookupString)
+ * do this because with XKB the event may have some funky modifiers that
+ * _XLookupString doesn't grok.
+ */
+#include "XKBlib.h"
+#define XLOOKUPSTRING lookup_string
+#else
+#define XLOOKUPSTRING XLookupString
+#endif
+
+/* bit (1<<i) means character is in codeset i */
+unsigned int _Xlatin1[128] = {
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x990ee, 0x88000, 0x89000, 0x89084, 0x0902e, 0x89000, 0x09080, 0x9908e,
+0x0908e, 0x89080, 0x88000, 0x89080, 0x89080, 0x990ee, 0x89000, 0x89008,
+0x9908e, 0x89080, 0x89084, 0x89084, 0x0908e, 0x89004, 0x89000, 0x99084,
+0x0900c, 0x89000, 0x88000, 0x89080, 0x09000, 0x09084, 0x09000, 0x88000,
+0x88004, 0x9800e, 0x9800e, 0x98008, 0x9800e, 0x98008, 0x98008, 0x88006,
+0x88004, 0x9800e, 0x88004, 0x9800e, 0x88004, 0x9800e, 0x9800e, 0x98004,
+0x90000, 0x88004, 0x88004, 0x98006, 0x9800e, 0x98008, 0x9800e, 0x8800e,
+0x98008, 0x88004, 0x9800e, 0x9800c, 0x9800e, 0x90002, 0x90000, 0x9800e,
+0x88004, 0x9800e, 0x9800e, 0x98008, 0x9800e, 0x98008, 0x98008, 0x88004,
+0x88004, 0x9800e, 0x88004, 0x9800e, 0x88004, 0x9800e, 0x9800e, 0x98004,
+0x90000, 0x88004, 0x88004, 0x98006, 0x9800e, 0x98008, 0x9800e, 0x8800e,
+0x98008, 0x88004, 0x9800e, 0x9800c, 0x9800e, 0x90002, 0x90000, 0x88000
+};
+
+/* bit (1<<i) means character is in codeset i */
+unsigned int _Xlatin2[128] = {
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+0x1800c, 0x10008, 0x00004, 0x00000, 0x0800c, 0x00000, 0x00000, 0x1800c,
+0x0800c, 0x00008, 0x00004, 0x00000, 0x00000, 0x1800c, 0x00008, 0x00004,
+0x1800c, 0x10008, 0x00008, 0x00000, 0x0800c, 0x00000, 0x00000, 0x00008,
+0x0800c, 0x00008, 0x00004, 0x00000, 0x00000, 0x00000, 0x00008, 0x00004,
+0x00000, 0x1800c, 0x1800c, 0x00000, 0x1800c, 0x00000, 0x00000, 0x08004,
+0x10008, 0x1800c, 0x10008, 0x1800c, 0x00000, 0x18008, 0x18008, 0x00000,
+0x00008, 0x00000, 0x00000, 0x18004, 0x1800c, 0x00000, 0x1800c, 0x0800c,
+0x00000, 0x00000, 0x0800c, 0x00000, 0x0800c, 0x10000, 0x00000, 0x1800c,
+0x00000, 0x1800c, 0x1800c, 0x00000, 0x1800c, 0x00000, 0x00000, 0x08004,
+0x10008, 0x1800c, 0x10008, 0x1800c, 0x00000, 0x1800c, 0x1800c, 0x00000,
+0x00008, 0x00000, 0x00000, 0x18004, 0x1800c, 0x00000, 0x1800c, 0x0800c,
+0x00000, 0x00000, 0x0800c, 0x00000, 0x0800c, 0x10000, 0x00000, 0x0000c
+};
+
+/* maps Cyrillic keysyms to 8859-5 */
+unsigned char _Xcyrillic[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 - */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 - */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xf2, 0xf3, 0xf1, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xa0 - */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0x00, 0xfe, 0xff,
+ 0xf0, 0xa2, 0xa3, 0xa1, 0xa4, 0xa5, 0xa6, 0xa7, /* 0xb0 - */
+ 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0x00, 0xae, 0xaf,
+ 0xee, 0xd0, 0xd1, 0xe6, 0xd4, 0xd5, 0xe4, 0xd3, /* 0xc0 - */
+ 0xe5, 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde,
+ 0xdf, 0xef, 0xe0, 0xe1, 0xe2, 0xe3, 0xd6, 0xd2, /* 0xd0 - */
+ 0xec, 0xeb, 0xd7, 0xe8, 0xed, 0xe9, 0xe7, 0xea,
+ 0xce, 0xb0, 0xb1, 0xc6, 0xb4, 0xb5, 0xc4, 0xb3, /* 0xe0 - */
+ 0xc5, 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe,
+ 0xbf, 0xcf, 0xc0, 0xc1, 0xc2, 0xc3, 0xb6, 0xb2, /* 0xf0 - */
+ 0xcc, 0xcb, 0xb7, 0xc8, 0xcd, 0xc9, 0xc7, 0xca
+};
+
+/* maps Cyrillic keysyms to KOI8-R */
+unsigned char _Xkoi8[] =
+ {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, /* 10 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x00, /* 11 */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 12 */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, /* 13 */
+ 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf,
+ 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 14 */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, /* 15 */
+ 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff};
+
+unsigned short _Xkoi8_size = sizeof _Xkoi8;
+
+/* maps Greek keysyms to 8859-7 */
+unsigned char _Xgreek[] = {
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x80 - */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, /* 0x90 - */
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xb6, 0xb8, 0xb9, 0xba, 0xda, 0x00, 0xbc, /* 0xa0 - */
+ 0xbe, 0xdb, 0x00, 0xbf, 0x00, 0x00, 0xb5, 0xaf,
+ 0x00, 0xdc, 0xdd, 0xde, 0xdf, 0xfa, 0xc0, 0xfc, /* 0xb0 - */
+ 0xfd, 0xfb, 0xe0, 0xfe, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, /* 0xc0 - */
+ 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf,
+ 0xd0, 0xd1, 0xd3, 0x00, 0xd4, 0xd5, 0xd6, 0xd7, /* 0xd0 - */
+ 0xd8, 0xd9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, /* 0xe0 - */
+ 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef,
+ 0xf0, 0xf1, 0xf3, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7, /* 0xf0 - */
+ 0xf8, 0xf9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
+
+static unsigned short keysym_to_unicode_1a1_1ff[] = {
+ 0x0104, 0x02d8, 0x0141, 0x0000, 0x013d, 0x015a, 0x0000, /* 0x01a0-0x01a7 */
+ 0x0000, 0x0160, 0x015e, 0x0164, 0x0179, 0x0000, 0x017d, 0x017b, /* 0x01a8-0x01af */
+ 0x0000, 0x0105, 0x02db, 0x0142, 0x0000, 0x013e, 0x015b, 0x02c7, /* 0x01b0-0x01b7 */
+ 0x0000, 0x0161, 0x015f, 0x0165, 0x017a, 0x02dd, 0x017e, 0x017c, /* 0x01b8-0x01bf */
+ 0x0154, 0x0000, 0x0000, 0x0102, 0x0000, 0x0139, 0x0106, 0x0000, /* 0x01c0-0x01c7 */
+ 0x010c, 0x0000, 0x0118, 0x0000, 0x011a, 0x0000, 0x0000, 0x010e, /* 0x01c8-0x01cf */
+ 0x0110, 0x0143, 0x0147, 0x0000, 0x0000, 0x0150, 0x0000, 0x0000, /* 0x01d0-0x01d7 */
+ 0x0158, 0x016e, 0x0000, 0x0170, 0x0000, 0x0000, 0x0162, 0x0000, /* 0x01d8-0x01df */
+ 0x0155, 0x0000, 0x0000, 0x0103, 0x0000, 0x013a, 0x0107, 0x0000, /* 0x01e0-0x01e7 */
+ 0x010d, 0x0000, 0x0119, 0x0000, 0x011b, 0x0000, 0x0000, 0x010f, /* 0x01e8-0x01ef */
+ 0x0111, 0x0144, 0x0148, 0x0000, 0x0000, 0x0151, 0x0000, 0x0000, /* 0x01f0-0x01f7 */
+ 0x0159, 0x016f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0163, 0x02d9 /* 0x01f8-0x01ff */
+};
+
+static unsigned short keysym_to_unicode_2a1_2fe[] = {
+ 0x0126, 0x0000, 0x0000, 0x0000, 0x0000, 0x0124, 0x0000, /* 0x02a0-0x02a7 */
+ 0x0000, 0x0130, 0x0000, 0x011e, 0x0134, 0x0000, 0x0000, 0x0000, /* 0x02a8-0x02af */
+ 0x0000, 0x0127, 0x0000, 0x0000, 0x0000, 0x0000, 0x0125, 0x0000, /* 0x02b0-0x02b7 */
+ 0x0000, 0x0131, 0x0000, 0x011f, 0x0135, 0x0000, 0x0000, 0x0000, /* 0x02b8-0x02bf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010a, 0x0108, 0x0000, /* 0x02c0-0x02c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02c8-0x02cf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0120, 0x0000, 0x0000, /* 0x02d0-0x02d7 */
+ 0x011c, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015c, 0x0000, /* 0x02d8-0x02df */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x010b, 0x0109, 0x0000, /* 0x02e0-0x02e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x02e8-0x02ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0121, 0x0000, 0x0000, /* 0x02f0-0x02f7 */
+ 0x011d, 0x0000, 0x0000, 0x0000, 0x0000, 0x016c, 0x015d /* 0x02f8-0x02ff */
+};
+
+static unsigned short keysym_to_unicode_3a2_3fe[] = {
+ 0x0138, 0x0156, 0x0000, 0x0128, 0x013b, 0x0000, /* 0x03a0-0x03a7 */
+ 0x0000, 0x0000, 0x0112, 0x0122, 0x0166, 0x0000, 0x0000, 0x0000, /* 0x03a8-0x03af */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x013c, 0x0000, /* 0x03b0-0x03b7 */
+ 0x0000, 0x0000, 0x0113, 0x0123, 0x0167, 0x014a, 0x0000, 0x014b, /* 0x03b8-0x03bf */
+ 0x0100, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012e, /* 0x03c0-0x03c7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0116, 0x0000, 0x0000, 0x012a, /* 0x03c8-0x03cf */
+ 0x0000, 0x0145, 0x014c, 0x0136, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03d0-0x03d7 */
+ 0x0000, 0x0172, 0x0000, 0x0000, 0x0000, 0x0168, 0x016a, 0x0000, /* 0x03d8-0x03df */
+ 0x0101, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x012f, /* 0x03e0-0x03e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0117, 0x0000, 0x0000, 0x012b, /* 0x03e8-0x03ef */
+ 0x0000, 0x0146, 0x014d, 0x0137, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x03f0-0x03f7 */
+ 0x0000, 0x0173, 0x0000, 0x0000, 0x0000, 0x0169, 0x016b /* 0x03f8-0x03ff */
+};
+
+static unsigned short keysym_to_unicode_4a1_4df[] = {
+ 0x3002, 0x3008, 0x3009, 0x3001, 0x30fb, 0x30f2, 0x30a1, /* 0x04a0-0x04a7 */
+ 0x30a3, 0x03a5, 0x30a7, 0x30a9, 0x30e3, 0x30e5, 0x30e7, 0x30c3, /* 0x04a8-0x04af */
+ 0x30fc, 0x03a2, 0x30a4, 0x30a6, 0x30a8, 0x30aa, 0x30ab, 0x30ad, /* 0x04b0-0x04b7 */
+ 0x30af, 0x30b1, 0x30b3, 0x30b5, 0x30b7, 0x30b9, 0x30bb, 0x30bd, /* 0x04b8-0x04bf */
+ 0x30bf, 0x30c1, 0x30c4, 0x30c6, 0x30c8, 0x30ca, 0x30cb, 0x30cc, /* 0x04c0-0x04c7 */
+ 0x30cd, 0x30ce, 0x30cf, 0x30d2, 0x30d5, 0x30d8, 0x30db, 0x30de, /* 0x04c8-0x04cf */
+ 0x30df, 0x30e0, 0x30e1, 0x30e2, 0x30e4, 0x30e6, 0x30e8, 0x30e9, /* 0x04d0-0x04d7 */
+ 0x30ea, 0x30eb, 0x30ec, 0x30ed, 0x30ef, 0x30f3, 0x309b, 0x309c /* 0x04d8-0x04df */
+};
+
+static unsigned short keysym_to_unicode_5ac_5f2[] = {
+ 0x060c, 0x0000, 0x0000, 0x0000, /* 0x05ac-0x05af */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05b0-0x05b7 */
+ 0x0000, 0x0000, 0x0000, 0x061b, 0x0000, 0x0000, 0x0000, 0x061f, /* 0x05b8-0x05bf */
+ 0x0000, 0x0621, 0x0622, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, /* 0x05c0-0x05c7 */
+ 0x0628, 0x0629, 0x062a, 0x062b, 0x062c, 0x062d, 0x062e, 0x062f, /* 0x05c8-0x05cf */
+ 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, /* 0x05d0-0x05d7 */
+ 0x0638, 0x0639, 0x063a, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x05d8-0x05df */
+ 0x0640, 0x0641, 0x0642, 0x0643, 0x0644, 0x0645, 0x0646, 0x0647, /* 0x05e0-0x05e7 */
+ 0x0648, 0x0649, 0x064a, 0x064b, 0x064c, 0x064d, 0x064e, 0x064f, /* 0x05e8-0x05ef */
+ 0x0650, 0x0651, 0x0652 /* 0x05f0-0x05f7 */
+};
+
+static unsigned short keysym_to_unicode_6a1_6ff[] = {
+ 0x0452, 0x0453, 0x0451, 0x0454, 0x0455, 0x0456, 0x0457, /* 0x06a0-0x06a7 */
+ 0x0458, 0x0459, 0x045a, 0x045b, 0x045c, 0x0000, 0x045e, 0x045f, /* 0x06a8-0x06af */
+ 0x2116, 0x0402, 0x0403, 0x0401, 0x0404, 0x0405, 0x0406, 0x0407, /* 0x06b0-0x06b7 */
+ 0x0408, 0x0409, 0x040a, 0x040b, 0x040c, 0x0000, 0x040e, 0x040f, /* 0x06b8-0x06bf */
+ 0x044e, 0x0430, 0x0431, 0x0446, 0x0434, 0x0435, 0x0444, 0x0433, /* 0x06c0-0x06c7 */
+ 0x0445, 0x0438, 0x0439, 0x043a, 0x043b, 0x043c, 0x043d, 0x043e, /* 0x06c8-0x06cf */
+ 0x043f, 0x044f, 0x0440, 0x0441, 0x0442, 0x0443, 0x0436, 0x0432, /* 0x06d0-0x06d7 */
+ 0x044c, 0x044b, 0x0437, 0x0448, 0x044d, 0x0449, 0x0447, 0x044a, /* 0x06d8-0x06df */
+ 0x042e, 0x0410, 0x0411, 0x0426, 0x0414, 0x0415, 0x0424, 0x0413, /* 0x06e0-0x06e7 */
+ 0x0425, 0x0418, 0x0419, 0x041a, 0x041b, 0x041c, 0x041d, 0x041e, /* 0x06e8-0x06ef */
+ 0x041f, 0x042f, 0x0420, 0x0421, 0x0422, 0x0423, 0x0416, 0x0412, /* 0x06f0-0x06f7 */
+ 0x042c, 0x042d, 0x0417, 0x0428, 0x042d, 0x0429, 0x0427, 0x042a /* 0x06f8-0x06ff */
+};
+
+static unsigned short keysym_to_unicode_7a1_7f9[] = {
+ 0x0386, 0x0388, 0x0389, 0x038a, 0x03aa, 0x0000, 0x038c, /* 0x07a0-0x07a7 */
+ 0x038e, 0x03ab, 0x0000, 0x038f, 0x0000, 0x0000, 0x0385, 0x2015, /* 0x07a8-0x07af */
+ 0x0000, 0x03ac, 0x03ad, 0x03ae, 0x03af, 0x03ca, 0x0390, 0x03cc, /* 0x07b0-0x07b7 */
+ 0x03cd, 0x03cb, 0x03b0, 0x03ce, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07b8-0x07bf */
+ 0x0000, 0x0391, 0x0392, 0x0393, 0x0394, 0x0395, 0x0396, 0x0397, /* 0x07c0-0x07c7 */
+ 0x0398, 0x0399, 0x039a, 0x039b, 0x039c, 0x039d, 0x039e, 0x039f, /* 0x07c8-0x07cf */
+ 0x03a0, 0x03a1, 0x03a2, 0x03a3, 0x03a4, 0x03a5, 0x03a6, 0x03a7, /* 0x07d0-0x07d7 */
+ 0x03a8, 0x03a9, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x07d8-0x07df */
+ 0x0000, 0x03b1, 0x03b2, 0x03b3, 0x03b4, 0x03b5, 0x03b6, 0x03b7, /* 0x07e0-0x07e7 */
+ 0x03b8, 0x03b9, 0x03ba, 0x03bb, 0x03bc, 0x03bd, 0x03be, 0x03bf, /* 0x07e8-0x07ef */
+ 0x03c0, 0x03c1, 0x03c2, 0x03c3, 0x03c4, 0x03c5, 0x03c6, 0x03c7, /* 0x07f0-0x07f7 */
+ 0x03c8, 0x03c9 /* 0x07f8-0x07ff */
+};
+
+static unsigned short keysym_to_unicode_8a4_8fe[] = {
+ 0x2320, 0x2321, 0x0000, 0x231c, /* 0x08a0-0x08a7 */
+ 0x231d, 0x231e, 0x231f, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08a8-0x08af */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08b0-0x08b7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x2264, 0x2260, 0x2265, 0x222b, /* 0x08b8-0x08bf */
+ 0x2234, 0x0000, 0x221e, 0x0000, 0x0000, 0x2207, 0x0000, 0x0000, /* 0x08c0-0x08c7 */
+ 0x2245, 0x2246, 0x0000, 0x0000, 0x0000, 0x0000, 0x22a2, 0x0000, /* 0x08c8-0x08cf */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x221a, 0x0000, /* 0x08d0-0x08d7 */
+ 0x0000, 0x0000, 0x2282, 0x2283, 0x2229, 0x222a, 0x2227, 0x2228, /* 0x08d8-0x08df */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e0-0x08e7 */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, /* 0x08e8-0x08ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0192, 0x0000, /* 0x08f0-0x08f7 */
+ 0x0000, 0x0000, 0x0000, 0x2190, 0x2191, 0x2192, 0x2193 /* 0x08f8-0x08ff */
+};
+
+static unsigned short keysym_to_unicode_9df_9f8[] = {
+ 0x2422, /* 0x09d8-0x09df */
+ 0x2666, 0x25a6, 0x2409, 0x240c, 0x240d, 0x240a, 0x0000, 0x0000, /* 0x09e0-0x09e7 */
+ 0x240a, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, 0x2500, /* 0x09e8-0x09ef */
+ 0x0000, 0x0000, 0x0000, 0x0000, 0x251c, 0x2524, 0x2534, 0x252c, /* 0x09f0-0x09f7 */
+ 0x2502 /* 0x09f8-0x09ff */
+};
+
+static unsigned short keysym_to_unicode_aa1_afe[] = {
+ 0x2003, 0x2002, 0x2004, 0x2005, 0x2007, 0x2008, 0x2009, /* 0x0aa0-0x0aa7 */
+ 0x200a, 0x2014, 0x2013, 0x0000, 0x0000, 0x0000, 0x2026, 0x2025, /* 0x0aa8-0x0aaf */
+ 0x2153, 0x2154, 0x2155, 0x2156, 0x2157, 0x2158, 0x2159, 0x215a, /* 0x0ab0-0x0ab7 */
+ 0x2105, 0x0000, 0x0000, 0x2012, 0x2039, 0x2024, 0x203a, 0x0000, /* 0x0ab8-0x0abf */
+ 0x0000, 0x0000, 0x0000, 0x215b, 0x215c, 0x215d, 0x215e, 0x0000, /* 0x0ac0-0x0ac7 */
+ 0x0000, 0x2122, 0x2120, 0x00ae, 0x25c1, 0x25b7, 0x25cb, 0x25ad, /* 0x0ac8-0x0acf */
+ 0x2018, 0x2019, 0x201c, 0x201d, 0x211e, 0x0000, 0x2032, 0x2033, /* 0x0ad0-0x0ad7 */
+ 0x0000, 0x271d, 0x0000, 0x220e, 0x25c2, 0x2023, 0x25cf, 0x25ac, /* 0x0ad8-0x0adf */
+ 0x25e6, 0x25ab, 0x25ae, 0x25b5, 0x25bf, 0x2606, 0x2022, 0x25aa, /* 0x0ae0-0x0ae7 */
+ 0x25b4, 0x25be, 0x261a, 0x261b, 0x2663, 0x2666, 0x2665, 0x0000, /* 0x0ae8-0x0aef */
+ 0x2720, 0x2020, 0x2021, 0x2713, 0x2612, 0x266f, 0x266d, 0x2642, /* 0x0af0-0x0af7 */
+ 0x2640, 0x2121, 0x2315, 0x2117, 0x2038, 0x201a, 0x201e /* 0x0af8-0x0aff */
+};
+
+/* none of the APL keysyms match the Unicode characters */
+
+static unsigned short keysym_to_unicode_cdf_cfa[] = {
+ 0x2017, /* 0x0cd8-0x0cdf */
+ 0x05d0, 0x05d1, 0x05d2, 0x05d3, 0x05d4, 0x05d5, 0x05d6, 0x05d7, /* 0x0ce0-0x0ce7 */
+ 0x05d8, 0x05d9, 0x05da, 0x05db, 0x05dc, 0x05dd, 0x05de, 0x05df, /* 0x0ce8-0x0cef */
+ 0x05e0, 0x05e1, 0x05e2, 0x05e3, 0x05e4, 0x05e5, 0x05e6, 0x05e7, /* 0x0cf0-0x0cf7 */
+ 0x05e8, 0x05e9, 0x05ea /* 0x0cf8-0x0cff */
+};
+
+static unsigned short keysym_to_unicode_da1_df9[] = {
+ 0x0e01, 0x0e02, 0x0e03, 0x0e04, 0x0e05, 0x0e06, 0x0e07, /* 0x0da0-0x0da7 */
+ 0x0e08, 0x0e09, 0x0e0a, 0x0e0b, 0x0e0c, 0x0e0d, 0x0e0e, 0x0e0f, /* 0x0da8-0x0daf */
+ 0x0e10, 0x0e11, 0x0e12, 0x0e13, 0x0e14, 0x0e15, 0x0e16, 0x0e17, /* 0x0db0-0x0db7 */
+ 0x0e18, 0x0e19, 0x0e1a, 0x0e1b, 0x0e1c, 0x0e1d, 0x0e1e, 0x0e1f, /* 0x0db8-0x0dbf */
+ 0x0e20, 0x0e21, 0x0e22, 0x0e23, 0x0e24, 0x0e25, 0x0e26, 0x0e27, /* 0x0dc0-0x0dc7 */
+ 0x0e28, 0x0e29, 0x0e2a, 0x0e2b, 0x0e2c, 0x0e2d, 0x0e2e, 0x0e2f, /* 0x0dc8-0x0dcf */
+ 0x0e30, 0x0e31, 0x0e32, 0x0e33, 0x0e34, 0x0e35, 0x0e36, 0x0e37, /* 0x0dd0-0x0dd7 */
+ 0x0e38, 0x0e39, 0x0e3a, 0x0e3b, 0x0e3c, 0x0e3d, 0x0e3e, 0x0e3f, /* 0x0dd8-0x0ddf */
+ 0x0e40, 0x0e41, 0x0e42, 0x0e43, 0x0e44, 0x0e45, 0x0e46, 0x0e47, /* 0x0de0-0x0de7 */
+ 0x0e48, 0x0e49, 0x0e4a, 0x0e4b, 0x0e4c, 0x0e4d, 0x0000, 0x0000, /* 0x0de8-0x0def */
+ 0x0e50, 0x0e51, 0x0e52, 0x0e53, 0x0e54, 0x0e55, 0x0e56, 0x0e57, /* 0x0df0-0x0df7 */
+ 0x0e58, 0x0e59 /* 0x0df8-0x0dff */
+};
+
+static unsigned short keysym_to_unicode_ea0_eff[] = {
+ 0x0000, 0x1101, 0x1101, 0x11aa, 0x1102, 0x11ac, 0x11ad, 0x1103, /* 0x0ea0-0x0ea7 */
+ 0x1104, 0x1105, 0x11b0, 0x11b1, 0x11b2, 0x11b3, 0x11b4, 0x11b5, /* 0x0ea8-0x0eaf */
+ 0x11b6, 0x1106, 0x1107, 0x1108, 0x11b9, 0x1109, 0x110a, 0x110b, /* 0x0eb0-0x0eb7 */
+ 0x110c, 0x110d, 0x110e, 0x110f, 0x1110, 0x1111, 0x1112, 0x1161, /* 0x0eb8-0x0ebf */
+ 0x1162, 0x1163, 0x1164, 0x1165, 0x1166, 0x1167, 0x1168, 0x1169, /* 0x0ec0-0x0ec7 */
+ 0x116a, 0x116b, 0x116c, 0x116d, 0x116e, 0x116f, 0x1170, 0x1171, /* 0x0ec8-0x0ecf */
+ 0x1172, 0x1173, 0x1174, 0x1175, 0x11a8, 0x11a9, 0x11aa, 0x11ab, /* 0x0ed0-0x0ed7 */
+ 0x11ac, 0x11ad, 0x11ae, 0x11af, 0x11b0, 0x11b1, 0x11b2, 0x11b3, /* 0x0ed8-0x0edf */
+ 0x11b4, 0x11b5, 0x11b6, 0x11b7, 0x11b8, 0x11b9, 0x11ba, 0x11bb, /* 0x0ee0-0x0ee7 */
+ 0x11bc, 0x11bd, 0x11be, 0x11bf, 0x11c0, 0x11c1, 0x11c2, 0x0000, /* 0x0ee8-0x0eef */
+ 0x0000, 0x0000, 0x1140, 0x0000, 0x0000, 0x1159, 0x119e, 0x0000, /* 0x0ef0-0x0ef7 */
+ 0x11eb, 0x0000, 0x11f9, 0x0000, 0x0000, 0x0000, 0x0000, 0x20a9, /* 0x0ef8-0x0eff */
+};
+
+static unsigned short keysym_to_unicode_13bc_13be[] = {
+ 0x0152, 0x0153, 0x0178 /* 0x13b8-0x13bf */
+};
+
+static unsigned short keysym_to_unicode_20a0_20ac[] = {
+ 0x20a0, 0x20a1, 0x20a2, 0x20a3, 0x20a4, 0x20a5, 0x20a6, 0x20a7, /* 0x20a0-0x20a7 */
+ 0x20a8, 0x20a9, 0x20aa, 0x20ab, 0x20ac /* 0x20a8-0x20af */
+};
+
+static int keysym_to_ucs4(keysym)
+ KeySym keysym;
+{
+ if (keysym > 0 && keysym < 0x100)
+ return keysym;
+ else if (keysym > 0x1a0 && keysym < 0x200)
+ return keysym_to_unicode_1a1_1ff[keysym - 0x1a1];
+ else if (keysym > 0x2a0 && keysym < 0x2ff)
+ return keysym_to_unicode_2a1_2fe[keysym - 0x2a1];
+ else if (keysym > 0x3a1 && keysym < 0x3ff)
+ return keysym_to_unicode_3a2_3fe[keysym - 0x3a2];
+ else if (keysym > 0x4a0 && keysym < 0x4e0)
+ return keysym_to_unicode_4a1_4df[keysym - 0x4a1];
+ else if (keysym > 0x5ab && keysym < 0x5f3)
+ return keysym_to_unicode_5ac_5f2[keysym - 0x5ac];
+ else if (keysym > 0x6a0 && keysym < 0x700)
+ return keysym_to_unicode_6a1_6ff[keysym - 0x6a1];
+ else if (keysym > 0x7a0 && keysym < 0x7fa)
+ return keysym_to_unicode_7a1_7f9[keysym - 0x7a1];
+ else if (keysym > 0x8a3 && keysym < 0x8ff)
+ return keysym_to_unicode_8a4_8fe[keysym - 0x8a4];
+ else if (keysym > 0x9de && keysym < 0x9f9)
+ return keysym_to_unicode_9df_9f8[keysym - 0x9df];
+ else if (keysym > 0xaa0 && keysym < 0xaff)
+ return keysym_to_unicode_aa1_afe[keysym - 0xaa1];
+ else if (keysym > 0xcde && keysym < 0xcfb)
+ return keysym_to_unicode_cdf_cfa[keysym - 0xcdf];
+ else if (keysym > 0xda0 && keysym < 0xdfa)
+ return keysym_to_unicode_da1_df9[keysym - 0xda1];
+ else if (keysym > 0xe9f && keysym < 0xf00)
+ return keysym_to_unicode_ea0_eff[keysym - 0xea0];
+ else if (keysym > 0x13bb && keysym < 0x13bf)
+ return keysym_to_unicode_13bc_13be[keysym - 0x13bc];
+ else if (keysym > 0x209f && keysym < 0x20ad)
+ return keysym_to_unicode_20a0_20ac[keysym - 0x20a0];
+ else
+ return 0;
+}
+
+struct CodesetRec {
+ unsigned long locale_code;
+ char* locale_name;
+ char* escape_seq;
+};
+
+#define sLatin1 0L
+#define sLatin2 1L
+#define sLatin3 2L
+#define sLatin4 3L
+#define sKana 4L
+#define sX0201 0x01000004L
+#define sArabic 5L
+#define sCyrillic 6L
+#define sKoi8 0x01000006L
+#define sGreek 7L
+#define sHebrew 12L
+#define sThai 13L
+#define sKorean 14L
+#define sLatin5 15L
+#define sLatin6 16L
+#define sLatin7 17L
+#define sLatin8 18L
+#define sLatin9 19L
+#define sCurrency 32L
+#define sUTF8 0x02000000L
+
+static struct CodesetRec CodesetTable[] = {
+ {sLatin1, "ISO8859-1", "\033-A"},
+ {sLatin2, "ISO8859-2", "\033-B"},
+ {sLatin3, "ISO8859-3", "\033-C"},
+ {sLatin4, "ISO8859-4", "\033-D"},
+ {sArabic, "ISO8859-6", "\033-G"},
+ {sCyrillic, "ISO8859-5", "\033-L"},
+ {sGreek, "ISO8859-7", "\033-F"},
+ {sHebrew, "ISO8859-8", "\033-H"},
+ {sLatin5, "ISO8859-9", "\033-M"},
+ {sLatin6, "ISO8859-10", "\033-V"},
+ {sThai, "TACTIS", "\033-T"},
+ {sKorean, "ko.euc", "\033$(C"},
+ {sThai, "ISO8859-11", "\033-T"},
+#if 0
+ {sLatin8, "ISO8859-12", "\033-?"},/* Celtic, superceded by -14 */
+ {sLatin7, "ISO8859-13", "\033-?"},/* Baltic Rim */
+ {sLatin8 "ISO8859-14", "\033-?"},/* Celtic */
+#endif
+ {sUTF8, "utf8", "\033%B"},
+ /* Non-standard */
+ {sKoi8, "KOI8-R", "\033%/1\200\210koi8-r\002"},
+ {sLatin9, "FCD8859-15", "\033%/1\200\213fcd8859-15\002"},/* a.k.a. Latin-0 */
+};
+
+#define NUM_CODESETS sizeof CodesetTable / sizeof CodesetTable[0]
+
+#ifndef XK_emdash
+#define XK_emdash 0xaa9
+#endif
+
+
+/* ================================================================ */
+/*
+File: ConvertUTF.C
+Author: Mark E. Davis
+Copyright (C) 1994 Taligent, Inc. All rights reserved.
+
+This code is copyrighted. Under the copyright laws, this code may not
+be copied, in whole or part, without prior written consent of Taligent.
+
+Taligent grants the right to use or reprint this code as long as this
+ENTIRE copyright notice is reproduced in the code or reproduction.
+The code is provided AS-IS, AND TALIGENT DISCLAIMS ALL WARRANTIES,
+EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN
+NO EVENT WILL TALIGENT BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING,
+WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
+INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
+LOSS) ARISING OUT OF THE USE OR INABILITY TO USE THIS CODE, EVEN
+IF TALIGENT HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
+BECAUSE SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF
+LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES, THE ABOVE
+LIMITATION MAY NOT APPLY TO YOU.
+
+RESTRICTED RIGHTS LEGEND: Use, duplication, or disclosure by the
+government is subject to restrictions as set forth in subparagraph
+(c)(l)(ii) of the Rights in Technical Data and Computer Software
+clause at DFARS 252.227-7013 and FAR 52.227-19.
+
+This code may be protected by one or more U.S. and International
+Patents.
+
+TRADEMARKS: Taligent and the Taligent Design Mark are registered
+trademarks of Taligent, Inc.
+*/
+/* ================================================================ */
+
+#define kReplacementCharacter 0x0000FFFDUL
+#define kMaximumUCS2 0x0000FFFFUL
+#define kMaximumUCS4 0x7FFFFFFFUL
+
+typedef enum {
+ ok, /* conversion successful */
+ sourceExhausted, /* partial character in source, but hit end */
+ targetExhausted /* insuff. room in target for conversion */
+} ConversionResult;
+
+#define halfShift 10
+#define halfBase 0x0010000UL
+#define halfMask 0x3FFUL
+#define kSurrogateHighStart 0xD800UL
+#define kSurrogateHighEnd 0xDBFFUL
+#define kSurrogateLowStart 0xDC00UL
+#define kSurrogateLowEnd 0xDFFFUL
+
+typedef unsigned int UCS4; /* wchar_t, but on AIX, SunOS wchar_t is 16 bits */
+typedef unsigned char UTF8;
+
+static UCS4 offsetsFromUTF8[6] = {
+ 0x00000000UL, 0x00003080UL, 0x000E2080UL,
+ 0x03C82080UL, 0xFA082080UL, 0x82082080UL
+};
+
+static char bytesFromUTF8[256] = {
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
+ 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1, 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,
+ 2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2, 3,3,3,3,3,3,3,3,4,4,4,4,5,5,5,5
+};
+
+static UTF8 firstByteMark[7] = {
+ 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC
+};
+
+static ConversionResult ConvertUCS4toUTF8 (
+ UCS4** sourceStart, UCS4* sourceEnd,
+ UTF8** targetStart, UTF8* targetEnd)
+{
+ ConversionResult result = ok;
+ register UCS4* source = *sourceStart;
+ register UTF8* target = *targetStart;
+ while (source < sourceEnd) {
+ register UCS4 ch;
+ register unsigned short bytesToWrite = 0;
+ register const UCS4 byteMask = 0xBF;
+ register const UCS4 byteMark = 0x80;
+ ch = *source++;
+ if (ch >= kSurrogateHighStart && ch <= kSurrogateHighEnd
+ && source < sourceEnd) {
+ register UCS4 ch2 = *source;
+ if (ch2 >= kSurrogateLowStart && ch2 <= kSurrogateLowEnd) {
+ ch = ((ch - kSurrogateHighStart) << halfShift)
+ + (ch2 - kSurrogateLowStart) + halfBase;
+ ++source;
+ };
+ };
+ if (ch < 0x80) { bytesToWrite = 1;
+ } else if (ch < 0x800) { bytesToWrite = 2;
+ } else if (ch < 0x10000) { bytesToWrite = 3;
+ } else if (ch < 0x200000) { bytesToWrite = 4;
+ } else if (ch < 0x4000000) { bytesToWrite = 5;
+ } else if (ch <= kMaximumUCS4){ bytesToWrite = 6;
+ } else { bytesToWrite = 2;
+ ch = kReplacementCharacter;
+ }; /* I wish there were a smart way to avoid this conditional */
+
+ target += bytesToWrite;
+ if (target > targetEnd) {
+ target -= bytesToWrite; result = targetExhausted; break;
+ };
+ switch (bytesToWrite) { /* note: code falls through cases! */
+ case 6: *--target = (ch | byteMark) & byteMask; ch >>= 6;
+ case 5: *--target = (ch | byteMark) & byteMask; ch >>= 6;
+ case 4: *--target = (ch | byteMark) & byteMask; ch >>= 6;
+ case 3: *--target = (ch | byteMark) & byteMask; ch >>= 6;
+ case 2: *--target = (ch | byteMark) & byteMask; ch >>= 6;
+ case 1: *--target = ch | firstByteMark[bytesToWrite];
+ };
+ target += bytesToWrite;
+ };
+ *sourceStart = source;
+ *targetStart = target;
+ return result;
+}
+
+/*ARGSUSED*/
+int
+#if NeedFunctionPrototypes
+_XGetCharCode (
+ unsigned long locale_code,
+ KeySym keysym,
+ unsigned char* buf,
+ int nbytes)
+#else
+_XGetCharCode (locale_code, keysym, buf, nbytes)
+ unsigned long locale_code;
+ KeySym keysym;
+ unsigned char *buf;
+ int nbytes;
+#endif
+{
+ unsigned long kset;
+ int count,isLatin1;
+
+ if (locale_code == sUTF8) {
+ unsigned int ucs4[2];
+ unsigned int* ucs4vec[1];
+ unsigned char* utf8vec[1];
+
+ ucs4[0] = keysym_to_ucs4 (keysym);
+ ucs4[1] = 0;
+ ucs4vec[0] = ucs4;
+ utf8vec[0] = buf;
+
+ (void) ConvertUCS4toUTF8 (ucs4vec, &ucs4[1], utf8vec, &buf[nbytes]);
+ return (strlen ((char*) buf));
+ }
+
+ kset = locale_code&0xffffff;
+
+ isLatin1 = ((keysym&0xffffff00)==0);
+ count = 0;
+
+ if ( keysym == NoSymbol )
+ return 0;
+ else if ((keysym >> 8) == kset) {
+ count = 1;
+ switch (kset) {
+ case sKana:
+ *buf = (unsigned char)(keysym & 0xff);
+ if (buf[0] == 0x7e)
+ count = 0;
+ break;
+ case sCyrillic:
+ if (locale_code == sKoi8)
+ *buf = _Xkoi8[keysym & 0x7f];
+ else
+ *buf = _Xcyrillic[keysym & 0x7f];
+ break;
+ case sGreek:
+ *buf = _Xgreek[keysym & 0x7f];
+ if (!buf[0])
+ count = 0;
+ break;
+ default:
+ *buf = (unsigned char)(keysym & 0xff);
+ break;
+ }
+ } else if ((locale_code != 0) && (isLatin1) && (keysym & 0x80)) {
+ if (_Xlatin1[keysym & 0x7f] & (1 << kset)) {
+ /* Most non-latin1 locales use some latin-1 upper half
+ keysyms as defined by bitpatterns in array latin1.
+ Enforce it. */
+ *buf = (unsigned char)(keysym & 0xff);
+ count = 1;
+ } else {
+ count= 1;
+ if ((locale_code == sHebrew) && (keysym == XK_multiply))
+ *buf = (unsigned char)0xaa;
+ else if ((locale_code == sHebrew) && (keysym == XK_division))
+ *buf = (unsigned char)0xba;
+ else if ((locale_code == sCyrillic) && (keysym == XK_section))
+ *buf = (unsigned char)0xfd;
+ else if ((locale_code == sX0201) && (keysym == XK_yen))
+ *buf = (unsigned char)0x5c;
+ else count = 0;
+ }
+ } else if (isLatin1) {
+ if ((locale_code == sX0201) &&
+ ((keysym == XK_backslash) || (keysym == XK_asciitilde)))
+ count = 0;
+ if ( (keysym&0x80)==0 ) {
+ *buf = (unsigned char)(keysym&0x7f);
+ count = 1;
+ }
+ } else if ((keysym >> 8) == sLatin2) {
+ count = 1;
+ if ((keysym & 0x80) && (_Xlatin2[keysym & 0x7f] & (1 << kset)))
+ *buf = (unsigned char)(keysym & 0xff);
+ else if (locale_code == sLatin5) {
+ if (keysym == XK_Scedilla)
+ *buf = (unsigned char)0xde;
+ else if (keysym == XK_scedilla)
+ *buf = (unsigned char)0xfe;
+ else count = 0;
+ } else if (locale_code == sLatin9) {
+ if (keysym == XK_Scaron)
+ *buf = (unsigned char)0xa6;
+ else if (keysym == XK_scaron)
+ *buf = (unsigned char)0xa8;
+ else if (keysym == XK_Zcaron)
+ *buf = (unsigned char)0xb4;
+ else if (keysym == XK_zcaron)
+ *buf = (unsigned char)0xb8;
+ else count = 0;
+ } else count = 0;
+ } else if ((keysym >> 8) == sLatin3) {
+ if (locale_code == sLatin5) {
+ count = 1;
+ switch (keysym) {
+ case XK_Gbreve: *buf = (unsigned char)0xd0; break;
+ case XK_gbreve: *buf = (unsigned char)0xf0; break;
+ case XK_Scedilla: *buf = (unsigned char)0xde; break;
+ case XK_scedilla: *buf = (unsigned char)0xfe; break;
+ case XK_Iabovedot: *buf = (unsigned char)0xdd; break;
+ case XK_idotless: *buf = (unsigned char)0xfd; break;
+ default: count = 0;
+ }
+ }
+ } else if ((keysym >> 8) == sLatin4) {
+ if (locale_code == sLatin6) {
+ count = 1;
+ switch (keysym) {
+ case XK_Emacron: *buf = (unsigned char)0xa2; break;
+ case XK_Gcedilla: *buf = (unsigned char)0xa3; break;
+ case XK_Imacron: *buf = (unsigned char)0xa4; break;
+ case XK_Lcedilla: *buf = (unsigned char) 0xa8; break;
+ case XK_Dstroke: *buf = (unsigned char)0xa9; break;
+ case XK_Scaron: *buf = (unsigned char)0xaa; break;
+ case XK_Tslash: *buf = (unsigned char)0xab; break;
+ case XK_Zcaron: *buf = (unsigned char)0xac; break;
+ case XK_Umacron: *buf = (unsigned char)0xae; break;
+ case XK_Utilde: *buf = (unsigned char)0xd7; break;
+ case XK_ENG: *buf = (unsigned char)0xaf; break;
+ case XK_emacron: *buf = (unsigned char)0xb2; break;
+ case XK_gcedilla: *buf = (unsigned char)0xb3; break;
+ case XK_imacron: *buf = (unsigned char)0xb4; break;
+ case XK_lcedilla: *buf = (unsigned char) 0xb8; break;
+ case XK_dstroke: *buf = (unsigned char)0xb9; break;
+ case XK_scaron: *buf = (unsigned char)0xba; break;
+ case XK_tslash: *buf = (unsigned char)0xbb; break;
+ case XK_zcaron: *buf = (unsigned char)0xbc; break;
+ case XK_umacron: *buf = (unsigned char)0xbe; break;
+ case XK_utilde: *buf = (unsigned char)0xf7; break;
+ case XK_eng: *buf = (unsigned char)0xbf; break;
+ case XK_kra: *buf = (unsigned char)0xff; break;
+ case XK_Itilde:
+ case XK_Kcedilla:
+ case XK_Iogonek:
+ case XK_Ncedilla:
+ case XK_Omacron:
+ case XK_Uogonek:
+ case XK_itilde:
+ case XK_kcedilla:
+ case XK_iogonek:
+ case XK_ncedilla:
+ case XK_omacron:
+ case XK_uogonek: *buf = (unsigned char)(keysym & 0xff); break;
+ default: count = 0;
+ }
+ }
+ } else if (locale_code == sLatin9 && keysym == XK_EuroSign) {
+ count = 1;
+ *buf = (unsigned char)0xa4;
+ } else if ((locale_code == sGreek) &&
+ ((keysym == XK_leftsinglequotemark) ||
+ (keysym == XK_rightsinglequotemark))) {
+ *buf = (unsigned char)(keysym - (XK_leftsinglequotemark - 0xa1));
+ count = 1;
+ }
+ if (count>nbytes)
+ return nbytes;
+ if (count<nbytes)
+ buf[count]= '\0';
+ return count;
+}
+
+#ifdef XKB
+static int lookup_string (event, buffer, nbytes, keysym, status)
+ XKeyEvent* event;
+ char* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int ret;
+ unsigned ctrls = XkbGetXlibControls (event->display);
+ XkbSetXlibControls (event->display,
+ XkbLC_ForceLatin1Lookup, XkbLC_ForceLatin1Lookup);
+ ret = XLookupString(event, buffer, nbytes, keysym, status);
+ XkbSetXlibControls (event->display, ctrls, ctrls);
+ return ret;
+}
+#endif
+
+#define BUF_SIZE (20)
+
+int
+_XimLookupMBText(ic, event, buffer, nbytes, keysym, status)
+ Xic ic;
+ XKeyEvent* event;
+ char* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int count, local_count;
+ KeySym symbol;
+ struct CodesetRec *cset;
+ int i;
+ Status dummy;
+ Xim im = (Xim)ic->core.im;
+ XLCd lcd = im->core.lcd;
+ unsigned char local_buf[BUF_SIZE];
+ unsigned char look[BUF_SIZE];
+
+
+ /* force a latin-1 lookup for compatibility */
+ count = XLOOKUPSTRING(event, (char *)buffer, nbytes, &symbol, status);
+ if (keysym != NULL) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+ for (cset = NULL, i = 0; i < NUM_CODESETS; i++) {
+ if (strcmp (XLC_PUBLIC(lcd,encoding_name), CodesetTable[i].locale_name) == 0) {
+ cset = &CodesetTable[i];
+ break;
+ }
+ }
+ if (count == 0 && cset != NULL ||
+ (count == 1 && (symbol > 0x7f && symbol < 0xff00) &&
+ cset != NULL && cset->locale_code != 0)) {
+ if ((count = _XGetCharCode(cset->locale_code, symbol,
+ look, sizeof look))) {
+ strcpy((char*) local_buf, cset->escape_seq);
+ local_count = strlen(cset->escape_seq);
+ local_buf[local_count] = look[0];
+ local_count++;
+ local_buf[local_count] = '\0';
+ if ((count = im->methods->ctstombs(ic->core.im,
+ (char*) local_buf, local_count,
+ (char *)buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ }
+ } else if (count > 1) { /* not ASCII Encoding */
+ memcpy(look, (char *)buffer,count);
+ look[count] = '\0';
+ if ((count = im->methods->ctstombs(ic->core.im,
+ (char*) look, count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ }
+ /*
+ * we should make sure that if the character is a Latin1 character
+ * and it's on the right side, and we're in a non-Latin1 locale
+ * that this is a valid Latin1 character for this locale.
+ */
+ return count;
+}
+
+int
+_XimLookupWCText(ic, event, buffer, nbytes, keysym, status)
+ Xic ic;
+ XKeyEvent* event;
+ wchar_t* buffer;
+ int nbytes;
+ KeySym* keysym;
+ XComposeStatus* status;
+{
+ int count, local_count;
+ KeySym symbol;
+ struct CodesetRec *cset;
+ int i;
+ Status dummy;
+ Xim im = (Xim)ic->core.im;
+ XLCd lcd = im->core.lcd;
+ unsigned char local_buf[BUF_SIZE];
+ unsigned char look[BUF_SIZE];
+
+ /* force a latin-1 lookup for compatibility */
+ count = XLOOKUPSTRING(event, (char *)look, nbytes, &symbol, status);
+ if (keysym != NULL) *keysym = symbol;
+ if ((nbytes == 0) || (symbol == NoSymbol)) return count;
+
+ for (cset = NULL, i = 0; i < NUM_CODESETS; i++) {
+ if (strcmp (XLC_PUBLIC(lcd,encoding_name), CodesetTable[i].locale_name) == 0) {
+ cset = &CodesetTable[i];
+ break;
+ }
+ }
+ if (count == 0 && cset != NULL ||
+ (count == 1 && (symbol > 0x7f && symbol < 0xff00) &&
+ cset != NULL && cset->locale_code != 0)) {
+ if ((count = _XGetCharCode(cset->locale_code, symbol,
+ look, sizeof look))) {
+ strcpy((char*) local_buf, cset->escape_seq);
+ local_count = strlen(cset->escape_seq);
+ local_buf[local_count] = look[0];
+ local_count++;
+ local_buf[local_count] = '\0';
+ if ((count = im->methods->ctstowcs(ic->core.im,
+ (char*) local_buf, local_count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ }
+ } else if (count > 1) {
+ if ((count = im->methods->ctstowcs(ic->core.im,
+ (char*) look, count,
+ buffer, nbytes, &dummy)) < 0) {
+ count = 0;
+ }
+ } else
+ /*
+ * we should make sure that if the character is a Latin1 character
+ * and it's on the right side, and we're in a non-Latin1 locale
+ * that this is a valid Latin1 character for this locale.
+ */
+ buffer[0] = look[0];
+
+ return count;
+}
diff --git a/src/locking.c b/src/locking.c
new file mode 100644
index 00000000..96926975
--- /dev/null
+++ b/src/locking.c
@@ -0,0 +1,642 @@
+/* $Xorg: locking.c,v 1.5 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * locking.c - multi-thread locking routines implemented in C Threads
+ */
+
+#include "Xlibint.h"
+#undef _XLockMutex
+#undef _XUnlockMutex
+#undef _XCreateMutex
+#undef _XFreeMutex
+
+#ifdef XTHREADS
+
+#include "locking.h"
+#ifdef XTHREADS_WARN
+#include <stdio.h> /* for warn/debug stuff */
+#endif
+
+#define NUM_FREE_CVLS 4
+
+/* in XOpenDis.c */
+extern int (*_XInitDisplayLock_fn)();
+extern void (*_XFreeDisplayLock_fn)();
+
+/* in lcWrap.c */
+extern LockInfoPtr _Xi18n_lock;
+
+#ifdef WIN32
+static DWORD _X_TlsIndex = (DWORD)-1;
+
+_Xthread_init()
+{
+ if (_X_TlsIndex == (DWORD)-1)
+ _X_TlsIndex = TlsAlloc();
+}
+
+struct _xthread_waiter *
+_Xthread_waiter()
+{
+ struct _xthread_waiter *me;
+
+ if (!(me = TlsGetValue(_X_TlsIndex))) {
+ me = (struct _xthread_waiter *)xmalloc(sizeof(struct _xthread_waiter));
+ me->sem = CreateSemaphore(NULL, 0, 1, NULL);
+ me->next = NULL;
+ TlsSetValue(_X_TlsIndex, me);
+ }
+ return me;
+}
+#endif /* WIN32 */
+
+static xthread_t _Xthread_self()
+{
+ return xthread_self();
+}
+
+static LockInfoRec global_lock;
+static LockInfoRec i18n_lock;
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XLockMutex(lip,file,line)
+ LockInfoPtr lip;
+ char* file;
+ int line;
+#else
+static void _XLockMutex(lip)
+ LockInfoPtr lip;
+#endif
+{
+ xmutex_lock(lip->lock);
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XUnlockMutex(lip,file,line)
+ LockInfoPtr lip;
+ char* file;
+ int line;
+#else
+static void _XUnlockMutex(lip)
+ LockInfoPtr lip;
+#endif
+{
+ xmutex_unlock(lip->lock);
+}
+
+static void _XCreateMutex(lip)
+ LockInfoPtr lip;
+{
+ lip->lock = xmutex_malloc();
+ if (lip->lock) {
+ xmutex_init(lip->lock);
+ xmutex_set_name(lip->lock, "Xlib");
+ }
+}
+
+static void _XFreeMutex(lip)
+ LockInfoPtr lip;
+{
+ xmutex_clear(lip->lock);
+ xmutex_free(lip->lock);
+}
+
+#ifdef XTHREADS_WARN
+static char *locking_file;
+static int locking_line;
+static xthread_t locking_thread;
+static Bool xlibint_unlock = False; /* XlibInt.c may Unlock and re-Lock */
+
+/* history that is useful to examine in a debugger */
+#define LOCK_HIST_SIZE 21
+
+static struct {
+ Bool lockp; /* True for lock, False for unlock */
+ xthread_t thread;
+ char *file;
+ int line;
+} locking_history[LOCK_HIST_SIZE];
+
+int lock_hist_loc = 0; /* next slot to fill */
+
+static void _XLockDisplayWarn(dpy,file,line)
+ Display *dpy;
+ char *file; /* source file, from macro */
+ int line;
+{
+ xthread_t self;
+ xthread_t old_locker;
+
+ self = xthread_self();
+ old_locker = locking_thread;
+ if (xthread_have_id(old_locker)) {
+ if (xthread_equal(old_locker, self))
+ printf("Xlib ERROR: %s line %d thread %x: locking display already locked at %s line %d\n",
+ file, line, self, locking_file, locking_line);
+#ifdef XTHREADS_DEBUG
+ else
+ printf("%s line %d: thread %x waiting on lock held by %s line %d thread %x\n",
+ file, line, self,
+ locking_file, locking_line, old_locker);
+#endif /* XTHREADS_DEBUG */
+ }
+
+ xmutex_lock(dpy->lock->mutex);
+
+ if (strcmp(file, "XlibInt.c") == 0) {
+ if (!xlibint_unlock)
+ printf("Xlib ERROR: XlibInt.c line %d thread %x locking display it did not unlock\n",
+ line, self);
+ xlibint_unlock = False;
+ }
+
+#ifdef XTHREADS_DEBUG
+ /* if (old_locker && old_locker != self) */
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x got display lock\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ locking_thread = self;
+ if (strcmp(file, "XlibInt.c") != 0) {
+ locking_file = file;
+ locking_line = line;
+ }
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+}
+#endif /* XTHREADS_WARN */
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XUnlockDisplay(dpy,file,line)
+ Display *dpy;
+ char *file;
+ int line;
+#else
+static void _XUnlockDisplay(dpy)
+ Display *dpy;
+#endif
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+
+#ifdef XTHREADS_DEBUG
+ if (strcmp("XClearArea.c", file) && strcmp("XDrSegs.c", file)) /* ico */
+ printf("%s line %d: thread %x unlocking display\n", file, line, self);
+#endif /* XTHREADS_DEBUG */
+
+ if (!xthread_have_id(locking_thread))
+ printf("Xlib ERROR: %s line %d thread %x: unlocking display that is not locked\n",
+ file, line, self);
+ else if (strcmp(file, "XlibInt.c") == 0)
+ xlibint_unlock = True;
+#ifdef XTHREADS_DEBUG
+ else if (strcmp(file, locking_file) != 0)
+ /* not always an error because locking_file is not per-thread */
+ printf("%s line %d: unlocking display locked from %s line %d (probably okay)\n",
+ file, line, locking_file, locking_line);
+#endif /* XTHREADS_DEBUG */
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+ xmutex_unlock(dpy->lock->mutex);
+}
+
+
+static struct _XCVList *_XCreateCVL(dpy)
+ Display *dpy;
+{
+ struct _XCVList *cvl;
+
+ if ((cvl = dpy->lock->free_cvls) != NULL) {
+ dpy->lock->free_cvls = cvl->next;
+ dpy->lock->num_free_cvls--;
+ } else {
+ cvl = (struct _XCVList *)Xmalloc(sizeof(struct _XCVList));
+ if (!cvl)
+ return NULL;
+ cvl->cv = xcondition_malloc();
+ if (!cvl->cv) {
+ Xfree(cvl);
+ return NULL;
+ }
+ xcondition_init(cvl->cv);
+ xcondition_set_name(cvl->cv, "Xlib read queue");
+ }
+ cvl->next = NULL;
+ return cvl;
+}
+
+/* Put ourselves on the queue to read the connection.
+ Allocates and returns a queue element. */
+
+static struct _XCVList *
+_XPushReader(dpy, tail)
+ Display *dpy;
+ struct _XCVList ***tail;
+{
+ struct _XCVList *cvl;
+
+ cvl = _XCreateCVL(dpy);
+#ifdef XTHREADS_DEBUG
+ printf("_XPushReader called in thread %x, pushing %x\n",
+ xthread_self(), cvl);
+#endif
+ **tail = cvl;
+ *tail = &cvl->next;
+ return cvl;
+}
+
+/* signal the next thread waiting to read the connection */
+
+static void _XPopReader(dpy, list, tail)
+ Display *dpy;
+ struct _XCVList **list;
+ struct _XCVList ***tail;
+{
+ register struct _XCVList *front = *list;
+
+#ifdef XTHREADS_DEBUG
+ printf("_XPopReader called in thread %x, popping %x\n",
+ xthread_self(), front);
+#endif
+
+ if (dpy->flags & XlibDisplayProcConni)
+ /* we never added ourself in the first place */
+ return;
+
+ if (front) { /* check "front" for paranoia */
+ *list = front->next;
+ if (*tail == &front->next) /* did we free the last elt? */
+ *tail = list;
+ if (dpy->lock->num_free_cvls < NUM_FREE_CVLS) {
+ front->next = dpy->lock->free_cvls;
+ dpy->lock->free_cvls = front;
+ dpy->lock->num_free_cvls++;
+ } else {
+ xcondition_clear(front->cv);
+ Xfree((char *)front->cv);
+ Xfree((char *)front);
+ }
+ }
+
+ /* signal new front after it is in place */
+ if ((dpy->lock->reply_first = (dpy->lock->reply_awaiters != NULL))) {
+ ConditionSignal(dpy, dpy->lock->reply_awaiters->cv);
+ } else if (dpy->lock->event_awaiters) {
+ ConditionSignal(dpy, dpy->lock->event_awaiters->cv);
+ }
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionWait(cv, mutex,file,line)
+ xcondition_t cv;
+ xmutex_t mutex;
+ char *file;
+ int line;
+#else
+static void _XConditionWait(cv, mutex)
+ xcondition_t cv;
+ xmutex_t mutex;
+#endif
+{
+#ifdef XTHREADS_WARN
+ xthread_t self = xthread_self();
+ char *old_file = locking_file;
+ int old_line = locking_line;
+
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x in condition wait\n", line, self);
+#endif
+ xthread_clear_id(locking_thread);
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = False;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#endif /* XTHREADS_WARN */
+
+ xcondition_wait(cv, mutex);
+
+#ifdef XTHREADS_WARN
+ locking_thread = self;
+ locking_file = old_file;
+ locking_line = old_line;
+
+ locking_history[lock_hist_loc].file = file;
+ locking_history[lock_hist_loc].line = line;
+ locking_history[lock_hist_loc].thread = self;
+ locking_history[lock_hist_loc].lockp = True;
+ lock_hist_loc++;
+ if (lock_hist_loc >= LOCK_HIST_SIZE)
+ lock_hist_loc = 0;
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x was signaled\n", line, self);
+#endif /* XTHREADS_DEBUG */
+#endif /* XTHREADS_WARN */
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionSignal(cv,file,line)
+ xcondition_t cv;
+ char *file;
+ int line;
+#else
+static void _XConditionSignal(cv)
+ xcondition_t cv;
+#endif
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is signalling\n", line, xthread_self());
+#endif
+#endif
+ xcondition_signal(cv);
+}
+
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XConditionBroadcast(cv,file,line)
+ xcondition_t cv;
+ char *file;
+ int line;
+#else
+static void _XConditionBroadcast(cv)
+ xcondition_t cv;
+#endif
+{
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ printf("line %d thread %x is broadcasting\n", line, xthread_self());
+#endif
+#endif
+ xcondition_broadcast(cv);
+}
+
+
+static void _XFreeDisplayLock(dpy)
+ Display *dpy;
+{
+ struct _XCVList *cvl;
+
+ if (dpy->lock != NULL) {
+ if (dpy->lock->mutex != NULL) {
+ xmutex_clear(dpy->lock->mutex);
+ xmutex_free(dpy->lock->mutex);
+ }
+ if (dpy->lock->cv != NULL) {
+ xcondition_clear(dpy->lock->cv);
+ xcondition_free(dpy->lock->cv);
+ }
+ if (dpy->lock->writers != NULL) {
+ xcondition_clear(dpy->lock->writers);
+ xcondition_free(dpy->lock->writers);
+ }
+ while ((cvl = dpy->lock->free_cvls)) {
+ dpy->lock->free_cvls = cvl->next;
+ xcondition_clear(cvl->cv);
+ Xfree((char *)cvl->cv);
+ Xfree((char *)cvl);
+ }
+ Xfree((char *)dpy->lock);
+ dpy->lock = NULL;
+ }
+ if (dpy->lock_fns != NULL) {
+ Xfree((char *)dpy->lock_fns);
+ dpy->lock_fns = NULL;
+ }
+}
+
+/*
+ * wait for thread with user-level display lock to release it.
+ */
+
+static void _XDisplayLockWait(dpy)
+ Display *dpy;
+{
+ xthread_t self;
+
+ while (dpy->lock->locking_level > 0) {
+ self = xthread_self();
+ if (xthread_equal(dpy->lock->locking_thread, self))
+ break;
+ ConditionWait(dpy, dpy->lock->cv);
+ }
+}
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XLockDisplay(dpy, file, line)
+ Display *dpy;
+ char *file; /* source file, from macro */
+ int line;
+#else
+static void _XLockDisplay(dpy)
+ Display *dpy;
+#endif
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+}
+
+/*
+ * _XReply is allowed to exit from select/poll and clean up even if a
+ * user-level lock is in force, so it uses this instead of _XFancyLockDisplay.
+ */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+static void _XInternalLockDisplay(dpy, wskip, file, line)
+ Display *dpy;
+ Bool wskip;
+ char *file; /* source file, from macro */
+ int line;
+#else
+static void _XInternalLockDisplay(dpy, wskip)
+ Display *dpy;
+ Bool wskip;
+#endif
+{
+#ifdef XTHREADS_WARN
+ _XLockDisplayWarn(dpy, file, line);
+#else
+ xmutex_lock(dpy->lock->mutex);
+#endif
+ if (!wskip && dpy->lock->locking_level > 0)
+ _XDisplayLockWait(dpy);
+}
+
+#if NeedFunctionPrototypes
+static void _XUserLockDisplay(
+ register Display* dpy)
+#else
+static void _XUserLockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+ if (++dpy->lock->locking_level == 1) {
+ dpy->lock->lock_wait = _XDisplayLockWait;
+ dpy->lock->locking_thread = xthread_self();
+ }
+}
+
+#if NeedFunctionPrototypes
+void _XUserUnlockDisplay(
+ register Display* dpy)
+#else
+void _XUserUnlockDisplay(dpy)
+ register Display* dpy;
+#endif
+{
+ if (dpy->lock->locking_level > 0 && --dpy->lock->locking_level == 0) {
+ /* signal other threads that might be waiting in XLockDisplay */
+ ConditionBroadcast(dpy, dpy->lock->cv);
+ dpy->lock->lock_wait = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ }
+}
+
+/* returns 0 if initialized ok, -1 if unable to allocate
+ a mutex or other memory */
+
+static int _XInitDisplayLock(dpy)
+ Display *dpy;
+{
+ dpy->lock_fns = (struct _XLockPtrs*)Xmalloc(sizeof(struct _XLockPtrs));
+ if (dpy->lock_fns == NULL)
+ return -1;
+ dpy->lock = (struct _XLockInfo *)Xmalloc(sizeof(struct _XLockInfo));
+ if (dpy->lock == NULL) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+ dpy->lock->cv = xcondition_malloc();
+ dpy->lock->mutex = xmutex_malloc();
+ dpy->lock->writers = xcondition_malloc();
+ if (!dpy->lock->cv || !dpy->lock->mutex || !dpy->lock->writers) {
+ _XFreeDisplayLock(dpy);
+ return -1;
+ }
+
+ dpy->lock->reply_bytes_left = 0;
+ dpy->lock->reply_was_read = False;
+ dpy->lock->reply_awaiters = NULL;
+ dpy->lock->reply_awaiters_tail = &dpy->lock->reply_awaiters;
+ dpy->lock->event_awaiters = NULL;
+ dpy->lock->event_awaiters_tail = &dpy->lock->event_awaiters;
+ dpy->lock->reply_first = False;
+ dpy->lock->locking_level = 0;
+ dpy->lock->num_free_cvls = 0;
+ dpy->lock->free_cvls = NULL;
+ xthread_clear_id(dpy->lock->locking_thread);
+ xthread_clear_id(dpy->lock->reading_thread);
+ xthread_clear_id(dpy->lock->conni_thread);
+ xmutex_init(dpy->lock->mutex);
+ xmutex_set_name(dpy->lock->mutex, "Xlib Display");
+ xcondition_init(dpy->lock->cv);
+ xcondition_set_name(dpy->lock->cv, "XLockDisplay");
+ xcondition_init(dpy->lock->writers);
+ xcondition_set_name(dpy->lock->writers, "Xlib wait for writable");
+ dpy->lock_fns->lock_display = _XLockDisplay;
+ dpy->lock->internal_lock_display = _XInternalLockDisplay;
+ dpy->lock_fns->unlock_display = _XUnlockDisplay;
+ dpy->lock->user_lock_display = _XUserLockDisplay;
+ dpy->lock->user_unlock_display = _XUserUnlockDisplay;
+ dpy->lock->pop_reader = _XPopReader;
+ dpy->lock->push_reader = _XPushReader;
+ dpy->lock->condition_wait = _XConditionWait;
+ dpy->lock->condition_signal = _XConditionSignal;
+ dpy->lock->condition_broadcast = _XConditionBroadcast;
+ dpy->lock->create_cvl = _XCreateCVL;
+ dpy->lock->lock_wait = NULL; /* filled in by XLockDisplay() */
+
+ return 0;
+}
+
+
+Status XInitThreads()
+{
+ if (_Xglobal_lock)
+ return 1;
+#ifdef xthread_init
+ xthread_init(); /* return value? */
+#endif
+ if (!(global_lock.lock = xmutex_malloc()))
+ return 0;
+ if (!(i18n_lock.lock = xmutex_malloc())) {
+ xmutex_free(global_lock.lock);
+ global_lock.lock = NULL;
+ return 0;
+ }
+ _Xglobal_lock = &global_lock;
+ xmutex_init(_Xglobal_lock->lock);
+ xmutex_set_name(_Xglobal_lock->lock, "Xlib global");
+ _Xi18n_lock = &i18n_lock;
+ xmutex_init(_Xi18n_lock->lock);
+ xmutex_set_name(_Xi18n_lock->lock, "Xlib i18n");
+ _XLockMutex_fn = _XLockMutex;
+ _XUnlockMutex_fn = _XUnlockMutex;
+ _XCreateMutex_fn = _XCreateMutex;
+ _XFreeMutex_fn = _XFreeMutex;
+ _XInitDisplayLock_fn = _XInitDisplayLock;
+ _XFreeDisplayLock_fn = _XFreeDisplayLock;
+ _Xthread_self_fn = _Xthread_self;
+
+#ifdef XTHREADS_WARN
+#ifdef XTHREADS_DEBUG
+ setlinebuf(stdout); /* for debugging messages */
+#endif
+#endif
+
+ return 1;
+}
+
+#else /* XTHREADS */
+Status XInitThreads()
+{
+ return 0;
+}
+#endif /* XTHREADS */
diff --git a/src/locking.h b/src/locking.h
new file mode 100644
index 00000000..2b3afd32
--- /dev/null
+++ b/src/locking.h
@@ -0,0 +1,173 @@
+/* $Xorg: locking.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1992, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Author: Stephen Gildea, MIT X Consortium
+ *
+ * locking.h - data types for C Threads locking.
+ * Used by XlibInt.c, locking.c, LockDis.c
+ */
+
+#ifndef _X_locking_H_
+#define _X_locking_H_
+
+#define xmalloc(s) Xmalloc(s)
+#define xfree(s) Xfree(s)
+#include <X11/Xthreads.h>
+
+struct _XCVList {
+ xcondition_t cv;
+ xReply *buf;
+ struct _XCVList *next;
+};
+
+extern xthread_t (*_Xthread_self_fn)( /* in XlibInt.c */
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+/* Display->lock is a pointer to one of these */
+
+struct _XLockInfo {
+ xmutex_t mutex; /* mutex for critical sections */
+ int reply_bytes_left; /* nbytes of the reply still to read */
+ Bool reply_was_read; /* _XReadEvents read a reply for _XReply */
+ struct _XCVList *reply_awaiters; /* list of CVs for _XReply */
+ struct _XCVList **reply_awaiters_tail;
+ struct _XCVList *event_awaiters; /* list of CVs for _XReadEvents */
+ struct _XCVList **event_awaiters_tail;
+ Bool reply_first; /* who may read, reply queue or event queue */
+ /* for XLockDisplay */
+ int locking_level; /* how many times into XLockDisplay we are */
+ xthread_t locking_thread; /* thread that did XLockDisplay */
+ xcondition_t cv; /* wait if another thread has XLockDisplay */
+ xthread_t reading_thread; /* cache */
+ xthread_t conni_thread; /* thread in XProcessInternalConnection */
+ xcondition_t writers; /* wait for writable */
+ int num_free_cvls;
+ struct _XCVList *free_cvls;
+ /* used only in XlibInt.c */
+ void (*pop_reader)(
+#if NeedNestedPrototypes
+ Display* /* dpy */,
+ struct _XCVList** /* list */,
+ struct _XCVList*** /* tail */
+#endif
+ );
+ struct _XCVList *(*push_reader)(
+#if NeedNestedPrototypes
+ Display * /* dpy */,
+ struct _XCVList*** /* tail */
+#endif
+ );
+ void (*condition_wait)(
+#if NeedNestedPrototypes
+ xcondition_t /* cv */,
+ xmutex_t /* mutex */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+#endif
+ );
+ void (*internal_lock_display)(
+#if NeedNestedPrototypes
+ Display* /* dpy */,
+ Bool /* wskip */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+#endif
+ );
+ /* used in XlibInt.c and locking.c */
+ void (*condition_signal)(
+#if NeedNestedPrototypes
+ xcondition_t /* cv */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+#endif
+ );
+ void (*condition_broadcast)(
+#if NeedNestedPrototypes
+ xcondition_t /* cv */
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+ , char* /* file */,
+ int /* line */
+#endif
+#endif
+ );
+ /* used in XlibInt.c and XLockDis.c */
+ void (*lock_wait)(
+#if NeedNestedPrototypes
+ Display* /* dpy */
+#endif
+ );
+ void (*user_lock_display)(
+#if NeedNestedPrototypes
+ Display* /* dpy */
+#endif
+ );
+ void (*user_unlock_display)(
+#if NeedNestedPrototypes
+ Display* /* dpy */
+#endif
+ );
+ struct _XCVList *(*create_cvl)(
+#if NeedNestedPrototypes
+ Display * /* dpy */
+#endif
+ );
+};
+
+#define UnlockNextEventReader(d) if ((d)->lock) \
+ (*(d)->lock->pop_reader)((d),&(d)->lock->event_awaiters,&(d)->lock->event_awaiters_tail)
+
+#if defined(XTHREADS_WARN) || defined(XTHREADS_FILE_LINE)
+#define ConditionWait(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_wait)(c, (d)->lock->mutex,__FILE__,__LINE__)
+#define ConditionSignal(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_signal)(c,__FILE__,__LINE__)
+#define ConditionBroadcast(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_broadcast)(c,__FILE__,__LINE__)
+#else
+#define ConditionWait(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_wait)(c, (d)->lock->mutex)
+#define ConditionSignal(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_signal)(c)
+#define ConditionBroadcast(d,c) if ((d)->lock) \
+ (*(d)->lock->condition_broadcast)(c)
+#endif
+
+typedef struct _LockInfoRec {
+ xmutex_t lock;
+} LockInfoRec;
+
+#endif /* _X_locking_H_ */
diff --git a/src/poly.h b/src/poly.h
new file mode 100644
index 00000000..0d82443c
--- /dev/null
+++ b/src/poly.h
@@ -0,0 +1,295 @@
+/* $Xorg: poly.h,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/************************************************************************
+
+Copyright 1987, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+************************************************************************/
+
+/*
+ * This file contains a few macros to help track
+ * the edge of a filled object. The object is assumed
+ * to be filled in scanline order, and thus the
+ * algorithm used is an extension of Bresenham's line
+ * drawing algorithm which assumes that y is always the
+ * major axis.
+ * Since these pieces of code are the same for any filled shape,
+ * it is more convenient to gather the library in one
+ * place, but since these pieces of code are also in
+ * the inner loops of output primitives, procedure call
+ * overhead is out of the question.
+ * See the author for a derivation if needed.
+ */
+
+
+/*
+ * In scan converting polygons, we want to choose those pixels
+ * which are inside the polygon. Thus, we add .5 to the starting
+ * x coordinate for both left and right edges. Now we choose the
+ * first pixel which is inside the pgon for the left edge and the
+ * first pixel which is outside the pgon for the right edge.
+ * Draw the left pixel, but not the right.
+ *
+ * How to add .5 to the starting x coordinate:
+ * If the edge is moving to the right, then subtract dy from the
+ * error term from the general form of the algorithm.
+ * If the edge is moving to the left, then add dy to the error term.
+ *
+ * The reason for the difference between edges moving to the left
+ * and edges moving to the right is simple: If an edge is moving
+ * to the right, then we want the algorithm to flip immediately.
+ * If it is moving to the left, then we don't want it to flip until
+ * we traverse an entire pixel.
+ */
+#define BRESINITPGON(dy, x1, x2, xStart, d, m, m1, incr1, incr2) { \
+ int dx; /* local storage */ \
+\
+ /* \
+ * if the edge is horizontal, then it is ignored \
+ * and assumed not to be processed. Otherwise, do this stuff. \
+ */ \
+ if ((dy) != 0) { \
+ xStart = (x1); \
+ dx = (x2) - xStart; \
+ if (dx < 0) { \
+ m = dx / (dy); \
+ m1 = m - 1; \
+ incr1 = -2 * dx + 2 * (dy) * m1; \
+ incr2 = -2 * dx + 2 * (dy) * m; \
+ d = 2 * m * (dy) - 2 * dx - 2 * (dy); \
+ } else { \
+ m = dx / (dy); \
+ m1 = m + 1; \
+ incr1 = 2 * dx - 2 * (dy) * m1; \
+ incr2 = 2 * dx - 2 * (dy) * m; \
+ d = -2 * m * (dy) + 2 * dx; \
+ } \
+ } \
+}
+
+#define BRESINCRPGON(d, minval, m, m1, incr1, incr2) { \
+ if (m1 > 0) { \
+ if (d > 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } else {\
+ if (d >= 0) { \
+ minval += m1; \
+ d += incr1; \
+ } \
+ else { \
+ minval += m; \
+ d += incr2; \
+ } \
+ } \
+}
+
+
+/*
+ * This structure contains all of the information needed
+ * to run the bresenham algorithm.
+ * The variables may be hardcoded into the declarations
+ * instead of using this structure to make use of
+ * register declarations.
+ */
+typedef struct {
+ int minor_axis; /* minor axis */
+ int d; /* decision variable */
+ int m, m1; /* slope and slope+1 */
+ int incr1, incr2; /* error increments */
+} BRESINFO;
+
+
+#define BRESINITPGONSTRUCT(dmaj, min1, min2, bres) \
+ BRESINITPGON(dmaj, min1, min2, bres.minor_axis, bres.d, \
+ bres.m, bres.m1, bres.incr1, bres.incr2)
+
+#define BRESINCRPGONSTRUCT(bres) \
+ BRESINCRPGON(bres.d, bres.minor_axis, bres.m, bres.m1, bres.incr1, bres.incr2)
+
+
+
+/*
+ * These are the data structures needed to scan
+ * convert regions. Two different scan conversion
+ * methods are available -- the even-odd method, and
+ * the winding number method.
+ * The even-odd rule states that a point is inside
+ * the polygon if a ray drawn from that point in any
+ * direction will pass through an odd number of
+ * path segments.
+ * By the winding number rule, a point is decided
+ * to be inside the polygon if a ray drawn from that
+ * point in any direction passes through a different
+ * number of clockwise and counter-clockwise path
+ * segments.
+ *
+ * These data structures are adapted somewhat from
+ * the algorithm in (Foley/Van Dam) for scan converting
+ * polygons.
+ * The basic algorithm is to start at the top (smallest y)
+ * of the polygon, stepping down to the bottom of
+ * the polygon by incrementing the y coordinate. We
+ * keep a list of edges which the current scanline crosses,
+ * sorted by x. This list is called the Active Edge Table (AET)
+ * As we change the y-coordinate, we update each entry in
+ * in the active edge table to reflect the edges new xcoord.
+ * This list must be sorted at each scanline in case
+ * two edges intersect.
+ * We also keep a data structure known as the Edge Table (ET),
+ * which keeps track of all the edges which the current
+ * scanline has not yet reached. The ET is basically a
+ * list of ScanLineList structures containing a list of
+ * edges which are entered at a given scanline. There is one
+ * ScanLineList per scanline at which an edge is entered.
+ * When we enter a new edge, we move it from the ET to the AET.
+ *
+ * From the AET, we can implement the even-odd rule as in
+ * (Foley/Van Dam).
+ * The winding number rule is a little trickier. We also
+ * keep the EdgeTableEntries in the AET linked by the
+ * nextWETE (winding EdgeTableEntry) link. This allows
+ * the edges to be linked just as before for updating
+ * purposes, but only uses the edges linked by the nextWETE
+ * link as edges representing spans of the polygon to
+ * drawn (as with the even-odd rule).
+ */
+
+/*
+ * for the winding number rule
+ */
+#define CLOCKWISE 1
+#define COUNTERCLOCKWISE -1
+
+typedef struct _EdgeTableEntry {
+ int ymax; /* ycoord at which we exit this edge. */
+ BRESINFO bres; /* Bresenham info to run the edge */
+ struct _EdgeTableEntry *next; /* next in the list */
+ struct _EdgeTableEntry *back; /* for insertion sort */
+ struct _EdgeTableEntry *nextWETE; /* for winding num rule */
+ int ClockWise; /* flag for winding number rule */
+} EdgeTableEntry;
+
+
+typedef struct _ScanLineList{
+ int scanline; /* the scanline represented */
+ EdgeTableEntry *edgelist; /* header node */
+ struct _ScanLineList *next; /* next in the list */
+} ScanLineList;
+
+
+typedef struct {
+ int ymax; /* ymax for the polygon */
+ int ymin; /* ymin for the polygon */
+ ScanLineList scanlines; /* header node */
+} EdgeTable;
+
+
+/*
+ * Here is a struct to help with storage allocation
+ * so we can allocate a big chunk at a time, and then take
+ * pieces from this heap when we need to.
+ */
+#define SLLSPERBLOCK 25
+
+typedef struct _ScanLineListBlock {
+ ScanLineList SLLs[SLLSPERBLOCK];
+ struct _ScanLineListBlock *next;
+} ScanLineListBlock;
+
+
+
+/*
+ *
+ * a few macros for the inner loops of the fill code where
+ * performance considerations don't allow a procedure call.
+ *
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The winding number rule is in effect, so we must notify
+ * the caller when the edge has been removed so he
+ * can reorder the Winding Active Edge Table.
+ */
+#define EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ fixWAET = 1; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
+
+
+/*
+ * Evaluate the given edge at the given scanline.
+ * If the edge has expired, then we leave it and fix up
+ * the active edge table; otherwise, we increment the
+ * x value to be ready for the next scanline.
+ * The even-odd rule is in effect.
+ */
+#define EVALUATEEDGEEVENODD(pAET, pPrevAET, y) { \
+ if (pAET->ymax == y) { /* leaving this edge */ \
+ pPrevAET->next = pAET->next; \
+ pAET = pPrevAET->next; \
+ if (pAET) \
+ pAET->back = pPrevAET; \
+ } \
+ else { \
+ BRESINCRPGONSTRUCT(pAET->bres); \
+ pPrevAET = pAET; \
+ pAET = pAET->next; \
+ } \
+}
diff --git a/src/udcInf.c b/src/udcInf.c
new file mode 100644
index 00000000..c1392bed
--- /dev/null
+++ b/src/udcInf.c
@@ -0,0 +1,711 @@
+/* $Xorg: udcInf.c,v 1.7 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+#include <stdio.h>
+#include <locale.h>
+#include <Xlib.h>
+#include <Xlibint.h>
+#include <Xlcint.h>
+#include <XlcPubI.h>
+#include <XlcGeneric.h>
+#include <XomGeneric.h>
+
+/*
+ external symbols
+*/
+extern FontData read_EncodingInfo();
+extern int _xudc_get_codeset();
+
+extern int _xudc_utyderror ;
+extern int _xudc_utyerror ;
+
+extern unsigned long _xudc_utyerrno ;
+
+#define _XUDC_ERROR -1
+
+
+/*
+ UDC structure define
+*/
+typedef struct __XUDCGlyphRegion {
+ unsigned long start;
+ unsigned long end;
+} _XUDCGlyphRegion ;
+
+/*
+ * "code" no jyoui "i" byte me wo "unsigned char" toshite kaesu.
+ */
+static unsigned char getbyte(code,i)
+unsigned long code;
+int i;
+{
+ unsigned long byteL;
+ unsigned char byte;
+ byteL = code >> (8*(3-i));
+ byte = (unsigned char)(0x000000ff & byteL);
+ return(byte);
+}
+/*
+ get codeset which described by charset_str and locale.
+ for examples ...
+ locale : ja_JP
+ charset_str : JISX0208.1983-0
+*/
+
+_xudc_get_codeset(locale,charset_str,codeset,num_codeset)
+char *locale;
+char *charset_str;
+int **codeset;
+int *num_codeset;
+{
+ XLCdRec lcdrec;
+ XLCd lcd;
+ XLCdPublicRec xlcdp;
+ XPointer rdb;
+ int num = 0,count,num_ret=0,i,*ret;
+ char **value,buf[128],*ptr;
+
+
+ _xudc_utyderror = 0;
+ _xudc_utyerror = 0;
+
+ if((locale == NULL) || (charset_str == NULL)){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04 ;
+ return(_XUDC_ERROR);
+ }
+ if(codeset == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04 ;
+ return(_XUDC_ERROR);
+ }
+
+ /* create XLCd */
+ xlcdp.pub.siname = locale;
+ lcdrec.core = (XLCdCore)&xlcdp;
+ lcd = &lcdrec;
+ /* create X RDB (X NLS DB) */
+ rdb = _XlcCreateLocaleDataBase(lcd);
+ if(rdb == NULL){
+ _xudc_utyerror = 1;
+ _xudc_utyerrno = 0x15 ;
+ return(_XUDC_ERROR);
+ }
+
+ for(num=0;;num++){
+ /* XLC_FONTSET */
+ sprintf(buf, "fs%d.font.primary", num);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count < 1){
+ break ;
+ }
+ for(i=0;i<count;i++){
+ if (strlen(value[i]) >= sizeof(buf))
+ continue;
+ strcpy(buf,value[i]);
+ ptr = (char *)strchr(buf,(int)':');
+ *ptr = 0;
+ if(!_XlcCompareISOLatin1(charset_str,buf)){
+ num_ret += 1;
+ if(num_ret == 1){
+ ret = (int *)Xmalloc(sizeof(int));
+ } else {
+ int *prev_ret = ret;
+
+ ret =
+ (int *)Xrealloc(ret,num_ret*sizeof(int));
+ if (ret == NULL){
+ Xfree(prev_ret);
+ }
+ }
+ if(ret == NULL){
+ _xudc_utyerrno = 0x03 ;
+ return(_XUDC_ERROR);
+ }
+ ret[num_ret-1]=num;
+ break ;
+ }
+ }
+ }
+ if(num_ret == 0){
+ *num_codeset = 0;
+ *codeset = NULL;
+ return (0xff);
+ }
+
+ *num_codeset = num_ret;
+ *codeset = ret;
+ return 0;
+}
+
+static Bool gi_to_vgi(gi,vgi,scope)
+unsigned long gi,*vgi;
+FontScope scope;
+{
+ if(scope->shift_direction == (unsigned long)'+'){
+ gi -= scope->shift;
+ } else {
+ gi += scope->shift;
+ }
+ if(gi >= scope->start && gi <= scope->end){
+ *vgi = gi;
+ return(True);
+ }
+ return(False);
+}
+
+static void shift_area(udc,scope)
+_XUDCGlyphRegion *udc;
+FontScope scope;
+{
+ if(scope->shift_direction == (unsigned long)'+'){
+ udc->start += scope->shift;
+ udc->end += scope->shift;
+ } else {
+ udc->start -= scope->shift;
+ udc->end -= scope->shift;
+ }
+}
+
+/*
+ get UDC area with glyph index.
+ for examples ...
+ locale : ja_JP
+ charset_str : JISX0208.1983-0
+*/
+_XUDCGetUDCGIArea(locale,codeset,charset_str,gr,num_gr)
+char *locale;
+int codeset;
+char *charset_str;
+_XUDCGlyphRegion **gr;
+int *num_gr;
+{
+ XLCdRec lcdrec;
+ XLCd lcd;
+ XLCdPublicRec xlcdp;
+ XPointer rdb;
+ _XUDCGlyphRegion *udc;
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+
+
+ _xudc_utyderror = 0;
+ _xudc_utyerror = 0;
+ _xudc_utyerrno = 0x00 ;
+
+ if((locale == NULL) || (charset_str == NULL)){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(gr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(num_gr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ /* create XLCd */
+ xlcdp.pub.siname = locale;
+ lcdrec.core = (XLCdCore)&xlcdp;
+ lcd = &lcdrec;
+ /* create X RDB (X NLS DB) */
+ rdb = _XlcCreateLocaleDataBase(lcd);
+ if(rdb == NULL){
+ _xudc_utyerror = 1;
+ _xudc_utyerrno = 0x15 ;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ udc = NULL;
+
+ /* XLC_FONTSET */
+ sprintf(buf, "fs%d.charset.udc_area", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ udc = (_XUDCGlyphRegion *)Xmalloc(count * sizeof(_XUDCGlyphRegion));
+ if(udc == NULL){
+ _xudc_utyerrno = 0x03 ;
+ _xudc_utyerrno |= (0x0b<<8) ;
+ return(_XUDC_ERROR);
+ }
+ for(i=0;i<count;i++){
+ sscanf(value[i],"\\x%lx,\\x%lx", &(udc[i].start), &(udc[i].end));
+ }
+ }
+
+ *num_gr = count;
+
+ sprintf(buf, "fs%d.font.primary", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
+ for(j=0;j<(*num_gr);j++){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if(udc[j].start == font_data[i].scopes[k].start
+ && font_data[i].scopes[k].shift){
+ shift_area(&udc[j],&(font_data[i].scopes[k]));
+ }
+ }
+ }
+ }
+ }
+ }
+
+ *gr = udc;
+ return 0;
+}
+
+/*
+ * Code convert wo tomonau UDC area no kakutoku
+ * GetUDCCPArea() / glyph_to_code()
+ *
+ */
+
+static int
+_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,gi,vgi,charsetname,size)
+XLCd lcd;
+char *locale;
+char *charset_str;
+int codeset;
+unsigned long gi;
+unsigned long *vgi;
+char *charsetname;
+int size;
+{
+ _XUDCGlyphRegion *udc;
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+
+
+ sprintf(buf, "fs%d.charset.name", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ strcpy(charsetname,value[0]);
+ }
+ if (count >= size)
+ return False;
+ sprintf(buf, "fs%d.font.primary", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ if( !_XlcCompareISOLatin1(font_data[i].name,charset_str)){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if( gi_to_vgi(gi,vgi,&(font_data[i].scopes[k])) == True){
+ return(True);
+ }
+ }
+ }
+ }
+ }
+/*
+ free_fontdata(font_data);
+*/
+ *vgi = gi;
+ return(True);
+}
+
+Bool non_standard(lcd,charset)
+XLCd lcd;
+XlcCharSet charset;
+{
+ char buf[256];
+ int count,i;
+ char **value;
+ if(charset->ct_sequence == NULL){
+ return(False);
+ }
+ for(i=0;;i++){
+ sprintf(buf, "csd%d.charset_name", i);
+ _XlcGetLocaleDataBase(lcd, "XLC_CHARSET_DEFINE", buf, &value, &count);
+ if(count > 0){
+ if(!_XlcNCompareISOLatin1(value[0],
+ charset->name,strlen(value[0])) ){
+ return(True);
+ }
+ } else {
+ return(False);
+ }
+ }
+}
+
+static Bool
+make_none_standard(from,charset,src,size)
+char *from;
+XlcCharSet charset;
+char *src;
+int size;
+{
+ int name_len,seq_len,i;
+ name_len = 2 + strlen(charset->encoding_name) + 1;
+ seq_len = strlen(charset->ct_sequence);
+ if (name_len + seq_len + strlen(src) >= size)
+ return False;
+ strcpy(from,charset->ct_sequence);
+ from[seq_len] = name_len / 128 + 128;
+ from[seq_len+1] = name_len % 128 + 128;
+ strcpy(&from[seq_len + 2],charset->encoding_name);
+ from[seq_len+name_len-1] = 0x02; /* STX */
+ strcpy(&from[seq_len + name_len],src);
+ return True;
+}
+int
+_xudc_glyph_to_code(locale,charset_str,codeset,glyph_index,codepoint)
+char *locale;
+char *charset_str;
+int codeset;
+unsigned long glyph_index;
+unsigned long *codepoint;
+{
+ XLCd lcd;
+ unsigned char *from; int from_left;
+ unsigned char *to ; int to_left = 10;
+ unsigned char *dst;
+ unsigned char byte;
+ unsigned long from32[25];
+ unsigned long to32[25];
+ int i,j;
+ char tmp[256],charsetname[256],src[10];
+ XlcConv conv;
+ XlcCharSet charset;
+ XPointer args[2];
+
+ from = (unsigned char *)from32;
+ to = (unsigned char *)to32;
+ dst = (unsigned char *)to32;
+
+ memset(dst,0,25);
+
+ lcd = (XLCd)_XlcGenericLoader(locale);
+
+ if (!_xudc_gi_to_vgi(lcd,locale,charset_str,codeset,
+ glyph_index,&glyph_index,charsetname,sizeof(charsetname)))
+ return(_XUDC_ERROR);
+
+ for(i=0,j=0;i<4;i++){
+ byte = getbyte(glyph_index,i);
+ if(byte){
+ src[j] = byte;
+ j ++;
+ }
+ }
+ src[j] = 0;
+
+
+ /* get charset */
+/*
+ sprintf(tmp,"%s%s",charset_str,":GL");
+ charset_name = strdup(tmp);
+*/
+ charset = _XlcGetCharSet(charsetname);
+ if(charset == NULL){
+ _xudc_utyerrno = 0x16 ;
+ return(_XUDC_ERROR);
+ }
+ /* make ct */
+ if( non_standard(lcd,charset)) {
+ if (!make_none_standard(from,charset,src,sizeof(from32)))
+ return(_XUDC_ERROR);
+ } else if(charset->ct_sequence){
+ if (strlen(charset->ct_sequence) + strlen(src) >= sizeof(from32))
+ return(_XUDC_ERROR);
+ sprintf((char *)from,"%s%s",charset->ct_sequence,src);
+ } else {
+ sprintf((char *)from,"%s\0",src);
+ }
+ /* compound text -> multi byte */
+ conv = _XlcOpenConverter(lcd, XlcNCompoundText, lcd, XlcNMultiByte);
+ from_left = strlen((char *)from);
+ _XlcConvert(conv,(XPointer *)&from,&from_left,
+ (XPointer *)&to, &to_left,args,0);
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+
+ *codepoint = 0;
+ for(i=0;dst[i];i++){
+ *codepoint = ((*codepoint << 8) | dst[i]) ;
+ }
+ return(0);
+}
+
+typedef struct __XUDCCodeRegion {
+ unsigned long start,end;
+} _XUDCCodeRegion ;
+
+int
+_XUDCGetUDCCPArea(locale,codeset,charset_str,cr,num_cr)
+char *locale;
+int codeset;
+char *charset_str;
+_XUDCCodeRegion **cr;
+int *num_cr;
+{
+ int i,num_gr,ret;
+ _XUDCGlyphRegion *gr;
+ _XUDCCodeRegion *crr;
+
+ _xudc_utyerror = 0;
+ _xudc_utyderror = 0;
+
+ if(cr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 1;
+ _xudc_utyerrno = 0x04 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+ if(num_cr == NULL){
+ _xudc_utyerror = 5;
+ _xudc_utyderror = 2;
+ _xudc_utyerrno = 0x04 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ ret = _XUDCGetUDCGIArea(locale,codeset,charset_str,&gr,&num_gr);
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno &= 0xff ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(ret);
+ }
+
+ crr = (_XUDCCodeRegion *)Xmalloc(num_gr*sizeof(_XUDCCodeRegion));
+ if(crr == NULL){
+ Xfree(gr);
+ _xudc_utyerrno = 0x03 ;
+ _xudc_utyerrno |= (0x0a<<8) ;
+ return(_XUDC_ERROR);
+ }
+
+ for(i=0;i<num_gr;i++){
+ ret = _xudc_glyph_to_code(locale,charset_str,codeset,
+ gr[i].start, &(crr[i].start));
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno |= (0x0a<<8) ;
+ Xfree(gr);
+ Xfree(crr);
+ return(ret);
+ }
+ ret = _xudc_glyph_to_code(locale,charset_str,codeset,
+ gr[i].end, &(crr[i].end));
+ if(ret == _XUDC_ERROR){
+ _xudc_utyerrno |= (0x0a<<8) ;
+ Xfree(gr);
+ Xfree(crr);
+ return(ret);
+ }
+ }
+ Xfree(gr);
+ *cr = crr;
+ *num_cr = num_gr;
+ return(0);
+}
+
+/*
+ * code_to_glyph()
+ *
+ */
+typedef struct __XUDCGIInf {
+ char *charset_str;
+ unsigned long glyph_index;
+} _XUDCGIInf ;
+
+/*
+ *
+ *
+ */
+static Bool vgi_to_gi(gi,vgi,scope)
+unsigned long *gi,vgi;
+FontScope scope;
+{
+ if(vgi >= scope->start && vgi <= scope->end){
+ if(scope->shift_direction == (unsigned long)'+'){
+ *gi = vgi + scope->shift;
+ } else {
+ *gi = vgi - scope->shift;
+ }
+ return(True);
+ }
+ return(False);
+}
+/*
+ *
+ *
+ */
+static Bool
+_xudc_vgi_to_gi(lcd,locale,vglyph,glyph,charset,charsetname,size)
+XLCd lcd;
+char *locale;
+unsigned long vglyph;
+unsigned long *glyph;
+XlcCharSet charset;
+char *charsetname;
+int size;
+{
+ int num = 0,count,num_ret=0;
+ int i,j,k;
+ char **value,buf[128],ptr;
+ FontData font_data;
+ CodeSet cs;
+
+
+ for(i=0;;i++){
+ sprintf(buf, "fs%d.charset.name",i);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ if(!_XlcNCompareISOLatin1(charset->name,value[0],
+ strlen(charset->name))){
+ break;
+ }
+ } else {
+ _xudc_utyerrno = 0x17 ;
+ return(False);
+ }
+ }
+/*
+ sprintf(buf, "fs%d.charset.name", codeset-1);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ strcpy(charsetname,value[0]);
+ }
+*/
+ sprintf(buf, "fs%d.font.primary", i);
+ _XlcGetLocaleDataBase(lcd, "XLC_FONTSET", buf, &value, &count);
+ if(count > 0){
+ font_data = read_EncodingInfo(count,value);
+ for(i=0;i<count;i++){
+ for(k=0;k<font_data[i].scopes_num;k++){
+ if( vgi_to_gi(glyph,vglyph,&(font_data[i].scopes[k])) == True){
+ if (strlen(font_data[i].name) >= size)
+ return(False);
+ strcpy(charsetname,font_data[i].name);
+ return(True);
+ }
+ }
+ }
+ }
+ *glyph = vglyph;
+ return(True);
+}
+int
+_xudc_code_to_glyph(locale,codepoint,gi,num_gi)
+char *locale;
+unsigned long codepoint;
+_XUDCGIInf **gi;
+int *num_gi;
+{
+ XLCd lcd;
+ unsigned char *from; int from_left;
+ unsigned char *to ; int to_left = 10;
+ unsigned char *dst;
+ unsigned char byte;
+ unsigned int from32[25];
+ unsigned int to32[25];
+ int i,j;
+ char tmp[256],charsetname[256],src[10];
+ XlcConv conv;
+ XlcCharSet charset;
+ XPointer args[2];
+ unsigned long glyph,vglyph;
+
+ from = (unsigned char *)from32;
+ to = (unsigned char *)to32;
+ dst = (unsigned char *)to32;
+ memset(dst,0,25);
+
+ lcd = (XLCd)_XlcGenericLoader(locale);
+
+ for(i=0,j=0;i<4;i++){
+ byte = getbyte(codepoint,i);
+ if(byte){
+ src[j] = byte;
+ j ++;
+ }
+ }
+ src[j] = 0;
+ sprintf((char *)from,"%s\0",src);
+ /* multi byte -> vgi */
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNCharSet);
+ from_left = strlen((char *)from);
+ args[0] = (XPointer) &charset;
+ _XlcConvert(conv,(XPointer *)&from,&from_left,
+ (XPointer *)&to, &to_left,args,1);
+
+ /* vgi -> gi */
+ vglyph = 0;
+ for(i=0;dst[i];i++){
+ vglyph = ((vglyph << 8) | dst[i]) ;
+ }
+ if(_xudc_vgi_to_gi(lcd,locale,vglyph,&glyph,charset,charsetname,
+ sizeof(charsetname))==False){
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+ *num_gi = 0;
+ return(0);
+ }
+
+ _XlcCloseConverter(conv);
+ _XlcDestroyLC(lcd);
+
+ *gi = (_XUDCGIInf *)Xmalloc(sizeof(_XUDCGIInf));
+ (*gi)->charset_str = (char *)Xmalloc(strlen(charsetname)+1);
+ strcpy((*gi)->charset_str,charsetname);
+ (*gi)->glyph_index = glyph;
+ if(*gi == NULL){
+ _xudc_utyerrno = 0x03 ;
+ return(_XUDC_ERROR);
+ }
+ *num_gi = 1;
+ return(0);
+}
+
diff --git a/src/util/makekeys.c b/src/util/makekeys.c
new file mode 100644
index 00000000..24272bfb
--- /dev/null
+++ b/src/util/makekeys.c
@@ -0,0 +1,259 @@
+/* $Xorg: makekeys.c,v 1.5 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/* Constructs hash tables for XStringToKeysym and XKeysymToString. */
+
+#include <X11/X.h>
+#include <X11/Xos.h>
+#include <X11/keysymdef.h>
+#include <stdio.h>
+
+#ifndef X_NOT_STDC_ENV
+#include <stdlib.h>
+#else
+char *malloc();
+#endif
+#if defined(macII) && !defined(__STDC__) /* stdlib.h fails to define these */
+char *malloc();
+#endif /* macII */
+
+typedef unsigned long Signature;
+
+#define KTNUM 3000
+
+static struct info {
+ char *name;
+ KeySym val;
+} info[KTNUM];
+
+#define MIN_REHASH 10
+#define MATCHES 10
+
+char tab[KTNUM];
+unsigned short offsets[KTNUM];
+unsigned short indexes[KTNUM];
+KeySym values[KTNUM];
+char buf[1024];
+
+main()
+{
+ int ksnum;
+ int max_rehash;
+ Signature sig;
+ register int i, j, k, z;
+ register char *name;
+ register char c;
+ int first;
+ int best_max_rehash;
+ int best_z = 0;
+ int num_found;
+ KeySym val;
+
+ for (ksnum = 0; 1; (void)fgets(buf, sizeof(buf), stdin)) {
+ i = scanf("#define XK_%s 0x%lx", buf, &info[ksnum].val);
+ if (i == EOF)
+ break;
+ if (i != 2)
+ continue;
+ if (info[ksnum].val == XK_VoidSymbol)
+ info[ksnum].val = 0;
+ if (info[ksnum].val > 0xffff) {
+ fprintf(stderr,
+ "ignoring illegal keysym (%s), remove it from .h file!\n",
+ buf);
+ continue;
+ }
+ name = malloc((unsigned)strlen(buf)+1);
+ if (!name) {
+ fprintf(stderr, "makekeys: out of memory!\n");
+ exit(1);
+ }
+ (void)strcpy(name, buf);
+ info[ksnum].name = name;
+ ksnum++;
+ if (ksnum == KTNUM) {
+ fprintf(stderr, "makekeys: too many keysyms!\n");
+ exit(1);
+ }
+ }
+
+ printf("/* This file is generated from keysymdef.h. */\n");
+ printf("/* Do not edit. */\n");
+ printf("\n");
+
+ best_max_rehash = ksnum;
+ num_found = 0;
+ for (z = ksnum; z < KTNUM; z++) {
+ max_rehash = 0;
+ for (name = tab, i = z; --i >= 0;)
+ *name++ = 0;
+ for (i = 0; i < ksnum; i++) {
+ name = info[i].name;
+ sig = 0;
+ while ((c = *name++))
+ sig = (sig << 1) + c;
+ first = j = sig % z;
+ for (k = 0; tab[j]; k++) {
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ if (j == first)
+ goto next1;
+ }
+ tab[j] = 1;
+ if (k > max_rehash)
+ max_rehash = k;
+ }
+ if (max_rehash < MIN_REHASH) {
+ if (max_rehash < best_max_rehash) {
+ best_max_rehash = max_rehash;
+ best_z = z;
+ }
+ num_found++;
+ if (num_found >= MATCHES)
+ break;
+ }
+next1: ;
+ }
+
+ z = best_z;
+ printf("#ifdef NEEDKTABLE\n");
+ printf("Const unsigned char _XkeyTable[] = {\n");
+ printf("0,\n");
+ k = 1;
+ for (i = 0; i < ksnum; i++) {
+ name = info[i].name;
+ sig = 0;
+ while ((c = *name++))
+ sig = (sig << 1) + c;
+ first = j = sig % z;
+ while (offsets[j]) {
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ }
+ offsets[j] = k;
+ indexes[i] = k;
+ val = info[i].val;
+ printf("0x%.2x, 0x%.2x, 0x%.2x, 0x%.2x, ",
+ (sig >> 8) & 0xff, sig & 0xff,
+ (val >> 8) & 0xff, val & 0xff);
+ for (name = info[i].name, k += 5; (c = *name++); k++)
+ printf("'%c',", c);
+ printf((i == (ksnum-1)) ? "0\n" : "0,\n");
+ }
+ printf("};\n");
+ printf("\n");
+ printf("#define KTABLESIZE %d\n", z);
+ printf("#define KMAXHASH %d\n", best_max_rehash + 1);
+ printf("\n");
+ printf("static Const unsigned short hashString[KTABLESIZE] = {\n");
+ for (i = 0; i < z;) {
+ printf("0x%.4x", offsets[i]);
+ i++;
+ if (i == z)
+ break;
+ printf((i & 7) ? ", " : ",\n");
+ }
+ printf("\n");
+ printf("};\n");
+ printf("#endif /* NEEDKTABLE */\n");
+
+ best_max_rehash = ksnum;
+ num_found = 0;
+ for (z = ksnum; z < KTNUM; z++) {
+ max_rehash = 0;
+ for (name = tab, i = z; --i >= 0;)
+ *name++ = 0;
+ for (i = 0; i < ksnum; i++) {
+ val = info[i].val;
+ first = j = val % z;
+ for (k = 0; tab[j]; k++) {
+ if (values[j] == val)
+ goto skip1;
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ if (j == first)
+ goto next2;
+ }
+ tab[j] = 1;
+ values[j] = val;
+ if (k > max_rehash)
+ max_rehash = k;
+skip1: ;
+ }
+ if (max_rehash < MIN_REHASH) {
+ if (max_rehash < best_max_rehash) {
+ best_max_rehash = max_rehash;
+ best_z = z;
+ }
+ num_found++;
+ if (num_found >= MATCHES)
+ break;
+ }
+next2: ;
+ }
+
+ z = best_z;
+ for (i = z; --i >= 0;)
+ offsets[i] = 0;
+ for (i = 0; i < ksnum; i++) {
+ val = info[i].val;
+ first = j = val % z;
+ while (offsets[j]) {
+ if (values[j] == val)
+ goto skip2;
+ j += first + 1;
+ if (j >= z)
+ j -= z;
+ }
+ offsets[j] = indexes[i] + 2;
+ values[j] = val;
+skip2: ;
+ }
+ printf("\n");
+ printf("#ifdef NEEDVTABLE\n");
+ printf("#define VTABLESIZE %d\n", z);
+ printf("#define VMAXHASH %d\n", best_max_rehash + 1);
+ printf("\n");
+ printf("static Const unsigned short hashKeysym[VTABLESIZE] = {\n");
+ for (i = 0; i < z;) {
+ printf("0x%.4x", offsets[i]);
+ i++;
+ if (i == z)
+ break;
+ printf((i & 7) ? ", " : ",\n");
+ }
+ printf("\n");
+ printf("};\n");
+ printf("#endif /* NEEDVTABLE */\n");
+
+ exit(0);
+}
diff --git a/src/util/mkks.sh b/src/util/mkks.sh
new file mode 100644
index 00000000..262cc954
--- /dev/null
+++ b/src/util/mkks.sh
@@ -0,0 +1,11 @@
+#!/bin/sh
+
+cat $* | awk 'BEGIN { \
+ printf "/*\n * This file is generated from %s. Do not edit.\n */\n", \
+ "$(INCLUDESRC)/keysymdef.h";\
+} \
+/^#define/ { \
+ len = length($2)-3; \
+ printf("{ \"%s\", %s },\n", substr($2,4,len), $3); \
+}'
+
diff --git a/src/xcms/AddDIC.c b/src/xcms/AddDIC.c
new file mode 100644
index 00000000..aefae0f8
--- /dev/null
+++ b/src/xcms/AddDIC.c
@@ -0,0 +1,156 @@
+/* $Xorg: AddDIC.c,v 1.3 2000/08/17 19:44:29 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAddDIC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAddColorSpace
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/*
+ * DEFINES
+ */
+#define NextUnregDiCsID(lastid) \
+ (XCMS_UNREG_ID(lastid) ? ++lastid : XCMS_FIRST_UNREG_DI_ID)
+#define MAX(x,y) ((x) < (y) ? (y) : (x))
+
+
+/*
+ * EXTERNS
+ */
+extern XcmsPerDpyInfo *_XcmsFindDpyInfo();
+extern XPointer *_XcmsPushPointerArray();
+extern XcmsColorFormat _XcmsRegFormatOfPrefix();
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+extern XcmsColorSpace *_XcmsDIColorSpacesInit[];
+
+/*
+ * NAME
+ * XcmsAddColorSpace - Add a Device-Independent Color Space
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAddColorSpace(pCS)
+ XcmsColorSpace *pCS;
+/*
+ * DESCRIPTION
+ * DI Color Spaces are managed on a global basis.
+ * This means that with exception of the provided DI color spaces:
+ * CIEXYZ, CIExyY, CIELab, CIEuvY, CIELuv, and TekHVC
+ * DI color spaces may have different XcmsColorFormat IDs between
+ * clients. So, you must be careful when using XcmsColor
+ * structures between clients! Use the routines XcmsFormatOfPrefix()
+ * and XcmsPrefixOfFormat() appropriately.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ XcmsColorSpace *ptmpCS;
+ XcmsColorFormat lastID = 0;
+
+ if ((pCS->id = _XcmsRegFormatOfPrefix(pCS->prefix)) != 0) {
+ if (XCMS_DD_ID(pCS->id)) {
+ /* This is a Device-Dependent Color Space */
+ return(XcmsFailure);
+ }
+ /*
+ * REGISTERED DI Color Space
+ * then see if the color space has already been added to the
+ * system:
+ * a. If the same ID/prefix and same XcmsColorSpec is found,
+ * then its a duplicate, so return success.
+ * b. If same ID/prefix but different XcmsColorSpec is
+ * found, then add the color space to the front of the
+ * list using the same ID. This allows one to override
+ * an existing DI Color Space.
+ * c. Otherwise none found so just add the color space.
+ */
+ if ((papColorSpaces = _XcmsDIColorSpaces) != NULL) {
+ while ((ptmpCS = *papColorSpaces++) != NULL) {
+ if (pCS->id == ptmpCS->id) {
+ if (pCS == ptmpCS) {
+ /* a. duplicate*/
+ return(XcmsSuccess);
+ }
+ /* b. same ID/prefix but different XcmsColorSpace */
+ break;
+ }
+ }
+ }
+ /* c. None found */
+ } else {
+ /*
+ * UNREGISTERED DI Color Space
+ * then see if the color space has already been added to the
+ * system:
+ * a. If same prefix and XcmsColorSpec, then
+ * its a duplicate ... return success.
+ * b. If same prefix but different XcmsColorSpec, then
+ * add the color space to the front of the list using
+ * the same ID. This allows one to override an existing
+ * DI Color Space.
+ * c. Otherwise none found so, add the color space using the
+ * next unregistered ID for the connection.
+ */
+ if ((papColorSpaces = _XcmsDIColorSpaces) != NULL) {
+ while ((ptmpCS = *papColorSpaces++) != NULL) {
+ lastID = MAX(lastID, ptmpCS->id);
+ if (strcmp(pCS->prefix, ptmpCS->prefix) == 0) {
+ if (pCS == ptmpCS) {
+ /* a. duplicate */
+ return(XcmsSuccess);
+ }
+ /* b. same prefix but different XcmsColorSpec */
+ pCS->id = ptmpCS->id;
+ goto AddColorSpace;
+ }
+ }
+ }
+ /* c. None found */
+ pCS->id = NextUnregDiCsID(lastID);
+ }
+
+
+AddColorSpace:
+ if ((papColorSpaces = (XcmsColorSpace **)
+ _XcmsPushPointerArray((XPointer *)_XcmsDIColorSpaces,
+ (XPointer)pCS,
+ (XPointer *)_XcmsDIColorSpacesInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsDIColorSpaces = papColorSpaces;
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/AddSF.c b/src/xcms/AddSF.c
new file mode 100644
index 00000000..5c2ae54d
--- /dev/null
+++ b/src/xcms/AddSF.c
@@ -0,0 +1,155 @@
+/* $Xorg: AddSF.c,v 1.3 2000/08/17 19:44:29 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAddSF.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAddFunctionSet
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define NextUnregDdCsID(lastid) \
+ (XCMS_UNREG_ID(lastid) ? ++lastid : XCMS_FIRST_UNREG_DD_ID)
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+
+
+/*
+ * EXTERNS
+ */
+extern XPointer *_XcmsPushPointerArray();
+extern XcmsColorFormat _XcmsRegFormatOfPrefix();
+extern XcmsFunctionSet **_XcmsSCCFuncSets;
+extern XcmsFunctionSet **_XcmsSCCFuncSetsInit;
+extern XcmsColorSpace **_XcmsDDColorSpaces;
+extern XcmsColorSpace **_XcmsDDColorSpacesInit;
+
+
+
+/*
+ * NAME
+ * XcmsAddFunctionSet - Add an Screen Color Characterization
+ * Function Set
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAddFunctionSet(pNewFS)
+ XcmsFunctionSet *pNewFS;
+/*
+ * DESCRIPTION
+ * Additional Screen Color Characterization Function Sets are
+ * managed on a global basis. This means that with exception
+ * of the provided DD color spaces:
+ * RGB and RGBi
+ * DD color spaces may have different XcmsColorFormat IDs between
+ * clients. So, you must be careful when using XcmsColorFormat
+ * across clients! Use the routines XcmsFormatOfPrefix()
+ * and XcmsPrefixOfFormat() appropriately.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure
+ *
+ * CAVEATS
+ * Additional Screen Color Characterization Function Sets
+ * should be added prior to any use of the routine
+ * XcmsCreateCCC(). If not, XcmsCCC structures created
+ * prior to the call of this routines will not have had
+ * a chance to initialize using the added Screen Color
+ * Characterization Function Set.
+ */
+{
+ XcmsFunctionSet **papSCCFuncSets = _XcmsSCCFuncSets;
+ XcmsColorSpace **papNewCSs;
+ XcmsColorSpace *pNewCS, **paptmpCS;
+ XcmsColorFormat lastID = 0;
+
+
+ if (papSCCFuncSets != NULL) {
+ if ((papNewCSs = pNewFS->DDColorSpaces) == NULL) {
+ /*
+ * Error, new Screen Color Characterization Function Set
+ * missing color spaces
+ */
+ return(XcmsFailure);
+ }
+ while ((pNewCS = *papNewCSs++) != NULL) {
+ if ((pNewCS->id = _XcmsRegFormatOfPrefix(pNewCS->prefix)) != 0) {
+ if (XCMS_DI_ID(pNewCS->id)) {
+ /* This is a Device-Independent Color Space */
+ return(XcmsFailure);
+ }
+ /*
+ * REGISTERED DD Color Space
+ * therefore use the registered ID.
+ */
+ } else {
+ /*
+ * UNREGISTERED DD Color Space
+ * then see if the color space is already in
+ * _XcmsDDColorSpaces.
+ * a. If same prefix, then use the same ID.
+ * b. Otherwise, use a new ID.
+ */
+ for (paptmpCS = _XcmsDDColorSpaces; *paptmpCS != NULL;
+ paptmpCS++){
+ lastID = MIN(lastID, (*paptmpCS)->id);
+ if (strcmp(pNewCS->prefix, (*paptmpCS)->prefix) == 0) {
+ pNewCS->id = (*paptmpCS)->id;
+ break;
+ }
+ }
+ if (pNewCS->id == 0) {
+ /* still haven't found one */
+ pNewCS->id = NextUnregDdCsID(lastID);
+ if ((paptmpCS = (XcmsColorSpace **)_XcmsPushPointerArray(
+ (XPointer *) _XcmsDDColorSpaces,
+ (XPointer) pNewCS,
+ (XPointer *) _XcmsDDColorSpacesInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsDDColorSpaces = paptmpCS;
+ }
+ }
+ }
+ }
+ if ((papSCCFuncSets = (XcmsFunctionSet **)
+ _XcmsPushPointerArray((XPointer *) _XcmsSCCFuncSets,
+ (XPointer) pNewFS,
+ (XPointer *)_XcmsSCCFuncSetsInit)) == NULL) {
+ return(XcmsFailure);
+ }
+ _XcmsSCCFuncSets = papSCCFuncSets;
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/CCC.c b/src/xcms/CCC.c
new file mode 100644
index 00000000..9a7d5162
--- /dev/null
+++ b/src/xcms/CCC.c
@@ -0,0 +1,287 @@
+/* $Xorg: CCC.c,v 1.4 2001/02/09 02:03:31 xorgcvs Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCCC.c - Color Conversion Context Routines
+ *
+ * DESCRIPTION
+ * Routines to create, access, and free Color Conversion
+ * Context structures.
+ *
+ *
+ */
+
+/*
+
+Copyright 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+extern XcmsIntensityMap *_XcmsGetIntensityMap();
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCreateCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsCCC
+XcmsCreateCCC(dpy, screenNumber, visual, clientWhitePt, gamutCompProc,
+ gamutCompClientData, whitePtAdjProc, whitePtAdjClientData)
+ Display *dpy;
+ int screenNumber;
+ Visual *visual;
+ XcmsColor *clientWhitePt;
+ XcmsCompressionProc gamutCompProc;
+ XPointer gamutCompClientData;
+ XcmsWhiteAdjustProc whitePtAdjProc;
+ XPointer whitePtAdjClientData;
+/*
+ * DESCRIPTION
+ * Given a Display, Screen, Visual, etc., this routine creates
+ * an appropriate Color Conversion Context.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise address of the newly
+ * created XcmsCCC.
+ *
+ */
+{
+ XcmsCCC pDefaultCCC = XcmsDefaultCCC(dpy, screenNumber);
+ XcmsCCC newccc;
+ XcmsIntensityMap *pIMap;
+ XcmsPerScrnInfo *pNewScrnInfo;
+
+ if (pDefaultCCC == NULL ||
+ !(newccc = (XcmsCCC) Xcalloc(1, (unsigned) sizeof(XcmsCCCRec)))) {
+ return(NULL);
+ }
+
+ /*
+ * Should inherit the following as result of a memmove():
+ * dpy
+ * screenNumber
+ * pPerScrnInfo
+ */
+ memcpy((char *)newccc, (char *)pDefaultCCC, sizeof(XcmsCCCRec));
+ if (clientWhitePt) {
+ memcpy((char *)&newccc->clientWhitePt, (char *)clientWhitePt,
+ sizeof(XcmsColor));
+ }
+ if (gamutCompProc) {
+ newccc->gamutCompProc = gamutCompProc;
+ }
+ if (gamutCompClientData) {
+ newccc->gamutCompClientData = gamutCompClientData;
+ }
+ if (whitePtAdjProc) {
+ newccc->whitePtAdjProc = whitePtAdjProc;
+ }
+ if (whitePtAdjClientData) {
+ newccc->whitePtAdjClientData = whitePtAdjClientData;
+ }
+
+ /*
+ * Now check our list of per-Visual Intensity tables.
+ * If one exists replace the pPerScrnInfo.
+ */
+ if ((pIMap = _XcmsGetIntensityMap(dpy, visual)) != NULL) {
+ if (!(pNewScrnInfo = (XcmsPerScrnInfo *)
+ Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ Xfree(newccc);
+ return(NULL);
+ }
+ memcpy((char *)pNewScrnInfo, (char *)newccc->pPerScrnInfo,
+ sizeof(XcmsPerScrnInfo));
+ pNewScrnInfo->screenData = pIMap->screenData;
+ newccc->pPerScrnInfo = pNewScrnInfo;
+ }
+
+ /*
+ * Set visual component
+ */
+ newccc->visual = visual;
+
+ return(newccc);
+}
+
+
+/*
+ * NAME
+ * XcmsDefaultCCC
+ *
+ * SYNOPSIS
+ */
+XcmsCCC
+XcmsDefaultCCC(dpy, screenNumber)
+ Display *dpy;
+ int screenNumber;
+/*
+ * DESCRIPTION
+ * Given a Display and Screen, this routine creates
+ * returns the Screen's default Color Conversion Context.
+ * Note that a Screen's default CCC is built with the
+ * screen default visual.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise address of the
+ * XcmsCCC for the Screen's default CCC.
+ *
+ */
+{
+ XcmsCCC ccc;
+
+
+ if ((screenNumber < 0) || (screenNumber >= ScreenCount(dpy))) {
+ return((XcmsCCC)NULL);
+ }
+
+ /*
+ * Check if the XcmsCCC's for each screen has been created
+ */
+ if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
+ if (!_XcmsInitDefaultCCCs(dpy)) {
+ return((XcmsCCC)NULL);
+ }
+ }
+
+ ccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
+
+ if (!ccc->pPerScrnInfo) {
+ /*
+ * Need to create the XcmsPerScrnInfo structure. The
+ * _XcmsInitScrnInfo routine will create the XcmsPerScrnInfo
+ * structure as well as initialize its functionSet and pScreenData
+ * components.
+ */
+ if (!_XcmsInitScrnInfo(dpy, screenNumber)) {
+ return((XcmsCCC)NULL);
+ }
+ return(ccc);
+ } else {
+ /*
+ * If ccc->pPerScrnInfo->state == XcmsInitSuccess,
+ * then the pPerScrnInfo component has already been initialized
+ * therefore, just return ccc.
+ * If ccc->pPerScrnInfo->state == XcmsInitFailure,
+ * then this means that we already attempted to initialize
+ * the pPerScrnInfo component but failed therefore stuffing
+ * the pPerScrnInfo component with defaults. Just return ccc.
+ * If ccc->pPerScrnInfo->state == XcmsInitNone,
+ * then attempt to initialize the pPerScrnInfo component.
+ */
+ switch (ccc->pPerScrnInfo->state) {
+ case XcmsInitFailure :
+ /* fall through */
+ case XcmsInitSuccess :
+ return(ccc);
+ case XcmsInitNone :
+ /* XcmsPerScreenInfo has not been initialized */
+ if (!_XcmsInitScrnInfo(dpy, screenNumber)) {
+ return((XcmsCCC)NULL);
+ }
+ return(ccc);
+ default :
+ return((XcmsCCC)NULL);
+ }
+ }
+}
+
+
+/*
+ * NAME
+ * XcmsFreeCCC
+ *
+ * SYNOPSIS
+ */
+void
+XcmsFreeCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Frees memory associated with a Color Conversion Context
+ * that was created with XcmsCreateCCC().
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ if (ccc->dpy->cms.defaultCCCs &&
+ ccc == ((XcmsCCC)ccc->dpy->cms.defaultCCCs) + ccc->screenNumber) {
+ /* do not allow clients to free DefaultCCC's */
+ return;
+ }
+
+ /*
+ * Note that XcmsPerScrnInfo sub-structures are freed here only if
+ * they are for visuals that have per-Visual intensity tables.
+ * Otherwise the XcmsPerScrnInfo structure is being shared!
+ * For the latter, there is only one allocated per Screen and it just
+ * so happens * that we place its initial reference is placed in the
+ * default CCC. The routine _XcmsFreeDefaultCCCs frees them.
+ */
+ if (_XcmsGetIntensityMap(ccc->dpy, ccc->visual) != NULL) {
+ Xfree(ccc->pPerScrnInfo);
+ }
+
+ Xfree(ccc);
+}
diff --git a/src/xcms/CvColW.c b/src/xcms/CvColW.c
new file mode 100644
index 00000000..249e30e5
--- /dev/null
+++ b/src/xcms/CvColW.c
@@ -0,0 +1,139 @@
+/* $Xorg: CvColW.c,v 1.3 2000/08/17 19:44:32 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * XcmsCvColW.c
+ *
+ * DESCRIPTION
+ * <overall description of what the package does>
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * _XcmsConvertColorsWithWhitePt - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ XcmsColor *pWhitePt;
+ unsigned int nColors;
+ XcmsColorFormat newFormat;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures between device-independent
+ * and/or device-dependent formats but allowing the calling
+ * routine to specify the white point to be associated
+ * with the color specifications (overriding
+ * ccc->clientWhitePt).
+ *
+ * This routine has been provided for use in white point
+ * adjustment routines.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ *
+ */
+{
+ if (ccc == NULL || pColors_in_out == NULL ||
+ pColors_in_out->format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0 || pColors_in_out->format == newFormat) {
+ /* do nothing */
+ return(XcmsSuccess);
+ }
+
+ if (XCMS_DI_ID(pColors_in_out->format) && XCMS_DI_ID(newFormat)) {
+ /*
+ * Device-Independent to Device-Independent Conversion
+ */
+ return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat));
+ }
+ if (XCMS_DD_ID(pColors_in_out->format) && XCMS_DD_ID(newFormat)) {
+ /*
+ * Device-Dependent to Device-Dependent Conversion
+ */
+ return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
+ pCompressed));
+ }
+
+ /*
+ * Otherwise we have:
+ * 1. Device-Independent to Device-Dependent Conversion
+ * OR
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+
+ if (XCMS_DI_ID(pColors_in_out->format)) {
+ /*
+ * 1. Device-Independent to Device-Dependent Conversion
+ */
+ /* First convert to CIEXYZ */
+ if (_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ /* Then convert to DD Format */
+ return(_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
+ pCompressed));
+ } else {
+ /*
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+ /* First convert to CIEXYZ */
+ if (_XcmsDDConvertColors(ccc, pColors_in_out, nColors,
+ XcmsCIEXYZFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ /* Then convert to DI Format */
+ return(_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat));
+ }
+}
diff --git a/src/xcms/CvCols.c b/src/xcms/CvCols.c
new file mode 100644
index 00000000..d74ea323
--- /dev/null
+++ b/src/xcms/CvCols.c
@@ -0,0 +1,1048 @@
+/* $Xorg: CvCols.c,v 1.3 2000/08/17 19:44:32 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCvCols.c
+ *
+ * DESCRIPTION
+ * Xcms API routine that converts between the
+ * device-independent color spaces.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ * External declarations required locally to this package
+ * that are not already declared in any of the included header
+ * files (external includes or internal includes).
+ */
+extern XcmsRegColorSpaceEntry _XcmsRegColorSpaces[];
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+extern XcmsColorSpace **_XcmsDDColorSpaces;
+
+/*
+ * LOCAL DEFINES
+ */
+#define DD_FORMAT 0x01
+#define DI_FORMAT 0x02
+#define MIX_FORMAT 0x04
+#ifndef MAX
+# define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif
+
+/*
+ * FORWARD DECLARATIONS
+ */
+Status _XcmsDIConvertColors();
+Status _XcmsDDConvertColors();
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * EqualCIEXYZ
+ *
+ * SYNOPSIS
+ */
+static int
+EqualCIEXYZ(p1, p2)
+ XcmsColor *p1, *p2;
+/*
+ * DESCRIPTION
+ * Compares two XcmsColor structures that are in XcmsCIEXYZFormat
+ *
+ * RETURNS
+ * Returns 1 if equal; 0 otherwise.
+ *
+ */
+{
+ if (p1->format != XcmsCIEXYZFormat || p2->format != XcmsCIEXYZFormat) {
+ return(0);
+ }
+ if ((p1->spec.CIEXYZ.X != p2->spec.CIEXYZ.X)
+ || (p1->spec.CIEXYZ.Y != p2->spec.CIEXYZ.Y)
+ || (p1->spec.CIEXYZ.Z != p2->spec.CIEXYZ.Z)) {
+ return(0);
+ }
+ return(1);
+}
+
+
+/*
+ * NAME
+ * XcmsColorSpace
+ *
+ * SYNOPSIS
+ */
+static XcmsColorSpace *
+ColorSpaceOfID(ccc, id)
+ XcmsCCC ccc;
+ XcmsColorFormat id;
+/*
+ * DESCRIPTION
+ * Returns a pointer to the color space structure
+ * (XcmsColorSpace) associated with the specified color space
+ * ID.
+ *
+ * RETURNS
+ * Pointer to matching XcmsColorSpace structure if found;
+ * otherwise NULL.
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+
+ if (ccc == NULL) {
+ return(NULL);
+ }
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
+
+
+/*
+ * NAME
+ * ValidDIColorSpaceID
+ *
+ * SYNOPSIS
+ */
+static int
+ValidDIColorSpaceID(id)
+ XcmsColorFormat id;
+/*
+ * DESCRIPTION
+ * Determines if the specified color space ID is a valid
+ * Device-Independent color space in the specified Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns zero if not valid; otherwise non-zero.
+ */
+{
+ XcmsColorSpace **papRec;
+ papRec = _XcmsDIColorSpaces;
+ if (papRec != NULL) {
+ while (*papRec != NULL) {
+ if ((*papRec)->id == id) {
+ return(1);
+ }
+ papRec++;
+ }
+ }
+ return(0);
+}
+
+
+/*
+ * NAME
+ * ValidDDColorSpaceID
+ *
+ * SYNOPSIS
+ */
+static int
+ValidDDColorSpaceID(ccc, id)
+ XcmsCCC ccc;
+ XcmsColorFormat id;
+/*
+ * DESCRIPTION
+ * Determines if the specified color space ID is a valid
+ * Device-Dependent color space in the specified Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns zero if not valid; otherwise non-zero.
+ */
+{
+ XcmsColorSpace **papRec;
+
+ if (ccc->pPerScrnInfo->state != XcmsInitNone) {
+ papRec = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ while (*papRec != NULL) {
+ if ((*papRec)->id == id) {
+ return(1);
+ }
+ papRec++;
+ }
+ }
+ return(0);
+}
+
+
+/*
+ * NAME
+ * ConvertMixedColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+static Status
+ConvertMixedColors(ccc, pColors_in_out, pWhitePt, nColors,
+ targetFormat, format_flag)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ XcmsColor *pWhitePt;
+ unsigned int nColors;
+ XcmsColorFormat targetFormat;
+ unsigned char format_flag;
+/*
+ * DESCRIPTION
+ * This routine will only convert the following types of
+ * batches:
+ * DI to DI
+ * DD to DD
+ * DD to CIEXYZ
+ * In other words, it will not convert the following types of
+ * batches:
+ * DI to DD
+ * DD to DI(not CIEXYZ)
+ *
+ * format_flag:
+ * 0x01 : convert Device-Dependent only specifications to the
+ * target format.
+ * 0x02 : convert Device-Independent only specifications to the
+ * target format.
+ * 0x03 : convert all specifications to the target format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if none of the color specifications were
+ * compressed in the conversion process
+ * XcmsSuccessWithCompression if at least one of the
+ * color specifications were compressed in the
+ * conversion process.
+ *
+ */
+{
+ XcmsColor *pColor, *pColors_start;
+ XcmsColorFormat format;
+ Status retval_tmp;
+ Status retval = XcmsSuccess;
+ unsigned int iColors;
+ unsigned int nBatch;
+
+ /*
+ * Convert array of mixed color specifications in batches of
+ * contiguous formats to the target format
+ */
+ iColors = 0;
+ while (iColors < nColors) {
+ /*
+ * Find contiguous array of color specifications with the
+ * same format
+ */
+ pColor = pColors_start = pColors_in_out + iColors;
+ format = pColors_start->format;
+ nBatch = 0;
+ while (iColors < nColors && pColor->format == format) {
+ pColor++;
+ nBatch++;
+ iColors++;
+ }
+ if (format != targetFormat) {
+ /*
+ * Need to convert this batch from current format to target format.
+ */
+ if (XCMS_DI_ID(format) && (format_flag & DI_FORMAT) &&
+ XCMS_DI_ID(targetFormat)) {
+ /*
+ * DI->DI
+ *
+ * Format of interest is Device-Independent,
+ * This batch contains Device-Independent specifications, and
+ * the Target format is Device-Independent.
+ */
+ retval_tmp = _XcmsDIConvertColors(ccc, pColors_start, pWhitePt,
+ nBatch, targetFormat);
+ } else if (XCMS_DD_ID(format) && (format_flag & DD_FORMAT) &&
+ (targetFormat == XcmsCIEXYZFormat)) {
+ /*
+ * DD->CIEXYZ
+ *
+ * Format of interest is Device-Dependent,
+ * This batch contains Device-Dependent specifications, and
+ * the Target format is CIEXYZ.
+ *
+ * Since DD->CIEXYZ we can use NULL instead of pCompressed.
+ */
+ if ((ccc->whitePtAdjProc != NULL) && !_XcmsEqualWhitePts(ccc,
+ pWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ /*
+ * Need to call WhiteAdjustProc (Screen White Point to
+ * White Point).
+ */
+ retval_tmp = (*ccc->whitePtAdjProc)(ccc,
+ ScreenWhitePointOfCCC(ccc), pWhitePt,
+ XcmsCIEXYZFormat, pColors_start, nBatch,
+ (Bool *)NULL);
+ } else {
+ retval_tmp = _XcmsDDConvertColors(ccc, pColors_start,
+ nBatch, XcmsCIEXYZFormat, (Bool *)NULL);
+ }
+ } else if (XCMS_DD_ID(format) && (format_flag & DD_FORMAT) &&
+ XCMS_DD_ID(targetFormat)) {
+ /*
+ * DD->DD(not CIEXYZ)
+ *
+ * Format of interest is Device-Dependent,
+ * This batch contains Device-Dependent specifications, and
+ * the Target format is Device-Dependent and not CIEXYZ.
+ */
+ retval_tmp = _XcmsDDConvertColors(ccc, pColors_start, nBatch,
+ targetFormat, (Bool *)NULL);
+ } else {
+ /*
+ * This routine is called for the wrong reason.
+ */
+ return(XcmsFailure);
+ }
+ if (retval_tmp == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = MAX(retval, retval_tmp);
+ }
+ }
+ return(retval);
+}
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsEqualWhitePts
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsEqualWhitePts(ccc, pWhitePt1, pWhitePt2)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePt1, *pWhitePt2;
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * Returns 0 if not equal; otherwise 1.
+ *
+ */
+{
+ XcmsColor tmp1, tmp2;
+
+ memcpy((char *)&tmp1, (char *)pWhitePt1, sizeof(XcmsColor));
+ memcpy((char *)&tmp2, (char *)pWhitePt2, sizeof(XcmsColor));
+
+ if (tmp1.format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, &tmp1, (XcmsColor *) NULL, 1,
+ XcmsCIEXYZFormat)==0) {
+ return(0);
+ }
+ }
+
+ if (tmp2.format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, &tmp2, (XcmsColor *) NULL, 1,
+ XcmsCIEXYZFormat)==0) {
+ return(0);
+ }
+ }
+
+ return (EqualCIEXYZ(&tmp1, &tmp2));
+}
+
+
+/*
+ * NAME
+ * _XcmsDIConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsDIConvertColors(ccc, pColors_in_out, pWhitePt, nColors,
+ newFormat)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ XcmsColor *pWhitePt;
+ unsigned int nColors;
+ XcmsColorFormat newFormat;
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures to another Device-Independent
+ * form.
+ *
+ * Here are some assumptions that this routine makes:
+ * 1. The calling routine has already checked if
+ * pColors_in_out->format == newFormat, therefore
+ * there is no need to check again here.
+ * 2. The calling routine has already checked nColors,
+ * therefore this routine assumes nColors > 0.
+ * 3. The calling routine may want to convert only between
+ * CIExyY <-> CIEXYZ <-> CIEuvY
+ * therefore, this routine allows pWhitePt to equal NULL.
+ *
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColorSpace *pFrom, *pTo;
+ XcmsConversionProc *src_to_CIEXYZ, *src_from_CIEXYZ;
+ XcmsConversionProc *dest_to_CIEXYZ, *dest_from_CIEXYZ;
+ XcmsConversionProc *to_CIEXYZ_stop, *from_CIEXYZ_start;
+ XcmsConversionProc *tmp;
+
+ /*
+ * Allow pWhitePt to equal NULL. This appropriate when converting
+ * anywhere between:
+ * CIExyY <-> CIEXYZ <-> CIEuvY
+ */
+
+ if (pColors_in_out == NULL ||
+ !ValidDIColorSpaceID(pColors_in_out->format) ||
+ !ValidDIColorSpaceID(newFormat)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Get a handle on the function list for the current specification format
+ */
+ if ((pFrom = ColorSpaceOfID(ccc, pColors_in_out->format))
+ == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Get a handle on the function list for the new specification format
+ */
+ if ((pTo = ColorSpaceOfID(ccc, newFormat)) == NULL) {
+ return(XcmsFailure);
+ }
+
+ src_to_CIEXYZ = pFrom->to_CIEXYZ;
+ src_from_CIEXYZ = pFrom->from_CIEXYZ;
+ dest_to_CIEXYZ = pTo->to_CIEXYZ;
+ dest_from_CIEXYZ = pTo->from_CIEXYZ;
+
+ if (pTo->inverse_flag && pFrom->inverse_flag) {
+ /*
+ * Find common function pointers
+ */
+ for (to_CIEXYZ_stop = src_to_CIEXYZ; *to_CIEXYZ_stop; to_CIEXYZ_stop++){
+ for (tmp = dest_to_CIEXYZ; *tmp; tmp++) {
+ if (*to_CIEXYZ_stop == *tmp) {
+ goto Continue;
+ }
+ }
+ }
+
+Continue:
+
+ /*
+ * Execute the functions to CIEXYZ, stopping short as necessary
+ */
+ while (src_to_CIEXYZ != to_CIEXYZ_stop) {
+ if ((*src_to_CIEXYZ++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ tmp = src_from_CIEXYZ;
+ while ((*from_CIEXYZ_start == *tmp) && (*from_CIEXYZ_start != NULL)) {
+ from_CIEXYZ_start++;
+ tmp++;
+ }
+
+ } else {
+ /*
+ * The function in at least one of the Color Spaces are not
+ * complementary, i.e.,
+ * for an i, 0 <= i < n elements
+ * from_CIEXYZ[i] is not the inverse of to_CIEXYZ[i]
+ *
+ * Execute the functions all the way to CIEXYZ
+ */
+ while (*src_to_CIEXYZ) {
+ if ((*src_to_CIEXYZ++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ }
+
+
+ /*
+ * Execute the functions from CIEXYZ.
+ */
+ while (*from_CIEXYZ_start) {
+ if ((*from_CIEXYZ_start++)(ccc, pWhitePt, pColors_in_out,
+ nColors) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsDDConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsDDConvertColors(ccc, pColors_in_out, nColors, newFormat,
+ pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat newFormat;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures:
+ *
+ * 1. From CIEXYZ to Device-Dependent formats (typically RGB and
+ * RGBi),
+ * or
+ * 2. Between Device-Dependent formats (typically RGB and RGBi).
+ *
+ * Assumes that these specifications have already been white point
+ * adjusted if necessary from Client White Point to Screen
+ * White Point. Therefore, the white point now associated
+ * with the specifications is the Screen White Point.
+ *
+ * pCompressed may be NULL. If so this indicates that the
+ * calling routine is not interested in knowing exactly which
+ * color was compressed, if any.
+ *
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if none of the color specifications were
+ * compressed in the conversion process
+ * XcmsSuccessWithCompression if at least one of the
+ * color specifications were compressed in the
+ * conversion process.
+ *
+ */
+{
+ XcmsColorSpace *pFrom, *pTo;
+ XcmsConversionProc *src_to_CIEXYZ, *src_from_CIEXYZ;
+ XcmsConversionProc *dest_to_CIEXYZ, *dest_from_CIEXYZ;
+ XcmsConversionProc *from_CIEXYZ_start, *to_CIEXYZ_stop;
+ XcmsConversionProc *tmp;
+ int retval;
+ int hasCompressed = 0;
+
+ if (ccc == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0 || pColors_in_out->format == newFormat) {
+ /* do nothing */
+ return(XcmsSuccess);
+ }
+
+ if (((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet) == NULL) {
+ return(XcmsFailure); /* hmm, an internal error? */
+ }
+
+ /*
+ * Its ok if pColors_in_out->format == XcmsCIEXYZFormat
+ * or
+ * if newFormat == XcmsCIEXYZFormat
+ */
+ if ( !( ValidDDColorSpaceID(ccc, pColors_in_out->format)
+ ||
+ (pColors_in_out->format == XcmsCIEXYZFormat))
+ ||
+ !(ValidDDColorSpaceID(ccc, newFormat)
+ ||
+ newFormat == XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+
+ if ((pFrom = ColorSpaceOfID(ccc, pColors_in_out->format)) == NULL){
+ return(XcmsFailure);
+ }
+
+ if ((pTo = ColorSpaceOfID(ccc, newFormat)) == NULL) {
+ return(XcmsFailure);
+ }
+
+ src_to_CIEXYZ = pFrom->to_CIEXYZ;
+ src_from_CIEXYZ = pFrom->from_CIEXYZ;
+ dest_to_CIEXYZ = pTo->to_CIEXYZ;
+ dest_from_CIEXYZ = pTo->from_CIEXYZ;
+
+ if (pTo->inverse_flag && pFrom->inverse_flag) {
+ /*
+ * Find common function pointers
+ */
+ for (to_CIEXYZ_stop = src_to_CIEXYZ; *to_CIEXYZ_stop; to_CIEXYZ_stop++){
+ for (tmp = dest_to_CIEXYZ; *tmp; tmp++) {
+ if (*to_CIEXYZ_stop == *tmp) {
+ goto Continue;
+ }
+ }
+ }
+Continue:
+
+ /*
+ * Execute the functions
+ */
+ while (src_to_CIEXYZ != to_CIEXYZ_stop) {
+ retval = (*src_to_CIEXYZ++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ tmp = src_from_CIEXYZ;
+ while ((*from_CIEXYZ_start == *tmp) && (*from_CIEXYZ_start != NULL)) {
+ from_CIEXYZ_start++;
+ tmp++;
+ }
+
+ } else {
+ /*
+ * The function in at least one of the Color Spaces are not
+ * complementary, i.e.,
+ * for an i, 0 <= i < n elements
+ * from_CIEXYZ[i] is not the inverse of to_CIEXYZ[i]
+ *
+ * Execute the functions all the way to CIEXYZ
+ */
+ while (*src_to_CIEXYZ) {
+ retval = (*src_to_CIEXYZ++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ /*
+ * Determine where to start on the from_CIEXYZ path.
+ */
+ from_CIEXYZ_start = dest_from_CIEXYZ;
+ }
+
+ while (*from_CIEXYZ_start) {
+ retval = (*from_CIEXYZ_start++)(ccc, pColors_in_out, nColors,
+ pCompressed);
+ if (retval == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ hasCompressed |= (retval == XcmsSuccessWithCompression);
+ }
+
+ return(hasCompressed ? XcmsSuccessWithCompression : XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsConvertColors - Convert XcmsColor structures
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsConvertColors(ccc, pColors_in_out, nColors, targetFormat, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat targetFormat;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert XcmsColor structures to another format
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ *
+ */
+{
+ XcmsColor clientWhitePt;
+ XcmsColor Color1;
+ XcmsColor *pColors_tmp;
+ int callWhiteAdjustProc = 0;
+ XcmsColorFormat format;
+ Status retval;
+ unsigned char contents_flag = 0x00;
+ unsigned int iColors;
+
+ if (ccc == NULL || pColors_in_out == NULL ||
+ !(ValidDIColorSpaceID(targetFormat) ||
+ ValidDDColorSpaceID(ccc, targetFormat))) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Check formats in color specification array
+ */
+ format = pColors_in_out->format;
+ for (pColors_tmp = pColors_in_out, iColors = nColors; iColors; pColors_tmp++, iColors--) {
+ if (!(ValidDIColorSpaceID(pColors_tmp->format) ||
+ ValidDDColorSpaceID(ccc, pColors_tmp->format))) {
+ return(XcmsFailure);
+ }
+ if (XCMS_DI_ID(pColors_tmp->format)) {
+ contents_flag |= DI_FORMAT;
+ } else {
+ contents_flag |= DD_FORMAT;
+ }
+ if (pColors_tmp->format != format) {
+ contents_flag |= MIX_FORMAT;
+ }
+ }
+
+ /*
+ * Check if we need the Client White Point.
+ */
+ if ((contents_flag & DI_FORMAT) || XCMS_DI_ID(targetFormat)) {
+ /* To proceed, we need to get the Client White Point */
+ memcpy((char *)&clientWhitePt, (char *)&ccc->clientWhitePt,
+ sizeof(XcmsColor));
+ if (clientWhitePt.format == XcmsUndefinedFormat) {
+ /*
+ * Client White Point is undefined, therefore set to the Screen
+ * White Point.
+ * Since Client White Point == Screen White Point, WhiteAdjustProc
+ * is not called.
+ */
+ memcpy((char *)&clientWhitePt,
+ (char *)&ccc->pPerScrnInfo->screenWhitePt,
+ sizeof(XcmsColor));
+ } else if ((ccc->whitePtAdjProc != NULL) && !_XcmsEqualWhitePts(ccc,
+ &clientWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ /*
+ * Client White Point != Screen White Point, and WhiteAdjustProc
+ * is not NULL, therefore, will need to call it when
+ * converting between DI and DD specifications.
+ */
+ callWhiteAdjustProc = 1;
+ }
+ }
+
+ /*
+ * Make copy of array of color specifications
+ */
+ if (nColors > 1) {
+ pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ } else {
+ pColors_tmp = &Color1;
+ }
+ memcpy((char *)pColors_tmp, (char *)pColors_in_out,
+ nColors * sizeof(XcmsColor));
+
+ /*
+ * zero out pCompressed
+ */
+ if (pCompressed) {
+ bzero((char *)pCompressed, nColors * sizeof(Bool));
+ }
+
+ if (contents_flag == DD_FORMAT || contents_flag == DI_FORMAT) {
+ /*
+ * ENTIRE ARRAY IS IN ONE FORMAT.
+ */
+ if (XCMS_DI_ID(format) && XCMS_DI_ID(targetFormat)) {
+ /*
+ * DI-to-DI only conversion
+ */
+ retval = _XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, targetFormat);
+ } else if (XCMS_DD_ID(format) && XCMS_DD_ID(targetFormat)) {
+ /*
+ * DD-to-DD only conversion
+ * Since DD->DD there will be no compressed thus we can
+ * pass NULL instead of pCompressed.
+ */
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, (Bool *)NULL);
+ } else {
+ /*
+ * Otherwise we have:
+ * 1. Device-Independent to Device-Dependent Conversion
+ * OR
+ * 2. Device-Dependent to Device-Independent Conversion
+ *
+ * We need to go from oldFormat -> CIEXYZ -> targetFormat
+ * adjusting for white points as necessary.
+ */
+
+ if (XCMS_DI_ID(format)) {
+ /*
+ * 1. Device-Independent to Device-Dependent Conversion
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Client White Point to Screen White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc, &clientWhitePt,
+ ScreenWhitePointOfCCC(ccc), targetFormat,
+ pColors_tmp, nColors, pCompressed);
+ } else {
+ if (_XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, XcmsCIEXYZFormat)
+ == XcmsFailure) {
+ goto Failure;
+ }
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, pCompressed);
+ }
+ } else {
+ /*
+ * 2. Device-Dependent to Device-Independent Conversion
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Screen White Point to Client White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc,
+ ScreenWhitePointOfCCC(ccc), &clientWhitePt,
+ targetFormat, pColors_tmp, nColors, pCompressed);
+ } else {
+ /*
+ * Since DD->CIEXYZ, no compression takes place therefore
+ * we can pass NULL instead of pCompressed.
+ */
+ if (_XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ XcmsCIEXYZFormat, (Bool *)NULL) == XcmsFailure) {
+ goto Failure;
+ }
+ retval = _XcmsDIConvertColors(ccc, pColors_tmp,
+ &clientWhitePt, nColors, targetFormat);
+ }
+ }
+ }
+ } else {
+ /*
+ * ARRAY HAS MIXED FORMATS.
+ */
+ if ((contents_flag == (DI_FORMAT | MIX_FORMAT)) &&
+ XCMS_DI_ID(targetFormat)) {
+ /*
+ * Convert from DI to DI in batches of contiguous formats
+ *
+ * Because DI->DI, WhiteAdjustProc not called.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, targetFormat, (unsigned char)DI_FORMAT);
+ } else if ((contents_flag == (DD_FORMAT | MIX_FORMAT)) &&
+ XCMS_DD_ID(targetFormat)) {
+ /*
+ * Convert from DD to DD in batches of contiguous formats
+ *
+ * Because DD->DD, WhiteAdjustProc not called.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp,
+ (XcmsColor *)NULL, nColors, targetFormat,
+ (unsigned char)DD_FORMAT);
+ } else if (XCMS_DI_ID(targetFormat)) {
+ /*
+ * We need to convert from DI-to-DI and DD-to-DI, therefore
+ * 1. convert DD specifications to CIEXYZ, then
+ * 2. convert all in batches to the target DI format.
+ *
+ * Note that ConvertMixedColors will call WhiteAdjustProc
+ * as necessary.
+ */
+
+ /*
+ * Convert only DD specifications in batches of contiguous formats
+ * to CIEXYZ
+ *
+ * Since DD->CIEXYZ, ConvertMixedColors will apply WhiteAdjustProc
+ * if required.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, XcmsCIEXYZFormat, (unsigned char)DD_FORMAT);
+
+ /*
+ * Because at this point we may have a mix of DI formats
+ * (e.g., CIEXYZ, CIELuv) we must convert the specs to the
+ * target DI format in batches of contiguous source formats.
+ */
+ retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, targetFormat, (unsigned char)DI_FORMAT);
+ } else {
+ /*
+ * We need to convert from DI-to-DD and DD-to-DD, therefore
+ * 1. convert DI specifications to CIEXYZ, then
+ * 2. convert all to the DD target format.
+ *
+ * This allows white point adjustment and gamut compression
+ * to be applied to all the color specifications in one
+ * swoop if those functions do in fact modify the entire
+ * group of color specifications.
+ */
+
+ /*
+ * Convert in batches to CIEXYZ
+ *
+ * If DD->CIEXYZ, ConvertMixedColors will apply WhiteAdjustProc
+ * if required.
+ */
+ if ((retval = ConvertMixedColors(ccc, pColors_tmp, &clientWhitePt,
+ nColors, XcmsCIEXYZFormat,
+ (unsigned char)(DI_FORMAT | DD_FORMAT))) == XcmsFailure) {
+ goto Failure;
+ }
+
+ /*
+ * Convert all specifications (now in CIEXYZ format) to
+ * the target DD format.
+ * Since CIEXYZ->DD, compression MAY take place therefore
+ * we must pass pCompressed.
+ * Note that WhiteAdjustProc must be used if necessary.
+ */
+ if (callWhiteAdjustProc) {
+ /*
+ * White Point Adjustment
+ * Client White Point to Screen White Point
+ */
+ retval = (*ccc->whitePtAdjProc)(ccc,
+ &clientWhitePt, ScreenWhitePointOfCCC(ccc),
+ targetFormat, pColors_tmp, nColors, pCompressed);
+ } else {
+ retval = _XcmsDDConvertColors(ccc, pColors_tmp, nColors,
+ targetFormat, pCompressed);
+ }
+ }
+ }
+
+ if (retval != XcmsFailure) {
+ memcpy((char *)pColors_in_out, (char *)pColors_tmp,
+ nColors * sizeof(XcmsColor));
+ }
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+ return(retval);
+
+Failure:
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+ return(XcmsFailure);
+}
+
+
+/*
+ * NAME
+ * XcmsRegFormatOfPrefix
+ *
+ * SYNOPSIS
+ */
+XcmsColorFormat
+_XcmsRegFormatOfPrefix(prefix)
+ char *prefix;
+/*
+ * DESCRIPTION
+ * Returns a color space ID associated with the specified
+ * X Consortium registered color space prefix.
+ *
+ * RETURNS
+ * The color space ID if found;
+ * otherwise NULL.
+ */
+{
+ XcmsRegColorSpaceEntry *pEntry = _XcmsRegColorSpaces;
+
+ while (pEntry->prefix != NULL) {
+ if (strcmp(prefix, pEntry->prefix) == 0) {
+ return(pEntry->id);
+ }
+ pEntry++;
+ }
+ return(XcmsUndefinedFormat);
+}
diff --git a/src/xcms/HVC.c b/src/xcms/HVC.c
new file mode 100644
index 00000000..26bca265
--- /dev/null
+++ b/src/xcms/HVC.c
@@ -0,0 +1,611 @@
+/* $Xorg: HVC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVC.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the TekHVC
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <X11/Xos.h>
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define u_BR 0.7127 /* u' Best Red */
+#define v_BR 0.4931 /* v' Best Red */
+#define EPS 0.001
+#define CHROMA_SCALE_FACTOR 7.50725
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.14159265358979323846264338327950
+# endif
+#endif
+#ifndef degrees
+# define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
+#endif /* degrees */
+#ifndef radians
+# define radians(d) ((XcmsFloat)(d) * PI / 180.0)
+#endif /* radians */
+
+/*************************************************************************
+ * Note: The DBL_EPSILON for ANSI is 1e-5 so my checks need to take
+ * this into account. If your DBL_EPSILON is different then
+ * adjust this define.
+ *
+ * Also note that EPS is the error factor in the calculations
+ * This may need to be the same as XMY_DBL_EPSILON in
+ * some implementations.
+ **************************************************************************/
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * EXTERNS
+ */
+
+extern char _XcmsTekHVC_prefix[];
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int TekHVC_ParseString();
+static Status XcmsTekHVC_ValidSpec();
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from TekHVC to CIEXYZ
+ */
+static XcmsConversionProc Fl_TekHVC_to_CIEXYZ[] = {
+ XcmsTekHVCToCIEuvY,
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to TekHVC
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_TekHVC[] = {
+ XcmsCIEXYZToCIEuvY,
+ XcmsCIEuvYToTekHVC,
+ NULL
+};
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * TekHVC Color Space
+ */
+XcmsColorSpace XcmsTekHVCColorSpace =
+ {
+ _XcmsTekHVC_prefix, /* prefix */
+ XcmsTekHVCFormat, /* id */
+ TekHVC_ParseString, /* parseString */
+ Fl_TekHVC_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_TekHVC, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * TekHVC_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+TekHVC_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsTekHVCFormat.
+ * The assumed TekHVC string syntax is:
+ * TekHVC:<H>/<V>/<C>
+ * Where H, V, and C are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * XcmsFailure if invalid;
+ * XcmsSuccess if valid.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsTekHVC_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.TekHVC.H,
+ &pColor->spec.TekHVC.V,
+ &pColor->spec.TekHVC.C) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsTekHVCFormat;
+ pColor->pixel = 0;
+ return(XcmsTekHVC_ValidSpec(pColor));
+}
+
+
+/*
+ * NAME
+ * ThetaOffset -- compute thetaOffset
+ *
+ * SYNOPSIS
+ */
+static int
+ThetaOffset(pWhitePt, pThetaOffset)
+ XcmsColor *pWhitePt;
+ XcmsFloat *pThetaOffset;
+/*
+ * DESCRIPTION
+ * This routine computes the theta offset of a given
+ * white point, i.e. XcmsColor. It is used in both this
+ * conversion and the printer conversions.
+ *
+ * RETURNS
+ * 0 if failed.
+ * 1 if succeeded with no modifications.
+ *
+ * ASSUMPTIONS
+ * Assumes:
+ * pWhitePt != NULL
+ * pWhitePt->format == XcmsCIEuvYFormat
+ *
+ */
+{
+ double div, slopeuv;
+
+ if (pWhitePt == NULL || pWhitePt->format != XcmsCIEuvYFormat) {
+ return(0);
+ }
+
+ if ((div = u_BR - pWhitePt->spec.CIEuvY.u_prime) == 0.0) {
+ return(0);
+ }
+ slopeuv = (v_BR - pWhitePt->spec.CIEuvY.v_prime) / div;
+ *pThetaOffset = degrees(XCMS_ATAN(slopeuv));
+ return(1);
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVC_ValidSpec()
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsTekHVC_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if values in the color specification are valid.
+ * Also brings hue into the range 0.0 <= Hue < 360.0
+ *
+ * RETURNS
+ * 0 if not valid.
+ * 1 if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsTekHVCFormat) {
+ return(XcmsFailure);
+ }
+ if (pColor->spec.TekHVC.V < (0.0 - XMY_DBL_EPSILON)
+ || pColor->spec.TekHVC.V > (100.0 + XMY_DBL_EPSILON)
+ || (pColor->spec.TekHVC.C < 0.0 - XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.TekHVC.V < 0.0) {
+ pColor->spec.TekHVC.V = 0.0 + XMY_DBL_EPSILON;
+ } else if (pColor->spec.TekHVC.V > 100.0) {
+ pColor->spec.TekHVC.V = 100.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.C < 0.0) {
+ pColor->spec.TekHVC.C = 0.0 - XMY_DBL_EPSILON;
+ }
+
+ while (pColor->spec.TekHVC.H < 0.0) {
+ pColor->spec.TekHVC.H += 360.0;
+ }
+ while (pColor->spec.TekHVC.H >= 360.0) {
+ pColor->spec.TekHVC.H -= 360.0;
+ }
+ return(XcmsSuccess);
+}
+
+/*
+ * NAME
+ * XcmsTekHVCToCIEuvY - convert TekHVC to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCToCIEuvY(ccc, pHVC_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pHVC_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Transforms an array of TekHVC color specifications, given
+ * their associated white point, to CIECIEuvY.color
+ * specifications.
+ *
+ * RETURNS
+ * XcmsFailure if failed, XcmsSuccess otherwise.
+ *
+ */
+{
+ XcmsFloat thetaOffset;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEuvY uvY_return;
+ XcmsFloat tempHue, u, v;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pHVC_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pHVC_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pHVC_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pHVC_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pHVC_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /* Get the thetaOffset */
+ if (!ThetaOffset(pHVC_WhitePt, &thetaOffset)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is TekHVC and is valid */
+ if (!XcmsTekHVC_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.TekHVC.V == 0.0 || pColor->spec.TekHVC.V == 100.0) {
+ if (pColor->spec.TekHVC.V == 100.0) {
+ uvY_return.Y = 1.0;
+ } else { /* pColor->spec.TekHVC.V == 0.0 */
+ uvY_return.Y = 0.0;
+ }
+ uvY_return.u_prime = pHVC_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pHVC_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+
+ /* Find the hue based on the white point offset */
+ tempHue = pColor->spec.TekHVC.H + thetaOffset;
+
+ while (tempHue < 0.0) {
+ tempHue += 360.0;
+ }
+ while (tempHue >= 360.0) {
+ tempHue -= 360.0;
+ }
+
+ tempHue = radians(tempHue);
+
+ /* Calculate u'v' for the obtained hue */
+ u = (XcmsFloat) ((XCMS_COS(tempHue) * pColor->spec.TekHVC.C) /
+ (pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
+ v = (XcmsFloat) ((XCMS_SIN(tempHue) * pColor->spec.TekHVC.C) /
+ (pColor->spec.TekHVC.V * (double)CHROMA_SCALE_FACTOR));
+
+ /* Based on the white point get the offset from best red */
+ uvY_return.u_prime = u + pHVC_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = v + pHVC_WhitePt->spec.CIEuvY.v_prime;
+
+ /* Calculate the Y value based on the L* = V. */
+ if (pColor->spec.TekHVC.V < 7.99953624) {
+ uvY_return.Y = pColor->spec.TekHVC.V / 903.29;
+ } else {
+ tmpVal = (pColor->spec.TekHVC.V + 16.0) / 116.0;
+ uvY_return.Y = tmpVal * tmpVal * tmpVal; /* tmpVal ** 3 */
+ }
+ }
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToTekHVC - convert CIEuvY to TekHVC
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToTekHVC(ccc, pHVC_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pHVC_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Transforms an array of CIECIEuvY.color specifications, given
+ * their assiciated white point, to TekHVC specifications.
+ *
+ * RETURNS
+ * XcmsFailure if failed, XcmsSuccess otherwise.
+ *
+ */
+{
+ XcmsFloat theta, L2, u, v, nThetaLow, nThetaHigh;
+ XcmsFloat thetaOffset;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsTekHVC HVC_return;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pHVC_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pHVC_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pHVC_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pHVC_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pHVC_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ if (!ThetaOffset(pHVC_WhitePt, &thetaOffset)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Use the white point offset to determine HVC */
+ u = pColor->spec.CIEuvY.u_prime - pHVC_WhitePt->spec.CIEuvY.u_prime;
+ v = pColor->spec.CIEuvY.v_prime - pHVC_WhitePt->spec.CIEuvY.v_prime;
+
+ /* Calculate the offset */
+ if (u == 0.0) {
+ theta = 0.0;
+ } else {
+ theta = v / u;
+ theta = (XcmsFloat) XCMS_ATAN((double)theta);
+ theta = degrees(theta);
+ }
+
+ nThetaLow = 0.0;
+ nThetaHigh = 360.0;
+ if (u > 0.0 && v > 0.0) {
+ nThetaLow = 0.0;
+ nThetaHigh = 90.0;
+ } else if (u < 0.0 && v > 0.0) {
+ nThetaLow = 90.0;
+ nThetaHigh = 180.0;
+ } else if (u < 0.0 && v < 0.0) {
+ nThetaLow = 180.0;
+ nThetaHigh = 270.0;
+ } else if (u > 0.0 && v < 0.0) {
+ nThetaLow = 270.0;
+ nThetaHigh = 360.0;
+ }
+ while (theta < nThetaLow) {
+ theta += 90.0;
+ }
+ while (theta >= nThetaHigh) {
+ theta -= 90.0;
+ }
+
+ /* calculate the L value from the given Y */
+ L2 = (pColor->spec.CIEuvY.Y < 0.008856)
+ ?
+ (pColor->spec.CIEuvY.Y * 903.29)
+ :
+ ((XcmsFloat)(XCMS_CUBEROOT(pColor->spec.CIEuvY.Y) * 116.0) - 16.0);
+ HVC_return.C = L2 * CHROMA_SCALE_FACTOR * XCMS_SQRT((double) ((u * u) + (v * v)));
+ if (HVC_return.C < 0.0) {
+ theta = 0.0;
+ }
+ HVC_return.V = L2;
+ HVC_return.H = theta - thetaOffset;
+
+ /*
+ * If this is within the error margin let some other routine later
+ * in the chain worry about the slop in the calculations.
+ */
+ while (HVC_return.H < -EPS) {
+ HVC_return.H += 360.0;
+ }
+ while (HVC_return.H >= 360.0 + EPS) {
+ HVC_return.H -= 360.0;
+ }
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&HVC_return, sizeof(XcmsTekHVC));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsTekHVCFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsTekHVC_CheckModify
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsTekHVC_CheckModify(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if values in the color specification are valid.
+ * If they are not it modifies the values.
+ * Also brings hue into the range 0.0 <= Hue < 360.0
+ *
+ * RETURNS
+ * 0 if not valid.
+ * 1 if valid.
+ *
+ */
+{
+ int n;
+
+ /* For now only use the TekHVC numbers as inputs */
+ if (pColor->format != XcmsTekHVCFormat) {
+ return(0);
+ }
+
+ if (pColor->spec.TekHVC.V < 0.0) {
+ pColor->spec.TekHVC.V = 0.0 + XMY_DBL_EPSILON;
+ } else if (pColor->spec.TekHVC.V > 100.0) {
+ pColor->spec.TekHVC.V = 100.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.C < 0.0) {
+ pColor->spec.TekHVC.C = 0.0 - XMY_DBL_EPSILON;
+ }
+
+ if (pColor->spec.TekHVC.H < 0.0) {
+ n = -pColor->spec.TekHVC.H / 360.0;
+ pColor->spec.TekHVC.H += (n + 1) * 360.0;
+ if (pColor->spec.TekHVC.H >= 360.0)
+ pColor->spec.TekHVC.H -= 360.0;
+ } else if (pColor->spec.TekHVC.H >= 360.0) {
+ n = pColor->spec.TekHVC.H / 360.0;
+ pColor->spec.TekHVC.H -= n * 360.0;
+ }
+ return(1);
+}
diff --git a/src/xcms/HVCGcC.c b/src/xcms/HVCGcC.c
new file mode 100644
index 00000000..26a3f121
--- /dev/null
+++ b/src/xcms/HVCGcC.c
@@ -0,0 +1,153 @@
+/* $Xorg: HVCGcC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipC() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+extern XcmsFunctionSet XcmsLinearRGBFunctionSet;
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipC - Reduce the chroma for a hue and value
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipC (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and value to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions in Xcms, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsTekHVCFormat);
+ pColor->spec.TekHVC.H = pColor->spec.TekHVC.C = 0.0;
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsTekHVCFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsTekHVCQueryMaxC(ccc,
+ pColor->spec.TekHVC.H,
+ pColor->spec.TekHVC.V,
+ pColor)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/HVCGcV.c b/src/xcms/HVCGcV.c
new file mode 100644
index 00000000..7b062123
--- /dev/null
+++ b/src/xcms/HVCGcV.c
@@ -0,0 +1,206 @@
+/* $Xorg: HVCGcV.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcV.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipV() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVC_CheckModify();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+extern XcmsFunctionSet XcmsLinearRGBFunctionSet;
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipV - Return the closest value
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipV (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest value for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsColor *pColor;
+ XcmsColor hvc_max;
+ XcmsCCCRec myCCC;
+ Status retval;
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to TekHVC format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* check to make sure we have a valid TekHVC number */
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&hvc_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, hvc_max.spec.TekHVC.H, &hvc_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Now check and return the appropriate value */
+ if (pColor->spec.TekHVC.C == hvc_max.spec.TekHVC.C) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the value for that chroma. */
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ } else if (pColor->spec.TekHVC.C > hvc_max.spec.TekHVC.C) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the value and chroma for the given hue. */
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ return (XcmsFailure);
+ } else if (pColor->spec.TekHVC.V < hvc_max.spec.TekHVC.V) {
+ /* When the value input is less than the maximum value point */
+ /* compute the intersection of the line from 0,0 to max_V, max_C */
+ /* using the chroma input. */
+ pColor->spec.TekHVC.V = pColor->spec.TekHVC.C *
+ hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C;
+ if (pColor->spec.TekHVC.V >= hvc_max.spec.TekHVC.V) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ }
+ if (!_XcmsTekHVC_CheckModify (pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ } else {
+ /* When the value input is greater than the maximum value point */
+ /* use HvcMaxValue to find the maximum value for the given chroma. */
+ if (pColor->format != XcmsTekHVCFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsTekHVCQueryMaxV(&myCCC,
+ pColor->spec.TekHVC.H,
+ pColor->spec.TekHVC.C,
+ pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/HVCGcVC.c b/src/xcms/HVCGcVC.c
new file mode 100644
index 00000000..00d09b2a
--- /dev/null
+++ b/src/xcms/HVCGcVC.c
@@ -0,0 +1,267 @@
+/* $Xorg: HVCGcVC.c,v 1.3 2000/08/17 19:44:36 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCGcVC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCClipVC() gamut
+ * compression function.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+/*
+ * EXTERNS
+ */
+extern int _XcmsTekHVC_CheckModify();
+extern Status _XcmsTekHVCQueryMaxVCRGB();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+extern XcmsFunctionSet XcmsLinearRGBFunctionSet;
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCClipVC - Return the closest value and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsTekHVCClipVC (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest value and chroma
+ * for a specific hue. The color input is converted to
+ * HVC format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor hvc_max;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+ XcmsFloat Chroma, Value, bestChroma, bestValue, nT, saveDist, tmpDist;
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor &&
+ FunctionSetOfCCC(ccc) != (XPointer) &XcmsLinearRGBFunctionSet) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsTekHVCFormat);
+ pColor->spec.TekHVC.H = pColor->spec.TekHVC.C = 0.0;
+ _XcmsDIConvertColors(ccc, pColor, &ccc->pPerScrnInfo->screenWhitePt,
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ /* Convert from CIEXYZ to TekHVC format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&hvc_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, hvc_max.spec.TekHVC.H, &hvc_max,
+ &rgb_max) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Now check and return the appropriate value */
+ if (pColor->spec.TekHVC.V == hvc_max.spec.TekHVC.V) {
+ /* When the value input is equal to the maximum value */
+ /* merely return the chroma for that value. */
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ }
+
+ if (pColor->spec.TekHVC.V < hvc_max.spec.TekHVC.V) {
+ /* return the intersection of the perpindicular line through */
+ /* the value and chroma given and the line from 0,0 and hvc_max. */
+ Chroma = pColor->spec.TekHVC.C;
+ Value = pColor->spec.TekHVC.V;
+ pColor->spec.TekHVC.C =
+ (Value + (hvc_max.spec.TekHVC.C / hvc_max.spec.TekHVC.V * Chroma)) /
+ ((hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C) +
+ (hvc_max.spec.TekHVC.C / hvc_max.spec.TekHVC.V));
+ if (pColor->spec.TekHVC.C >= hvc_max.spec.TekHVC.C) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ } else {
+ pColor->spec.TekHVC.V = pColor->spec.TekHVC.C *
+ hvc_max.spec.TekHVC.V / hvc_max.spec.TekHVC.C;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return (retval);
+ }
+
+ /* return the closest point on the upper part of the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestValue = Value = pColor->spec.TekHVC.V;
+ bestChroma = Chroma = pColor->spec.TekHVC.C;
+ saveDist = (XcmsFloat) XCMS_SQRT ((double) (((Chroma - hvc_max.spec.TekHVC.C) *
+ (Chroma - hvc_max.spec.TekHVC.C)) +
+ ((Value - hvc_max.spec.TekHVC.V) *
+ (Value - hvc_max.spec.TekHVC.V))));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+ tmpDist = (XcmsFloat) XCMS_SQRT ((double)
+ (((Chroma - pColor->spec.TekHVC.C) *
+ (Chroma - pColor->spec.TekHVC.C)) +
+ ((Value - pColor->spec.TekHVC.V) *
+ (Value - pColor->spec.TekHVC.V))));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestValue = pColor->spec.TekHVC.V;
+ bestChroma = pColor->spec.TekHVC.C;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+
+ }
+
+ if (bestChroma >= hvc_max.spec.TekHVC.C) {
+ pColor->spec.TekHVC.C = hvc_max.spec.TekHVC.C;
+ pColor->spec.TekHVC.V = hvc_max.spec.TekHVC.V;
+ } else {
+ pColor->spec.TekHVC.C = bestChroma;
+ pColor->spec.TekHVC.V = bestValue;
+ }
+ if (!_XcmsTekHVC_CheckModify(pColor)) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/HVCMnV.c b/src/xcms/HVCMnV.c
new file mode 100644
index 00000000..f66e0e1c
--- /dev/null
+++ b/src/xcms/HVCMnV.c
@@ -0,0 +1,167 @@
+/* $Xorg: HVCMnV.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMnV.c
+ *
+ * DESCRIPTION
+ * Source for XcmsTekHVCQueryMinV gamut boundary querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define EPS 0.001
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVCQueryMaxVCRGB();
+extern Status _XcmsTekHVC_CheckModify();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMinV - Compute minimum value for hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMinV (ccc, hue, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the minimum value for a specific hue, and the
+ * corresponding chroma. The input color specification
+ * may be in any format, however output is in XcmsTekHVCFormat.
+ *
+ * Since this routine works with the value within
+ * pColor_return intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = 100.0;
+ tmp.spec.TekHVC.C = chroma;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+
+ /* Check for a valid HVC */
+ if (!_XcmsTekHVC_CheckModify (&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB (&myCCC, max_vc.spec.TekHVC.H, &max_vc,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 2: find the intersection with the maximum hvc and chroma line. */
+ if (tmp.spec.TekHVC.C > max_vc.spec.TekHVC.C + EPS) {
+ /* If the chroma is to large then return maximum hvc. */
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ } else {
+ tmp.spec.TekHVC.V = tmp.spec.TekHVC.C *
+ max_vc.spec.TekHVC.V / max_vc.spec.TekHVC.C;
+ if (tmp.spec.TekHVC.V > max_vc.spec.TekHVC.V) {
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ } else if (tmp.spec.TekHVC.V < 0.0) {
+ tmp.spec.TekHVC.V = tmp.spec.TekHVC.C = 0.0;
+ }
+ }
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+}
diff --git a/src/xcms/HVCMxC.c b/src/xcms/HVCMxC.c
new file mode 100644
index 00000000..e7e316fe
--- /dev/null
+++ b/src/xcms/HVCMxC.c
@@ -0,0 +1,247 @@
+/* $Xorg: HVCMxC.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxC() gamut boudary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS 0.001
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVCQueryMaxVCRGB();
+extern int _XcmsTekHVC_CheckModify();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxC - Compute the maximum chroma for a hue and value
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxC(ccc, hue, value, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat value;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue and value.
+ * The returned format is in XcmsTekHVCFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+ XcmsFloat nValue, savedValue, lastValue, lastChroma, prevValue;
+ XcmsFloat maxDist, nT, rFactor;
+ XcmsFloat ftmp1, ftmp2;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat; /* inherit screen white Pt */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = value;
+ tmp.spec.TekHVC.C = 100.0;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+ /* check to make sure we have a valid TekHVC number */
+ if (!_XcmsTekHVC_CheckModify(&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, hue, &max_vc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 2: If the value is less than the value for the maximum */
+ /* value, chroma point then the chroma is on the line */
+ /* from max_vc to 0,0. */
+ if (value <= max_vc.spec.TekHVC.V) {
+ tmp.spec.TekHVC.C = value
+ * max_vc.spec.TekHVC.C / max_vc.spec.TekHVC.V;
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ } else {
+ /* must do a bisection here to compute the maximum chroma */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nValue = savedValue = value;
+ lastValue = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ maxDist = 100.0 - max_vc.spec.TekHVC.V;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevValue = lastValue;
+ lastValue = tmp.spec.TekHVC.V;
+ lastChroma = tmp.spec.TekHVC.C;
+ nT = (nValue - max_vc.spec.TekHVC.V) / maxDist * rFactor;
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ if (tmp.spec.TekHVC.V <= savedValue + EPS &&
+ tmp.spec.TekHVC.V >= savedValue - EPS) {
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ }
+ nValue += savedValue - tmp.spec.TekHVC.V;
+ if (nValue < max_vc.spec.TekHVC.V) {
+ nValue = max_vc.spec.TekHVC.V;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nValue > 100.0) {
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ /* avoid using fabs */
+ ftmp1 = lastValue - savedValue;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.V - savedValue;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ if (_XcmsTekHVC_CheckModify (&tmp)) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ return(XcmsFailure);
+ }
+ } else if (tmp.spec.TekHVC.V <= prevValue + EPS &&
+ tmp.spec.TekHVC.V >= prevValue - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+ if (nCount >= nMaxCount) {
+ /* avoid using fabs */
+ ftmp1 = lastValue - savedValue;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.V - savedValue;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ }
+ }
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/HVCMxV.c b/src/xcms/HVCMxV.c
new file mode 100644
index 00000000..b1e70094
--- /dev/null
+++ b/src/xcms/HVCMxV.c
@@ -0,0 +1,250 @@
+/* $Xorg: HVCMxV.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxV.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxV() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS 0.001
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVCQueryMaxVCRGB();
+extern int _XcmsTekHVC_CheckModify();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxV - Compute maximum value for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxV(ccc, hue, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum value for a specified hue and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_vc;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+ XcmsFloat nT, nChroma, savedChroma, lastValue, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsFloat ftmp1, ftmp2;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ tmp.spec.TekHVC.H = hue;
+ tmp.spec.TekHVC.V = 0.0;
+ tmp.spec.TekHVC.C = chroma;
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsTekHVCFormat;
+
+ if (!_XcmsTekHVC_CheckModify (&tmp)) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&max_vc, (char *)&tmp, sizeof(XcmsColor));
+ hue = max_vc.spec.TekHVC.H;
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, max_vc.spec.TekHVC.H, &max_vc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ if (max_vc.spec.TekHVC.C < tmp.spec.TekHVC.C) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum value/chroma point then the value is the
+ * the value for the maximum value, chroma point.
+ * This is an error but it I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else if (max_vc.spec.TekHVC.C == tmp.spec.TekHVC.C) {
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum value/chroma point then the value is the
+ * the value for the maximum value, chroma point.
+ */
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else {
+ /* must do a bisection here to compute the maximum value */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = savedChroma = tmp.spec.TekHVC.C;
+ tmp.spec.TekHVC.C = max_vc.spec.TekHVC.C;
+ tmp.spec.TekHVC.V = max_vc.spec.TekHVC.V;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastValue = tmp.spec.TekHVC.V;
+ lastChroma = tmp.spec.TekHVC.C;
+ nT = (1.0 - (nChroma / max_vc.spec.TekHVC.C)) * rFactor;
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ if (tmp.spec.TekHVC.C <= savedChroma + EPS &&
+ tmp.spec.TekHVC.C >= savedChroma - EPS) {
+ tmp.spec.TekHVC.H = hue; /* use the saved hue */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += savedChroma - tmp.spec.TekHVC.C;
+ if (nChroma > max_vc.spec.TekHVC.C) {
+ nChroma = max_vc.spec.TekHVC.C;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ /* avoid using fabs */
+ ftmp1 = lastChroma - savedChroma;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.C - savedChroma;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ if (!_XcmsTekHVC_CheckModify(&tmp)) {
+ return(XcmsFailure);
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ } else if (tmp.spec.TekHVC.C <= prevChroma + EPS &&
+ tmp.spec.TekHVC.C >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+ if (nCount >= nMaxCount) {
+ /* avoid using fabs */
+ ftmp1 = lastChroma - savedChroma;
+ if (ftmp1 < 0.0)
+ ftmp1 = -ftmp1;
+ ftmp2 = tmp.spec.TekHVC.C - savedChroma;
+ if (ftmp2 < 0.0)
+ ftmp2 = -ftmp2;
+ if (ftmp1 < ftmp2) {
+ tmp.spec.TekHVC.V = lastValue;
+ tmp.spec.TekHVC.C = lastChroma;
+ }
+ }
+ }
+
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/HVCMxVC.c b/src/xcms/HVCMxVC.c
new file mode 100644
index 00000000..7c8ec7d0
--- /dev/null
+++ b/src/xcms/HVCMxVC.c
@@ -0,0 +1,244 @@
+/* $Xorg: HVCMxVC.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxVC() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_V 40.0
+#define START_C 120.0
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVC_CheckModify();
+extern Status _XcmsConvertColorsWithWhitePt();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+/*
+ * FORWARD DECLARATIONS
+ */
+Status _XcmsTekHVCQueryMaxVCRGB();
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsTekHVCQueryMaxVCRGB - Compute maximum value/chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsTekHVCQueryMaxVCRGB(ccc, hue, pColor_return, pRGB_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsColor *pColor_return;
+ XcmsRGBi *pRGB_return;
+
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specified hue, and the
+ * corresponding value. This is computed by a binary search of
+ * all possible chromas. An assumption is made that there are
+ * no local maxima. Use the unrounded Max Chroma because
+ * the difference check can be small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue as input and outputs
+ * HVC's and RGBi's.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XCMS_SUCCUSS - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsTekHVCFormat;
+ tmp.spec.TekHVC.H = hue;
+ /* Use some unreachable color on the given hue */
+ tmp.spec.TekHVC.V = START_V;
+ tmp.spec.TekHVC.C = START_C;
+
+
+ /*
+ * Convert from HVC to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to HVC */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* make sure to return the input hue */
+ tmp.spec.TekHVC.H = hue;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxVC - Compute maximum value and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxVC (ccc, hue, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for the specified hue, and the
+ * corresponding value.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue < 0.0) {
+ hue += 360.0;
+ }
+ while (hue >= 360.0) {
+ hue -= 360.0;
+ }
+
+ return(_XcmsTekHVCQueryMaxVCRGB (&myCCC, hue, pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/src/xcms/HVCMxVs.c b/src/xcms/HVCMxVs.c
new file mode 100644
index 00000000..33f84b61
--- /dev/null
+++ b/src/xcms/HVCMxVs.c
@@ -0,0 +1,166 @@
+/* $Xorg: HVCMxVs.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * TekHVCMxVs.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsTekHVCQueryMaxVSamples() gamut boundary
+ * querying routine.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsTekHVCQueryMaxVCRGB();
+extern Status _XcmsTekHVC_CheckModify();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCQueryMaxVSamples - Compute a set of value/chroma
+ * pairs.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCQueryMaxVSamples(ccc, hue, pColor_in_out, nSamples)
+ XcmsCCC ccc;
+ XcmsFloat hue;
+ XcmsColor *pColor_in_out;
+ unsigned int nSamples;
+
+/*
+ * DESCRIPTION
+ * Return a set of values and chromas for the input Hue.
+ * This routine will take any color as input.
+ * It returns TekHVC colors.
+ *
+ * Since this routine works with the value within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pHVC;
+ XcmsRGBi rgb_saved;
+ unsigned short nI;
+ XcmsFloat nT;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_in_out == NULL || nSamples == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ /* Step 1: compute the maximum value and chroma for this hue. */
+
+
+ /* save the Hue for use later. */
+ while (hue < 0.0) {
+ hue += 360.0;
+ }
+ while (hue > 360.0) {
+ hue -= 360.0;
+ }
+ pColor_in_out->spec.TekHVC.H = hue;
+ pColor_in_out->format = XcmsTekHVCFormat;
+
+ /* Get the maximum value and chroma point for this hue */
+ if (_XcmsTekHVCQueryMaxVCRGB(&myCCC, pColor_in_out->spec.TekHVC.H,
+ pColor_in_out, (XcmsRGBi *)&rgb_saved) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ /* Step 2: Convert each of the RGBi's to HVC's */
+ pHVC = pColor_in_out;
+ for (nI = 0; nI < nSamples; nI++, pHVC++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nSamples;
+ pHVC->spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ pHVC->spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ pHVC->spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ pHVC->format = XcmsRGBiFormat;
+ pHVC->pixel = pColor_in_out->pixel;
+ /* convert from RGB to HVC */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pHVC,
+ &myCCC.pPerScrnInfo->screenWhitePt, 1, XcmsTekHVCFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* make sure to return the input hue */
+ pHVC->spec.TekHVC.H = hue;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/HVCWpAj.c b/src/xcms/HVCWpAj.c
new file mode 100644
index 00000000..76e64c05
--- /dev/null
+++ b/src/xcms/HVCWpAj.c
@@ -0,0 +1,118 @@
+/* $Xorg: HVCWpAj.c,v 1.3 2000/08/17 19:44:37 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. TekColor is a
+ * trademark of Tektronix, Inc. The term "TekHVC" designates a particular
+ * color space that is the subject of U.S. Patent No. 4,985,853 (equivalent
+ * foreign patents pending). Permission is hereby granted to use, copy,
+ * modify, sell, and otherwise distribute this software and its
+ * documentation for any purpose and without fee, provided that:
+ *
+ * 1. This copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and any modification thereof and in
+ * supporting documentation;
+ * 2. Any color-handling application which displays TekHVC color
+ * cooordinates identifies these as TekHVC color coordinates in any
+ * interface that displays these coordinates and in any associated
+ * documentation;
+ * 3. The term "TekHVC" is always used, and is only used, in association
+ * with the mathematical derivations of the TekHVC Color Space,
+ * including those provided in this file and any equivalent pathways and
+ * mathematical derivations, regardless of digital (e.g., floating point
+ * or integer) representation.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * DESCRIPTION
+ * TekHVCWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the TekHVC color
+ * space.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsConvertColorsWithWhitePt();
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsTekHVCWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsTekHVCWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Convert color specifications in an array of XcmsColor structures
+ * for differences in white points.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with
+ * gamut compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Insure TekHVC installed
+ */
+ if (XcmsAddColorSpace(&XcmsTekHVCColorSpace) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to TekHVC using pWhitePtFrom
+ * We can ignore return value for compression because we are converting
+ * to XcmsTekHVCFormat which is device-independent, not device-dependent.
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsTekHVCFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from TekHVC to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtTo,
+ nColors, destSpecFmt, pCompressed));
+}
diff --git a/src/xcms/IdOfPr.c b/src/xcms/IdOfPr.c
new file mode 100644
index 00000000..d84986eb
--- /dev/null
+++ b/src/xcms/IdOfPr.c
@@ -0,0 +1,111 @@
+/* $Xorg: IdOfPr.c,v 1.3 2000/08/17 19:44:38 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsIdOfPr.c
+ *
+ * DESCRIPTION
+ * Source for XcmsFormatOfPrefix()
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+extern XcmsColorSpace **_XcmsDDColorSpaces;
+void _XcmsCopyISOLatin1Lowered();
+
+
+/*
+ * NAME
+ * XcmsFormatOfPrefix
+ *
+ * SYNOPSIS
+ */
+XcmsColorFormat
+XcmsFormatOfPrefix(prefix)
+ char *prefix;
+/*
+ * DESCRIPTION
+ * Returns the Color Space ID for the specified prefix
+ * if the color space is found in the Color Conversion
+ * Context.
+ *
+ * RETURNS
+ * Color Space ID if found; zero otherwise.
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ char string_buf[64];
+ char *string_lowered;
+ int len;
+
+ /*
+ * While copying prefix to string_lowered, convert to lowercase
+ */
+ if ((len = strlen(prefix)) >= sizeof(string_buf)) {
+ string_lowered = (char *) Xmalloc(len+1);
+ } else {
+ string_lowered = string_buf;
+ }
+ _XcmsCopyISOLatin1Lowered(string_lowered, prefix);
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strcmp((*papColorSpaces)->prefix, string_lowered) == 0) {
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return((*papColorSpaces)->id);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = _XcmsDDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strcmp((*papColorSpaces)->prefix, string_lowered) == 0) {
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return((*papColorSpaces)->id);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return(XcmsUndefinedFormat);
+}
diff --git a/src/xcms/LRGB.c b/src/xcms/LRGB.c
new file mode 100644
index 00000000..5b8b8068
--- /dev/null
+++ b/src/xcms/LRGB.c
@@ -0,0 +1,1813 @@
+/* $Xorg: LRGB.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsLRGB.c
+ *
+ * DESCRIPTION
+ * This file contains the conversion routines:
+ * 1. CIE XYZ to RGB intensity
+ * 2. RGB intensity to device RGB
+ * 3. device RGB to RGB intensity
+ * 4. RGB intensity to CIE XYZ
+ *
+ */
+
+#include <stdio.h>
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * EXTERNS
+ * External declarations required locally to this package
+ * that are not already declared in any of the included header
+ * files (external includes or internal includes).
+ */
+extern char _XcmsRGB_prefix[];
+extern char _XcmsRGBi_prefix[];
+extern unsigned long _XcmsGetElement();
+extern void _XcmsFreeIntensityMaps();
+
+
+/*
+ * LOCAL DEFINES
+ * #define declarations local to this package.
+ */
+#define EPS 0.001
+#ifndef MIN
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#endif /* MIN */
+#ifndef MAX
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#endif /* MAX */
+#ifndef MIN3
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#endif /* MIN3 */
+#ifndef MAX3
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#endif /* MAX3 */
+
+/*
+ * LOCAL TYPEDEFS
+ * typedefs local to this package (for use with local vars).
+ *
+ */
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static void LINEAR_RGB_FreeSCCData();
+static int LINEAR_RGB_InitSCCData();
+static int XcmsLRGB_RGB_ParseString();
+static int XcmsLRGB_RGBi_ParseString();
+Status _XcmsGetTableType0();
+Status _XcmsGetTableType1();
+
+/*
+ * LOCALS VARIABLES
+ * Variables local to this package.
+ * Usage example:
+ * static int ExampleLocalVar;
+ */
+
+static unsigned short Const MASK[17] = {
+ 0x0000, /* 0 bitsPerRGB */
+ 0x8000, /* 1 bitsPerRGB */
+ 0xc000, /* 2 bitsPerRGB */
+ 0xe000, /* 3 bitsPerRGB */
+ 0xf000, /* 4 bitsPerRGB */
+ 0xf800, /* 5 bitsPerRGB */
+ 0xfc00, /* 6 bitsPerRGB */
+ 0xfe00, /* 7 bitsPerRGB */
+ 0xff00, /* 8 bitsPerRGB */
+ 0xff80, /* 9 bitsPerRGB */
+ 0xffc0, /* 10 bitsPerRGB */
+ 0xffe0, /* 11 bitsPerRGB */
+ 0xfff0, /* 12 bitsPerRGB */
+ 0xfff8, /* 13 bitsPerRGB */
+ 0xfffc, /* 14 bitsPerRGB */
+ 0xfffe, /* 15 bitsPerRGB */
+ 0xffff /* 16 bitsPerRGB */
+};
+
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsRGBFormat
+ * to XcmsCIEXYZFormat.
+ */
+static XcmsConversionProc Fl_RGB_to_CIEXYZ[] = {
+ XcmsRGBToRGBi,
+ XcmsRGBiToCIEXYZ,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsCIEXYZFormat
+ * to XcmsRGBFormat.
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_RGB[] = {
+ XcmsCIEXYZToRGBi,
+ XcmsRGBiToRGB,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsRGBiFormat
+ * to XcmsCIEXYZFormat.
+ */
+static XcmsConversionProc Fl_RGBi_to_CIEXYZ[] = {
+ XcmsRGBiToCIEXYZ,
+ NULL
+};
+
+ /*
+ * A NULL terminated array of function pointers that when applied
+ * in series will convert an XcmsColor structure from XcmsCIEXYZFormat
+ * to XcmsRGBiFormat.
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_RGBi[] = {
+ XcmsCIEXYZToRGBi,
+ NULL
+};
+
+ /*
+ * RGBi Color Spaces
+ */
+XcmsColorSpace XcmsRGBiColorSpace =
+ {
+ _XcmsRGBi_prefix, /* prefix */
+ XcmsRGBiFormat, /* id */
+ XcmsLRGB_RGBi_ParseString, /* parseString */
+ Fl_RGBi_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_RGBi, /* from_CIEXYZ */
+ 1
+ };
+
+ /*
+ * RGB Color Spaces
+ */
+XcmsColorSpace XcmsRGBColorSpace =
+ {
+ _XcmsRGB_prefix, /* prefix */
+ XcmsRGBFormat, /* id */
+ XcmsLRGB_RGB_ParseString, /* parseString */
+ Fl_RGB_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_RGB, /* from_CIEXYZ */
+ 1
+ };
+
+ /*
+ * Device-Independent Color Spaces known to the
+ * LINEAR_RGB Screen Color Characteristics Function Set.
+ */
+static XcmsColorSpace *DDColorSpaces[] = {
+ &XcmsRGBColorSpace,
+ &XcmsRGBiColorSpace,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+
+ /*
+ * LINEAR_RGB Screen Color Characteristics Function Set.
+ */
+XcmsFunctionSet XcmsLinearRGBFunctionSet =
+ {
+ &DDColorSpaces[0], /* pDDColorSpaces */
+ LINEAR_RGB_InitSCCData, /* pInitScrnFunc */
+ LINEAR_RGB_FreeSCCData /* pFreeSCCData */
+ };
+
+/*
+ * DESCRIPTION
+ * Contents of Default SCCData should be replaced if other
+ * data should be used as default.
+ *
+ *
+ */
+
+/*
+ * NAME Tektronix 19" (Sony) CRT
+ * PART_NUMBER 119-2451-00
+ * MODEL Tek4300, Tek4800
+ */
+
+static IntensityRec Const Default_RGB_RedTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ 0x0000, 0.000000,
+ 0x0909, 0.000000,
+ 0x0a0a, 0.000936,
+ 0x0f0f, 0.001481,
+ 0x1414, 0.002329,
+ 0x1919, 0.003529,
+ 0x1e1e, 0.005127,
+ 0x2323, 0.007169,
+ 0x2828, 0.009699,
+ 0x2d2d, 0.012759,
+ 0x3232, 0.016392,
+ 0x3737, 0.020637,
+ 0x3c3c, 0.025533,
+ 0x4141, 0.031119,
+ 0x4646, 0.037431,
+ 0x4b4b, 0.044504,
+ 0x5050, 0.052373,
+ 0x5555, 0.061069,
+ 0x5a5a, 0.070624,
+ 0x5f5f, 0.081070,
+ 0x6464, 0.092433,
+ 0x6969, 0.104744,
+ 0x6e6e, 0.118026,
+ 0x7373, 0.132307,
+ 0x7878, 0.147610,
+ 0x7d7d, 0.163958,
+ 0x8282, 0.181371,
+ 0x8787, 0.199871,
+ 0x8c8c, 0.219475,
+ 0x9191, 0.240202,
+ 0x9696, 0.262069,
+ 0x9b9b, 0.285089,
+ 0xa0a0, 0.309278,
+ 0xa5a5, 0.334647,
+ 0xaaaa, 0.361208,
+ 0xafaf, 0.388971,
+ 0xb4b4, 0.417945,
+ 0xb9b9, 0.448138,
+ 0xbebe, 0.479555,
+ 0xc3c3, 0.512202,
+ 0xc8c8, 0.546082,
+ 0xcdcd, 0.581199,
+ 0xd2d2, 0.617552,
+ 0xd7d7, 0.655144,
+ 0xdcdc, 0.693971,
+ 0xe1e1, 0.734031,
+ 0xe6e6, 0.775322,
+ 0xebeb, 0.817837,
+ 0xf0f0, 0.861571,
+ 0xf5f5, 0.906515,
+ 0xfafa, 0.952662,
+ 0xffff, 1.000000
+};
+
+static IntensityRec Const Default_RGB_GreenTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ 0x0000, 0.000000,
+ 0x1313, 0.000000,
+ 0x1414, 0.000832,
+ 0x1919, 0.001998,
+ 0x1e1e, 0.003612,
+ 0x2323, 0.005736,
+ 0x2828, 0.008428,
+ 0x2d2d, 0.011745,
+ 0x3232, 0.015740,
+ 0x3737, 0.020463,
+ 0x3c3c, 0.025960,
+ 0x4141, 0.032275,
+ 0x4646, 0.039449,
+ 0x4b4b, 0.047519,
+ 0x5050, 0.056520,
+ 0x5555, 0.066484,
+ 0x5a5a, 0.077439,
+ 0x5f5f, 0.089409,
+ 0x6464, 0.102418,
+ 0x6969, 0.116485,
+ 0x6e6e, 0.131625,
+ 0x7373, 0.147853,
+ 0x7878, 0.165176,
+ 0x7d7d, 0.183604,
+ 0x8282, 0.203140,
+ 0x8787, 0.223783,
+ 0x8c8c, 0.245533,
+ 0x9191, 0.268384,
+ 0x9696, 0.292327,
+ 0x9b9b, 0.317351,
+ 0xa0a0, 0.343441,
+ 0xa5a5, 0.370580,
+ 0xaaaa, 0.398747,
+ 0xafaf, 0.427919,
+ 0xb4b4, 0.458068,
+ 0xb9b9, 0.489165,
+ 0xbebe, 0.521176,
+ 0xc3c3, 0.554067,
+ 0xc8c8, 0.587797,
+ 0xcdcd, 0.622324,
+ 0xd2d2, 0.657604,
+ 0xd7d7, 0.693588,
+ 0xdcdc, 0.730225,
+ 0xe1e1, 0.767459,
+ 0xe6e6, 0.805235,
+ 0xebeb, 0.843491,
+ 0xf0f0, 0.882164,
+ 0xf5f5, 0.921187,
+ 0xfafa, 0.960490,
+ 0xffff, 1.000000
+};
+
+static IntensityRec Const Default_RGB_BlueTuples[] = {
+ /* {unsigned short value, XcmsFloat intensity} */
+ 0x0000, 0.000000,
+ 0x0e0e, 0.000000,
+ 0x0f0f, 0.001341,
+ 0x1414, 0.002080,
+ 0x1919, 0.003188,
+ 0x1e1e, 0.004729,
+ 0x2323, 0.006766,
+ 0x2828, 0.009357,
+ 0x2d2d, 0.012559,
+ 0x3232, 0.016424,
+ 0x3737, 0.021004,
+ 0x3c3c, 0.026344,
+ 0x4141, 0.032489,
+ 0x4646, 0.039481,
+ 0x4b4b, 0.047357,
+ 0x5050, 0.056154,
+ 0x5555, 0.065903,
+ 0x5a5a, 0.076634,
+ 0x5f5f, 0.088373,
+ 0x6464, 0.101145,
+ 0x6969, 0.114968,
+ 0x6e6e, 0.129862,
+ 0x7373, 0.145841,
+ 0x7878, 0.162915,
+ 0x7d7d, 0.181095,
+ 0x8282, 0.200386,
+ 0x8787, 0.220791,
+ 0x8c8c, 0.242309,
+ 0x9191, 0.264937,
+ 0x9696, 0.288670,
+ 0x9b9b, 0.313499,
+ 0xa0a0, 0.339410,
+ 0xa5a5, 0.366390,
+ 0xaaaa, 0.394421,
+ 0xafaf, 0.423481,
+ 0xb4b4, 0.453547,
+ 0xb9b9, 0.484592,
+ 0xbebe, 0.516587,
+ 0xc3c3, 0.549498,
+ 0xc8c8, 0.583291,
+ 0xcdcd, 0.617925,
+ 0xd2d2, 0.653361,
+ 0xd7d7, 0.689553,
+ 0xdcdc, 0.726454,
+ 0xe1e1, 0.764013,
+ 0xe6e6, 0.802178,
+ 0xebeb, 0.840891,
+ 0xf0f0, 0.880093,
+ 0xf5f5, 0.919723,
+ 0xfafa, 0.959715,
+ 0xffff, 1.00000
+};
+
+static IntensityTbl Default_RGB_RedTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *) Default_RGB_RedTuples,
+ /* unsigned int nEntries */
+ 52
+};
+
+static IntensityTbl Default_RGB_GreenTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *)Default_RGB_GreenTuples,
+ /* unsigned int nEntries */
+ 50
+};
+
+static IntensityTbl Default_RGB_BlueTbl = {
+ /* IntensityRec *pBase */
+ (IntensityRec *)Default_RGB_BlueTuples,
+ /* unsigned int nEntries */
+ 51
+};
+
+static LINEAR_RGB_SCCData Default_RGB_SCCData = {
+
+ /* XcmsFloat XYZtoRGBmatrix[3][3] */
+ 3.48340481253539000, -1.52176374927285200, -0.55923133354049780,
+ -1.07152751306193600, 1.96593795204372400, 0.03673691339553462,
+ 0.06351179790497788, -0.20020501000496480, 0.81070942031648220,
+
+ /* XcmsFloat RGBtoXYZmatrix[3][3] */
+ 0.38106149108714790, 0.32025712365352110, 0.24834578525933100,
+ 0.20729745115140850, 0.68054638776373240, 0.11215616108485920,
+ 0.02133944350088028, 0.14297193020246480, 1.24172892629665500,
+
+ /* IntensityTbl *pRedTbl */
+ &Default_RGB_RedTbl,
+
+ /* IntensityTbl *pGreenTbl */
+ &Default_RGB_GreenTbl,
+
+ /* IntensityTbl *pBlueTbl */
+ &Default_RGB_BlueTbl
+};
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * LINEAR_RGB_InitSCCData()
+ *
+ * SYNOPSIS
+ */
+static Status
+LINEAR_RGB_InitSCCData(dpy, screenNumber, pPerScrnInfo)
+ Display *dpy;
+ int screenNumber;
+ XcmsPerScrnInfo *pPerScrnInfo;
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ Atom CorrectAtom = XInternAtom (dpy, XDCCC_CORRECT_ATOM_NAME, True);
+ Atom MatrixAtom = XInternAtom (dpy, XDCCC_MATRIX_ATOM_NAME, True);
+ int format_return, count, cType, nTables;
+ unsigned long nitems, nbytes_return;
+ char *property_return, *pChar;
+ XcmsFloat *pValue;
+#ifdef ALLDEBUG
+ IntensityRec *pIRec;
+#endif /* ALLDEBUG */
+ VisualID visualID;
+
+ LINEAR_RGB_SCCData *pScreenData, *pScreenDefaultData;
+ XcmsIntensityMap *pNewMap;
+
+ /*
+ * Allocate memory for pScreenData
+ */
+ if (!(pScreenData = pScreenDefaultData = (LINEAR_RGB_SCCData *)
+ Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 1. Get the XYZ->RGB and RGB->XYZ matrices
+ */
+
+ if (MatrixAtom == None ||
+ !_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), MatrixAtom,
+ &format_return, &nitems, &nbytes_return, &property_return) ||
+ nitems != 18 || format_return != 32) {
+ /*
+ * As per the XDCCC, there must be 18 data items and each must be
+ * in 32 bits !
+ */
+ goto FreeSCCData;
+
+ } else {
+
+ /*
+ * RGBtoXYZ and XYZtoRGB matrices
+ */
+ pValue = (XcmsFloat *) pScreenData;
+ pChar = property_return;
+ for (count = 0; count < 18; count++) {
+ *pValue++ = (long)_XcmsGetElement(format_return, &pChar,
+ &nitems) / (XcmsFloat)XDCCC_NUMBER;
+ }
+ Xfree ((char *)property_return);
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
+ pScreenData->RGBtoXYZmatrix[0][0] +
+ pScreenData->RGBtoXYZmatrix[0][1] +
+ pScreenData->RGBtoXYZmatrix[0][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y =
+ pScreenData->RGBtoXYZmatrix[1][0] +
+ pScreenData->RGBtoXYZmatrix[1][1] +
+ pScreenData->RGBtoXYZmatrix[1][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z =
+ pScreenData->RGBtoXYZmatrix[2][0] +
+ pScreenData->RGBtoXYZmatrix[2][1] +
+ pScreenData->RGBtoXYZmatrix[2][2];
+
+ /*
+ * Compute the Screen White Point
+ */
+ if ((pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y < (1.0 - EPS) )
+ || (pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y > (1.0 + EPS))) {
+ goto FreeSCCData;
+ } else {
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y = 1.0;
+ }
+ pPerScrnInfo->screenWhitePt.format = XcmsCIEXYZFormat;
+ pPerScrnInfo->screenWhitePt.pixel = 0;
+
+#ifdef PDEBUG
+ printf ("RGB to XYZ Matrix values:\n");
+ printf (" %f %f %f\n %f %f %f\n %f %f %f\n",
+ pScreenData->RGBtoXYZmatrix[0][0],
+ pScreenData->RGBtoXYZmatrix[0][1],
+ pScreenData->RGBtoXYZmatrix[0][2],
+ pScreenData->RGBtoXYZmatrix[1][0],
+ pScreenData->RGBtoXYZmatrix[1][1],
+ pScreenData->RGBtoXYZmatrix[1][2],
+ pScreenData->RGBtoXYZmatrix[2][0],
+ pScreenData->RGBtoXYZmatrix[2][1],
+ pScreenData->RGBtoXYZmatrix[2][2]);
+ printf ("XYZ to RGB Matrix values:\n");
+ printf (" %f %f %f\n %f %f %f\n %f %f %f\n",
+ pScreenData->XYZtoRGBmatrix[0][0],
+ pScreenData->XYZtoRGBmatrix[0][1],
+ pScreenData->XYZtoRGBmatrix[0][2],
+ pScreenData->XYZtoRGBmatrix[1][0],
+ pScreenData->XYZtoRGBmatrix[1][1],
+ pScreenData->XYZtoRGBmatrix[1][2],
+ pScreenData->XYZtoRGBmatrix[2][0],
+ pScreenData->XYZtoRGBmatrix[2][1],
+ pScreenData->XYZtoRGBmatrix[2][2]);
+ printf ("Screen White Pt value: %f %f %f\n",
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X,
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y,
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z);
+#endif /* PDEBUG */
+ }
+
+ /*
+ * 2. Get the Intensity Profile
+ */
+ if (CorrectAtom == None ||
+ !_XcmsGetProperty (dpy, RootWindow(dpy, screenNumber), CorrectAtom,
+ &format_return, &nitems, &nbytes_return, &property_return)) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+ pChar = property_return;
+
+ while (nitems) {
+ switch (format_return) {
+ case 8:
+ /*
+ * Must have at least:
+ * VisualID0
+ * VisualID1
+ * VisualID2
+ * VisualID3
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 9) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 3;
+ break;
+ case 16:
+ /*
+ * Must have at least:
+ * VisualID0
+ * VisualID3
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 7) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 1;
+ break;
+ case 32:
+ /*
+ * Must have at least:
+ * VisualID0
+ * type
+ * count
+ * length
+ * intensity1
+ * intensity2
+ */
+ if (nitems < 6) {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+ count = 0;
+ break;
+ default:
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+ /*
+ * Get VisualID
+ */
+ visualID = _XcmsGetElement(format_return, &pChar, &nitems);
+ while (count--) {
+ visualID = visualID << format_return;
+ visualID |= _XcmsGetElement(format_return, &pChar, &nitems);
+ }
+
+ if (visualID == 0) {
+ /*
+ * This is a shared intensity table
+ */
+ pScreenData = pScreenDefaultData;
+ } else {
+ /*
+ * This is a per-Visual intensity table
+ */
+ if (!(pScreenData = (LINEAR_RGB_SCCData *)
+ Xcalloc (1, sizeof(LINEAR_RGB_SCCData)))) {
+ return(XcmsFailure);
+ }
+ /* copy matrices */
+ memcpy((char *)pScreenData, (char *)pScreenDefaultData,
+ 18 * sizeof(XcmsFloat));
+
+ /* Create, initialize, and add map */
+ if (!(pNewMap = (XcmsIntensityMap *)
+ Xcalloc (1, sizeof(XcmsIntensityMap)))) {
+ Xfree((char *)pScreenData);
+ return(XcmsFailure);
+ }
+ pNewMap->visualID = visualID;
+ pNewMap->screenData = (XPointer)pScreenData;
+ pNewMap->pFreeScreenData = LINEAR_RGB_FreeSCCData;
+ pNewMap->pNext =
+ (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ dpy->cms.perVisualIntensityMaps = (XPointer)pNewMap;
+ dpy->free_funcs->intensityMaps = _XcmsFreeIntensityMaps;
+ }
+
+ cType = _XcmsGetElement(format_return, &pChar, &nitems);
+ nTables = _XcmsGetElement(format_return, &pChar, &nitems);
+
+ if (cType == 0) {
+
+ /* Red Intensity Table */
+ if (!(pScreenData->pRedTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeSCCData;
+ }
+ if (_XcmsGetTableType0(pScreenData->pRedTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeRedTbl;
+ }
+
+ if (nTables == 1) {
+ /* Green Intensity Table */
+ pScreenData->pGreenTbl = pScreenData->pRedTbl;
+ /* Blue Intensity Table */
+ pScreenData->pBlueTbl = pScreenData->pRedTbl;
+ } else {
+ /* Green Intensity Table */
+ if (!(pScreenData->pGreenTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeRedTblElements;
+ }
+ if (_XcmsGetTableType0(pScreenData->pGreenTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeGreenTbl;
+ }
+
+ /* Blue Intensity Table */
+ if (!(pScreenData->pBlueTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeGreenTblElements;
+ }
+ if (_XcmsGetTableType0(pScreenData->pBlueTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeBlueTbl;
+ }
+ }
+ } else if (cType == 1) {
+ /* Red Intensity Table */
+ if (!(pScreenData->pRedTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeSCCData;
+ }
+ if (_XcmsGetTableType1(pScreenData->pRedTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeRedTbl;
+ }
+
+ if (nTables == 1) {
+
+ /* Green Intensity Table */
+ pScreenData->pGreenTbl = pScreenData->pRedTbl;
+ /* Blue Intensity Table */
+ pScreenData->pBlueTbl = pScreenData->pRedTbl;
+
+ } else {
+
+ /* Green Intensity Table */
+ if (!(pScreenData->pGreenTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeRedTblElements;
+ }
+ if (_XcmsGetTableType1(pScreenData->pGreenTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeGreenTbl;
+ }
+
+ /* Blue Intensity Table */
+ if (!(pScreenData->pBlueTbl = (IntensityTbl *)
+ Xcalloc (1, sizeof(IntensityTbl)))) {
+ goto FreeBlueTblElements;
+ }
+ if (_XcmsGetTableType1(pScreenData->pBlueTbl, format_return, &pChar,
+ &nitems) == XcmsFailure) {
+ goto FreeBlueTbl;
+ }
+ }
+ } else {
+ Xfree ((char *)property_return);
+ goto FreeSCCData;
+ }
+
+#ifdef ALLDEBUG
+ printf ("Intensity Table RED %d\n", pScreenData->pRedTbl->nEntries);
+ pIRec = (IntensityRec *) pScreenData->pRedTbl->pBase;
+ for (count = 0; count < pScreenData->pRedTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ if (pScreenData->pGreenTbl->pBase != pScreenData->pRedTbl->pBase) {
+ printf ("Intensity Table GREEN %d\n", pScreenData->pGreenTbl->nEntries);
+ pIRec = (IntensityRec *)pScreenData->pGreenTbl->pBase;
+ for (count = 0; count < pScreenData->pGreenTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ }
+ if (pScreenData->pBlueTbl->pBase != pScreenData->pRedTbl->pBase) {
+ printf ("Intensity Table BLUE %d\n", pScreenData->pBlueTbl->nEntries);
+ pIRec = (IntensityRec *) pScreenData->pBlueTbl->pBase;
+ for (count = 0; count < pScreenData->pBlueTbl->nEntries; count++, pIRec++) {
+ printf ("\t0x%4x\t%f\n", pIRec->value, pIRec->intensity);
+ }
+ }
+#endif /* ALLDEBUG */
+ }
+
+ Xfree ((char *)property_return);
+
+ /* Free the old memory and use the new structure created. */
+ LINEAR_RGB_FreeSCCData(pPerScrnInfo->screenData);
+
+ pPerScrnInfo->functionSet = (XPointer) &XcmsLinearRGBFunctionSet;
+
+ pPerScrnInfo->screenData = (XPointer) pScreenData;
+
+ pPerScrnInfo->state = XcmsInitSuccess;
+
+ return(XcmsSuccess);
+
+FreeBlueTblElements:
+ Xfree((char *)pScreenData->pBlueTbl->pBase);
+
+FreeBlueTbl:
+ Xfree((char *)pScreenData->pBlueTbl);
+
+FreeGreenTblElements:
+ Xfree((char *)pScreenData->pBlueTbl->pBase);
+
+FreeGreenTbl:
+ Xfree((char *)pScreenData->pGreenTbl);
+
+FreeRedTblElements:
+ Xfree((char *)pScreenData->pRedTbl->pBase);
+
+FreeRedTbl:
+ Xfree((char *)pScreenData->pRedTbl);
+
+FreeSCCData:
+ Xfree((char *)pScreenData);
+ pPerScrnInfo->state = XcmsInitNone;
+ return(XcmsFailure);
+}
+
+
+/*
+ * NAME
+ * LINEAR_RGB_FreeSCCData()
+ *
+ * SYNOPSIS
+ */
+static void
+LINEAR_RGB_FreeSCCData(pScreenDataTemp)
+ XPointer pScreenDataTemp;
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * 0 if failed.
+ * 1 if succeeded with no modifications.
+ *
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData = (LINEAR_RGB_SCCData *) pScreenDataTemp;
+
+ if (pScreenData && pScreenData != &Default_RGB_SCCData) {
+ if (pScreenData->pRedTbl) {
+ if (pScreenData->pGreenTbl) {
+ if (pScreenData->pRedTbl->pBase !=
+ pScreenData->pGreenTbl->pBase) {
+ if (pScreenData->pGreenTbl->pBase) {
+ Xfree ((char *)pScreenData->pGreenTbl->pBase);
+ }
+ }
+ if (pScreenData->pGreenTbl != pScreenData->pRedTbl) {
+ Xfree ((char *)pScreenData->pGreenTbl);
+ }
+ }
+ if (pScreenData->pBlueTbl) {
+ if (pScreenData->pRedTbl->pBase !=
+ pScreenData->pBlueTbl->pBase) {
+ if (pScreenData->pBlueTbl->pBase) {
+ Xfree ((char *)pScreenData->pBlueTbl->pBase);
+ }
+ }
+ if (pScreenData->pBlueTbl != pScreenData->pRedTbl) {
+ Xfree ((char *)pScreenData->pBlueTbl);
+ }
+ }
+ if (pScreenData->pRedTbl->pBase) {
+ Xfree ((char *)pScreenData->pRedTbl->pBase);
+ }
+ Xfree ((char *)pScreenData->pRedTbl);
+ }
+ Xfree ((char *)pScreenData);
+ }
+}
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsGetTableType0
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsGetTableType0(pTbl, format, pChar, pCount)
+ IntensityTbl *pTbl;
+ int format;
+ char **pChar;
+ unsigned long *pCount;
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ unsigned int nElements;
+ IntensityRec *pIRec;
+
+ nElements = pTbl->nEntries =
+ _XcmsGetElement(format, pChar, pCount) + 1;
+ if (!(pIRec = pTbl->pBase = (IntensityRec *)
+ Xcalloc (nElements, sizeof(IntensityRec)))) {
+ return(XcmsFailure);
+ }
+
+ switch (format) {
+ case 8:
+ for (; nElements--; pIRec++) {
+ /* 0xFFFF/0xFF = 0x101 */
+ pIRec->value = _XcmsGetElement (format, pChar, pCount) * 0x101;
+ pIRec->intensity =
+ _XcmsGetElement (format, pChar, pCount) / (XcmsFloat)255.0;
+ }
+ break;
+ case 16:
+ for (; nElements--; pIRec++) {
+ pIRec->value = _XcmsGetElement (format, pChar, pCount);
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)65535.0;
+ }
+ break;
+ case 32:
+ for (; nElements--; pIRec++) {
+ pIRec->value = _XcmsGetElement (format, pChar, pCount);
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)4294967295.0;
+ }
+ break;
+ default:
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsGetTableType1
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsGetTableType1(pTbl, format, pChar, pCount)
+ IntensityTbl *pTbl;
+ int format;
+ char **pChar;
+ unsigned long *pCount;
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * XcmsFailure if failed.
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ int count;
+ unsigned int max_index;
+ IntensityRec *pIRec;
+
+ max_index = _XcmsGetElement(format, pChar, pCount);
+ pTbl->nEntries = max_index + 1;
+ if (!(pIRec = pTbl->pBase = (IntensityRec *)
+ Xcalloc (max_index+1, sizeof(IntensityRec)))) {
+ return(XcmsFailure);
+ }
+
+ switch (format) {
+ case 8:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)255.0;
+ }
+ break;
+ case 16:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)65535.0;
+ }
+ break;
+ case 32:
+ for (count = 0; count < max_index+1; count++, pIRec++) {
+ pIRec->value = (count * 65535) / max_index;
+ pIRec->intensity = _XcmsGetElement (format, pChar, pCount)
+ / (XcmsFloat)4294967295.0;
+ }
+ break;
+ default:
+ return(XcmsFailure);
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * ValueCmp
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsValueCmp (p1, p2)
+ IntensityRec *p1, *p2;
+/*
+ * DESCRIPTION
+ * Compares the value component of two IntensityRec
+ * structures.
+ *
+ * RETURNS
+ * 0 if p1->value is equal to p2->value
+ * < 0 if p1->value is less than p2->value
+ * > 0 if p1->value is greater than p2->value
+ *
+ */
+{
+ return (p1->value - p2->value);
+}
+
+
+/*
+ * NAME
+ * IntensityCmp
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsIntensityCmp (p1, p2)
+ IntensityRec *p1, *p2;
+/*
+ * DESCRIPTION
+ * Compares the intensity component of two IntensityRec
+ * structures.
+ *
+ * RETURNS
+ * 0 if equal;
+ * < 0 if first precedes second
+ * > 0 if first succeeds second
+ *
+ */
+{
+ if (p1->intensity < p2->intensity) {
+ return (-1);
+ }
+ if (p1->intensity > p2->intensity) {
+ return (XcmsSuccess);
+ }
+ return (XcmsFailure);
+}
+
+/*
+ * NAME
+ * ValueInterpolation
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+int
+_XcmsValueInterpolation (key, lo, hi, answer, bitsPerRGB)
+ IntensityRec *key, *lo, *hi, *answer;
+ int bitsPerRGB;
+/*
+ * DESCRIPTION
+ * Based on a given value, performs a linear interpolation
+ * on the intensities between two IntensityRec structures.
+ * Note that the bitsPerRGB parameter is ignored.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ */
+{
+ XcmsFloat ratio;
+
+ ratio = ((XcmsFloat)key->value - (XcmsFloat)lo->value) /
+ ((XcmsFloat)hi->value - (XcmsFloat)lo->value);
+ answer->value = key->value;
+ answer->intensity = (hi->intensity - lo->intensity) * ratio;
+ answer->intensity += lo->intensity;
+ return (XcmsSuccess);
+}
+
+/*
+ * NAME
+ * IntensityInterpolation
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsIntensityInterpolation (key, lo, hi, answer, bitsPerRGB)
+ IntensityRec *key, *lo, *hi, *answer;
+ int bitsPerRGB;
+/*
+ * DESCRIPTION
+ * Based on a given intensity, performs a linear interpolation
+ * on the values between two IntensityRec structures.
+ * The bitsPerRGB parameter is necessary to perform rounding
+ * to the correct number of significant bits.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ */
+{
+ XcmsFloat ratio;
+ long target, up, down;
+ int shift = 16 - bitsPerRGB;
+ int max_color = (1 << bitsPerRGB) - 1;
+
+ ratio = (key->intensity - lo->intensity) / (hi->intensity - lo->intensity);
+ answer->intensity = key->intensity;
+ target = hi->value - lo->value;
+ target *= ratio;
+ target += lo->value;
+
+ /*
+ * Ok now, lets find the closest in respects to bits per RGB
+ */
+ up = ((target >> shift) * 0xFFFF) / max_color;
+ if (up < target) {
+ down = up;
+ up = (MIN((down >> shift) + 1, max_color) * 0xFFFF) / max_color;
+ } else {
+ down = (MAX((up >> shift) - 1, 0) * 0xFFFF) / max_color;
+ }
+ answer->value = ((up - target) < (target - down) ? up : down);
+ answer->value &= MASK[bitsPerRGB];
+ return (XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsTableSearch
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsTableSearch (key, bitsPerRGB, base, nel, nKeyPtrSize, compar, interpol, answer)
+ char *key;
+ int bitsPerRGB;
+ char *base;
+ unsigned nel;
+ unsigned nKeyPtrSize;
+ int (*compar)();
+ int (*interpol)();
+ char *answer;
+
+/*
+ * DESCRIPTION
+ * A binary search through the specificied table.
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ *
+ */
+{
+ char *hi, *lo, *mid, *last;
+ int result;
+
+ last = hi = base + ((nel - 1) * nKeyPtrSize);
+ mid = lo = base;
+
+ /* use only the significants bits, then scale into 16 bits */
+ ((IntensityRec *)key)->value = ((unsigned long)
+ (((IntensityRec *)key)->value >> (16 - bitsPerRGB)) * 0xFFFF)
+ / ((1 << bitsPerRGB) - 1);
+
+ /* Special case so that zero intensity always maps to zero value */
+ if ((*compar) (key,lo) <= 0) {
+ memcpy (answer, lo, nKeyPtrSize);
+ ((IntensityRec *)answer)->value &= MASK[bitsPerRGB];
+ return XcmsSuccess;
+ }
+ while (mid != last) {
+ last = mid;
+ mid = lo + (((unsigned)(hi - lo) / nKeyPtrSize) / 2) * nKeyPtrSize;
+ result = (*compar) (key, mid);
+ if (result == 0) {
+
+ memcpy(answer, mid, nKeyPtrSize);
+ ((IntensityRec *)answer)->value &= MASK[bitsPerRGB];
+ return (XcmsSuccess);
+ } else if (result < 0) {
+ hi = mid;
+ } else {
+ lo = mid;
+ }
+ }
+
+ /*
+ * If we got to here, we didn't find a solution, so we
+ * need to apply interpolation.
+ */
+ return ((*interpol)(key, lo, hi, answer, bitsPerRGB));
+}
+
+
+/*
+ * NAME
+ * _XcmsMatVec - multiply a 3 x 3 by a 3 x 1 vector
+ *
+ * SYNOPSIS
+ */
+void _XcmsMatVec(pMat, pIn, pOut)
+ XcmsFloat *pMat, *pIn, *pOut;
+/*
+ * DESCRIPTION
+ * Multiply the passed vector by the passed matrix to return a
+ * vector. Matrix is 3x3, vectors are of length 3.
+ *
+ * RETURNS
+ * void
+ */
+{
+ int i, j;
+
+ for (i = 0; i < 3; i++) {
+ pOut[i] = 0.0;
+ for (j = 0; j < 3; j++)
+ pOut[i] += *(pMat+(i*3)+j) * pIn[j];
+ }
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * XcmsLRGB_RGB_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsLRGB_RGB_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsRGBFormat.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ register int n, i;
+ unsigned short r, g, b;
+ char c;
+ char *pchar;
+ unsigned short *pShort;
+
+ /*
+ * Check for old # format
+ */
+ if (*spec == '#') {
+ /*
+ * Attempt to parse the value portion.
+ */
+ spec++;
+ n = strlen(spec);
+ if (n != 3 && n != 6 && n != 9 && n != 12) {
+ return(XcmsFailure);
+ }
+
+ n /= 3;
+ g = b = 0;
+ do {
+ r = g;
+ g = b;
+ b = 0;
+ for (i = n; --i >= 0; ) {
+ c = *spec++;
+ b <<= 4;
+ if (c >= '0' && c <= '9')
+ b |= c - '0';
+ /* assume string in lowercase
+ else if (c >= 'A' && c <= 'F')
+ b |= c - ('A' - 10);
+ */
+ else if (c >= 'a' && c <= 'f')
+ b |= c - ('a' - 10);
+ else return (XcmsFailure);
+ }
+ } while (*spec != '\0');
+
+ /*
+ * Succeeded !
+ */
+ n <<= 2;
+ n = 16 - n;
+ /* shift instead of scale, to match old broken semantics */
+ pColor->spec.RGB.red = r << n;
+ pColor->spec.RGB.green = g << n;
+ pColor->spec.RGB.blue = b << n;
+ } else {
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsRGB_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ spec += (n + 1);
+ pShort = &pColor->spec.RGB.red;
+ for (i = 0; i < 3; i++, pShort++, spec++) {
+ n = 0;
+ *pShort = 0;
+ while (*spec != '/' && *spec != '\0') {
+ if (++n > 4) {
+ return(XcmsFailure);
+ }
+ c = *spec++;
+ *pShort <<= 4;
+ if (c >= '0' && c <= '9')
+ *pShort |= c - '0';
+ /* assume string in lowercase
+ else if (c >= 'A' && c <= 'F')
+ *pShort |= c - ('A' - 10);
+ */
+ else if (c >= 'a' && c <= 'f')
+ *pShort |= c - ('a' - 10);
+ else return (XcmsFailure);
+ }
+ if (n == 0)
+ return (XcmsFailure);
+ if (n < 4) {
+ *pShort = ((unsigned long)*pShort * 0xFFFF) / ((1 << n*4) - 1);
+ }
+ }
+ }
+ pColor->format = XcmsRGBFormat;
+ pColor->pixel = 0;
+ return (XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsLRGB_RGBi_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+XcmsLRGB_RGBi_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsRGBiFormat.
+ * The assumed RGBi string syntax is:
+ * RGBi:<r>/<g>/<b>
+ * Where r, g, and b are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsRGBi_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.RGBi.red,
+ &pColor->spec.RGBi.green,
+ &pColor->spec.RGBi.blue) != 3) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Succeeded !
+ */
+ pColor->format = XcmsRGBiFormat;
+ pColor->pixel = 0;
+ return (XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToRGBi - convert CIE XYZ to RGB
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIEXYZToRGBi(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to an array of Bool */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGB format to RGBi format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression.
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsFloat tmp[3];
+ int hasCompressed = 0;
+ unsigned int i;
+ XcmsColor *pColor = pXcmsColors_in_out;
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ /*
+ * XcmsColors should be White Point Adjusted, if necessary, by now!
+ */
+
+ /*
+ * NEW!!! for extended gamut compression
+ *
+ * 1. Need to zero out pCompressed
+ *
+ * 2. Need to save initial address of pColor
+ *
+ * 3. Need to save initial address of pCompressed
+ */
+
+ for (i = 0; i < nColors; i++) {
+
+ /* Make sure format is XcmsCIEXYZFormat */
+ if (pColor->format != XcmsCIEXYZFormat) {
+ return(XcmsFailure);
+ }
+
+ /* Multiply [A]-1 * [XYZ] to get RGB intensity */
+ _XcmsMatVec((XcmsFloat *) pScreenData->XYZtoRGBmatrix,
+ (XcmsFloat *) &pColor->spec, tmp);
+
+ if ((MIN3 (tmp[0], tmp[1], tmp[2]) < -EPS) ||
+ (MAX3 (tmp[0], tmp[1], tmp[2]) > (1.0 + EPS))) {
+
+ /*
+ * RGBi out of screen's gamut
+ */
+
+ if (ccc->gamutCompProc == NULL) {
+ /*
+ * Aha!! Here's that little trick that will allow
+ * gamut compression routines to get the out of bound
+ * RGBi.
+ */
+ memcpy((char *)&pColor->spec, (char *)tmp, sizeof(tmp));
+ pColor->format = XcmsRGBiFormat;
+ return(XcmsFailure);
+ } else if ((*ccc->gamutCompProc)(ccc, pXcmsColors_in_out, nColors,
+ i, pCompressed) == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * The gamut compression function should return colors in CIEXYZ
+ * Also check again to if the new color is within gamut.
+ */
+ if (pColor->format != XcmsCIEXYZFormat) {
+ return(XcmsFailure);
+ }
+ _XcmsMatVec((XcmsFloat *) pScreenData->XYZtoRGBmatrix,
+ (XcmsFloat *) &pColor->spec, tmp);
+ if ((MIN3 (tmp[0], tmp[1], tmp[2]) < -EPS) ||
+ (MAX3 (tmp[0], tmp[1], tmp[2]) > (1.0 + EPS))) {
+ return(XcmsFailure);
+ }
+ hasCompressed++;
+ }
+ memcpy((char *)&pColor->spec, (char *)tmp, sizeof(tmp));
+ /* These if statements are done to ensure the fudge factor is */
+ /* is taken into account. */
+ if (pColor->spec.RGBi.red < 0.0) {
+ pColor->spec.RGBi.red = 0.0;
+ } else if (pColor->spec.RGBi.red > 1.0) {
+ pColor->spec.RGBi.red = 1.0;
+ }
+ if (pColor->spec.RGBi.green < 0.0) {
+ pColor->spec.RGBi.green = 0.0;
+ } else if (pColor->spec.RGBi.green > 1.0) {
+ pColor->spec.RGBi.green = 1.0;
+ }
+ if (pColor->spec.RGBi.blue < 0.0) {
+ pColor->spec.RGBi.blue = 0.0;
+ } else if (pColor->spec.RGBi.blue > 1.0) {
+ pColor->spec.RGBi.blue = 1.0;
+ }
+ (pColor++)->format = XcmsRGBiFormat;
+ }
+ return (hasCompressed ? XcmsSuccessWithCompression : XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * LINEAR_RGBi_to_CIEXYZ - convert RGBi to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBiToCIEXYZ(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGBi format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsFloat tmp[3];
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ /*
+ * XcmsColors should be White Point Adjusted, if necessary, by now!
+ */
+
+ while (nColors--) {
+
+ /* Multiply [A]-1 * [XYZ] to get RGB intensity */
+ _XcmsMatVec((XcmsFloat *) pScreenData->RGBtoXYZmatrix,
+ (XcmsFloat *) &pXcmsColors_in_out->spec, tmp);
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)tmp, sizeof(tmp));
+ (pXcmsColors_in_out++)->format = XcmsCIEXYZFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsRGBiToRGB
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBiToRGB(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGBi format to RGB format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression.
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsRGB tmpRGB;
+ IntensityRec keyIRec, answerIRec;
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ while (nColors--) {
+
+ /* Make sure format is XcmsRGBiFormat */
+ if (pXcmsColors_in_out->format != XcmsRGBiFormat) {
+ return(XcmsFailure);
+ }
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.red;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pRedTbl->pBase,
+ (unsigned)pScreenData->pRedTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsIntensityCmp, _XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.red = answerIRec.value;
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.green;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pGreenTbl->pBase,
+ (unsigned)pScreenData->pGreenTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsIntensityCmp, _XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.green = answerIRec.value;
+
+ keyIRec.intensity = pXcmsColors_in_out->spec.RGBi.blue;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pBlueTbl->pBase,
+ (unsigned)pScreenData->pBlueTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsIntensityCmp, _XcmsIntensityInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGB.blue = answerIRec.value;
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)&tmpRGB, sizeof(XcmsRGB));
+ (pXcmsColors_in_out++)->format = XcmsRGBFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsRGBToRGBi
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsRGBToRGBi(ccc, pXcmsColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColors_in_out;/* pointer to XcmsColors to convert */
+ unsigned int nColors; /* Number of colors */
+ Bool *pCompressed; /* pointer to a bit array */
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from RGB format to RGBi format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ LINEAR_RGB_SCCData *pScreenData;
+ XcmsRGBi tmpRGBi;
+ IntensityRec keyIRec, answerIRec;
+
+ /*
+ * pCompressed ignored in this function.
+ */
+
+ if (ccc == NULL) {
+ return(XcmsFailure);
+ }
+
+ pScreenData = (LINEAR_RGB_SCCData *)ccc->pPerScrnInfo->screenData;
+
+ while (nColors--) {
+
+ /* Make sure format is XcmsRGBFormat */
+ if (pXcmsColors_in_out->format != XcmsRGBFormat) {
+ return(XcmsFailure);
+ }
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.red;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pRedTbl->pBase,
+ (unsigned)pScreenData->pRedTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsValueCmp, _XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.red = answerIRec.intensity;
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.green;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pGreenTbl->pBase,
+ (unsigned)pScreenData->pGreenTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsValueCmp, _XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.green = answerIRec.intensity;
+
+ keyIRec.value = pXcmsColors_in_out->spec.RGB.blue;
+ if (!_XcmsTableSearch((char *)&keyIRec, ccc->visual->bits_per_rgb,
+ (char *)pScreenData->pBlueTbl->pBase,
+ (unsigned)pScreenData->pBlueTbl->nEntries,
+ (unsigned)sizeof(IntensityRec),
+ _XcmsValueCmp, _XcmsValueInterpolation, (char *)&answerIRec)) {
+ return(XcmsFailure);
+ }
+ tmpRGBi.blue = answerIRec.intensity;
+
+ memcpy((char *)&pXcmsColors_in_out->spec, (char *)&tmpRGBi, sizeof(XcmsRGBi));
+ (pXcmsColors_in_out++)->format = XcmsRGBiFormat;
+ }
+ return(XcmsSuccess);
+}
+
+/*
+ * NAME
+ * _XcmsInitScrnDefaultInfo
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+int
+_XcmsLRGB_InitScrnDefault(dpy, screenNumber, pPerScrnInfo)
+ Display *dpy;
+ int screenNumber;
+ XcmsPerScrnInfo *pPerScrnInfo;
+/*
+ * DESCRIPTION
+ * Given a display and screen number, this routine attempts
+ * to initialize the Xcms per Screen Info structure
+ * (XcmsPerScrnInfo) with defaults.
+ *
+ * RETURNS
+ * Returns zero if initialization failed; non-zero otherwise.
+ */
+{
+ pPerScrnInfo->screenData = (XPointer)&Default_RGB_SCCData;
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.X =
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[0][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y =
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[1][2];
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Z =
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][0] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][1] +
+ Default_RGB_SCCData.RGBtoXYZmatrix[2][2];
+ if ((pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y < (1.0 - EPS) )
+ || (pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y > (1.0 + EPS))) {
+ pPerScrnInfo->screenData = (XPointer)NULL;
+ pPerScrnInfo->state = XcmsInitNone;
+ return(0);
+ }
+ pPerScrnInfo->screenWhitePt.spec.CIEXYZ.Y = 1.0;
+ pPerScrnInfo->screenWhitePt.format = XcmsCIEXYZFormat;
+ pPerScrnInfo->screenWhitePt.pixel = 0;
+ pPerScrnInfo->functionSet = (XPointer)&XcmsLinearRGBFunctionSet;
+ pPerScrnInfo->state = XcmsInitFailure; /* default initialization */
+ return(1);
+}
diff --git a/src/xcms/Lab.c b/src/xcms/Lab.c
new file mode 100644
index 00000000..7827d8e7
--- /dev/null
+++ b/src/xcms/Lab.c
@@ -0,0 +1,416 @@
+/* $Xorg: Lab.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELab.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE L*a*b*
+ * color space to include conversions to and from the CIE
+ * XYZ space. These conversions are from Principles of
+ * Color Technology Second Edition, Fred W. Billmeyer, Jr.
+ * and Max Saltzman, John Wiley & Sons, Inc., 1981.
+ *
+ * Note that the range for L* is 0 to 1.
+ */
+
+
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+#define DIV16BY116 0.137931
+
+/*
+ * EXTERNS
+ */
+extern char _XcmsCIELab_prefix[];
+
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIELab_ParseString();
+static Status XcmsCIELab_ValidSpec();
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+
+ /*
+ * NULL terminated list of functions applied to get from CIELab to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIELab_to_CIEXYZ[] = {
+ XcmsCIELabToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIELab
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIELab[] = {
+ XcmsCIEXYZToCIELab,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+ /*
+ * CIE Lab Color Space
+ */
+XcmsColorSpace XcmsCIELabColorSpace =
+ {
+ _XcmsCIELab_prefix, /* prefix */
+ XcmsCIELabFormat, /* id */
+ CIELab_ParseString, /* parseString */
+ Fl_CIELab_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIELab, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIELab_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIELab_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIELabFormat.
+ * The assumed CIELab string syntax is:
+ * CIELab:<L>/<a>/<b>
+ * Where L, a, and b are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIELab_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIELab.L_star,
+ &pColor->spec.CIELab.a_star,
+ &pColor->spec.CIELab.b_star) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIELabFormat;
+ pColor->pixel = 0;
+
+ return(XcmsCIELab_ValidSpec(pColor));
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELab_ValidSpec
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIELab_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE L*a*b*.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIELabFormat
+ ||
+ (pColor->spec.CIELab.L_star < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIELab.L_star > 100.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIELabToCIEXYZ - convert CIELab to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabToCIEXYZ(ccc, pLab_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLab_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIELab format to CIEXYZ format.
+ *
+ * WARNING: This routine assumes that Yn = 1.0;
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEXYZ XYZ_return;
+ XcmsFloat tmpFloat, tmpL;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+
+ /*
+ * Check arguments
+ */
+ if (pLab_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEXYZ form, if not, convert it.
+ */
+ if (pLab_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make a copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLab_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt,
+ (XcmsColor *)NULL, 1, XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pLab_WhitePt = &whitePt;
+ }
+
+ /*
+ * Make sure it is a white point, i.e., Y == 1.0
+ */
+ if (pLab_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return (0);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELab */
+ if (!XcmsCIELab_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Calculate Y: assume that Yn = 1.0 */
+ tmpL = (pColor->spec.CIELab.L_star + 16.0) / 116.0;
+ XYZ_return.Y = tmpL * tmpL * tmpL;
+
+ if (XYZ_return.Y < 0.008856) {
+ /* Calculate Y: assume that Yn = 1.0 */
+ tmpL = pColor->spec.CIELab.L_star / 9.03292;
+
+ /* Calculate X */
+ XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X *
+ ((pColor->spec.CIELab.a_star / 3893.5) + tmpL);
+ /* Calculate Y */
+ XYZ_return.Y = tmpL;
+ /* Calculate Z */
+ XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z *
+ (tmpL - (pColor->spec.CIELab.b_star / 1557.4));
+ } else {
+ /* Calculate X */
+ tmpFloat = tmpL + (pColor->spec.CIELab.a_star / 5.0);
+ XYZ_return.X = pLab_WhitePt->spec.CIEXYZ.X * tmpFloat * tmpFloat * tmpFloat;
+
+ /* Calculate Z */
+ tmpFloat = tmpL - (pColor->spec.CIELab.b_star / 2.0);
+ XYZ_return.Z = pLab_WhitePt->spec.CIEXYZ.Z * tmpFloat * tmpFloat * tmpFloat;
+ }
+
+ memcpy((char *)&pColor->spec.CIEXYZ, (char *)&XYZ_return,
+ sizeof(XcmsCIEXYZ));
+ pColor->format = XcmsCIEXYZFormat;
+ }
+
+ return (1);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIELab - convert CIEXYZ to CIELab
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEXYZToCIELab(ccc, pLab_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLab_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIELab format.
+ *
+ * WARNING: This routine assumes that Yn = 1.0;
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIELab Lab_return;
+ XcmsFloat fX_Xn, fY_Yn, fZ_Zn;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+
+ /*
+ * Check arguments
+ */
+ if (pLab_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEXYZ form, if not, convert it.
+ */
+ if (pLab_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make a copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLab_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL,
+ 1, XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pLab_WhitePt = &whitePt;
+ }
+
+ /*
+ * Make sure it is a white point, i.e., Y == 1.0
+ */
+ if (pLab_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELab */
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Calculate L*: assume Yn = 1.0 */
+ if (pColor->spec.CIEXYZ.Y < 0.008856) {
+ fY_Yn = (0.07787 * pColor->spec.CIEXYZ.Y) + DIV16BY116;
+ /* note fY_Yn used to compute Lab_return.a below */
+ Lab_return.L_star = 116.0 * (fY_Yn - DIV16BY116);
+ } else {
+ fY_Yn = (XcmsFloat)XCMS_CUBEROOT(pColor->spec.CIEXYZ.Y);
+ /* note fY_Yn used to compute Lab_return.a_star below */
+ Lab_return.L_star = (116.0 * fY_Yn) - 16.0;
+ }
+
+ /* Calculate f(X/Xn) */
+ if ((fX_Xn = pColor->spec.CIEXYZ.X / pLab_WhitePt->spec.CIEXYZ.X) < 0.008856) {
+ fX_Xn = (0.07787 * fX_Xn) + DIV16BY116;
+ } else {
+ fX_Xn = (XcmsFloat) XCMS_CUBEROOT(fX_Xn);
+ }
+
+ /* Calculate f(Z/Zn) */
+ if ((fZ_Zn = pColor->spec.CIEXYZ.Z / pLab_WhitePt->spec.CIEXYZ.Z) < 0.008856) {
+ fZ_Zn = (0.07787 * fZ_Zn) + DIV16BY116;
+ } else {
+ fZ_Zn = (XcmsFloat) XCMS_CUBEROOT(fZ_Zn);
+ }
+
+ Lab_return.a_star = 5.0 * (fX_Xn - fY_Yn);
+ Lab_return.b_star = 2.0 * (fY_Yn - fZ_Zn);
+
+ memcpy((char *)&pColor->spec.CIELab, (char *)&Lab_return,
+ sizeof(XcmsCIELab));
+ pColor->format = XcmsCIELabFormat;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LabGcC.c b/src/xcms/LabGcC.c
new file mode 100644
index 00000000..0618dcbb
--- /dev/null
+++ b/src/xcms/LabGcC.c
@@ -0,0 +1,124 @@
+/* $Xorg: LabGcC.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipuv() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipab - Reduce the chroma for a hue and L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipab (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and chroma to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < PseudoColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELabFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMaxC(ccc,
+ degrees(XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star)),
+ pColor->spec.CIELab.L_star,
+ pColor) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/LabGcL.c b/src/xcms/LabGcL.c
new file mode 100644
index 00000000..bc6d20ef
--- /dev/null
+++ b/src/xcms/LabGcL.c
@@ -0,0 +1,176 @@
+/* $Xorg: LabGcL.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcL.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipL() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipL - Return the closest L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipL (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest L* for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Lab_max;
+ XcmsFloat hue, chroma, maxChroma;
+ Status retval;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to CIE L*u*v* format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ hue = XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star,
+ Lab_max.spec.CIELab.b_star);
+
+ /* Now check and return the appropriate L* */
+ if (chroma == maxChroma) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the L* for that chroma. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else if (chroma > maxChroma) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the L* and chroma for the given hue. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ return (XcmsFailure);
+ } else if (pColor->spec.CIELab.L_star < Lab_max.spec.CIELab.L_star) {
+ /* Find the minimum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMinL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* Find the maximum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELabFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELabQueryMaxL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/LabGcLC.c b/src/xcms/LabGcLC.c
new file mode 100644
index 00000000..8ffaf8c3
--- /dev/null
+++ b/src/xcms/LabGcLC.c
@@ -0,0 +1,225 @@
+/* $Xorg: LabGcLC.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabGcLC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELabClipLab() gamut
+ * compression function.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabClipLab - Return the closest L* and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELabClipLab (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest L* and chroma
+ * for a specific hue. The color input is converted to
+ * CIE L*u*v* format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Lab_max;
+ XcmsFloat hue, chroma, maxChroma;
+ XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar;
+ XcmsFloat bestLstar, bestastar, bestbstar;
+ XcmsFloat nT, saveDist, tmpDist;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELabFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ }
+
+ /* Convert from CIEXYZ to CIELab format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ saveLstar = pColor->spec.CIELab.L_star;
+ hue = XCMS_CIELAB_PMETRIC_HUE(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ memcpy((char *)&Lab_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB (&myCCC, hue, &Lab_max, &rgb_max)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxLstar = Lab_max.spec.CIELab.L_star;
+
+ /* Now check and return the appropriate L* */
+ if (saveLstar == maxLstar) {
+ /* When the L* input is equal to the maximum L* */
+ /* merely return the maximum Lab point. */
+ memcpy((char *)pColor, (char *)&Lab_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* return the closest point on the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ maxChroma = XCMS_CIELAB_PMETRIC_CHROMA(Lab_max.spec.CIELab.a_star,
+ Lab_max.spec.CIELab.b_star);
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestLstar = Lstar = pColor->spec.CIELab.L_star;
+ bestastar = pColor->spec.CIELab.a_star;
+ bestbstar = pColor->spec.CIELab.b_star;
+ bestChroma = Chroma = chroma;
+ saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) +
+ ((Lstar - maxLstar) * (Lstar - maxLstar)));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ if (saveLstar > maxLstar) {
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ } else {
+ pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT);
+ pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT);
+ pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT);
+ }
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to CIE Lab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ chroma = XCMS_CIELAB_PMETRIC_CHROMA(pColor->spec.CIELab.a_star,
+ pColor->spec.CIELab.b_star);
+ tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) +
+ ((Lstar - pColor->spec.CIELab.L_star) *
+ (Lstar - pColor->spec.CIELab.L_star)));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestLstar = pColor->spec.CIELab.L_star;
+ bestastar = pColor->spec.CIELab.a_star;
+ bestbstar = pColor->spec.CIELab.b_star;
+ bestChroma = chroma;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+ }
+ if (bestChroma >= maxChroma) {
+ pColor->spec.CIELab.L_star = maxLstar;
+ pColor->spec.CIELab.a_star = Lab_max.spec.CIELab.a_star;
+ pColor->spec.CIELab.b_star = Lab_max.spec.CIELab.b_star;
+ } else {
+ pColor->spec.CIELab.L_star = bestLstar;
+ pColor->spec.CIELab.a_star = bestastar;
+ pColor->spec.CIELab.b_star = bestbstar;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ }
+ return(retval);
+}
diff --git a/src/xcms/LabMnL.c b/src/xcms/LabMnL.c
new file mode 100644
index 00000000..c5ca3e8e
--- /dev/null
+++ b/src/xcms/LabMnL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LabMnL.c,v 1.3 2000/08/17 19:44:39 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabMnL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMinL() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMinL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMinL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = START_L_STAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star,
+ max_lc.spec.CIELab.b_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (nChroma - max_chroma) / max_chroma * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star,
+ tmp.spec.CIELab.b_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LabMxC.c b/src/xcms/LabMxC.c
new file mode 100644
index 00000000..a1a3d69d
--- /dev/null
+++ b/src/xcms/LabMxC.c
@@ -0,0 +1,205 @@
+/* $Xorg: LabMxC.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELabMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxC() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_CHROMA (XcmsFloat)3.6
+#define TOPL (XcmsFloat)100.0
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxC - max chroma for a hue_angle and L_star
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxC(ccc, hue_angle, L_star, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat L_star;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue_angle and L_star.
+ * The returned format is in XcmsCIELabFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_lc;
+ XcmsFloat n_L_star, last_L_star, prev_L_star;
+ XcmsFloat hue, lastaStar, lastbStar, /*lastChroma,*/ maxDist, nT, rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC and inherit screen white Pt */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = L_star;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: compute the maximum L_star and chroma for this hue. */
+ memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Step 2: Do a bisection here to compute the maximum chroma
+ * Note the differences between when the point to be found
+ * is above the maximum LC point and when it is below.
+ */
+ if (L_star <= max_lc.spec.CIELab.L_star) {
+ maxDist = max_lc.spec.CIELab.L_star;
+ } else {
+ maxDist = TOPL - max_lc.spec.CIELab.L_star;
+ }
+
+ n_L_star = L_star;
+ last_L_star = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prev_L_star = last_L_star;
+ last_L_star = tmp.spec.CIELab.L_star;
+/* lastChroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star, */
+/* tmp.spec.CIELab.b_star); */
+ lastaStar = tmp.spec.CIELab.a_star;
+ lastbStar = tmp.spec.CIELab.b_star;
+ nT = (n_L_star - max_lc.spec.CIELab.L_star) / maxDist * rFactor;
+ if (nT > 0) {
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ } else {
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ }
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now check if we've reached the target L_star
+ */
+ /* printf("result Lstar = %lf\n", tmp.spec.CIELab.L_star); */
+ if (tmp.spec.CIELab.L_star <= L_star + EPS &&
+ tmp.spec.CIELab.L_star >= L_star - EPS) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ }
+ if (nT > 0) {
+ n_L_star += ((TOPL - n_L_star) *
+ (L_star - tmp.spec.CIELab.L_star)) / (TOPL - L_star);
+ } else {
+ n_L_star *= L_star / tmp.spec.CIELuv.L_star;
+ }
+ if (tmp.spec.CIELab.L_star <= prev_L_star + EPS &&
+ tmp.spec.CIELab.L_star >= prev_L_star - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ /* printf("rFactor = %lf\n", rFactor); */
+ }
+ }
+ if (XCMS_FABS(last_L_star - L_star) <
+ XCMS_FABS(tmp.spec.CIELab.L_star - L_star)) {
+ tmp.spec.CIELab.a_star = lastaStar;
+ tmp.spec.CIELab.b_star = lastbStar;
+/* tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, lastChroma); */
+/* tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, lastChroma); */
+ }
+ tmp.spec.CIELab.L_star = L_star;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LabMxL.c b/src/xcms/LabMxL.c
new file mode 100644
index 00000000..a31a8f41
--- /dev/null
+++ b/src/xcms/LabMxL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LabMxL.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELabMxL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxL() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELab.L_star = START_L_STAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, chroma);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELabFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELabQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELAB_PMETRIC_CHROMA(max_lc.spec.CIELab.a_star,
+ max_lc.spec.CIELab.b_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (1.0 - (nChroma / max_chroma)) * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELab */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELabFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELAB_PMETRIC_CHROMA(tmp.spec.CIELab.a_star,
+ tmp.spec.CIELab.b_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LabMxLC.c b/src/xcms/LabMxLC.c
new file mode 100644
index 00000000..6fdeeb1b
--- /dev/null
+++ b/src/xcms/LabMxLC.c
@@ -0,0 +1,226 @@
+/* $Xorg: LabMxLC.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELabMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELabQueryMaxLC() gamut boundary
+ * querying routine.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_LSTAR (XcmsFloat)40.0
+#define START_CHROMA (XcmsFloat)3.6
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsConvertColorsWithWhitePt();
+
+/*
+ * FORWARD DECLARATIONS
+ */
+Status _XcmsCIELabQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCIELabQueryMaxLCRGB - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIELabQueryMaxLCRGB(ccc, hue, pColor_return, pRGB_return)
+ XcmsCCC ccc;
+ XcmsFloat hue; /* hue in radians */
+ XcmsColor *pColor_return;
+ XcmsRGBi *pRGB_return;
+
+/*
+ * DESCRIPTION
+ * Return the maximum psychometric chroma for a specified
+ * hue, and the corresponding L*. This is computed
+ * by a binary search of all possible chromas. An assumption
+ * is made that there are no local maxima. Use the unrounded
+ * Max psychometric chroma because the difference check can be
+ * small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue in radians as input and outputs
+ * Lab and RGBi.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsCIELabFormat;
+ /* Use some unreachable color on the given hue */
+ tmp.spec.CIELab.L_star = START_LSTAR;
+ tmp.spec.CIELab.a_star = XCMS_CIEASTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELab.b_star = XCMS_CIEBSTAROFHUE(hue, START_CHROMA);
+ /*
+ * Convert from Lab to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc),
+ (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to Lab */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELabFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabQueryMaxLC - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabQueryMaxLC (ccc, hue_angle, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue_angle in degrees */
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the point of maximum chroma for the specified
+ * hue_angle.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ return(_XcmsCIELabQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/src/xcms/LabWpAj.c b/src/xcms/LabWpAj.c
new file mode 100644
index 00000000..b4fc4a32
--- /dev/null
+++ b/src/xcms/LabWpAj.c
@@ -0,0 +1,97 @@
+/* $Xorg: LabWpAj.c,v 1.3 2000/08/17 19:44:40 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELabWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the CIE L*a*b* color
+ * space.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+
+extern Status _XcmsConvertColorsWithWhitePt();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELabWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELabWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Adjust color specifications in XcmsColor structures for
+ * differences in white points.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with gamut
+ * compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(0);
+ }
+
+ /*
+ * Convert to CIELab using pWhitePtFrom
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsCIELabFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from CIELab to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out,
+ pWhitePtTo, nColors, destSpecFmt, pCompressed));
+}
diff --git a/src/xcms/Luv.c b/src/xcms/Luv.c
new file mode 100644
index 00000000..9cb56cfd
--- /dev/null
+++ b/src/xcms/Luv.c
@@ -0,0 +1,385 @@
+/* $Xorg: Luv.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELuv.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE L*u*v*
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+
+extern char _XcmsCIELuv_prefix[];
+
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIELuv_ParseString();
+static Status XcmsCIELuv_ValidSpec();
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIELuv to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIELuv_to_CIEXYZ[] = {
+ XcmsCIELuvToCIEuvY,
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIELuv
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIELuv[] = {
+ XcmsCIEXYZToCIEuvY,
+ XcmsCIEuvYToCIELuv,
+ NULL
+};
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE Luv Color Space
+ */
+XcmsColorSpace XcmsCIELuvColorSpace =
+ {
+ _XcmsCIELuv_prefix, /* prefix */
+ XcmsCIELuvFormat, /* id */
+ CIELuv_ParseString, /* parseString */
+ Fl_CIELuv_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIELuv, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIELuv_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIELuv_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIELuvFormat.
+ * The assumed CIELuv string syntax is:
+ * CIELuv:<L>/<u>/<v>
+ * Where L, u, and v are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIELuv_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIELuv.L_star,
+ &pColor->spec.CIELuv.u_star,
+ &pColor->spec.CIELuv.v_star) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIELuvFormat;
+ pColor->pixel = 0;
+ return(XcmsCIELuv_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuv_ValidSpec
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIELuv_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE L*u*v*.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIELuvFormat
+ ||
+ (pColor->spec.CIELuv.L_star < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIELuv.L_star > 100.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIELuvToCIEuvY - convert CIELuv to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvToCIEuvY(ccc, pLuv_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLuv_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIELuv format to CIEuvY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEuvY uvY_return;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pLuv_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pLuv_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLuv_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL,
+ 1, XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pLuv_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pLuv_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIELuv and is valid */
+ if (!XcmsCIELuv_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if (pColor->spec.CIELuv.L_star < 7.99953624) {
+ uvY_return.Y = pColor->spec.CIELuv.L_star / 903.29;
+ } else {
+ tmpVal = (pColor->spec.CIELuv.L_star + 16.0) / 116.0;
+ uvY_return.Y = tmpVal * tmpVal * tmpVal; /* tmpVal ** 3 */
+ }
+
+
+
+ if (pColor->spec.CIELuv.L_star == 0.0) {
+ uvY_return.u_prime = pLuv_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pLuv_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+ tmpVal = 13.0 * (pColor->spec.CIELuv.L_star / 100.0);
+ uvY_return.u_prime = pColor->spec.CIELuv.u_star/tmpVal +
+ pLuv_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = pColor->spec.CIELuv.v_star/tmpVal +
+ pLuv_WhitePt->spec.CIEuvY.v_prime;
+ }
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToCIELuv - convert CIEuvY to CIELuv
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToCIELuv(ccc, pLuv_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pLuv_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEuvY format to CIELab format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIELuv Luv_return;
+ XcmsFloat tmpVal;
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pLuv_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (pLuv_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pLuv_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt,
+ (XcmsColor *)NULL, 1, XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ pLuv_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pLuv_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Now convert the uvY to Luv */
+ Luv_return.L_star =
+ (pColor->spec.CIEuvY.Y < 0.008856)
+ ?
+ (pColor->spec.CIEuvY.Y * 903.29)
+ :
+ ((XcmsFloat)(XCMS_CUBEROOT(pColor->spec.CIEuvY.Y) * 116.0) - 16.0);
+ tmpVal = 13.0 * (Luv_return.L_star / 100.0);
+ Luv_return.u_star = tmpVal *
+ (pColor->spec.CIEuvY.u_prime - pLuv_WhitePt->spec.CIEuvY.u_prime);
+ Luv_return.v_star = tmpVal *
+ (pColor->spec.CIEuvY.v_prime - pLuv_WhitePt->spec.CIEuvY.v_prime);
+
+ /* Copy result to pColor */
+ memcpy((char *)&pColor->spec, (char *)&Luv_return, sizeof(XcmsCIELuv));
+
+ /* Identify that the format is now CIEuvY */
+ pColor->format = XcmsCIELuvFormat;
+ }
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LuvGcC.c b/src/xcms/LuvGcC.c
new file mode 100644
index 00000000..fa3b3f11
--- /dev/null
+++ b/src/xcms/LuvGcC.c
@@ -0,0 +1,124 @@
+/* $Xorg: LuvGcC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipuv() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipuv - Reduce the chroma for a hue and L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipuv (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Reduce the Chroma for a specific hue and chroma to
+ * to bring the given color into the gamut of the
+ * specified device. As required of gamut compression
+ * functions, this routine returns pColor_in_out
+ * in XcmsCIEXYZFormat on successful completion.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsColor *pColor;
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < PseudoColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELuvFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ } else {
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMaxC(ccc,
+ degrees(XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star)),
+ pColor->spec.CIELuv.L_star,
+ pColor) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(ccc, pColor,
+ &ccc->pPerScrnInfo->screenWhitePt, 1, XcmsCIEXYZFormat);
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/LuvGcL.c b/src/xcms/LuvGcL.c
new file mode 100644
index 00000000..32d09bdb
--- /dev/null
+++ b/src/xcms/LuvGcL.c
@@ -0,0 +1,176 @@
+/* $Xorg: LuvGcL.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcL.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipL() gamut compression routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipL - Return the closest L*
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipL (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Return the closest L* for a specific hue and chroma.
+ * This routine takes any color as input and outputs
+ * a CIE XYZ color.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Luv_max;
+ XcmsFloat hue, chroma, maxChroma;
+ Status retval;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* Inherit Screen WP */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ return(XcmsFailure);
+ } else {
+ /* Convert from CIEXYZ to CIE L*u*v* format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ hue = XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max,
+ (XcmsRGBi *)NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star,
+ Luv_max.spec.CIELuv.v_star);
+
+ /* Now check and return the appropriate L* */
+ if (chroma == maxChroma) {
+ /* When the chroma input is equal to the maximum chroma */
+ /* merely return the L* for that chroma. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else if (chroma > maxChroma) {
+ /* When the chroma input is greater than the maximum chroma */
+ /* merely return the L* and chroma for the given hue. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ return (XcmsFailure);
+ } else if (pColor->spec.CIELuv.L_star < Luv_max.spec.CIELuv.L_star) {
+ /* Find the minimum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMinL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* Find the maximum lightness for the given chroma. */
+ if (pColor->format != XcmsCIELuvFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (XcmsCIELuvQueryMaxL(&myCCC, degrees(hue), chroma, pColor)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ }
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ return(retval);
+ }
+}
diff --git a/src/xcms/LuvGcLC.c b/src/xcms/LuvGcLC.c
new file mode 100644
index 00000000..376f5f40
--- /dev/null
+++ b/src/xcms/LuvGcLC.c
@@ -0,0 +1,225 @@
+/* $Xorg: LuvGcLC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvGcLC.c
+ *
+ * DESCRIPTION
+ * Source for XcmsCIELuvClipLuv() gamut
+ * compression function.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * INTERNALS
+ * Internal defines that need NOT be exported to any package or
+ * program using this package.
+ */
+#define MAXBISECTCOUNT 100
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvClipLuv - Return the closest L* and chroma
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIELuvClipLuv (ccc, pColors_in_out, nColors, i, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ unsigned int i;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * This routine will find the closest L* and chroma
+ * for a specific hue. The color input is converted to
+ * CIE L*u*v* format and returned as CIE XYZ format.
+ *
+ * Since this routine works with the L* within
+ * pColor_in_out intermediate results may be returned
+ * even though it may be invalid.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ Status retval;
+ XcmsCCCRec myCCC;
+ XcmsColor *pColor;
+ XcmsColor Luv_max;
+ XcmsFloat hue, chroma, maxChroma;
+ XcmsFloat Chroma, bestChroma, Lstar, maxLstar, saveLstar;
+ XcmsFloat bestLstar, bestustar, bestvstar;
+ XcmsFloat nT, saveDist, tmpDist;
+ XcmsRGBi rgb_max;
+ int nCount, nMaxCount, nI, nILast;
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;/* inherit screen white */
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut compression func */
+
+ /*
+ * Color specification passed as input can be assumed to:
+ * 1. Be in XcmsCIEXYZFormat
+ * 2. Already be white point adjusted for the Screen White Point.
+ * This means that the white point now associated with this
+ * color spec is the Screen White Point (even if the
+ * ccc->clientWhitePt differs).
+ */
+
+ pColor = pColors_in_out + i;
+
+ if (ccc->visual->class < StaticColor) {
+ /*
+ * GRAY !
+ */
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIELuvFormat);
+ _XcmsDIConvertColors(ccc, pColor, ScreenWhitePointOfCCC(ccc),
+ 1, XcmsCIEXYZFormat);
+ if (pCompressed) {
+ *(pCompressed + i) = True;
+ }
+ return(XcmsSuccess);
+ }
+
+ /* Convert from CIEXYZ to CIELuv format */
+ if (_XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Step 1: compute the maximum L* and chroma for this hue. */
+ /* This copy may be overkill but it preserves the pixel etc. */
+ saveLstar = pColor->spec.CIELuv.L_star;
+ hue = XCMS_CIELUV_PMETRIC_HUE(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ memcpy((char *)&Luv_max, (char *)pColor, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB (&myCCC, hue, &Luv_max, &rgb_max)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ maxLstar = Luv_max.spec.CIELuv.L_star;
+
+ /* Now check and return the appropriate L* */
+ if (saveLstar == maxLstar) {
+ /* When the L* input is equal to the maximum L* */
+ /* merely return the maximum Luv point. */
+ memcpy((char *)pColor, (char *)&Luv_max, sizeof(XcmsColor));
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+ } else {
+ /* return the closest point on the hue leaf. */
+ /* must do a bisection here to compute the delta e. */
+ maxChroma = XCMS_CIELUV_PMETRIC_CHROMA(Luv_max.spec.CIELuv.u_star,
+ Luv_max.spec.CIELuv.v_star);
+ nMaxCount = MAXBISECTCOUNT;
+ nI = nMaxCount / 2;
+ bestLstar = Lstar = pColor->spec.CIELuv.L_star;
+ bestustar = pColor->spec.CIELuv.u_star;
+ bestvstar = pColor->spec.CIELuv.v_star;
+ bestChroma = Chroma = chroma;
+ saveDist = XCMS_SQRT(((Chroma - maxChroma) * (Chroma - maxChroma)) +
+ ((Lstar - maxLstar) * (Lstar - maxLstar)));
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ nT = (XcmsFloat) nI / (XcmsFloat) nMaxCount;
+ if (saveLstar > maxLstar) {
+ pColor->spec.RGBi.red = rgb_max.red * (1.0 - nT) + nT;
+ pColor->spec.RGBi.green = rgb_max.green * (1.0 - nT) + nT;
+ pColor->spec.RGBi.blue = rgb_max.blue * (1.0 - nT) + nT;
+ } else {
+ pColor->spec.RGBi.red = rgb_max.red - (rgb_max.red * nT);
+ pColor->spec.RGBi.green = rgb_max.green - (rgb_max.green * nT);
+ pColor->spec.RGBi.blue = rgb_max.blue - (rgb_max.blue * nT);
+ }
+ pColor->format = XcmsRGBiFormat;
+
+ /* Convert from RGBi to CIE Luv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return (XcmsFailure);
+ }
+ chroma = XCMS_CIELUV_PMETRIC_CHROMA(pColor->spec.CIELuv.u_star,
+ pColor->spec.CIELuv.v_star);
+ tmpDist = XCMS_SQRT(((Chroma - chroma) * (Chroma - chroma)) +
+ ((Lstar - pColor->spec.CIELuv.L_star) *
+ (Lstar - pColor->spec.CIELuv.L_star)));
+ nILast = nI;
+ if (tmpDist > saveDist) {
+ nI /= 2;
+ } else {
+ nI = (nMaxCount + nI) / 2;
+ saveDist = tmpDist;
+ bestLstar = pColor->spec.CIELuv.L_star;
+ bestustar = pColor->spec.CIELuv.u_star;
+ bestvstar = pColor->spec.CIELuv.v_star;
+ bestChroma = chroma;
+ }
+ if (nI == nILast || nI == 0) {
+ break;
+ }
+ }
+ if (bestChroma >= maxChroma) {
+ pColor->spec.CIELuv.L_star = maxLstar;
+ pColor->spec.CIELuv.u_star = Luv_max.spec.CIELuv.u_star;
+ pColor->spec.CIELuv.v_star = Luv_max.spec.CIELuv.v_star;
+ } else {
+ pColor->spec.CIELuv.L_star = bestLstar;
+ pColor->spec.CIELuv.u_star = bestustar;
+ pColor->spec.CIELuv.v_star = bestvstar;
+ }
+ retval = _XcmsDIConvertColors(&myCCC, pColor,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIEXYZFormat);
+
+ if (retval != XcmsFailure && pCompressed != NULL) {
+ *(pCompressed + i) = True;
+ }
+ }
+ return(retval);
+}
diff --git a/src/xcms/LuvMnL.c b/src/xcms/LuvMnL.c
new file mode 100644
index 00000000..c687037d
--- /dev/null
+++ b/src/xcms/LuvMnL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LuvMnL.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvMnL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMinL() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMinL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMinL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = START_L_STAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star,
+ max_lc.spec.CIELuv.v_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (nChroma - max_chroma) / max_chroma * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star,
+ tmp.spec.CIELuv.v_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LuvMxC.c b/src/xcms/LuvMxC.c
new file mode 100644
index 00000000..100a3b9e
--- /dev/null
+++ b/src/xcms/LuvMxC.c
@@ -0,0 +1,205 @@
+/* $Xorg: LuvMxC.c,v 1.3 2000/08/17 19:44:41 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELuvMxC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxC() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_CHROMA (XcmsFloat)2.2
+#define TOPL (XcmsFloat)100.0
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxC - max chroma for a hue_angle and L_star
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxC(ccc, hue_angle, L_star, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat L_star;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum chroma for a specific hue_angle and L_star.
+ * The returned format is in XcmsCIELuvFormat.
+ *
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor tmp;
+ XcmsColor max_lc;
+ XcmsFloat n_L_star, last_L_star, prev_L_star;
+ XcmsFloat hue, lastuStar, lastvStar, /*lastChroma,*/ maxDist, nT, rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC and inherit screen white Pt */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;/* no gamut comp func */
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = L_star;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: compute the maximum L_star and chroma for this hue. */
+ memcpy((char *)&max_lc, (char *)&tmp, sizeof(XcmsColor));
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Step 2: Do a bisection here to compute the maximum chroma
+ * Note the differences between when the point to be found
+ * is above the maximum LC point and when it is below.
+ */
+ if (L_star <= max_lc.spec.CIELuv.L_star) {
+ maxDist = max_lc.spec.CIELuv.L_star;
+ } else {
+ maxDist = TOPL - max_lc.spec.CIELuv.L_star;
+ }
+
+ n_L_star = L_star;
+ last_L_star = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prev_L_star = last_L_star;
+ last_L_star = tmp.spec.CIELuv.L_star;
+/* lastChroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star, */
+/* tmp.spec.CIELuv.v_star); */
+ lastuStar = tmp.spec.CIELuv.u_star;
+ lastvStar = tmp.spec.CIELuv.v_star;
+ nT = (n_L_star - max_lc.spec.CIELuv.L_star) / maxDist * rFactor;
+ /* printf("(n_L_star, nT) = %lf %lf ", n_L_star, nT); */
+ if (nT > 0) {
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ } else {
+ tmp.spec.RGBi.red = rgb_saved.red + (rgb_saved.red * nT);
+ tmp.spec.RGBi.green = rgb_saved.green + (rgb_saved.green * nT);
+ tmp.spec.RGBi.blue = rgb_saved.blue + (rgb_saved.blue * nT);
+ }
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now check if we've reached the target L_star
+ */
+ /* printf("result Lstar = %lf\n", tmp.spec.CIELuv.L_star); */
+ if (tmp.spec.CIELuv.L_star <= L_star + EPS &&
+ tmp.spec.CIELuv.L_star >= L_star - EPS) {
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+ }
+ if (nT > 0) {
+ n_L_star += ((TOPL - n_L_star) *
+ (L_star - tmp.spec.CIELuv.L_star)) / (TOPL - L_star);
+ } else {
+ n_L_star *= L_star / tmp.spec.CIELuv.L_star;
+ }
+ if (tmp.spec.CIELuv.L_star <= prev_L_star + EPS &&
+ tmp.spec.CIELuv.L_star >= prev_L_star - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ /* printf("rFactor = %lf\n", rFactor); */
+ }
+ }
+ if (XCMS_FABS(last_L_star - L_star) <
+ XCMS_FABS(tmp.spec.CIELuv.L_star - L_star)) {
+ tmp.spec.CIELuv.u_star = lastuStar;
+ tmp.spec.CIELuv.v_star = lastvStar;
+/* tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, lastChroma); */
+/* tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, lastChroma); */
+ }
+ tmp.spec.CIELuv.L_star = L_star;
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LuvMxL.c b/src/xcms/LuvMxL.c
new file mode 100644
index 00000000..7925b010
--- /dev/null
+++ b/src/xcms/LuvMxL.c
@@ -0,0 +1,218 @@
+/* $Xorg: LuvMxL.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIELuvMxL.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxL() gamut boundary
+ * querying routine.
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <math.h>
+
+/*
+ * DEFINES
+ */
+#define MAXBISECTCOUNT 100
+#define EPS (XcmsFloat)0.001
+#define START_L_STAR (XcmsFloat)40.0
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxL - Compute max Lstar for a hue and chroma
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxL(ccc, hue_angle, chroma, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsFloat chroma;
+ XcmsColor *pColor_return;
+/*
+ * DESCRIPTION
+ * Return the maximum Lstar for a specified hue_angle and chroma.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded with no modifications
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+ XcmsColor max_lc, tmp, prev;
+ XcmsFloat max_chroma, tmp_chroma;
+ XcmsFloat hue, nT, nChroma, lastChroma, prevChroma;
+ XcmsFloat rFactor;
+ XcmsRGBi rgb_saved;
+ int nCount, nMaxCount;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* setup the CCC to use for the conversions. */
+ memcpy ((char *) &myCCC, (char *) ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc) NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ hue = radians(hue_angle);
+ tmp.spec.CIELuv.L_star = START_L_STAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, chroma);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, chroma);
+ tmp.pixel = pColor_return->pixel;
+ tmp.format = XcmsCIELuvFormat;
+
+ /* Step 1: Obtain the maximum L_star and chroma for this hue. */
+ if (_XcmsCIELuvQueryMaxLCRGB(&myCCC, hue, &max_lc, &rgb_saved)
+ == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ max_chroma = XCMS_CIELUV_PMETRIC_CHROMA(max_lc.spec.CIELuv.u_star,
+ max_lc.spec.CIELuv.v_star);
+
+ if (max_chroma <= chroma) {
+ /*
+ * If the chroma is greater than the chroma for the
+ * maximum L/chroma point then the L_star is the
+ * the L_star for the maximum L_star/chroma point.
+ * This is an error but I return the best approximation I can.
+ * Thus the inconsistency.
+ */
+ memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+
+ /*
+ * If the chroma is equal to the chroma for the
+ * maximum L_star/chroma point then the L_star is the
+ * the L_star for the maximum L* and chroma point.
+ */
+ /* if (max_chroma == chroma) {
+ * memcpy ((char *) pColor_return, (char *) &max_lc, sizeof (XcmsColor));
+ * return(XcmsSuccess);
+ * }
+ */
+
+ /* must do a bisection here to compute the maximum L* */
+ /* save the structure input so that any elements that */
+ /* are not touched are recopied later in the routine. */
+ nChroma = chroma;
+ tmp_chroma = max_chroma;
+ lastChroma = -1.0;
+ nMaxCount = MAXBISECTCOUNT;
+ rFactor = 1.0;
+
+ for (nCount = 0; nCount < nMaxCount; nCount++) {
+ prevChroma = lastChroma;
+ lastChroma = tmp_chroma;
+ nT = (1.0 - (nChroma / max_chroma)) * rFactor;
+ memcpy ((char *)&prev, (char *)&tmp, sizeof(XcmsColor));
+ tmp.spec.RGBi.red = rgb_saved.red * (1.0 - nT) + nT;
+ tmp.spec.RGBi.green = rgb_saved.green * (1.0 - nT) + nT;
+ tmp.spec.RGBi.blue = rgb_saved.blue * (1.0 - nT) + nT;
+ tmp.format = XcmsRGBiFormat;
+
+ /* convert from RGB to CIELuv */
+ if (_XcmsConvertColorsWithWhitePt(&myCCC, &tmp,
+ ScreenWhitePointOfCCC(&myCCC), 1, XcmsCIELuvFormat,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /* Now check the return against what is expected */
+ tmp_chroma = XCMS_CIELUV_PMETRIC_CHROMA(tmp.spec.CIELuv.u_star,
+ tmp.spec.CIELuv.v_star);
+ if (tmp_chroma <= chroma + EPS && tmp_chroma >= chroma - EPS) {
+ /* Found It! */
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+ }
+ nChroma += chroma - tmp_chroma;
+ if (nChroma > max_chroma) {
+ nChroma = max_chroma;
+ rFactor *= 0.5; /* selective relaxation employed */
+ } else if (nChroma < 0.0) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+ } else if (tmp_chroma <= prevChroma + EPS &&
+ tmp_chroma >= prevChroma - EPS) {
+ rFactor *= 0.5; /* selective relaxation employed */
+ }
+ }
+
+ if (nCount >= nMaxCount) {
+ if (XCMS_FABS(lastChroma - chroma) <
+ XCMS_FABS(tmp_chroma - chroma)) {
+ memcpy ((char *)pColor_return, (char *)&prev,
+ sizeof(XcmsColor));
+ } else {
+ memcpy ((char *)pColor_return, (char *)&tmp,
+ sizeof(XcmsColor));
+ }
+ }
+ memcpy ((char *) pColor_return, (char *) &tmp, sizeof (XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/LuvMxLC.c b/src/xcms/LuvMxLC.c
new file mode 100644
index 00000000..337bbbf2
--- /dev/null
+++ b/src/xcms/LuvMxLC.c
@@ -0,0 +1,226 @@
+/* $Xorg: LuvMxLC.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIELuvMxVC.c
+ *
+ * DESCRIPTION
+ * Source for the XcmsCIELuvQueryMaxLC() gamut boundary
+ * querying routine.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ * and
+ * Fred W. Billmeyer & Max Saltzman, "Principles of Color
+ * Technology", John Wily & Sons, Inc, 1981.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define MIN(x,y) ((x) > (y) ? (y) : (x))
+#define MIN3(x,y,z) ((x) > (MIN((y), (z))) ? (MIN((y), (z))) : (x))
+#define MAX(x,y) ((x) > (y) ? (x) : (y))
+#define MAX3(x,y,z) ((x) > (MAX((y), (z))) ? (x) : (MAX((y), (z))))
+#define START_LSTAR (XcmsFloat)40.0
+#define START_CHROMA (XcmsFloat)2.2
+
+/*
+ * EXTERNS
+ */
+extern Status _XcmsConvertColorsWithWhitePt();
+
+/*
+ * FORWARD DECLARATIONS
+ */
+Status _XcmsCIELuvQueryMaxLCRGB();
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCIELuvQueryMaxLCRGB - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIELuvQueryMaxLCRGB(ccc, hue, pColor_return, pRGB_return)
+ XcmsCCC ccc;
+ XcmsFloat hue; /* hue in radians */
+ XcmsColor *pColor_return;
+ XcmsRGBi *pRGB_return;
+
+/*
+ * DESCRIPTION
+ * Return the maximum psychometric chroma for a specified
+ * hue angle(radians), and the corresponding L*. This is computed
+ * by a binary search of all possible chromas. An assumption
+ * is made that there are no local maxima. Use the unrounded
+ * Max psychometric chroma because the difference check can be
+ * small.
+ *
+ * NOTE: No local CCC is used because this is a private
+ * routine and all routines that call it are expected
+ * to behave properly, i.e. send a local CCC with
+ * no white adjust function and no gamut compression
+ * function.
+ *
+ * This routine only accepts hue as input and outputs
+ * Luv and RGBi.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsFloat nSmall, nLarge;
+ XcmsColor tmp;
+
+ tmp.format = XcmsCIELuvFormat;
+ /* Use some unreachable color on the given hue angle */
+ tmp.spec.CIELuv.L_star = START_LSTAR;
+ tmp.spec.CIELuv.u_star = XCMS_CIEUSTAROFHUE(hue, START_CHROMA);
+ tmp.spec.CIELuv.v_star = XCMS_CIEVSTAROFHUE(hue, START_CHROMA);
+ /*
+ * Convert from Luv to RGB
+ *
+ * Note that the CIEXYZ to RGBi conversion routine must stuff the
+ * out of bounds RGBi values in tmp when the ccc->gamutCompProc
+ * is NULL.
+ */
+ if ((_XcmsConvertColorsWithWhitePt(ccc, &tmp, ScreenWhitePointOfCCC(ccc),
+ (unsigned int)1, XcmsRGBiFormat, (Bool *) NULL)
+ == XcmsFailure) && tmp.format != XcmsRGBiFormat) {
+ return (XcmsFailure);
+ }
+
+ /* Now pick the smallest RGB */
+ nSmall = MIN3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Make the smallest RGB equal to zero */
+ tmp.spec.RGBi.red -= nSmall;
+ tmp.spec.RGBi.green -= nSmall;
+ tmp.spec.RGBi.blue -= nSmall;
+
+ /* Now pick the largest RGB */
+ nLarge = MAX3(tmp.spec.RGBi.red,
+ tmp.spec.RGBi.green,
+ tmp.spec.RGBi.blue);
+ /* Scale the RGB values based on the largest one */
+ tmp.spec.RGBi.red /= nLarge;
+ tmp.spec.RGBi.green /= nLarge;
+ tmp.spec.RGBi.blue /= nLarge;
+ tmp.format = XcmsRGBiFormat;
+
+ /* If the calling routine wants RGB value give them the ones used. */
+ if (pRGB_return) {
+ pRGB_return->red = tmp.spec.RGBi.red;
+ pRGB_return->green = tmp.spec.RGBi.green;
+ pRGB_return->blue = tmp.spec.RGBi.blue;
+ }
+
+ /* Convert from RGBi to Luv */
+ if (_XcmsConvertColorsWithWhitePt(ccc, &tmp,
+ ScreenWhitePointOfCCC(ccc), 1, XcmsCIELuvFormat, (Bool *) NULL)
+ == XcmsFailure) {
+ return (XcmsFailure);
+ }
+
+ memcpy((char *)pColor_return, (char *)&tmp, sizeof(XcmsColor));
+ return (XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvQueryMaxLC - Compute maximum L* and chroma.
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvQueryMaxLC (ccc, hue_angle, pColor_return)
+ XcmsCCC ccc;
+ XcmsFloat hue_angle; /* hue angle in degrees */
+ XcmsColor *pColor_return;
+
+/*
+ * DESCRIPTION
+ * Return the point of maximum chroma for the specified
+ * hue angle.
+ *
+ * ASSUMPTIONS
+ * This routine assumes that the white point associated with
+ * the color specification is the Screen White Point. The
+ * Screen White Point will also be associated with the
+ * returned color specification.
+ *
+ * RETURNS
+ * XcmsFailure - Failure
+ * XcmsSuccess - Succeeded
+ *
+ */
+{
+ XcmsCCCRec myCCC;
+
+ /*
+ * Check Arguments
+ */
+ if (ccc == NULL || pColor_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ /* Use my own CCC */
+ memcpy ((char *)&myCCC, (char *)ccc, sizeof(XcmsCCCRec));
+ myCCC.clientWhitePt.format = XcmsUndefinedFormat;
+ myCCC.gamutCompProc = (XcmsCompressionProc)NULL;
+
+ while (hue_angle < 0.0) {
+ hue_angle += 360.0;
+ }
+ while (hue_angle >= 360.0) {
+ hue_angle -= 360.0;
+ }
+
+ return(_XcmsCIELuvQueryMaxLCRGB (&myCCC, radians(hue_angle), pColor_return,
+ (XcmsRGBi *)NULL));
+}
diff --git a/src/xcms/LuvWpAj.c b/src/xcms/LuvWpAj.c
new file mode 100644
index 00000000..5083ccb7
--- /dev/null
+++ b/src/xcms/LuvWpAj.c
@@ -0,0 +1,100 @@
+/* $Xorg: LuvWpAj.c,v 1.3 2000/08/17 19:44:45 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIELuvWpAj.c
+ *
+ * DESCRIPTION
+ * This file contains routine(s) that support white point
+ * adjustment of color specifications in the CIE CIELuv.color
+ * space.
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+
+extern Status _XcmsConvertColorsWithWhitePt();
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELuvWhiteShiftColors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIELuvWhiteShiftColors(ccc, pWhitePtFrom, pWhitePtTo, destSpecFmt,
+ pColors_in_out, nColors, pCompressed)
+ XcmsCCC ccc;
+ XcmsColor *pWhitePtFrom;
+ XcmsColor *pWhitePtTo;
+ XcmsColorFormat destSpecFmt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Adjusts color specifications in an array of XcmsColor
+ * structures for white point differences.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded without gamut compression,
+ * XcmsSuccessWithCompression if succeeded with
+ * gamut compression.
+ */
+{
+ if (pWhitePtFrom == NULL || pWhitePtTo == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to CIELuv using pWhitePtFrom
+ * We can ignore return value for compression because we are converting
+ * to XcmsCIELuvFormat which is device-independent, not device-dependent.
+ */
+ if (_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtFrom,
+ nColors, XcmsCIELuvFormat, pCompressed) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert from CIELuv to destSpecFmt using pWhitePtTo
+ */
+ return(_XcmsConvertColorsWithWhitePt(ccc, pColors_in_out, pWhitePtTo,
+ nColors, destSpecFmt, pCompressed));
+}
diff --git a/src/xcms/OfCCC.c b/src/xcms/OfCCC.c
new file mode 100644
index 00000000..20d3a9be
--- /dev/null
+++ b/src/xcms/OfCCC.c
@@ -0,0 +1,160 @@
+/* $Xorg: OfCCC.c,v 1.3 2000/08/17 19:44:47 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsOfCCC.c - Color Conversion Context Querying Routines
+ *
+ * DESCRIPTION
+ * Routines to query components of a Color Conversion
+ * Context structure.
+ *
+ *
+ */
+
+#include "Xlib.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsDisplayOfCCC
+ *
+ * SYNOPSIS
+ */
+
+Display *
+XcmsDisplayOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the Display of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the Display.
+ *
+ */
+{
+ return(ccc->dpy);
+}
+
+
+/*
+ * NAME
+ * XcmsVisualOfCCC
+ *
+ * SYNOPSIS
+ */
+
+Visual *
+XcmsVisualOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the Visual of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the Visual.
+ *
+ */
+{
+ return(ccc->visual);
+}
+
+
+/*
+ * NAME
+ * XcmsScreenNumberOfCCC
+ *
+ * SYNOPSIS
+ */
+
+int
+XcmsScreenNumberOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the screen number of the specified CCC.
+ *
+ * RETURNS
+ * screen number.
+ *
+ */
+{
+ return(ccc->screenNumber);
+}
+
+
+/*
+ * NAME
+ * XcmsScreenWhitePointOfCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsColor *
+XcmsScreenWhitePointOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the screen white point of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the XcmsColor containing the screen white point.
+ *
+ */
+{
+ return(&ccc->pPerScrnInfo->screenWhitePt);
+}
+
+
+/*
+ * NAME
+ * XcmsClientWhitePointOfCCC
+ *
+ * SYNOPSIS
+ */
+
+XcmsColor *
+XcmsClientWhitePointOfCCC(ccc)
+ XcmsCCC ccc;
+/*
+ * DESCRIPTION
+ * Queries the client white point of the specified CCC.
+ *
+ * RETURNS
+ * Pointer to the XcmsColor containing the client white point.
+ *
+ */
+{
+ return(&ccc->clientWhitePt);
+}
diff --git a/src/xcms/PrOfId.c b/src/xcms/PrOfId.c
new file mode 100644
index 00000000..7b301e41
--- /dev/null
+++ b/src/xcms/PrOfId.c
@@ -0,0 +1,107 @@
+/* $Xorg: PrOfId.c,v 1.3 2000/08/17 19:44:48 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsPrOfId.c
+ *
+ * DESCRIPTION
+ * Source for XcmsPrefixOfFormat()
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+extern XcmsColorSpace **_XcmsDDColorSpaces;
+
+
+/*
+ * NAME
+ * XcmsPrefixOfId
+ *
+ * SYNOPSIS
+ */
+char *
+XcmsPrefixOfFormat(id)
+ XcmsColorFormat id;
+/*
+ * DESCRIPTION
+ * Returns the color space prefix for the specified color
+ * space ID if the color space is found in the Color
+ * Conversion Context.
+ *
+ * RETURNS
+ * Returns a color space prefix.
+ *
+ * CAVEATS
+ * Space is allocated for the returned string, therefore,
+ * the application is responsible for freeing (using XFree)
+ * the space.
+ *
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ char *prefix;
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
+ 1) * sizeof(char));
+ strcpy(prefix, (*papColorSpaces)->prefix);
+ return(prefix);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = _XcmsDDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if ((*papColorSpaces)->id == id) {
+ prefix = (char *)Xmalloc((strlen((*papColorSpaces)->prefix) +
+ 1) * sizeof(char));
+ strcpy(prefix, (*papColorSpaces)->prefix);
+ return(prefix);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
diff --git a/src/xcms/QBlack.c b/src/xcms/QBlack.c
new file mode 100644
index 00000000..c54dccb4
--- /dev/null
+++ b/src/xcms/QBlack.c
@@ -0,0 +1,82 @@
+/* $Xorg: QBlack.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQBlack.c - Query Black
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for zero
+ * red, green, and blue intensities.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryBlack
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryBlack(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * zero intensity red, green, and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/QBlue.c b/src/xcms/QBlue.c
new file mode 100644
index 00000000..2bca3877
--- /dev/null
+++ b/src/xcms/QBlue.c
@@ -0,0 +1,82 @@
+/* $Xorg: QBlue.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQBlue.c - Query Blue
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * blue intensity and zero red and green intensities.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryBlue
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryBlue(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity blue and zero intensity red and green.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 1.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/QGreen.c b/src/xcms/QGreen.c
new file mode 100644
index 00000000..f7858c32
--- /dev/null
+++ b/src/xcms/QGreen.c
@@ -0,0 +1,82 @@
+/* $Xorg: QGreen.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQGreen.c - Query Green
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * green intensity and zero red and blue intensities.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryGreen
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryGreen(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity green and zero intensity red and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 0.0;
+ tmp.spec.RGBi.green = 1.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/QRed.c b/src/xcms/QRed.c
new file mode 100644
index 00000000..136ebc2e
--- /dev/null
+++ b/src/xcms/QRed.c
@@ -0,0 +1,82 @@
+/* $Xorg: QRed.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQRed.c - Query Red
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * red intensity and zero green and blue intensities.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryRed
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryRed(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity red and zero intensity green and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 1.0;
+ tmp.spec.RGBi.green = 0.0;
+ tmp.spec.RGBi.blue = 0.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/QWhite.c b/src/xcms/QWhite.c
new file mode 100644
index 00000000..93d37d38
--- /dev/null
+++ b/src/xcms/QWhite.c
@@ -0,0 +1,82 @@
+/* $Xorg: QWhite.c,v 1.3 2000/08/17 19:44:49 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQWhite.c - Query White
+ *
+ * DESCRIPTION
+ * Routine to obtain a color specification for full
+ * red, green, and blue intensities.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryWhite
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsQueryWhite(ccc, target_format, pColor_ret)
+ XcmsCCC ccc;
+ XcmsColorFormat target_format;
+ XcmsColor *pColor_ret;
+/*
+ * DESCRIPTION
+ * Returns the color specification in the target format for
+ * full intensity red, green, and blue.
+ *
+ * RETURNS
+ * Returns XcmsSuccess, if failed; otherwise XcmsFailure
+ *
+ */
+{
+ XcmsColor tmp;
+
+ tmp.format = XcmsRGBiFormat;
+ tmp.pixel = 0;
+ tmp.spec.RGBi.red = 1.0;
+ tmp.spec.RGBi.green = 1.0;
+ tmp.spec.RGBi.blue = 1.0;
+ if (XcmsConvertColors(ccc, &tmp, 1, target_format, NULL) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+ memcpy((char *)pColor_ret, (char *)&tmp, sizeof(XcmsColor));
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/QuCol.c b/src/xcms/QuCol.c
new file mode 100644
index 00000000..d632d457
--- /dev/null
+++ b/src/xcms/QuCol.c
@@ -0,0 +1,76 @@
+/* $Xorg: QuCol.c,v 1.3 2000/08/17 19:44:50 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQuCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsQueryColors
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsQueryColor - Query Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsQueryColor(dpy, colormap, pXcmsColor_in_out, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColor_in_out;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * This routine uses XQueryColor to obtain the X RGB values
+ * stored in the specified colormap for the specified pixel.
+ * The X RGB values are then converted to the target format as
+ * specified by the format component of the XcmsColor structure.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded.
+ *
+ * Returns a color specification of the color stored in the
+ * specified pixel.
+ */
+{
+ return(_XcmsSetGetColors (XQueryColor, dpy, colormap,
+ pXcmsColor_in_out, 1, result_format, (Bool *) NULL));
+}
diff --git a/src/xcms/QuCols.c b/src/xcms/QuCols.c
new file mode 100644
index 00000000..9a35cf05
--- /dev/null
+++ b/src/xcms/QuCols.c
@@ -0,0 +1,75 @@
+/* $Xorg: QuCols.c,v 1.3 2000/08/17 19:44:50 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsQuCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsQueryColors
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+/*
+ * NAME
+ * XcmsQueryColors - Query Colors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsQueryColors(dpy, colormap, pXcmsColors_in_out, nColors, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * This routine uses XQueryColors to obtain the X RGB values
+ * stored in the specified colormap for the specified pixels.
+ * The X RGB values are then converted to the target format as
+ * specified by the format component of the XcmsColor structure.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded.
+ *
+ * Returns the color specifications of the colors stored in the
+ * specified pixels.
+ */
+{
+ return(_XcmsSetGetColors (XQueryColors, dpy, colormap,
+ pXcmsColors_in_out, nColors, result_format, (Bool *) NULL));
+}
diff --git a/src/xcms/SetCCC.c b/src/xcms/SetCCC.c
new file mode 100644
index 00000000..d58daf8a
--- /dev/null
+++ b/src/xcms/SetCCC.c
@@ -0,0 +1,150 @@
+/* $Xorg: SetCCC.c,v 1.3 2000/08/17 19:44:52 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsSetCCC.c - Color Conversion Context Setting Routines
+ *
+ * DESCRIPTION
+ * Routines to set components of a Color Conversion
+ * Context structure.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcms.h"
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsSetWhitePoint
+ *
+ * SYNOPSIS
+ */
+
+Status
+XcmsSetWhitePoint(ccc, pColor)
+ XcmsCCC ccc;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Sets the Client White Point in the specified CCC.
+ *
+ * RETURNS
+ * Returns XcmsSuccess if succeeded; otherwise XcmsFailure.
+ *
+ */
+{
+ if (pColor == NULL || pColor->format == XcmsUndefinedFormat) {
+ ccc->clientWhitePt.format = XcmsUndefinedFormat;
+ } else if (pColor->format != XcmsCIEXYZFormat &&
+ pColor->format != XcmsCIEuvYFormat &&
+ pColor->format != XcmsCIExyYFormat) {
+ return(XcmsFailure);
+ } else {
+ memcpy((char *)&ccc->clientWhitePt, (char *)pColor, sizeof(XcmsColor));
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsSetCompressionProc
+ *
+ * SYNOPSIS
+ */
+
+XcmsCompressionProc
+#if NeedFunctionPrototypes
+XcmsSetCompressionProc(
+ XcmsCCC ccc,
+ XcmsCompressionProc compression_proc,
+ XPointer client_data)
+#else
+XcmsSetCompressionProc(ccc, compression_proc, client_data)
+ XcmsCCC ccc;
+ XcmsCompressionProc compression_proc;
+ XPointer client_data;
+#endif
+/*
+ * DESCRIPTION
+ * Set the specified CCC's compression function and client data.
+ *
+ * RETURNS
+ * Returns the old compression function.
+ *
+ */
+{
+ XcmsCompressionProc old = ccc->gamutCompProc;
+
+ ccc->gamutCompProc = compression_proc;
+ ccc->gamutCompClientData = client_data;
+ return(old);
+}
+
+
+/*
+ * NAME
+ * XcmsSetWhiteAdjustProc
+ *
+ * SYNOPSIS
+ */
+
+XcmsWhiteAdjustProc
+#if NeedFunctionPrototypes
+XcmsSetWhiteAdjustProc(
+ XcmsCCC ccc,
+ XcmsWhiteAdjustProc white_adjust_proc,
+ XPointer client_data )
+#else
+XcmsSetWhiteAdjustProc(ccc, white_adjust_proc, client_data)
+ XcmsCCC ccc;
+ XcmsWhiteAdjustProc white_adjust_proc;
+ XPointer client_data;
+#endif
+/*
+ * DESCRIPTION
+ * Set the specified CCC's white_adjust function and client data.
+ *
+ * RETURNS
+ * Returns the old white_adjust function.
+ *
+ */
+{
+ XcmsWhiteAdjustProc old = ccc->whitePtAdjProc;
+
+ ccc->whitePtAdjProc = white_adjust_proc;
+ ccc->whitePtAdjClientData = client_data;
+ return(old);
+}
diff --git a/src/xcms/SetGetCols.c b/src/xcms/SetGetCols.c
new file mode 100644
index 00000000..5ee68985
--- /dev/null
+++ b/src/xcms/SetGetCols.c
@@ -0,0 +1,201 @@
+/* $Xorg: SetGetCols.c,v 1.3 2000/08/17 19:44:54 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsSetGet.c
+ *
+ * DESCRIPTION
+ * Source for _XcmsSetGetColors()
+ *
+ *
+ */
+
+/*
+ * EXTERNAL INCLUDES
+ * Include files that must be exported to any package or
+ * program using this package.
+ */
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/*
+ * EXTERNS
+ */
+
+extern void _XcmsRGB_to_XColor();
+extern void _XColor_to_XcmsRGB();
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsSetColors -
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsSetGetColors(xColorProc, dpy, cmap, pColors_in_out, nColors,
+ result_format, pCompressed)
+ Status (*xColorProc)();
+ Display *dpy;
+ Colormap cmap;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+ XcmsColorFormat result_format;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Routine containing code common to:
+ * XcmsAllocColor
+ * XcmsQueryColor
+ * XcmsQueryColors
+ * XcmsStoreColor
+ * XcmsStoreColors
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ */
+{
+ XcmsCCC ccc;
+ XColor *pXColors_in_out;
+ Status retval = XcmsSuccess;
+
+ /*
+ * Argument Checking
+ * 1. Assume xColorProc is correct
+ * 2. Insure ccc not NULL
+ * 3. Assume cmap correct (should be checked by Server)
+ * 4. Insure pColors_in_out valid
+ * 5. Assume method_in is valid (should be checked by Server)
+ * 6. Insure nColors > 0
+ */
+
+ if (dpy == NULL) {
+ return(XcmsFailure);
+ }
+
+ if (nColors == 0) {
+ return(XcmsSuccess);
+ }
+
+ if (result_format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ if (!((*xColorProc == XAllocColor) || (*xColorProc == XStoreColor)
+ || (*xColorProc == XStoreColors) || (*xColorProc == XQueryColor)
+ || (*xColorProc == XQueryColors))) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((*xColorProc == XAllocColor) || (*xColorProc == XStoreColor)
+ || (*xColorProc == XQueryColor)) {
+ nColors = 1;
+ }
+
+ /*
+ * Allocate space for XColors
+ */
+ if ((pXColors_in_out = (XColor *)Xcalloc(nColors, sizeof(XColor))) ==
+ NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((*xColorProc == XQueryColor) || (*xColorProc == XQueryColors)) {
+ goto Query;
+ }
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ if ((retval = XcmsConvertColors(ccc, pColors_in_out, nColors, XcmsRGBFormat,
+ pCompressed)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+Query:
+ /*
+ * Convert XcmsColor to XColor structures
+ */
+ _XcmsRGB_to_XColor(pColors_in_out, pXColors_in_out, nColors);
+
+ /*
+ * Now make appropriate X Call
+ */
+ if (*xColorProc == XAllocColor) {
+ if ((*xColorProc)(ccc->dpy, cmap, pXColors_in_out) == 0) {
+ Xfree((char *)pXColors_in_out);
+ return(XcmsFailure);
+ }
+ } else if ((*xColorProc == XQueryColor) || (*xColorProc == XStoreColor)) {
+ /* Note: XQueryColor and XStoreColor do not return any Status */
+ (*xColorProc)(ccc->dpy, cmap, pXColors_in_out);
+ } else if ((*xColorProc == XQueryColors) || (*xColorProc == XStoreColors)){
+ /* Note: XQueryColors and XStoreColors do not return any Status */
+ (*xColorProc)(ccc->dpy, cmap, pXColors_in_out, nColors);
+ } else {
+ Xfree((char *)pXColors_in_out);
+ return(XcmsFailure);
+ }
+
+ if ((*xColorProc == XStoreColor) || (*xColorProc == XStoreColors)) {
+ Xfree((char *)pXColors_in_out);
+ return(retval);
+ }
+
+ /*
+ * Now, convert returned XColor(i.e., rgb) to XcmsColor structures
+ */
+ _XColor_to_XcmsRGB(ccc, pXColors_in_out, pColors_in_out, nColors);
+ Xfree((char *)pXColors_in_out);
+
+ /*
+ * Then, convert XcmsColor structures to the original specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format != XcmsRGBFormat) {
+ if (XcmsConvertColors(ccc, pColors_in_out, nColors, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ return(retval);
+}
diff --git a/src/xcms/StCol.c b/src/xcms/StCol.c
new file mode 100644
index 00000000..b6229f98
--- /dev/null
+++ b/src/xcms/StCol.c
@@ -0,0 +1,79 @@
+/* $Xorg: StCol.c,v 1.3 2000/08/17 19:44:55 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsStCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsStoreColor
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsStoreColor - Store Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsStoreColor(dpy, colormap, pColor_in)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pColor_in;
+/*
+ * DESCRIPTION
+ * Given a device-dependent or device-independent color
+ * specification, this routine will convert it to X RGB
+ * values then use it in a call to XStoreColor.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Since XStoreColor has no return value this routine
+ * does not return the color specification of the color actually
+ * stored.
+ */
+{
+ XcmsColor tmpColor;
+
+ tmpColor = *pColor_in;
+ return(_XcmsSetGetColors (XStoreColor, dpy, colormap,
+ &tmpColor, 1, XcmsRGBFormat, (Bool *) NULL));
+}
diff --git a/src/xcms/StCols.c b/src/xcms/StCols.c
new file mode 100644
index 00000000..1e833c34
--- /dev/null
+++ b/src/xcms/StCols.c
@@ -0,0 +1,110 @@
+/* $Xorg: StCols.c,v 1.3 2000/08/17 19:44:56 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsStCols.c
+ *
+ * DESCRIPTION
+ * Source for XcmsStoreColors
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsStoreColors - Store Colors
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsStoreColors(dpy, colormap, pColors_in,
+ nColors, pCompressed)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pColors_in;
+ unsigned int nColors;
+ Bool *pCompressed;
+/*
+ * DESCRIPTION
+ * Given device-dependent or device-independent color
+ * specifications, this routine will convert them to X RGB
+ * values then use it in a call to XStoreColors.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Since XStoreColors has no return value, this routine
+ * does not return color specifications of the colors actually
+ * stored.
+ */
+{
+ XcmsColor Color1;
+ XcmsColor *pColors_tmp;
+ Status retval;
+
+ /*
+ * Make copy of array of color specifications so we don't
+ * overwrite the contents.
+ */
+ if (nColors > 1) {
+ pColors_tmp = (XcmsColor *) Xmalloc(nColors * sizeof(XcmsColor));
+ } else {
+ pColors_tmp = &Color1;
+ }
+ memcpy((char *)pColors_tmp, (char *)pColors_in,
+ nColors * sizeof(XcmsColor));
+
+ /*
+ * Call routine to store colors using the copied color structures
+ */
+ retval = _XcmsSetGetColors (XStoreColors, dpy, colormap,
+ pColors_tmp, nColors, XcmsRGBFormat, pCompressed);
+
+ /*
+ * Free copies as needed.
+ */
+ if (nColors > 1) {
+ Xfree((char *)pColors_tmp);
+ }
+
+ /*
+ * Ah, finally return.
+ */
+ return(retval);
+}
diff --git a/src/xcms/UNDEFINED.c b/src/xcms/UNDEFINED.c
new file mode 100644
index 00000000..a4e05551
--- /dev/null
+++ b/src/xcms/UNDEFINED.c
@@ -0,0 +1,102 @@
+/* $Xorg: UNDEFINED.c,v 1.3 2000/08/17 19:44:57 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * UNDEFINED.c
+ *
+ * DESCRIPTION
+ * UNDEFINED Color Space
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int ReturnZero();
+
+
+/*
+ * LOCALS VARIABLES
+ */
+
+static Status (*(Fl_ReturnZero[]))() = {
+ ReturnZero,
+ NULL
+};
+
+
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+ /*
+ * UNDEFINED Color Space
+ */
+XcmsColorSpace XcmsUNDEFINEDColorSpace =
+ {
+ "undefined", /* prefix */
+ XcmsUndefinedFormat, /* id */
+ ReturnZero, /* parseString */
+ Fl_ReturnZero, /* to_CIEXYZ */
+ Fl_ReturnZero /* from_CIEXYZ */
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * ReturnZero
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+static int
+ReturnZero()
+/*
+ * DESCRIPTION
+ * Does nothing.
+ *
+ * RETURNS
+ * 0
+ *
+ */
+{
+ return(0);
+}
diff --git a/src/xcms/XRGB.c b/src/xcms/XRGB.c
new file mode 100644
index 00000000..7e5b7f84
--- /dev/null
+++ b/src/xcms/XRGB.c
@@ -0,0 +1,245 @@
+/* $Xorg: XRGB.c,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsRtoX.c
+ *
+ * DESCRIPTION
+ * Convert color specifications in XcmsRGB format in one array of
+ * XcmsColor structures to RGB in an array of XColor structures.
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+/*
+ * LOCAL VARIABLES
+ */
+
+static unsigned short Const MASK[17] = {
+ 0x0000, /* 0 bitsPerRGB */
+ 0x8000, /* 1 bitsPerRGB */
+ 0xc000, /* 2 bitsPerRGB */
+ 0xe000, /* 3 bitsPerRGB */
+ 0xf000, /* 4 bitsPerRGB */
+ 0xf800, /* 5 bitsPerRGB */
+ 0xfc00, /* 6 bitsPerRGB */
+ 0xfe00, /* 7 bitsPerRGB */
+ 0xff00, /* 8 bitsPerRGB */
+ 0xff80, /* 9 bitsPerRGB */
+ 0xffc0, /* 10 bitsPerRGB */
+ 0xffe0, /* 11 bitsPerRGB */
+ 0xfff0, /* 12 bitsPerRGB */
+ 0xfff8, /* 13 bitsPerRGB */
+ 0xfffc, /* 14 bitsPerRGB */
+ 0xfffe, /* 15 bitsPerRGB */
+ 0xffff /* 16 bitsPerRGB */
+};
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsRGB_to_XColor -
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsRGB_to_XColor(pColors, pXColors, nColors)
+ XcmsColor *pColors;
+ XColor *pXColors;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Translates a color specification in XcmsRGBFormat in a XcmsColor
+ * structure to an XColor structure.
+ *
+ * RETURNS
+ * void.
+ */
+{
+ for (; nColors--; pXColors++, pColors++) {
+ pXColors->pixel = pColors->pixel;
+ pXColors->red = pColors->spec.RGB.red;
+ pXColors->green = pColors->spec.RGB.green;
+ pXColors->blue = pColors->spec.RGB.blue;
+ pXColors->flags = (DoRed | DoGreen | DoBlue);
+ }
+}
+
+
+/*
+ * NAME
+ * _XColor_to_XcmsRGB
+ *
+ * SYNOPSIS
+ */
+void
+_XColor_to_XcmsRGB(ccc, pXColors, pColors, nColors)
+ XcmsCCC ccc;
+ XColor *pXColors;
+ XcmsColor *pColors;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Translates an RGB color specification in an XColor
+ * structure to an XcmsRGB structure.
+ *
+ * IMPORTANT NOTE: Bit replication that may have been caused
+ * with ResolveColor() routine in the X Server is undone
+ * here if requested! For example, if red = 0xcaca and the
+ * bits_per_rgb is 8, then spec.RGB.red will be 0xca00.
+ *
+ * RETURNS
+ * void
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ for (; nColors--; pXColors++, pColors++) {
+ pColors->spec.RGB.red = (pXColors->red & MASK[bits_per_rgb]);
+ pColors->spec.RGB.green = (pXColors->green & MASK[bits_per_rgb]);
+ pColors->spec.RGB.blue = (pXColors->blue & MASK[bits_per_rgb]);
+ pColors->format = XcmsRGBFormat;
+ pColors->pixel = pXColors->pixel;
+ }
+}
+
+
+/*
+ * NAME
+ * _XcmsResolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsResolveColor(ccc, pXcmsColor)
+ XcmsCCC ccc;
+ XcmsColor *pXcmsColor;
+/*
+ * DESCRIPTION
+ * Uses the X Server ResolveColor() algorithm to
+ * modify values to closest values supported by hardware.
+ * Old algorithm simply masked low-order bits. The new algorithm
+ * has the effect of replicating significant bits into lower order
+ * bits in order to stretch the hardware value into all 16 bits.
+ *
+ * On a display with N-bit DACs, the "hardware" color is computed as:
+ *
+ * ((unsignedlong)(ClientValue >> (16-N)) * 0xFFFF) / ((1 << N) - 1)
+ *
+ *
+ * RETURNS
+ * void.
+ */
+{
+ int shift;
+ int max_color;
+
+ shift = 16 - ccc->visual->bits_per_rgb;
+ max_color = (1 << ccc->visual->bits_per_rgb) - 1;
+
+
+ pXcmsColor->spec.RGB.red =
+ ((unsigned long)(pXcmsColor->spec.RGB.red >> shift) * 0xFFFF)
+ / max_color;
+ pXcmsColor->spec.RGB.green =
+ ((unsigned long)(pXcmsColor->spec.RGB.green >> shift) * 0xFFFF)
+ / max_color;
+ pXcmsColor->spec.RGB.blue =
+ ((unsigned long)(pXcmsColor->spec.RGB.blue >> shift) * 0xFFFF)
+ / max_color;
+}
+
+
+/*
+ * NAME
+ * _XcmsUnresolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsUnresolveColor(ccc, pColor)
+ XcmsCCC ccc;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Masks out insignificant bits.
+ *
+ * RETURNS
+ * void.
+ *
+ * ASSUMPTIONS
+ * format == XcmsRGBFormat
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ pColor->spec.RGB.red &= MASK[bits_per_rgb];
+ pColor->spec.RGB.green &= MASK[bits_per_rgb];
+ pColor->spec.RGB.blue &= MASK[bits_per_rgb];
+}
+
+
+/*
+ * NAME
+ * _XUnresolveColor
+ *
+ * SYNOPSIS
+ */
+void
+_XUnresolveColor(ccc, pXColor)
+ XcmsCCC ccc;
+ XColor *pXColor;
+/*
+ * DESCRIPTION
+ * Masks out insignificant bits.
+ *
+ * RETURNS
+ * void.
+ */
+{
+ int bits_per_rgb = ccc->visual->bits_per_rgb;
+
+ pXColor->red &= MASK[bits_per_rgb];
+ pXColor->green &= MASK[bits_per_rgb];
+ pXColor->blue &= MASK[bits_per_rgb];
+}
+
diff --git a/src/xcms/XYZ.c b/src/xcms/XYZ.c
new file mode 100644
index 00000000..a06b2132
--- /dev/null
+++ b/src/xcms/XYZ.c
@@ -0,0 +1,192 @@
+/* $Xorg: XYZ.c,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ *
+ * NAME
+ * CIEXYZ.c
+ *
+ * DESCRIPTION
+ * CIE XYZ Color Space
+ *
+ *
+ */
+
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/*
+ * EXTERNS
+ * External declarations required locally to this package
+ * that are not already declared in any of the included header
+ * files (external includes or internal includes).
+ */
+extern char _XcmsCIEXYZ_prefix[];
+
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * FORWARD DECLARATIONS
+ */
+static int CIEXYZ_ParseString();
+Status _XcmsCIEXYZ_ValidSpec();
+
+
+/*
+ * LOCALS VARIABLES
+ */
+
+static XcmsConversionProc Fl_CIEXYZ_to_CIEXYZ[] = {
+ NULL
+};
+
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+ /*
+ * CIE XYZ Color Space
+ */
+XcmsColorSpace XcmsCIEXYZColorSpace =
+ {
+ _XcmsCIEXYZ_prefix, /* prefix */
+ XcmsCIEXYZFormat, /* id */
+ CIEXYZ_ParseString, /* parseString */
+ Fl_CIEXYZ_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIEXYZ, /* from_CIEXYZ */
+ 1
+ };
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIEXYZ_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIEXYZ_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIEXYZFormat.
+ * The assumed CIEXYZ string syntax is:
+ * CIEXYZ:<X>/<Y>/<Z>
+ * Where X, Y, and Z are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIEXYZ_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIEXYZ.X,
+ &pColor->spec.CIEXYZ.Y,
+ &pColor->spec.CIEXYZ.Z) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIEXYZFormat;
+ pColor->pixel = 0;
+ return(_XcmsCIEXYZ_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIELab_ValidSpec
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIEXYZ_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE XYZ
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIEXYZFormat
+ ||
+ (pColor->spec.CIEXYZ.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIEXYZ.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/Xcms.txt b/src/xcms/Xcms.txt
new file mode 100644
index 00000000..c27fd8f4
--- /dev/null
+++ b/src/xcms/Xcms.txt
@@ -0,0 +1,61 @@
+/*
+ * (c) Copyright 1990 1991 Tektronix Inc.
+ * All Rights Reserved
+ *
+ * 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 Tektronix not be used
+ * in advertising or publicity pertaining to distribution of the software
+ * without specific, written prior permission.
+ *
+ * Tektronix disclaims all warranties with regard to this software, including
+ * all implied warranties of merchantability and fitness, in no event shall
+ * Tektronix 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.
+ *
+ *
+ * NAME
+ * Xcms.txt
+ *
+ * DESCRIPTION
+ * Sample Color Name Database
+ *
+ */
+
+
+This device-independent color name database is provided just as an example.
+There are no claims that these color specifications are or should be bound
+to the corresponding color name.
+
+As you can see, the start of the database is indicated by "XCMS_COLORDB_START".
+Anything before this is assumed to be comments. The "0.1" indicates the
+version number of the format/syntax used in this file. The color name is
+delimited from the color specification by one or more tabs.
+
+XCMS_COLORDB_START 0.1
+red CIEXYZ:0.371298/0.201443/0.059418
+green CIEXYZ:0.321204/0.660070/0.159833
+blue CIEXYZ:0.279962/0.160195/1.210705
+aquamarine CIEXYZ:0.34672401/0.54832153/0.44658871
+cadet blue CIEXYZ:0.22601070/0.28905571/0.47233452
+cornflower blue CIEXYZ:0.05658276/0.04476296/0.17063955
+navy blue CIEXYZ:0.06713718/0.03366278/0.31293880
+navy CIEXYZ:0.06713718/0.03366278/0.31293880
+brown CIEXYZ:0.08443233/0.06011398/0.01840693
+gray0 TekHVC:0.0/0.0/0.0
+gray10 TekHVC:0.0/10.0/0.0
+gray20 TekHVC:0.0/20.0/0.0
+gray30 TekHVC:0.0/30.0/0.0
+gray40 TekHVC:0.0/40.0/0.0
+gray50 TekHVC:0.0/50.0/0.0
+gray60 TekHVC:0.0/60.0/0.0
+gray70 TekHVC:0.0/70.0/0.0
+gray80 TekHVC:0.0/80.0/0.0
+gray90 TekHVC:0.0/90.0/0.0
+gray100 TekHVC:0.0/100.0/0.0
+XCMS_COLORDB_END
diff --git a/src/xcms/Xcmsint.h b/src/xcms/Xcmsint.h
new file mode 100644
index 00000000..68cd1b7b
--- /dev/null
+++ b/src/xcms/Xcmsint.h
@@ -0,0 +1,246 @@
+/* $Xorg: Xcmsint.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * DESCRIPTION
+ * Private include file for Color Management System.
+ * (i.e., for API internal use only)
+ *
+ */
+#ifndef _XCMSINT_H_
+#define _XCMSINT_H_
+
+#include <X11/Xcms.h>
+
+/*
+ * DEFINES
+ */
+
+ /*
+ * Private Status Value
+ */
+#define _XCMS_NEWNAME -1
+
+ /*
+ * Color Space ID's are of XcmsColorFormat type.
+ *
+ * bit 31
+ * 0 == Device-Independent
+ * 1 == Device-Dependent
+ *
+ * bit 30:
+ * 0 == Registered with X Consortium
+ * 1 == Unregistered
+ */
+#define XCMS_DD_ID(id) ((id) & (XcmsColorFormat)0x80000000)
+#define XCMS_DI_ID(id) (!((id) & (XcmsColorFormat)0x80000000))
+#define XCMS_UNREG_ID(id) ((id) & (XcmsColorFormat)0x40000000)
+#define XCMS_REG_ID(id) (!((id) & (XcmsColorFormat)0x40000000))
+#define XCMS_FIRST_REG_DI_ID (XcmsColorFormat)0x00000001
+#define XCMS_FIRST_UNREG_DI_ID (XcmsColorFormat)0x40000000
+#define XCMS_FIRST_REG_DD_ID (XcmsColorFormat)0x80000000
+#define XCMS_FIRST_UNREG_DD_ID (XcmsColorFormat)0xc0000000
+
+/*
+ * TYPEDEFS
+ */
+
+ /*
+ * Structure for caching Colormap info.
+ * This is provided for the Xlib modifications to:
+ * XAllocNamedColor()
+ * XLookupColor()
+ * XParseColor()
+ * XStoreNamedColor()
+ */
+typedef struct _XcmsCmapRec {
+ Colormap cmapID;
+ Display *dpy;
+ Window windowID;
+ Visual *visual;
+ struct _XcmsCCC *ccc;
+ struct _XcmsCmapRec *pNext;
+} XcmsCmapRec;
+
+ /*
+ * Intensity Record (i.e., value / intensity tuple)
+ */
+typedef struct _IntensityRec {
+ unsigned short value;
+ XcmsFloat intensity;
+} IntensityRec;
+
+ /*
+ * Intensity Table
+ */
+typedef struct _IntensityTbl {
+ IntensityRec *pBase;
+ unsigned int nEntries;
+} IntensityTbl;
+
+ /*
+ * Structure for storing per-Visual Intensity Tables (aka gamma maps).
+ */
+typedef struct _XcmsIntensityMap {
+ VisualID visualID;
+ XPointer screenData; /* pointer to corresponding Screen Color*/
+ /* Characterization Data */
+ void (*pFreeScreenData)(); /* Function that frees a Screen */
+ /* structure. */
+ struct _XcmsIntensityMap *pNext;
+} XcmsIntensityMap;
+
+
+ /*
+ * Structure for storing "registered" color space prefix/ID
+ */
+typedef struct _XcmsRegColorSpaceEntry {
+ char *prefix; /* Color Space prefix (e.g., "CIEXYZ:") */
+ XcmsColorFormat id; /* Color Space ID (e.g., XcmsCIEXYZFormat) */
+} XcmsRegColorSpaceEntry;
+
+
+ /*
+ * Xcms Per Display (i.e. connection) related data
+ */
+typedef struct _XcmsPerDpyInfo {
+
+ XcmsCCC paDefaultCCC; /* based on default visual of screen */
+ /*
+ * Pointer to an array of XcmsCCC structures, one for
+ * each screen.
+ */
+ XcmsCmapRec *pClientCmaps; /* Pointer to linked list of XcmsCmapRec's */
+
+} XcmsPerDpyInfo, *XcmsPerDpyInfoPtr;
+
+/*
+ * DEFINES
+ */
+
+#define XDCCC_NUMBER 0x8000000L /* 2**27 per XDCCC */
+
+#ifdef GRAY
+#define XDCCC_SCREENWHITEPT_ATOM_NAME "XDCCC_GRAY_SCREENWHITEPOINT"
+#define XDCCC_GRAY_CORRECT_ATOM_NAME "XDCCC_GRAY_CORRECTION"
+#endif /* GRAY */
+
+#ifndef _ConversionValues
+typedef struct _ConversionValues {
+ IntensityTbl IntensityTbl;
+} ConversionValues;
+#endif
+
+#ifdef GRAY
+typedef struct {
+ IntensityTbl *IntensityTbl;
+} GRAY_SCCData;
+#endif /* GRAY */
+
+/*
+ * DEFINES
+ */
+
+#define XDCCC_MATRIX_ATOM_NAME "XDCCC_LINEAR_RGB_MATRICES"
+#define XDCCC_CORRECT_ATOM_NAME "XDCCC_LINEAR_RGB_CORRECTION"
+
+typedef struct {
+ XcmsFloat XYZtoRGBmatrix[3][3];
+ XcmsFloat RGBtoXYZmatrix[3][3];
+ IntensityTbl *pRedTbl;
+ IntensityTbl *pGreenTbl;
+ IntensityTbl *pBlueTbl;
+} LINEAR_RGB_SCCData;
+
+/*
+ * DESCRIPTION
+ * Include file for defining the math macros used in the
+ * XCMS source. Instead of using math library routines
+ * directly, XCMS uses macros so that based on the
+ * definitions here, vendors and sites can specify exactly
+ * what routine will be called (those from libm.a or their
+ * custom routines). If not defined to math library routines
+ * (e.g., sqrt in libm.a), then the client is not forced to
+ * be linked with -lm.
+ */
+
+#define XCMS_ATAN(x) _XcmsArcTangent(x)
+#define XCMS_COS(x) _XcmsCosine(x)
+#define XCMS_CUBEROOT(x) _XcmsCubeRoot(x)
+#define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x))
+#define XCMS_SIN(x) _XcmsSine(x)
+#define XCMS_SQRT(x) _XcmsSquareRoot(x)
+#define XCMS_TAN(x) (XCMS_SIN(x) / XCMS_COS(x))
+
+#ifdef __STDC__
+double _XcmsArcTangent(double a);
+double _XcmsCosine(double a);
+double _XcmsCubeRoot(double a);
+double _XcmsSine(double a);
+double _XcmsSquareRoot(double a);
+#else
+double _XcmsArcTangent();
+double _XcmsCosine();
+double _XcmsCubeRoot();
+double _XcmsSine();
+double _XcmsSquareRoot();
+#endif
+
+/*
+ * DEFINES FOR GAMUT COMPRESSION AND QUERY ROUTINES
+ */
+#ifndef PI
+# ifdef M_PI
+# define PI M_PI
+# else
+# define PI 3.14159265358979323846264338327950
+# endif /* M_PI */
+#endif /* PI */
+#ifndef degrees
+# define degrees(r) ((XcmsFloat)(r) * 180.0 / PI)
+#endif /* degrees */
+#ifndef radians
+# define radians(d) ((XcmsFloat)(d) * PI / 180.0)
+#endif /* radians */
+
+#define XCMS_CIEUSTAROFHUE(h,c) \
+((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
+((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT((XCMS_TAN(h) * XCMS_TAN(h)) + \
+(XcmsFloat)1.0)))
+#define XCMS_CIEVSTAROFHUE(h,c) \
+((XCMS_COS((h)) == 0.0) ? (XcmsFloat)0.0 : (XcmsFloat) \
+((XcmsFloat)(c) / (XcmsFloat)XCMS_SQRT(((XcmsFloat)1.0 / \
+(XcmsFloat)(XCMS_TAN(h) * XCMS_TAN(h))) + (XcmsFloat)1.0)))
+/* this hue is returned in radians */
+#define XCMS_CIELUV_PMETRIC_HUE(u,v) \
+(((u) != 0.0) ? XCMS_ATAN( (v) / (u)) : ((v >= 0.0) ? PI / 2 : -(PI / 2)))
+#define XCMS_CIELUV_PMETRIC_CHROMA(u,v) XCMS_SQRT(((u)*(u)) + ((v)*(v)))
+
+#define XCMS_CIEASTAROFHUE(h,c) XCMS_CIEUSTAROFHUE((h), (c))
+#define XCMS_CIEBSTAROFHUE(h,c) XCMS_CIEVSTAROFHUE((h), (c))
+#define XCMS_CIELAB_PMETRIC_HUE(a,b) XCMS_CIELUV_PMETRIC_HUE((a), (b))
+#define XCMS_CIELAB_PMETRIC_CHROMA(a,b) XCMS_CIELUV_PMETRIC_CHROMA((a), (b))
+
+#endif /* _XCMSINT_H_ */
diff --git a/src/xcms/cmsAllCol.c b/src/xcms/cmsAllCol.c
new file mode 100644
index 00000000..b631064b
--- /dev/null
+++ b/src/xcms/cmsAllCol.c
@@ -0,0 +1,71 @@
+/* $Xorg: cmsAllCol.c,v 1.3 2000/08/17 19:45:08 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAllCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAllocColor
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/*
+ * NAME
+ * XcmsAllocColor - Allocate Color
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsAllocColor(dpy, colormap, pXcmsColor_in_out, result_format)
+ Display *dpy;
+ Colormap colormap;
+ XcmsColor *pXcmsColor_in_out;
+ XcmsColorFormat result_format;
+/*
+ * DESCRIPTION
+ * Given a device-dependent or device-independent color
+ * specification, XcmsAllocColor will convert it to X RGB
+ * values then use it in a call to XAllocColor.
+ *
+ * RETURNS
+ * XcmsFailure if failed;
+ * XcmsSuccess if it succeeded without gamut compression;
+ * XcmsSuccessWithCompression if it succeeded with gamut
+ * compression;
+ *
+ * Also returns the pixel value of the color cell and a color
+ * specification of the color actually stored.
+ *
+ */
+{
+ return(_XcmsSetGetColors (XAllocColor, dpy, colormap, pXcmsColor_in_out, 1,
+ result_format, (Bool *)NULL));
+}
diff --git a/src/xcms/cmsAllNCol.c b/src/xcms/cmsAllNCol.c
new file mode 100644
index 00000000..960173f8
--- /dev/null
+++ b/src/xcms/cmsAllNCol.c
@@ -0,0 +1,214 @@
+/* $Xorg: cmsAllNCol.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsAlNCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsAllocNamedColor
+ *
+ *
+ */
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern void _XColor_to_XcmsRGB();
+extern void _XcmsRGB_to_XColor();
+
+
+/*
+ * NAME
+ * XcmsAllocNamedColor -
+ *
+ * SYNOPSIS
+ */
+#if NeedFunctionPrototypes
+Status
+XcmsAllocNamedColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_scrn_return,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format)
+#else
+Status
+XcmsAllocNamedColor(dpy, cmap, colorname, pColor_scrn_return,
+ pColor_exact_return, result_format)
+ Display *dpy;
+ Colormap cmap;
+ char *colorname;
+ XcmsColor *pColor_scrn_return;
+ XcmsColor *pColor_exact_return;
+ XcmsColorFormat result_format;
+#endif
+/*
+ * DESCRIPTION
+ * Finds the color specification associated with the color
+ * name in the Device-Independent Color Name Database, then
+ * converts that color specification to an RGB format. This
+ * RGB value is then used in a call to XAllocColor to allocate
+ * a read-only color cell.
+ *
+ * RETURNS
+ * 0 if failed to parse string or find any entry in the database.
+ * 1 if succeeded in converting color name to XcmsColor.
+ * 2 if succeeded in converting color name to another color name.
+ *
+ */
+{
+ long nbytes;
+ xAllocNamedColorReply rep;
+ xAllocNamedColorReq *req;
+ XColor hard_def;
+ XColor exact_def;
+ Status retval1 = 1;
+ Status retval2 = XcmsSuccess;
+ XcmsColor tmpColor;
+ XColor XColor_in_out;
+ XcmsCCC ccc;
+
+ /*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 1. Convert string to a XcmsColor using Xcms and i18n mechanism
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ &tmpColor, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+ memcpy((char *)pColor_exact_return, (char *)&tmpColor, sizeof(XcmsColor));
+
+ /*
+ * 2. Convert tmpColor to RGB
+ * Assume pColor_exact_return is now adjusted to Client White Point
+ */
+ if ((retval2 = XcmsConvertColors(ccc, &tmpColor,
+ 1, XcmsRGBFormat, (Bool *) NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 3. Convert to XColor and call XAllocColor
+ */
+ _XcmsRGB_to_XColor(&tmpColor, &XColor_in_out, 1);
+ if (XAllocColor(ccc->dpy, cmap, &XColor_in_out) == 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * 4. pColor_scrn_return
+ *
+ * Now convert to the target format.
+ * We can ignore the return value because we're already in a
+ * device-dependent format.
+ */
+ _XColor_to_XcmsRGB(ccc, &XColor_in_out, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat) {
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * All previous methods failed, so lets pass it to the server
+ * for parsing.
+ */
+ dpy = ccc->dpy;
+ LockDisplay(dpy);
+ GetReq(AllocNamedColor, req);
+
+ req->cmap = cmap;
+ nbytes = req->nbytes = strlen(colorname);
+ req->length += (nbytes + 3) >> 2; /* round up to mult of 4 */
+
+ _XSend(dpy, colorname, nbytes);
+ /* _XSend is more efficient that Data, since _XReply follows */
+
+ if (!_XReply (dpy, (xReply *) &rep, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (0);
+ }
+
+ exact_def.red = rep.exactRed;
+ exact_def.green = rep.exactGreen;
+ exact_def.blue = rep.exactBlue;
+
+ hard_def.red = rep.screenRed;
+ hard_def.green = rep.screenGreen;
+ hard_def.blue = rep.screenBlue;
+
+ exact_def.pixel = hard_def.pixel = rep.pixel;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ /*
+ * Now convert to the target format.
+ */
+ _XColor_to_XcmsRGB(ccc, &exact_def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &hard_def, pColor_scrn_return, 1);
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/cmsCmap.c b/src/xcms/cmsCmap.c
new file mode 100644
index 00000000..84d60a46
--- /dev/null
+++ b/src/xcms/cmsCmap.c
@@ -0,0 +1,492 @@
+/* $Xorg: cmsCmap.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsCmap.c - Client Colormap Management Routines
+ *
+ * DESCRIPTION
+ * Routines that store additional information about
+ * colormaps being used by the X Client.
+ *
+ *
+ */
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include "Xutil.h"
+
+/*
+ * FORWARD DECLARATIONS
+ */
+XcmsCmapRec *_XcmsAddCmapRec();
+static void _XcmsFreeClientCmaps();
+
+
+/************************************************************************
+ * *
+ * PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CmapRecForColormap
+ *
+ * SYNOPSIS
+ */
+static XcmsCmapRec *
+CmapRecForColormap(dpy, cmap)
+ Display *dpy;
+ Colormap cmap;
+/*
+ * DESCRIPTION
+ * Find the corresponding XcmsCmapRec for cmap. In not found
+ * this routines attempts to create one.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the corresponding XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec;
+ int nScrn;
+ int i, j;
+ XVisualInfo visualTemplate; /* Template of the visual we want */
+ XVisualInfo *visualList; /* List for visuals that match */
+ int nVisualsMatched; /* Number of visuals that match */
+ Window tmpWindow;
+ Visual *vp;
+ unsigned long border = 0;
+ _XAsyncHandler async;
+ _XAsyncErrorState async_state;
+
+ for (pRec = (XcmsCmapRec *)dpy->cms.clientCmaps; pRec != NULL;
+ pRec = pRec->pNext) {
+ if (pRec->cmapID == cmap) {
+ return(pRec);
+ }
+ }
+
+ /*
+ * Can't find an XcmsCmapRec associated with cmap in our records.
+ * Let's try to see if its a default colormap
+ */
+ nScrn = ScreenCount(dpy);
+ for (i = 0; i < nScrn; i++) {
+ if (cmap == DefaultColormap(dpy, i)) {
+ /* It is ... lets go ahead and store that info */
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, RootWindow(dpy, i),
+ DefaultVisual(dpy, i))) == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ DefaultVisual(dpy, i),
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ return(pRec);
+ }
+ }
+
+ /*
+ * Nope, its not a default colormap, so it's probably a foreign color map
+ * of which we have no specific details. Let's go through the
+ * rigorous process of finding this colormap:
+ * for each screen
+ * for each screen's visual types
+ * create a window with cmap specified as the colormap
+ * if successful
+ * Add a CmapRec
+ * Create an XcmsCCC
+ * return the CmapRec
+ * else
+ * continue
+ */
+
+ async_state.error_code = 0; /* don't care */
+ async_state.major_opcode = X_CreateWindow;
+ async_state.minor_opcode = 0;
+ for (i = 0; i < nScrn; i++) {
+ visualTemplate.screen = i;
+ visualList = XGetVisualInfo(dpy, VisualScreenMask, &visualTemplate,
+ &nVisualsMatched);
+ if (nVisualsMatched == 0) {
+ continue;
+ }
+
+ /*
+ * Attempt to create a window with cmap
+ */
+ j = 0;
+ do {
+ vp = (visualList+j)->visual;
+ LockDisplay(dpy);
+ {
+ register xCreateWindowReq *req;
+
+ GetReq(CreateWindow, req);
+ async_state.min_sequence_number = dpy->request;
+ async_state.max_sequence_number = dpy->request;
+ async_state.error_count = 0;
+ async.next = dpy->async_handlers;
+ async.handler = _XAsyncErrorHandler;
+ async.data = (XPointer)&async_state;
+ dpy->async_handlers = &async;
+ req->parent = RootWindow(dpy, i);
+ req->x = 0;
+ req->y = 0;
+ req->width = 1;
+ req->height = 1;
+ req->borderWidth = 0;
+ req->depth = (visualList+j)->depth;
+ req->class = CopyFromParent;
+ req->visual = vp->visualid;
+ tmpWindow = req->wid = XAllocID(dpy);
+ req->mask = CWBorderPixel | CWColormap;
+ req->length += 2;
+ Data32 (dpy, (long *) &border, 4);
+ Data32 (dpy, (long *) &cmap, 4);
+ }
+ {
+ xGetInputFocusReply rep;
+ register xReq *req;
+
+ GetEmptyReq(GetInputFocus, req);
+ (void) _XReply (dpy, (xReply *)&rep, 0, xTrue);
+ }
+ DeqAsyncHandler(dpy, &async);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ } while (async_state.error_count > 0 && ++j < nVisualsMatched);
+
+ Xfree((char *)visualList);
+
+ /*
+ * if successful
+ */
+ if (j < nVisualsMatched) {
+ if ((pRec = _XcmsAddCmapRec(dpy, cmap, tmpWindow, vp)) == NULL)
+ return((XcmsCmapRec *)NULL);
+ pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ vp,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ );
+ XDestroyWindow(dpy, tmpWindow);
+ return(pRec);
+ }
+ }
+
+ return(NULL);
+}
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsAddCmapRec
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsAddCmapRec(dpy, cmap, windowID, visual)
+ Display *dpy;
+ Colormap cmap;
+ Window windowID;
+ Visual *visual;
+/*
+ * DESCRIPTION
+ * Create an XcmsCmapRec for the specified cmap, windowID,
+ * and visual, then adds it to its list of CmapRec's.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the added XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pNew;
+
+ if ((pNew = (XcmsCmapRec *) Xcalloc(1, (unsigned) sizeof(XcmsCmapRec)))
+ == NULL) {
+ return((XcmsCmapRec *)NULL);
+ }
+
+ pNew->cmapID = cmap;
+ pNew->dpy = dpy;
+ pNew->windowID = windowID;
+ pNew->visual = visual;
+ pNew->pNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ dpy->cms.clientCmaps = (XPointer)pNew;
+ dpy->free_funcs->clientCmaps = _XcmsFreeClientCmaps;
+
+ /*
+ * Note, we don't create the XcmsCCC for pNew->ccc here because
+ * it may require the use of XGetWindowAttributes (a round trip request)
+ * to determine the screen.
+ */
+ return(pNew);
+}
+
+
+/*
+ * NAME
+ * _XcmsCopyCmapRecAndFree
+ *
+ * SYNOPSIS
+ */
+XcmsCmapRec *
+_XcmsCopyCmapRecAndFree(dpy, src_cmap, copy_cmap)
+ Display *dpy;
+ Colormap src_cmap;
+ Colormap copy_cmap;
+/*
+ * DESCRIPTION
+ * Augments Xlib's XCopyColormapAndFree() to copy
+ * XcmsCmapRecs.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy XcmsCmapRec.
+ *
+ */
+{
+ XcmsCmapRec *pRec_src;
+ XcmsCmapRec *pRec_copy;
+
+ if ((pRec_src = CmapRecForColormap(dpy, src_cmap)) != NULL) {
+ pRec_copy =_XcmsAddCmapRec(dpy, copy_cmap, pRec_src->windowID,
+ pRec_src->visual);
+ if (pRec_copy != NULL && pRec_src->ccc) {
+ pRec_copy->ccc = (XcmsCCC)Xcalloc(1, (unsigned) sizeof(XcmsCCCRec));
+ memcpy((char *)pRec_copy->ccc, (char *)pRec_src->ccc,
+ sizeof(XcmsCCCRec));
+ }
+ return(pRec_copy);
+ }
+ return((XcmsCmapRec *)NULL);
+}
+
+
+/*
+ * NAME
+ * _XcmsDeleteCmapRec
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsDeleteCmapRec(dpy, cmap)
+ Display *dpy;
+ Colormap cmap;
+/*
+ * DESCRIPTION
+ * Removes and frees the specified XcmsCmapRec structure
+ * from the linked list of structures.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec **pPrevPtr;
+ XcmsCmapRec *pRec;
+ int scr;
+
+ /* If it is the default cmap for a screen, do not delete it,
+ * because the server will not actually free it */
+ for (scr = ScreenCount(dpy); --scr >= 0; ) {
+ if (cmap == DefaultColormap(dpy, scr))
+ return;
+ }
+
+ /* search for it in the list */
+ pPrevPtr = (XcmsCmapRec **)&dpy->cms.clientCmaps;
+ while ((pRec = *pPrevPtr) && (pRec->cmapID != cmap)) {
+ pPrevPtr = &pRec->pNext;
+ }
+
+ if (pRec) {
+ if (pRec->ccc) {
+ XcmsFreeCCC(pRec->ccc);
+ }
+ *pPrevPtr = pRec->pNext;
+ Xfree((char *)pRec);
+ }
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeClientCmaps
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeClientCmaps(dpy)
+ Display *dpy;
+/*
+ * DESCRIPTION
+ * Frees all XcmsCmapRec structures in the linked list
+ * and sets dpy->cms.clientCmaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsCmapRec *pRecNext, *pRecFree;
+
+ pRecNext = (XcmsCmapRec *)dpy->cms.clientCmaps;
+ while (pRecNext != NULL) {
+ pRecFree = pRecNext;
+ pRecNext = pRecNext->pNext;
+ if (pRecFree->ccc) {
+ /* Free the XcmsCCC structure */
+ XcmsFreeCCC(pRecFree->ccc);
+ }
+ /* Now free the XcmsCmapRec structure */
+ Xfree((char *)pRecFree);
+ }
+ dpy->cms.clientCmaps = (XPointer)NULL;
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC INTERFACES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCCCOfColormap
+ *
+ * SYNOPSIS
+ */
+XcmsCCC
+XcmsCCCOfColormap(dpy, cmap)
+ Display *dpy;
+ Colormap cmap;
+/*
+ * DESCRIPTION
+ * Finds the XcmsCCC associated with the specified colormap.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the associated XcmsCCC structure.
+ *
+ */
+{
+ XWindowAttributes windowAttr;
+ XcmsCmapRec *pRec;
+ int nScrn = ScreenCount(dpy);
+ int i;
+
+ if ((pRec = CmapRecForColormap(dpy, cmap)) != NULL) {
+ if (pRec->ccc) {
+ /* XcmsCmapRec already has a XcmsCCC */
+ return(pRec->ccc);
+ }
+
+ /*
+ * The XcmsCmapRec does not have a XcmsCCC yet, so let's create
+ * one. But first, we need to know the screen associated with
+ * cmap, so use XGetWindowAttributes() to extract that
+ * information. Unless, of course there is only one screen!!
+ */
+ if (nScrn == 1) {
+ /* Assume screenNumber == 0 */
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ 0, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ } else {
+ if (XGetWindowAttributes(dpy, pRec->windowID, &windowAttr)) {
+ for (i = 0; i < nScrn; i++) {
+ if (ScreenOfDisplay(dpy, i) == windowAttr.screen) {
+ return(pRec->ccc = XcmsCreateCCC(
+ dpy,
+ i, /* screenNumber */
+ pRec->visual,
+ (XcmsColor *)NULL, /* clientWhitePt */
+ (XcmsCompressionProc)NULL, /* gamutCompProc */
+ (XPointer)NULL, /* gamutCompClientData */
+ (XcmsWhiteAdjustProc)NULL, /* whitePtAdjProc */
+ (XPointer)NULL /* whitePtAdjClientData */
+ ));
+ }
+ }
+ }
+ }
+ }
+
+ /*
+ * No such cmap
+ */
+ return(NULL);
+}
+
+XcmsCCC XcmsSetCCCOfColormap(dpy, cmap, ccc)
+ Display *dpy;
+ Colormap cmap;
+ XcmsCCC ccc;
+{
+ XcmsCCC prev_ccc = NULL;
+ XcmsCmapRec *pRec;
+
+ pRec = CmapRecForColormap(dpy, cmap);
+ if (pRec) {
+ prev_ccc = pRec->ccc;
+ pRec->ccc = ccc;
+ }
+ return prev_ccc;
+}
diff --git a/src/xcms/cmsColNm.c b/src/xcms/cmsColNm.c
new file mode 100644
index 00000000..e4a9fc90
--- /dev/null
+++ b/src/xcms/cmsColNm.c
@@ -0,0 +1,1049 @@
+/* $Xorg: cmsColNm.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * XcmsColNm.c
+ *
+ * DESCRIPTION
+ * Source for _XcmsLookupColorName().
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+#include <X11/Xos.h>
+#include <sys/stat.h>
+#include <stdio.h>
+#include <ctype.h>
+#define XK_LATIN1
+#include <X11/keysymdef.h>
+
+
+/*
+ * EXTERNS
+ * External declarations required locally to this package
+ * that are not already declared in any of the included header
+ * files (external includes or internal includes).
+ */
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+extern void qsort();
+extern char *bsearch();
+#endif
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+static Status LoadColornameDB();
+void _XcmsCopyISOLatin1Lowered();
+
+/*
+ * LOCAL DEFINES
+ * #define declarations local to this package.
+ */
+#ifndef XCMSDB
+#define XCMSDB "/usr/lib/X11/Xcms.txt"
+#endif
+
+#ifndef isgraph
+# define isgraph(c) (isprint((c)) && !isspace((c)))
+#endif
+
+#ifndef XCMSDB_MAXLINELEN
+# define XCMSDB_MAXLINELEN 256
+#endif
+
+#define FORMAT_VERSION "0.1"
+#define START_TOKEN "XCMS_COLORDB_START"
+#define END_TOKEN "XCMS_COLORDB_END"
+#define DELIM_CHAR '\t'
+
+#define NOT_VISITED 0x0
+#define VISITED 0x1
+#define CYCLE 0xFFFF
+#define XcmsDbInitNone -1
+#define XcmsDbInitFailure 0
+#define XcmsDbInitSuccess 1
+
+/*
+ * LOCAL TYPEDEFS
+ */
+typedef struct _XcmsPair {
+ char *first;
+ char *second;
+ int flag;
+} XcmsPair;
+
+/*
+ * LOCAL VARIABLES
+ */
+static int XcmsColorDbState = XcmsDbInitNone;
+static int nEntries;
+static char *strings;
+static XcmsPair *pairs;
+static char whitePtStr[] = "WhitePoint";
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsColorSpaceOfString
+ *
+ * SYNOPSIS
+ */
+static XcmsColorSpace *
+_XcmsColorSpaceOfString(ccc, color_string)
+ XcmsCCC ccc;
+ char *color_string;
+/*
+ * DESCRIPTION
+ * Returns a pointer to the color space structure
+ * (XcmsColorSpace) associated with the specified color string.
+ *
+ * RETURNS
+ * Pointer to matching XcmsColorSpace structure if found;
+ * otherwise NULL.
+ *
+ * CAVEATS
+ *
+ */
+{
+ XcmsColorSpace **papColorSpaces;
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(color_string, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - color_string);
+
+ if (ccc == NULL) {
+ return(NULL);
+ }
+
+ /*
+ * First try Device-Independent color spaces
+ */
+ papColorSpaces = _XcmsDIColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strncmp((*papColorSpaces)->prefix, color_string, n) == 0 &&
+ !((*papColorSpaces)->prefix)[n]) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ /*
+ * Next try Device-Dependent color spaces
+ */
+ papColorSpaces = ((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->DDColorSpaces;
+ if (papColorSpaces != NULL) {
+ while (*papColorSpaces != NULL) {
+ if (strncmp((*papColorSpaces)->prefix, color_string, n) == 0 &&
+ !((*papColorSpaces)->prefix)[n]) {
+ return(*papColorSpaces);
+ }
+ papColorSpaces++;
+ }
+ }
+
+ return(NULL);
+}
+
+
+/*
+ * NAME
+ * _XcmsParseColorString
+ *
+ * SYNOPSIS
+ */
+static int
+_XcmsParseColorString(ccc, color_string, pColor)
+ XcmsCCC ccc;
+ char *color_string;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Assuming color_string contains a numerical string color
+ * specification, attempts to parse a string into an
+ * XcmsColor structure.
+ *
+ * RETURNS
+ * 0 if failed; otherwise non-zero.
+ *
+ * CAVEATS
+ * A color string containing a numerical color specification
+ * must be in ISO Latin-1 encoding!
+ */
+{
+ XcmsColorSpace *pColorSpace;
+ char string_buf[64];
+ char *string_lowered;
+ int len;
+ int res;
+
+ if (ccc == NULL) {
+ return(0);
+ }
+
+ /*
+ * While copying color_string to string_lowered, convert to lowercase
+ */
+ if ((len = strlen(color_string)) >= sizeof(string_buf)) {
+ string_lowered = (char *) Xmalloc(len+1);
+ } else {
+ string_lowered = string_buf;
+ }
+
+ _XcmsCopyISOLatin1Lowered(string_lowered, color_string);
+
+ if (*string_lowered == '#') {
+ if ((pColorSpace = _XcmsColorSpaceOfString(ccc, "rgb:")) != NULL) {
+ res = (*pColorSpace->parseString)(string_lowered, pColor);
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return res;
+ }
+ }
+
+ if ((pColorSpace = _XcmsColorSpaceOfString(ccc, string_lowered)) != NULL) {
+ res = (*pColorSpace->parseString)(string_lowered, pColor);
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return res;
+ }
+
+ if (len >= sizeof(string_buf)) Xfree(string_lowered);
+ return(0);
+}
+
+
+/*
+ * NAME
+ * FirstCmp - Compare color names of pair recs
+ *
+ * SYNOPSIS
+ */
+static int
+FirstCmp(p1, p2)
+#ifdef __STDC__
+ const void *p1, *p2;
+#else
+ XcmsPair *p1, *p2;
+#endif
+/*
+ * DESCRIPTION
+ * Compares the color names of XcmsColorTuples.
+ * This routine is public to allow access from qsort???.
+ *
+ * RETURNS
+ * 0 if equal;
+ * < 0 if first precedes second,
+ * > 0 if first succeeds second.
+ *
+ */
+{
+ return(strcmp(((XcmsPair *)p1)->first, ((XcmsPair *)p2)->first));
+}
+
+
+
+/*
+ * NAME
+ * stringSectionSize - determine memory needed for strings
+ *
+ * SYNOPSIS
+ */
+static void
+SetNoVisit()
+/*
+ * DESCRIPTION
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ int i;
+ XcmsPair *pair = pairs;
+
+ for (i = 0; i < nEntries; i++, pair++) {
+ if (pair->flag != CYCLE) {
+ pair->flag = NOT_VISITED;
+ }
+ }
+}
+
+
+
+
+/*
+ * NAME
+ * field2 - extract two fields
+ *
+ * SYNOPSIS
+ */
+static int
+field2(pBuf, delim, p1, p2)
+ char *pBuf;
+ char delim; /* in: field delimiter */
+ char **p1; /* in/out: pointer to pointer to field 1 */
+ char **p2; /* in/out: pointer to pointer to field 2 */
+/*
+ * DESCRIPTION
+ * Extracts two fields from a "record".
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ *p1 = *p2 = NULL;
+
+ /* Find Field 1 */
+ while (!isgraph(*pBuf)) {
+ if ((*pBuf != '\n') || (*pBuf != '\0')) {
+ return(XcmsFailure);
+ }
+ if (isspace(*pBuf) || (*pBuf == delim)) {
+ pBuf++;
+ }
+ }
+ *p1 = pBuf;
+
+ /* Find end of Field 2 */
+ while (isprint(*pBuf) && (*pBuf != delim)) {
+ pBuf++;
+ }
+ if ((*pBuf == '\n') || (*pBuf == '\0')) {
+ return(XcmsFailure);
+ }
+ if ((*pBuf == ' ') || (*pBuf == delim)) {
+ *pBuf++ = '\0'; /* stuff end of string character */
+ } else {
+ return(XcmsFailure);
+ }
+
+ /* Find Field 2 */
+ while (!isgraph(*pBuf)) {
+ if ((*pBuf == '\n') || (*pBuf == '\0')) {
+ return(XcmsFailure);
+ }
+ if (isspace(*pBuf) || (*pBuf == delim)) {
+ pBuf++;
+ }
+ }
+ *p2 = pBuf;
+
+ /* Find end of Field 2 */
+ while (isprint(*pBuf) && (*pBuf != delim)) {
+ pBuf++;
+ }
+ if (*pBuf != '\0') {
+ *pBuf = '\0'; /* stuff end of string character */
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * _XcmsLookupColorName - Lookup DB entry for a color name
+ *
+ * SYNOPSIS
+ */
+static Status
+_XcmsLookupColorName(ccc, name, pColor)
+ XcmsCCC ccc;
+ char **name;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Searches for an entry in the Device-Independent Color Name
+ * Database for the specified string.
+ *
+ * RETURNS
+ * XcmsFailure if failed to find a matching entry in
+ * the database.
+ * XcmsSuccess if succeeded in converting color name to
+ * XcmsColor.
+ * _XCMS_NEWNAME if succeeded in converting color string (which
+ * is a color name to yet another color name. Note
+ * that the new name is passed back via 'name'.
+ */
+ {
+ Status retval = 0;
+ char name_lowered_64[64];
+ char *name_lowered;
+ register int i, j, left, right;
+ int len;
+ char *tmpName;
+ XcmsPair *pair;
+
+ /*
+ * Check state of Database:
+ * XcmsDbInitNone
+ * XcmsDbInitSuccess
+ * XcmsDbInitFailure
+ */
+ if (XcmsColorDbState == XcmsDbInitFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsColorDbState == XcmsDbInitNone) {
+ if (!LoadColornameDB()) {
+ return(XcmsFailure);
+ }
+ }
+
+ SetNoVisit();
+
+ /*
+ * While copying name to name_lowered, convert to lowercase
+ */
+
+ tmpName = *name;
+
+Retry:
+ if ((len = strlen(tmpName)) > 63) {
+ name_lowered = (char *) Xmalloc(len+1);
+ } else {
+ name_lowered = name_lowered_64;
+ }
+
+ _XcmsCopyISOLatin1Lowered(name_lowered, tmpName);
+
+ /*
+ * Now, remove spaces.
+ */
+ for (i = 0, j = 0; j < len; j++) {
+ if (!isspace(name_lowered[j])) {
+ name_lowered[i++] = name_lowered[j];
+ }
+ }
+ name_lowered[i] = '\0';
+
+ left = 0;
+ right = nEntries - 1;
+ while (left <= right) {
+ i = (left + right) >> 1;
+ pair = &pairs[i];
+ j = strcmp(name_lowered, pair->first);
+ if (j < 0)
+ right = i - 1;
+ else if (j > 0)
+ left = i + 1;
+ else {
+ break;
+ }
+ }
+ if (len > 63) Xfree(name_lowered);
+
+ if (left > right) {
+ if (retval == 2) {
+ if (*name != tmpName) {
+ *name = tmpName;
+ }
+ return(_XCMS_NEWNAME);
+ }
+ return(XcmsFailure);
+ }
+
+ if (pair->flag == CYCLE) {
+ return(XcmsFailure);
+ }
+ if (pair->flag == VISITED) {
+ pair->flag = CYCLE;
+ return(XcmsFailure);
+ }
+
+ if (_XcmsParseColorString(ccc, pair->second, pColor) == XcmsSuccess) {
+ /* f2 contains a numerical string specification */
+ return(XcmsSuccess);
+ } else {
+ /* f2 does not contain a numerical string specification */
+ tmpName = pair->second;
+ pair->flag = VISITED;
+ retval = 2;
+ goto Retry;
+ }
+}
+
+
+/*
+ * NAME
+ * RemoveSpaces
+ *
+ * SYNOPSIS
+ */
+static int
+RemoveSpaces(pString)
+ char *pString;
+/*
+ * DESCRIPTION
+ * Removes spaces from string.
+ *
+ * RETURNS
+ * Void
+ *
+ */
+{
+ int i, count = 0;
+ char *cptr;
+
+ /* REMOVE SPACES */
+ cptr = pString;
+ for (i = strlen(pString); i; i--, cptr++) {
+ if (!isspace(*cptr)) {
+ *pString++ = *cptr;
+ count++;
+ }
+ }
+ *pString = '\0';
+ return(count);
+}
+
+
+/*
+ * NAME
+ * stringSectionSize - determine memory needed for strings
+ *
+ * SYNOPSIS
+ */
+static int
+stringSectionSize(stream, pNumEntries, pSectionSize)
+ FILE *stream;
+ int *pNumEntries;
+ int *pSectionSize;
+/*
+ * DESCRIPTION
+ * Determines the amount of memory required to store the
+ * color name strings and also the number of strings.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ char buf[XCMSDB_MAXLINELEN];
+ char token[XCMSDB_MAXLINELEN];
+ char token2[XCMSDB_MAXLINELEN];
+ char *pBuf;
+ char *f1;
+ char *f2;
+ int i;
+
+ *pNumEntries = 0;
+ *pSectionSize = 0;
+
+ /*
+ * Advance to START_TOKEN
+ * Anything before is just considered as comments.
+ */
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s %s", token, token2))
+ && (strcmp(token, START_TOKEN) == 0)) {
+ if (strcmp(token2, FORMAT_VERSION) != 0) {
+ /* text file not in the right format */
+ return(XcmsFailure);
+ }
+ break;
+ } /* else it was just a blank line or comment */
+ }
+
+ if (pBuf == NULL) {
+ return(XcmsFailure);
+ }
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
+ break;
+ }
+
+ if (field2(buf, DELIM_CHAR, &f1, &f2) != XcmsSuccess) {
+ return(XcmsFailure);
+ }
+
+ (*pNumEntries)++;
+
+ (*pSectionSize) += (i = strlen(f1)) + 1;
+ for (; i; i--, f1++) {
+ /* REMOVE SPACES FROM COUNT */
+ if (isspace(*f1)) {
+ (*pSectionSize)--;
+ }
+ }
+
+ (*pSectionSize) += (i = strlen(f2)) + 1;
+ for (; i; i--, f2++) {
+ /* REMOVE SPACES FROM COUNT */
+ if (isspace(*f2)) {
+ (*pSectionSize)--;
+ }
+ }
+
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * ReadColornameDB - Read the Color Name Database
+ *
+ * SYNOPSIS
+ */
+static Status
+ReadColornameDB(stream, pRec, pString)
+ FILE *stream;
+ XcmsPair *pRec;
+ char *pString;
+/*
+ * DESCRIPTION
+ * Loads the Color Name Database from a text file.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ char buf[XCMSDB_MAXLINELEN];
+ char token[XCMSDB_MAXLINELEN];
+ char token2[XCMSDB_MAXLINELEN];
+ char *f1;
+ char *f2;
+ char *pBuf;
+
+ /*
+ * Advance to START_TOKEN
+ * Anything before is just considered as comments.
+ */
+
+ while((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s %s", token, token2))
+ && (strcmp(token, START_TOKEN) == 0)) {
+ if (strcmp(token2, FORMAT_VERSION) != 0) {
+ /* text file not in the right format */
+ return(XcmsFailure);
+ }
+ break;
+ } /* else it was just a blank line or comment */
+ }
+
+ if (pBuf == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Process lines between START_TOKEN to END_TOKEN
+ */
+
+ while ((pBuf = fgets(buf, XCMSDB_MAXLINELEN, stream)) != NULL) {
+ if ((sscanf(buf, "%s", token)) && (strcmp(token, END_TOKEN) == 0)) {
+ /*
+ * Found END_TOKEN so break out of for loop
+ */
+ break;
+ }
+
+ /*
+ * Get pairs
+ */
+ if (field2(buf, DELIM_CHAR, &f1, &f2) != XcmsSuccess) {
+ /* Invalid line */
+ continue;
+ }
+
+ /*
+ * Add strings
+ */
+
+ /* Left String */
+ pRec->first = pString;
+ _XcmsCopyISOLatin1Lowered(pString, f1);
+ pString += (1 + RemoveSpaces(pString));
+ pRec->second = pString;
+ /* Right String */
+ _XcmsCopyISOLatin1Lowered(pString, f2);
+ pString += RemoveSpaces(pString) + 1;
+ pRec++;
+
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * LoadColornameDB - Load the Color Name Database
+ *
+ * SYNOPSIS
+ */
+static Status
+LoadColornameDB()
+/*
+ * DESCRIPTION
+ * Loads the Color Name Database from a text file.
+ *
+ * RETURNS
+ * XcmsSuccess if succeeded, otherwise XcmsFailure.
+ *
+ */
+{
+ int size;
+ FILE *stream;
+ char *pathname;
+ struct stat txt;
+ int length;
+
+ /* use and name of this env var is not part of the standard */
+ /* implementation-dependent feature */
+ if ((pathname = getenv("XCMSDB")) == NULL) {
+ pathname = XCMSDB;
+ }
+
+ length = strlen(pathname);
+ if ((length == 0) || (length >= (BUFSIZ - 5))){
+ XcmsColorDbState = XcmsDbInitFailure;
+ return(XcmsFailure);
+ }
+
+ if (stat(pathname, &txt)) {
+ /* can't stat file */
+ XcmsColorDbState = XcmsDbInitFailure;
+ return(XcmsFailure);
+ }
+
+ if ((stream = _XFopenFile (pathname, "r")) == NULL) {
+ return(XcmsFailure);
+ }
+
+ stringSectionSize(stream, &nEntries, &size);
+ rewind(stream);
+
+ strings = (char *) Xmalloc(size);
+ pairs = (XcmsPair *)Xcalloc(nEntries, sizeof(XcmsPair));
+
+ ReadColornameDB(stream, pairs, strings);
+ (void) fclose(stream);
+
+ /*
+ * sort the pair recs
+ */
+ qsort((char *)pairs, nEntries, sizeof(XcmsPair), FirstCmp);
+
+ XcmsColorDbState = XcmsDbInitSuccess;
+ return(XcmsSuccess);
+}
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCopyISOLatin1Lowered
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsCopyISOLatin1Lowered(dst, src)
+ char *dst, *src;
+/*
+ * DESCRIPTION
+ * ISO Latin-1 case conversion routine
+ * Identical to XmuCopyISOLatin1Lowered() but provided here
+ * to eliminate need to link with libXmu.a.
+ *
+ * IMPLEMENTORS NOTE:
+ * This routine is also used in XcmsFormatOfPrefix.
+ *
+ * RETURNS
+ * Void
+ *
+ */
+{
+ register unsigned char *dest, *source;
+
+ for (dest = (unsigned char *)dst, source = (unsigned char *)src;
+ *source;
+ source++, dest++)
+ {
+ if ((*source >= XK_A) && (*source <= XK_Z))
+ *dest = *source + (XK_a - XK_A);
+ else if ((*source >= XK_Agrave) && (*source <= XK_Odiaeresis))
+ *dest = *source + (XK_agrave - XK_Agrave);
+ else if ((*source >= XK_Ooblique) && (*source <= XK_Thorn))
+ *dest = *source + (XK_oslash - XK_Ooblique);
+ else
+ *dest = *source;
+ }
+ *dest = '\0';
+}
+
+
+/*
+ * NAME
+ * _XcmsResolveColorString -
+ *
+ * SYNOPSIS
+ */
+#if NeedFunctionPrototypes
+Status
+_XcmsResolveColorString (
+ XcmsCCC ccc,
+ _Xconst char **color_string,
+ XcmsColor *pColor_exact_return,
+ XcmsColorFormat result_format)
+#else
+Status
+_XcmsResolveColorString(ccc, color_string, pColor_exact_return, result_format)
+ XcmsCCC ccc;
+ char **color_string;
+ XcmsColor *pColor_exact_return;
+ XcmsColorFormat result_format;
+#endif
+/*
+ * DESCRIPTION
+ * The XcmsLookupColor function finds the color specification
+ * associated with a color name in the Device-Independent Color
+ * Name Database.
+ * RETURNS
+ * XcmsFailure if failed to convert valid color string.
+ * XcmsSuccess if succeeded in converting color string to
+ * XcmsColor.
+ * _XCMS_NEWNAME if failed to parse the string or find it in
+ * the database, or if succeeded in looking it up and
+ * found another name which is not in the database.
+ * Note that the new name is returned in color_string.
+ *
+ * This function returns both the color specification found in the
+ * database (db specification) and the color specification for the
+ * color displayable by the specified screen (screen
+ * specification). The calling routine sets the format for these
+ * returned specifications in the XcmsColor format component.
+ * If XcmsUndefinedFormat, the specification is returned in the
+ * format used to store the color in the database.
+ */
+{
+ XcmsColor dbWhitePt; /* whitePt associated with pColor_exact_return*/
+ /* the screen's white point */
+ XcmsColor *pClientWhitePt;
+ int retval;
+ char *strptr = whitePtStr;
+
+/*
+ * 0. Check for invalid arguments.
+ */
+ if (ccc == NULL || (*color_string)[0] == '\0' || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+/*
+ * 1. First attempt to parse the string
+ * If successful, then convert the specification to the target format
+ * and return.
+ */
+ if (_XcmsParseColorString(ccc, *color_string, pColor_exact_return)
+ == 1) {
+ if (result_format != XcmsUndefinedFormat
+ && pColor_exact_return->format != result_format) {
+ /* need to be converted to the target format */
+ return(XcmsConvertColors(ccc, pColor_exact_return, 1,
+ result_format, (Bool *)NULL));
+ } else {
+ return(XcmsSuccess);
+ }
+ }
+
+/*
+ * 2. Attempt to find it in the DI Color Name Database
+ */
+
+ /*
+ * a. Convert String into a XcmsColor structure
+ * Attempt to extract the specification for color_string from the
+ * DI Database (pColor_exact_return). If the DI Database does not
+ * have this entry, then return failure.
+ */
+ retval = _XcmsLookupColorName(ccc, color_string, pColor_exact_return);
+
+ if (retval != XcmsSuccess) {
+ /* color_string replaced with a color name, or not found */
+ return(_XCMS_NEWNAME);
+ }
+
+ if (pColor_exact_return->format == XcmsUndefinedFormat) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * b. If result_format not defined, then assume target format
+ * is the exact format.
+ */
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+
+ if ((ClientWhitePointOfCCC(ccc))->format == XcmsUndefinedFormat) {
+ pClientWhitePt = ScreenWhitePointOfCCC(ccc);
+ } else {
+ pClientWhitePt = ClientWhitePointOfCCC(ccc);
+ }
+
+ /*
+ * c. Convert to the target format, making adjustments for white
+ * point differences as necessary.
+ */
+ if (XCMS_DD_ID(pColor_exact_return->format)) {
+ /*
+ * The spec format is Device-Dependent, therefore assume the
+ * its white point is the Screen White Point.
+ */
+ if (XCMS_DD_ID(result_format)) {
+ /*
+ * Target format is Device-Dependent
+ * Therefore, DD --> DD conversion
+ */
+ return(_XcmsDDConvertColors(ccc, pColor_exact_return,
+ 1, result_format, (Bool *) NULL));
+ } else {
+ /*
+ * Target format is Device-Independent
+ * Therefore, DD --> DI conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ pClientWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ return((*ccc->whitePtAdjProc)(ccc, ScreenWhitePointOfCCC(ccc),
+ pClientWhitePt, result_format,
+ pColor_exact_return, 1, (Bool *) NULL));
+ } else {
+ if (_XcmsDDConvertColors(ccc, pColor_exact_return, 1,
+ XcmsCIEXYZFormat, (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ return(_XcmsDIConvertColors(ccc, pColor_exact_return,
+ pClientWhitePt, 1, result_format));
+ }
+ }
+ } else {
+ /*
+ * The spec format is Device-Independent, therefore attempt
+ * to find a database white point.
+ *
+ * If the Database does not have a white point, then assume the
+ * database white point is the same as the Screen White Point.
+ */
+
+ if (_XcmsLookupColorName(ccc, &strptr, &dbWhitePt) != 1) {
+ memcpy((char *)&dbWhitePt,
+ (char *)&ccc->pPerScrnInfo->screenWhitePt,
+ sizeof(XcmsColor));
+ }
+ if (XCMS_DD_ID(result_format)) {
+ /*
+ * Target format is Device-Dependent
+ * Therefore, DI --> DD conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, ScreenWhitePointOfCCC(ccc))) {
+ return((*ccc->whitePtAdjProc)(ccc, &dbWhitePt,
+ ScreenWhitePointOfCCC(ccc), result_format,
+ pColor_exact_return, 1, (Bool *)NULL));
+ } else {
+ if (pColor_exact_return->format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ return (_XcmsDDConvertColors(ccc, pColor_exact_return, 1,
+ result_format, (Bool *)NULL));
+ }
+ } else {
+ /*
+ * Target format is Device-Independent
+ * Therefore, DI --> DI conversion
+ */
+ if (ccc->whitePtAdjProc && !_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, pClientWhitePt)) {
+ /*
+ * The calling routine wants to resolve this color
+ * in terms if it's white point (i.e. Client White Point).
+ * Therefore, apply white adjustment for the displacement
+ * between dbWhitePt to clientWhitePt.
+ */
+ return((*ccc->whitePtAdjProc)(ccc, &dbWhitePt,
+ pClientWhitePt, result_format,
+ pColor_exact_return, 1, (Bool *)NULL));
+ } else if (_XcmsEqualWhitePts(ccc,
+ &dbWhitePt, pClientWhitePt)) {
+ /*
+ * Can use either dbWhitePt or pClientWhitePt to
+ * convert to the result_format.
+ */
+ if (pColor_exact_return->format == result_format) {
+ return(XcmsSuccess);
+ } else {
+ return (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, result_format));
+ }
+ } else {
+ /*
+ * Need to convert to a white point independent color
+ * space (let's choose CIEXYZ) then convert to the
+ * target color space. Why? Lets assume that
+ * pColor_exact_return->format and result format
+ * are white point dependent format (e.g., CIELUV, CIELAB,
+ * TekHVC ... same or any combination). If so, we'll
+ * need to convert the color with dbWhitePt to an absolute
+ * spec (i.e. non-white point dependent) then convert that
+ * absolute value with clientWhitePt to the result_format.
+ */
+ if (pColor_exact_return->format != XcmsCIEXYZFormat) {
+ if (_XcmsDIConvertColors(ccc, pColor_exact_return,
+ &dbWhitePt, 1, XcmsCIEXYZFormat) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+ if (result_format == XcmsCIEXYZFormat) {
+ return(XcmsSuccess);
+ } else {
+ return(_XcmsDIConvertColors(ccc, pColor_exact_return,
+ pClientWhitePt, 1, result_format));
+ }
+ }
+ }
+ }
+}
diff --git a/src/xcms/cmsGlobls.c b/src/xcms/cmsGlobls.c
new file mode 100644
index 00000000..deeea982
--- /dev/null
+++ b/src/xcms/cmsGlobls.c
@@ -0,0 +1,160 @@
+/*$Xorg: cmsGlobls.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsGlobls.c
+ *
+ * DESCRIPTION
+ * Source file containing Xcms globals
+ *
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ * External declarations required locally to this package
+ * that are not already declared in any of the included header
+ * files (external includes or internal includes).
+ */
+extern XcmsFunctionSet XcmsLinearRGBFunctionSet;
+#ifdef GRAY
+extern XcmsFunctionSet XcmsGrayFunctionSet;
+#endif /* GRAY */
+
+/* UNDEFINED Color Space */
+extern XcmsColorSpace XcmsUNDEFINEDColorSpace;
+
+/* CIE XYZ Color Space */
+extern XcmsColorSpace XcmsCIEXYZColorSpace;
+
+/* CIE uvY Color Space */
+extern XcmsColorSpace XcmsCIEuvYColorSpace;
+
+/* CIE xyY Color Space */
+extern XcmsColorSpace XcmsCIExyYColorSpace;
+
+/* CIE Lab Color Space */
+extern XcmsColorSpace XcmsCIELabColorSpace;
+
+/* CIE Luv Color Space */
+extern XcmsColorSpace XcmsCIELuvColorSpace;
+
+/* TekHVC Color Space */
+extern XcmsColorSpace XcmsTekHVCColorSpace;
+
+/* Device Dependent Color Space Structures */
+extern XcmsColorSpace XcmsRGBiColorSpace;
+extern XcmsColorSpace XcmsRGBColorSpace;
+
+
+/*
+ * GLOBALS
+ * Variables declared in this package that are allowed
+ * to be used globally.
+ */
+
+ /*
+ * Initial array of Device Independent Color Spaces
+ */
+XcmsColorSpace *_XcmsDIColorSpacesInit[] = {
+ &XcmsCIEXYZColorSpace,
+ &XcmsCIEuvYColorSpace,
+ &XcmsCIExyYColorSpace,
+ &XcmsCIELabColorSpace,
+ &XcmsCIELuvColorSpace,
+ &XcmsTekHVCColorSpace,
+ &XcmsUNDEFINEDColorSpace,
+ NULL
+};
+ /*
+ * Pointer to the array of pointers to XcmsColorSpace structures for
+ * Device-Independent Color Spaces that are currently accessible by
+ * the color management system. End of list is indicated by a NULL pointer.
+ */
+XcmsColorSpace **_XcmsDIColorSpaces = _XcmsDIColorSpacesInit;
+
+ /*
+ * Initial array of Device Dependent Color Spaces
+ */
+XcmsColorSpace *_XcmsDDColorSpacesInit[] = {
+ &XcmsRGBColorSpace,
+ &XcmsRGBiColorSpace,
+ NULL
+};
+ /*
+ * Pointer to the array of pointers to XcmsColorSpace structures for
+ * Device-Dependent Color Spaces that are currently accessible by
+ * the color management system. End of list is indicated by a NULL pointer.
+ */
+XcmsColorSpace **_XcmsDDColorSpaces = &_XcmsDDColorSpacesInit[0];
+
+ /*
+ * Initial array of Screen Color Characterization Function Sets
+ */
+XcmsFunctionSet *_XcmsSCCFuncSetsInit[] = {
+ &XcmsLinearRGBFunctionSet,
+#ifdef GRAY
+ &XcmsGrayFunctionSet,
+#endif /* GRAY */
+ NULL};
+ /*
+ * Pointer to the array of pointers to XcmsSCCFuncSet structures
+ * (Screen Color Characterization Function Sets) that are currently
+ * accessible by the color management system. End of list is
+ * indicated by a NULL pointer.
+ */
+XcmsFunctionSet **_XcmsSCCFuncSets = _XcmsSCCFuncSetsInit;
+
+ /*
+ * X Consortium Registered Device-Independent Color Spaces
+ * Note that prefix must be in lowercase.
+ */
+char _XcmsCIEXYZ_prefix[] = "ciexyz";
+char _XcmsCIEuvY_prefix[] = "cieuvy";
+char _XcmsCIExyY_prefix[] = "ciexyy";
+char _XcmsCIELab_prefix[] = "cielab";
+char _XcmsCIELuv_prefix[] = "cieluv";
+char _XcmsTekHVC_prefix[] = "tekhvc";
+ /*
+ * Registered Device-Dependent Color Spaces
+ */
+char _XcmsRGBi_prefix[] = "rgbi";
+char _XcmsRGB_prefix[] = "rgb";
+
+XcmsRegColorSpaceEntry _XcmsRegColorSpaces[] = {
+ _XcmsCIEXYZ_prefix, XcmsCIEXYZFormat,
+ _XcmsCIEuvY_prefix, XcmsCIEuvYFormat,
+ _XcmsCIExyY_prefix, XcmsCIExyYFormat,
+ _XcmsCIELab_prefix, XcmsCIELabFormat,
+ _XcmsCIELuv_prefix, XcmsCIELuvFormat,
+ _XcmsTekHVC_prefix, XcmsTekHVCFormat,
+ _XcmsRGB_prefix, XcmsRGBFormat,
+ _XcmsRGBi_prefix, XcmsRGBiFormat,
+ NULL, 0
+};
diff --git a/src/xcms/cmsInt.c b/src/xcms/cmsInt.c
new file mode 100644
index 00000000..b70e2c08
--- /dev/null
+++ b/src/xcms/cmsInt.c
@@ -0,0 +1,420 @@
+/* $Xorg: cmsInt.c,v 1.4 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsInt.c - Xcms API utility routines
+ *
+ * DESCRIPTION
+ * Xcms Application Program Interface (API) utility
+ * routines for hanging information directly onto
+ * the Display structure.
+ *
+ *
+ */
+
+/* #define NEED_EVENTS */
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+#ifndef XCMSCOMPPROC
+# define XCMSCOMPPROC XcmsTekHVCClipC
+#endif
+
+/*
+ * EXTERNS
+ */
+extern XcmsColorSpace **_XcmsDIColorSpaces;
+extern XcmsFunctionSet **_XcmsSCCFuncSets;
+
+static void _XcmsFreeDefaultCCCs();
+
+/*
+ * GLOBALS
+ */
+
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * _XcmsCopyPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsCopyPointerArray(pap)
+ XPointer *pap;
+/*
+ * DESCRIPTION
+ * Copies an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the copy.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+ n++; /* add 1 to include the NULL pointer */
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)newArray, (char *)pap,
+ (unsigned)(n * sizeof(XPointer)));
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsFreePointerArray
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreePointerArray(pap)
+ XPointer *pap;
+/*
+ * DESCRIPTION
+ * Frees an array of NULL terminated pointers.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ Xfree(pap);
+}
+
+/*
+ * NAME
+ * _XcmsPushPointerArray
+ *
+ * SYNOPSIS
+ */
+XPointer *
+_XcmsPushPointerArray(pap, p, papNoFree)
+ XPointer *pap;
+ XPointer p;
+ XPointer *papNoFree;
+/*
+ * DESCRIPTION
+ * Places the specified pointer at the head of an array of NULL
+ * terminated pointers.
+ *
+ * RETURNS
+ * Returns NULL if failed; otherwise the address to
+ * the head of the array.
+ *
+ */
+{
+ XPointer *newArray;
+ char **tmp;
+ int n;
+
+ for (tmp = pap, n = 0; *tmp != NULL; tmp++, n++);
+
+ /* add 2: 1 for the new pointer and another for the NULL pointer */
+ n += 2;
+
+ if ((newArray = (XPointer *)Xmalloc(n * sizeof(XPointer)))) {
+ memcpy((char *)(newArray+1),(char *)pap,
+ (unsigned)((n-1) * sizeof(XPointer)));
+ *newArray = p;
+ }
+ if (pap != papNoFree) {
+ _XcmsFreePointerArray(pap);
+ }
+ return((XPointer *)newArray);
+}
+
+/*
+ * NAME
+ * _XcmsInitDefaultCCCs
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitDefaultCCCs(dpy)
+ Display *dpy;
+/*
+ * DESCRIPTION
+ * Initializes the Xcms per Display Info structure
+ * (XcmsPerDpyInfo).
+ *
+ * RETURNS
+ * Returns 0 if failed; otherwise non-zero.
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ int i;
+ XcmsCCC ccc;
+
+ if (nScrn <= 0) {
+ return(0);
+ }
+
+ /*
+ * Create an array of XcmsCCC structures, one for each screen.
+ * They serve as the screen's default CCC.
+ */
+ if (!(ccc = (XcmsCCC)
+ Xcalloc((unsigned)nScrn, (unsigned) sizeof(XcmsCCCRec)))) {
+ return(0);
+ }
+ dpy->cms.defaultCCCs = (XPointer)ccc;
+ dpy->free_funcs->defaultCCCs = _XcmsFreeDefaultCCCs;
+
+ for (i = 0; i < nScrn; i++, ccc++) {
+ ccc->dpy = dpy;
+ ccc->screenNumber = i;
+ ccc->visual = DefaultVisual(dpy, i);
+ /*
+ * Used calloc to allocate memory so:
+ * ccc->clientWhitePt->format == XcmsUndefinedFormat
+ * ccc->gamutCompProc == NULL
+ * ccc->whitePtAdjProc == NULL
+ * ccc->pPerScrnInfo = NULL
+ *
+ * Don't need to create XcmsPerScrnInfo and its functionSet and
+ * pScreenData components until the default CCC is accessed.
+ * Note that the XcmsDefaultCCC routine calls _XcmsInitScrnInto
+ * to do this.
+ */
+ ccc->gamutCompProc = XCMSCOMPPROC;
+ }
+
+ return(1);
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeDefaultCCCs - Free Default CCCs and its PerScrnInfo
+ *
+ * SYNOPSIS
+ */
+static void
+_XcmsFreeDefaultCCCs(dpy)
+ Display *dpy;
+/*
+ * DESCRIPTION
+ * This routine frees the default XcmsCCC's associated with
+ * each screen and its associated substructures as neccessary.
+ *
+ * RETURNS
+ * void
+ *
+ *
+ */
+{
+ int nScrn = ScreenCount(dpy);
+ XcmsCCC ccc;
+ int i;
+
+ /*
+ * Free Screen data in each DefaultCCC
+ * Do not use XcmsFreeCCC here because it will not free
+ * DefaultCCC's.
+ */
+ ccc = (XcmsCCC)dpy->cms.defaultCCCs;
+ for (i = nScrn; i--; ccc++) {
+ /*
+ * Check if XcmsPerScrnInfo exists.
+ *
+ * This is the only place where XcmsPerScrnInfo structures
+ * are freed since there is only one allocated per Screen.
+ * It just so happens that we place its reference in the
+ * default CCC.
+ */
+ if (ccc->pPerScrnInfo) {
+ /* Check if SCCData exists */
+ if (ccc->pPerScrnInfo->state != XcmsInitNone
+ && ccc->pPerScrnInfo->screenData) {
+ (*((XcmsFunctionSet *)ccc->pPerScrnInfo->functionSet)->screenFreeProc)
+ (ccc->pPerScrnInfo->screenData);
+ }
+ Xfree(ccc->pPerScrnInfo);
+ }
+ }
+
+ /*
+ * Free the array of XcmsCCC structures
+ */
+ Xfree(dpy->cms.defaultCCCs);
+ dpy->cms.defaultCCCs = (XPointer)NULL;
+}
+
+
+
+/*
+ * NAME
+ * _XcmsInitScrnInfo
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsInitScrnInfo(dpy, screenNumber)
+ register Display *dpy;
+ int screenNumber;
+/*
+ * DESCRIPTION
+ * Given a display and screen number, this routine attempts
+ * to initialize the Xcms per Screen Info structure
+ * (XcmsPerScrnInfo).
+ *
+ * RETURNS
+ * Returns zero if initialization failed; non-zero otherwise.
+ */
+{
+ XcmsFunctionSet **papSCCFuncSet = _XcmsSCCFuncSets;
+ XcmsCCC defaultccc;
+
+ /*
+ * Check if the XcmsCCC's for each screen has been created.
+ * Really dont need to be created until some routine uses the Xcms
+ * API routines.
+ */
+ if ((XcmsCCC)dpy->cms.defaultCCCs == NULL) {
+ if (!_XcmsInitDefaultCCCs(dpy)) {
+ return(0);
+ }
+ }
+
+ defaultccc = (XcmsCCC)dpy->cms.defaultCCCs + screenNumber;
+
+ /*
+ * For each SCCFuncSet, try its pInitScrnFunc.
+ * If the function succeeds, then we got it!
+ */
+
+ if (!defaultccc->pPerScrnInfo) {
+ /*
+ * This is one of two places where XcmsPerScrnInfo structures
+ * are allocated. There is one allocated per Screen that is
+ * shared among visuals that do not have specific intensity
+ * tables. Other XcmsPerScrnInfo structures are created
+ * for the latter (see XcmsCreateCCC). The ones created
+ * here are referenced by the default CCC.
+ */
+ if (!(defaultccc->pPerScrnInfo = (XcmsPerScrnInfo *)
+ Xcalloc(1, (unsigned) sizeof(XcmsPerScrnInfo)))) {
+ return(0);
+ }
+ defaultccc->pPerScrnInfo->state = XcmsInitNone;
+ }
+
+ while (*papSCCFuncSet != NULL) {
+ if ((*(*papSCCFuncSet)->screenInitProc)(dpy, screenNumber,
+ defaultccc->pPerScrnInfo)) {
+ defaultccc->pPerScrnInfo->state = XcmsInitSuccess;
+ return(1);
+ }
+ papSCCFuncSet++;
+ }
+
+ /*
+ * Use Default SCCData
+ */
+ return(_XcmsLRGB_InitScrnDefault(dpy, screenNumber, defaultccc->pPerScrnInfo));
+}
+
+
+/*
+ * NAME
+ * _XcmsFreeIntensityMaps
+ *
+ * SYNOPSIS
+ */
+void
+_XcmsFreeIntensityMaps(dpy)
+ Display *dpy;
+/*
+ * DESCRIPTION
+ * Frees all XcmsIntensityMap structures in the linked list
+ * and sets dpy->cms.perVisualIntensityMaps to NULL.
+ *
+ * RETURNS
+ * void
+ *
+ */
+{
+ XcmsIntensityMap *pNext, *pFree;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ pFree = pNext;
+ pNext = pNext->pNext;
+ (*pFree->pFreeScreenData)(pFree->screenData);
+ /* Now free the XcmsIntensityMap structure */
+ Xfree(pFree);
+ }
+ dpy->cms.perVisualIntensityMaps = (XPointer)NULL;
+}
+
+
+/*
+ * NAME
+ * _XcmsGetIntensityMap
+ *
+ * SYNOPSIS
+ */
+XcmsIntensityMap *
+_XcmsGetIntensityMap(dpy, visual)
+ Display *dpy;
+ Visual *visual;
+/*
+ * DESCRIPTION
+ * Attempts to return a per-Visual intensity map.
+ *
+ * RETURNS
+ * Pointer to the XcmsIntensityMap structure if found;
+ * otherwise NULL
+ *
+ */
+{
+ VisualID targetID = visual->visualid;
+ XcmsIntensityMap *pNext;
+
+ pNext = (XcmsIntensityMap *)dpy->cms.perVisualIntensityMaps;
+ while (pNext != NULL) {
+ if (targetID == pNext->visualID) {
+ return(pNext);
+ }
+ pNext = pNext->pNext;
+ }
+ return((XcmsIntensityMap *)NULL);
+}
diff --git a/src/xcms/cmsLkCol.c b/src/xcms/cmsLkCol.c
new file mode 100644
index 00000000..eb9669ff
--- /dev/null
+++ b/src/xcms/cmsLkCol.c
@@ -0,0 +1,213 @@
+/* $Xorg: cmsLkCol.c,v 1.3 2000/08/17 19:45:09 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * XcmsLkCol.c
+ *
+ * DESCRIPTION
+ * Source for XcmsLookupColor
+ *
+ *
+ */
+
+#define NEED_REPLIES
+#include <stdio.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * EXTERNS
+ */
+extern void _XColor_to_XcmsRGB();
+extern void _XcmsRGB_to_XColor();
+extern void _XcmsResolveColor();
+extern void _XcmsUnresolveColor();
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+/*
+ * NAME
+ * XcmsLookupColor -
+ *
+ * SYNOPSIS
+ */
+#if NeedFunctionPrototypes
+Status
+XcmsLookupColor (
+ Display *dpy,
+ Colormap cmap,
+ _Xconst char *colorname,
+ XcmsColor *pColor_exact_return,
+ XcmsColor *pColor_scrn_return,
+ XcmsColorFormat result_format)
+#else
+Status
+XcmsLookupColor(dpy, cmap, colorname, pColor_exact_return, pColor_scrn_return,
+ result_format)
+ Display *dpy;
+ Colormap cmap;
+ char *colorname;
+ XcmsColor *pColor_exact_return;
+ XcmsColor *pColor_scrn_return;
+ XcmsColorFormat result_format;
+#endif
+/*
+ * DESCRIPTION
+ * The XcmsLookupColor function finds the color specification
+ * associated with a color name in the Device-Independent Color
+ * Name Database.
+ * RETURNS
+ * This function returns both the color specification found in the
+ * database (db specification) and the color specification for the
+ * color displayable by the specified screen (screen
+ * specification). The calling routine sets the format for these
+ * returned specifications in the XcmsColor format component.
+ * If XcmsUndefinedFormat, the specification is returned in the
+ * format used to store the color in the database.
+ */
+{
+ Status retval1 = XcmsSuccess;
+ Status retval2 = XcmsSuccess;
+ XcmsCCC ccc;
+ register int n;
+ xLookupColorReply reply;
+ register xLookupColorReq *req;
+ XColor def, scr;
+
+/*
+ * 0. Check for invalid arguments.
+ */
+ if (dpy == NULL || colorname[0] == '\0' || pColor_scrn_return == 0
+ || pColor_exact_return == NULL) {
+ return(XcmsFailure);
+ }
+
+ if ((ccc = XcmsCCCOfColormap(dpy, cmap)) == (XcmsCCC)NULL) {
+ return(XcmsFailure);
+ }
+
+/*
+ * 1. Convert string to a XcmsColor
+ */
+ if ((retval1 = _XcmsResolveColorString(ccc, &colorname,
+ pColor_exact_return, result_format)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (retval1 == _XCMS_NEWNAME) {
+ goto PassToServer;
+ }
+
+/*
+ * 2. pColor_scrn_return
+ * Assume the pColor_exact_return has already been adjusted to
+ * the Client White Point.
+ *
+ */
+ /*
+ * Convert to RGB, adjusting for white point differences if necessary.
+ */
+ memcpy((char *)pColor_scrn_return, (char *)pColor_exact_return,
+ sizeof(XcmsColor));
+ if (pColor_scrn_return->format == XcmsRGBFormat) {
+ retval2 = XcmsSuccess;
+ } else if ((retval2 = XcmsConvertColors(ccc, pColor_scrn_return, 1,
+ XcmsRGBFormat, (Bool *)NULL)) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format == XcmsUndefinedFormat) {
+ result_format = pColor_exact_return->format;
+ }
+ if (result_format == XcmsRGBFormat) {
+ _XcmsUnresolveColor(ccc, pColor_scrn_return);
+ } else {
+ _XcmsResolveColor(ccc, pColor_scrn_return);
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(retval1 > retval2 ? retval1 : retval2);
+
+PassToServer:
+ /*
+ * Xcms and i18n methods failed, so lets pass it to the server
+ * for parsing.
+ */
+
+ LockDisplay(dpy);
+ GetReq (LookupColor, req);
+ req->cmap = cmap;
+ req->nbytes = n = strlen(colorname);
+ req->length += (n + 3) >> 2;
+ Data (dpy, colorname, (long)n);
+ if (!_XReply (dpy, (xReply *) &reply, 0, xTrue)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (XcmsFailure);
+ }
+ def.red = reply.exactRed;
+ def.green = reply.exactGreen;
+ def.blue = reply.exactBlue;
+
+ scr.red = reply.screenRed;
+ scr.green = reply.screenGreen;
+ scr.blue = reply.screenBlue;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ _XColor_to_XcmsRGB(ccc, &def, pColor_exact_return, 1);
+ _XColor_to_XcmsRGB(ccc, &scr, pColor_scrn_return, 1);
+
+ /*
+ * Then, convert XcmsColor structure to the target specification
+ * format. Note that we must use NULL instead of passing
+ * pCompressed.
+ */
+
+ if (result_format != XcmsRGBFormat
+ && result_format != XcmsUndefinedFormat) {
+ if (XcmsConvertColors(ccc, pColor_exact_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ if (XcmsConvertColors(ccc, pColor_scrn_return, 1, result_format,
+ (Bool *) NULL) == XcmsFailure) {
+ return(XcmsFailure);
+ }
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/cmsMath.c b/src/xcms/cmsMath.c
new file mode 100644
index 00000000..fd09cec1
--- /dev/null
+++ b/src/xcms/cmsMath.c
@@ -0,0 +1,138 @@
+/* $Xorg: cmsMath.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+
+/*
+
+Copyright 1990, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+*/
+
+/*
+ * Stephen Gildea, MIT X Consortium, January 1991
+ */
+
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+#if !defined(X_NOT_STDC_ENV) && (defined(__STDC__) || !(defined(sun) || (defined(sony) && !defined(SYSTYPE_SYSV) && !defined(_SYSTYPE_SYSV))))
+#include <float.h>
+#endif
+#ifndef DBL_EPSILON
+#define DBL_EPSILON 1e-6
+#endif
+
+#ifdef _X_ROOT_STATS
+int cbrt_loopcount;
+int sqrt_loopcount;
+#endif
+
+/* Newton's Method: x_n+1 = x_n - ( f(x_n) / f'(x_n) ) */
+
+
+/* for cube roots, x^3 - a = 0, x_new = x - 1/3 (x - a/x^2) */
+
+double
+_XcmsCubeRoot(a)
+ double a;
+{
+ register double abs_a, cur_guess, delta;
+
+#ifdef DEBUG
+ printf("_XcmsCubeRoot passed in %g\n", a);
+#endif
+#ifdef _X_ROOT_STATS
+ cbrt_loopcount = 0;
+#endif
+ if (a == 0.)
+ return 0.;
+
+ abs_a = a<0. ? -a : a; /* convert to positive to speed loop tests */
+
+ /* arbitrary first guess */
+ if (abs_a > 1.)
+ cur_guess = abs_a/8.;
+ else
+ cur_guess = abs_a*8.;
+
+ do {
+#ifdef _X_ROOT_STATS
+ cbrt_loopcount++;
+#endif
+ delta = (cur_guess - abs_a/(cur_guess*cur_guess))/3.;
+ cur_guess -= delta;
+ if (delta < 0.) delta = -delta;
+ } while (delta >= cur_guess*DBL_EPSILON);
+
+ if (a < 0.)
+ cur_guess = -cur_guess;
+
+#ifdef DEBUG
+ printf("_XcmsCubeRoot returning %g\n", cur_guess);
+#endif
+ return cur_guess;
+}
+
+
+
+/* for square roots, x^2 - a = 0, x_new = x - 1/2 (x - a/x) */
+
+double
+_XcmsSquareRoot(a)
+ double a;
+{
+ register double cur_guess, delta;
+
+#ifdef DEBUG
+ printf("_XcmsSquareRoot passed in %g\n", a);
+#endif
+#ifdef _X_ROOT_STATS
+ sqrt_loopcount = 0;
+#endif
+ if (a == 0.)
+ return 0.;
+
+ if (a < 0.) {
+ /* errno = EDOM; */
+ return 0.;
+ }
+
+ /* arbitrary first guess */
+ if (a > 1.)
+ cur_guess = a/4.;
+ else
+ cur_guess = a*4.;
+
+ do {
+#ifdef _X_ROOT_STATS
+ sqrt_loopcount++;
+#endif
+ delta = (cur_guess - a/cur_guess)/2.;
+ cur_guess -= delta;
+ if (delta < 0.) delta = -delta;
+ } while (delta >= cur_guess*DBL_EPSILON);
+
+#ifdef DEBUG
+ printf("_XcmsSquareRoot returning %g\n", cur_guess);
+#endif
+ return cur_guess;
+}
+
diff --git a/src/xcms/cmsProp.c b/src/xcms/cmsProp.c
new file mode 100644
index 00000000..28d7a880
--- /dev/null
+++ b/src/xcms/cmsProp.c
@@ -0,0 +1,143 @@
+/* $Xorg: cmsProp.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */
+
+/*
+ *
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * XcmsProp.c
+ *
+ * DESCRIPTION
+ * This utility routines for manipulating properties.
+ *
+ */
+
+#include <X11/Xatom.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/************************************************************************
+ * *
+ * API PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+
+/*
+ * NAME
+ * _XcmsGetElement -- get an element value from the property passed
+ *
+ * SYNOPSIS
+ */
+unsigned long
+_XcmsGetElement (format, pValue, pCount)
+ int format;
+ char **pValue;
+ unsigned long *pCount;
+/*
+ * DESCRIPTION
+ * Get the next element from the property and return it.
+ * Also increment the pointer the amount needed.
+ *
+ * Returns
+ * unsigned long
+ */
+{
+ unsigned long value;
+
+ switch (format) {
+ case 32:
+ value = *((unsigned long *)(*pValue)) & 0xFFFFFFFF;
+ *pValue += sizeof(unsigned long);
+ *pCount -= 1;
+ break;
+ case 16:
+ value = *((unsigned short *)(*pValue));
+ *pValue += sizeof(unsigned short);
+ *pCount -= 1;
+ break;
+ case 8:
+ value = *((unsigned char *) (*pValue));
+ *pValue += 1;
+ *pCount -= 1;
+ break;
+ default:
+ value = 0;
+ break;
+ }
+ return(value);
+}
+
+
+/*
+ * NAME
+ * _XcmsGetProperty -- Determine the existance of a property
+ *
+ * SYNOPSIS
+ */
+int
+_XcmsGetProperty (pDpy, w, property, pFormat, pNItems, pNBytes, pValue)
+ Display *pDpy;
+ Window w;
+ Atom property;
+ int *pFormat;
+ unsigned long *pNItems;
+ unsigned long *pNBytes;
+ char **pValue;
+/*
+ * DESCRIPTION
+ *
+ * Returns
+ * 0 if property does not exist.
+ * 1 if property exists.
+ */
+{
+ char *prop_ret;
+ int format_ret;
+ long len = 6516;
+ unsigned long nitems_ret, after_ret;
+ Atom atom_ret;
+
+ while (XGetWindowProperty (pDpy, w, property, 0, len, False,
+ XA_INTEGER, &atom_ret, &format_ret,
+ &nitems_ret, &after_ret,
+ (unsigned char **)&prop_ret)) {
+ if (after_ret > 0) {
+ len += nitems_ret * (format_ret >> 3);
+ XFree (prop_ret);
+ } else {
+ break;
+ }
+ }
+ if (format_ret == 0 || nitems_ret == 0) {
+ /* the property does not exist or is of an unexpected type */
+ return(XcmsFailure);
+ }
+
+ *pFormat = format_ret;
+ *pNItems = nitems_ret;
+ *pNBytes = nitems_ret * (format_ret >> 3);
+ *pValue = prop_ret;
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/cmsTrig.c b/src/xcms/cmsTrig.c
new file mode 100644
index 00000000..a1e9b50c
--- /dev/null
+++ b/src/xcms/cmsTrig.c
@@ -0,0 +1,600 @@
+/* $Xorg: cmsTrig.c,v 1.3 2000/08/17 19:45:10 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
+ * It should be pointed out that for simplicity's sake, the
+ * environment parameters are defined as floating point constants,
+ * rather than octal or hexadecimal initializations of allocated
+ * storage areas. This means that the range of allowed numbers
+ * may not exactly match the hardware's capabilities. For example,
+ * if the maximum positive double precision floating point number
+ * is EXACTLY 1.11...E100 and the constant "MAXDOUBLE is
+ * defined to be 1.11E100 then the numbers between 1.11E100 and
+ * 1.11...E100 are considered to be undefined. For most
+ * applications, this will cause no problems.
+ *
+ * An alternate method is to allocate a global static "double" variable,
+ * say "maxdouble", and use a union declaration and initialization
+ * to initialize it with the proper bits for the EXACT maximum value.
+ * This was not done because the only compilers available to the
+ * author did not fully support union initialization features.
+ *
+ */
+
+/*
+ * EXTERNS
+ */
+extern double _XcmsSquareRoot();
+
+/*
+ * FORWARD DECLARATIONS
+ */
+double _XcmsCosine();
+static double _XcmsModulo();
+static double _XcmsModuloF();
+static double _XcmsPolynomial();
+double _XcmsSine();
+double _XcmsArcTangent();
+
+/*
+ * DEFINES
+ */
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+#define XCMS_MAXERROR 0.000001
+#define XCMS_MAXITER 10000
+#define XCMS_PI 3.14159265358979323846264338327950
+#define XCMS_TWOPI 6.28318530717958620
+#define XCMS_HALFPI 1.57079632679489660
+#define XCMS_FOURTHPI 0.785398163397448280
+#define XCMS_SIXTHPI 0.523598775598298820
+#define XCMS_RADIANS(d) ((d) * XCMS_PI / 180.0)
+#define XCMS_DEGREES(r) ((r) * 180.0 / XCMS_PI)
+#define XCMS_X6_UNDERFLOWS (4.209340e-52) /* X**6 almost underflows */
+#define XCMS_X16_UNDERFLOWS (5.421010e-20) /* X**16 almost underflows*/
+#define XCMS_CHAR_BIT 8
+#define XCMS_LONG_MAX 0x7FFFFFFF
+#define XCMS_DEXPLEN 11
+#define XCMS_NBITS(type) (XCMS_CHAR_BIT * (int)sizeof(type))
+#define XCMS_FABS(x) ((x) < 0.0 ? -(x) : (x))
+
+/* XCMS_DMAXPOWTWO - largest power of two exactly representable as a double */
+#ifdef _CRAY
+#define XCMS_DMAXPOWTWO ((double)(1 < 47))
+#else
+#define XCMS_DMAXPOWTWO ((double)(XCMS_LONG_MAX) * \
+ (1L << (XCMS_NBITS(double)-XCMS_DEXPLEN) - XCMS_NBITS(long) + 1))
+#endif
+
+/*
+ * LOCAL VARIABLES
+ */
+
+static double Const cos_pcoeffs[] = {
+ 0.12905394659037374438e7,
+ -0.37456703915723204710e6,
+ 0.13432300986539084285e5,
+ -0.11231450823340933092e3
+};
+
+static double Const cos_qcoeffs[] = {
+ 0.12905394659037373590e7,
+ 0.23467773107245835052e5,
+ 0.20969518196726306286e3,
+ 1.0
+};
+
+static double Const sin_pcoeffs[] = {
+ 0.20664343336995858240e7,
+ -0.18160398797407332550e6,
+ 0.35999306949636188317e4,
+ -0.20107483294588615719e2
+};
+
+static double Const sin_qcoeffs[] = {
+ 0.26310659102647698963e7,
+ 0.39270242774649000308e5,
+ 0.27811919481083844087e3,
+ 1.0
+};
+
+/*
+ *
+ * FUNCTION
+ *
+ * _XcmsCosine double precision cosine
+ *
+ * KEY WORDS
+ *
+ * cos
+ * machine independent routines
+ * trigonometric functions
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision cosine of double precision
+ * floating point argument.
+ *
+ * USAGE
+ *
+ * double _XcmsCosine (x)
+ * double x;
+ *
+ * REFERENCES
+ *
+ * Computer Approximations, J.F. Hart et al, John Wiley & Sons,
+ * 1968, pp. 112-120.
+ *
+ * RESTRICTIONS
+ *
+ * The sin and cos routines are interactive in the sense that
+ * in the process of reducing the argument to the range -PI/4
+ * to PI/4, each may call the other. Ultimately one or the
+ * other uses a polynomial approximation on the reduced
+ * argument. The sin approximation has a maximum relative error
+ * of 10**(-17.59) and the cos approximation has a maximum
+ * relative error of 10**(-16.18).
+ *
+ * These error bounds assume exact arithmetic
+ * in the polynomial evaluation. Additional rounding and
+ * truncation errors may occur as the argument is reduced
+ * to the range over which the polynomial approximation
+ * is valid, and as the polynomial is evaluated using
+ * finite-precision arithmetic.
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Computes cos(x) from:
+ *
+ * (1) Reduce argument x to range -PI to PI.
+ *
+ * (2) If x > PI/2 then call cos recursively
+ * using relation cos(x) = -cos(x - PI).
+ *
+ * (3) If x < -PI/2 then call cos recursively
+ * using relation cos(x) = -cos(x + PI).
+ *
+ * (4) If x > PI/4 then call sin using
+ * relation cos(x) = sin(PI/2 - x).
+ *
+ * (5) If x < -PI/4 then call cos using
+ * relation cos(x) = sin(PI/2 + x).
+ *
+ * (6) If x would cause underflow in approx
+ * evaluation arithmetic then return
+ * sqrt(1.0 - x**2).
+ *
+ * (7) By now x has been reduced to range
+ * -PI/4 to PI/4 and the approximation
+ * from HART pg. 119 can be used:
+ *
+ * cos(x) = ( p(y) / q(y) )
+ * Where:
+ *
+ * y = x * (4/PI)
+ *
+ * p(y) = SUM [ Pj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * q(y) = SUM [ Qj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * P0 = 0.12905394659037374438571854e+7
+ * P1 = -0.3745670391572320471032359e+6
+ * P2 = 0.134323009865390842853673e+5
+ * P3 = -0.112314508233409330923e+3
+ * Q0 = 0.12905394659037373590295914e+7
+ * Q1 = 0.234677731072458350524124e+5
+ * Q2 = 0.2096951819672630628621e+3
+ * Q3 = 1.0000...
+ * (coefficients from HART table #3843 pg 244)
+ *
+ *
+ * **** NOTE **** The range reduction relations used in
+ * this routine depend on the final approximation being valid
+ * over the negative argument range in addition to the positive
+ * argument range. The particular approximation chosen from
+ * HART satisfies this requirement, although not explicitly
+ * stated in the text. This may not be true of other
+ * approximations given in the reference.
+ *
+ */
+
+double _XcmsCosine (x)
+double x;
+{
+ auto double y;
+ auto double yt2;
+ double retval;
+
+ if (x < -XCMS_PI || x > XCMS_PI) {
+ x = _XcmsModulo (x, XCMS_TWOPI);
+ if (x > XCMS_PI) {
+ x = x - XCMS_TWOPI;
+ } else if (x < -XCMS_PI) {
+ x = x + XCMS_TWOPI;
+ }
+ }
+ if (x > XCMS_HALFPI) {
+ retval = -(_XcmsCosine (x - XCMS_PI));
+ } else if (x < -XCMS_HALFPI) {
+ retval = -(_XcmsCosine (x + XCMS_PI));
+ } else if (x > XCMS_FOURTHPI) {
+ retval = _XcmsSine (XCMS_HALFPI - x);
+ } else if (x < -XCMS_FOURTHPI) {
+ retval = _XcmsSine (XCMS_HALFPI + x);
+ } else if (x < XCMS_X6_UNDERFLOWS && x > -XCMS_X6_UNDERFLOWS) {
+ retval = _XcmsSquareRoot (1.0 - (x * x));
+ } else {
+ y = x / XCMS_FOURTHPI;
+ yt2 = y * y;
+ retval = _XcmsPolynomial (3, cos_pcoeffs, yt2) / _XcmsPolynomial (3, cos_qcoeffs, yt2);
+ }
+ return (retval);
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsModulo double precision modulo
+ *
+ * KEY WORDS
+ *
+ * _XcmsModulo
+ * machine independent routines
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision modulo of two double
+ * precision arguments.
+ *
+ * USAGE
+ *
+ * double _XcmsModulo (value, base)
+ * double value;
+ * double base;
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ */
+static double _XcmsModulo (value, base)
+double value;
+double base;
+{
+ auto double intpart;
+
+ value /= base;
+ value = _XcmsModuloF (value, &intpart);
+ value *= base;
+ return(value);
+}
+
+
+/*
+ * frac = (double) _XcmsModuloF(double val, double *dp)
+ * return fractional part of 'val'
+ * set *dp to integer part of 'val'
+ *
+ * Note -> only compiled for the CA or KA. For the KB/MC,
+ * "math.c" instantiates a copy of the inline function
+ * defined in "math.h".
+ */
+static double
+_XcmsModuloF(val, dp)
+double val;
+register double *dp;
+{
+ register double abs;
+ register double ip;
+
+ /* should check for illegal values here - nan, inf, etc */
+ abs = XCMS_FABS(val);
+ if (abs >= XCMS_DMAXPOWTWO) {
+ ip = val;
+ } else {
+ ip = abs + XCMS_DMAXPOWTWO; /* dump fraction */
+ ip -= XCMS_DMAXPOWTWO; /* restore w/o frac */
+ if (ip > abs) /* if it rounds up */
+ ip -= 1.0; /* fix it */
+ ip = XCMS_FABS(ip);
+ }
+ *dp = ip;
+ return (val - ip); /* signed fractional part */
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsPolynomial double precision polynomial evaluation
+ *
+ * KEY WORDS
+ *
+ * poly
+ * machine independent routines
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Evaluates a polynomial and returns double precision
+ * result. Is passed a the order of the polynomial,
+ * a pointer to an array of double precision polynomial
+ * coefficients (in ascending order), and the independent
+ * variable.
+ *
+ * USAGE
+ *
+ * double _XcmsPolynomial (order, coeffs, x)
+ * int order;
+ * double *coeffs;
+ * double x;
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Evalates the polynomial using recursion and the form:
+ *
+ * P(x) = P0 + x(P1 + x(P2 +...x(Pn)))
+ *
+ */
+
+static double _XcmsPolynomial (order, coeffs, x)
+register int order;
+double Const *coeffs;
+double x;
+{
+ auto double rtn_value;
+
+#if 0
+ auto double curr_coeff;
+ if (order <= 0) {
+ rtn_value = *coeffs;
+ } else {
+ curr_coeff = *coeffs; /* Bug in Unisoft's compiler. Does not */
+ coeffs++; /* generate good code for *coeffs++ */
+ rtn_value = curr_coeff + x * _XcmsPolynomial (--order, coeffs, x);
+ }
+#else /* ++jrb -- removed tail recursion */
+ coeffs += order;
+ rtn_value = *coeffs--;
+ while(order-- > 0)
+ rtn_value = *coeffs-- + (x * rtn_value);
+#endif
+
+ return(rtn_value);
+}
+
+
+/*
+ * FUNCTION
+ *
+ * _XcmsSine double precision sine
+ *
+ * KEY WORDS
+ *
+ * sin
+ * machine independent routines
+ * trigonometric functions
+ * math libraries
+ *
+ * DESCRIPTION
+ *
+ * Returns double precision sine of double precision
+ * floating point argument.
+ *
+ * USAGE
+ *
+ * double _XcmsSine (x)
+ * double x;
+ *
+ * REFERENCES
+ *
+ * Computer Approximations, J.F. Hart et al, John Wiley & Sons,
+ * 1968, pp. 112-120.
+ *
+ * RESTRICTIONS
+ *
+ * The sin and cos routines are interactive in the sense that
+ * in the process of reducing the argument to the range -PI/4
+ * to PI/4, each may call the other. Ultimately one or the
+ * other uses a polynomial approximation on the reduced
+ * argument. The sin approximation has a maximum relative error
+ * of 10**(-17.59) and the cos approximation has a maximum
+ * relative error of 10**(-16.18).
+ *
+ * These error bounds assume exact arithmetic
+ * in the polynomial evaluation. Additional rounding and
+ * truncation errors may occur as the argument is reduced
+ * to the range over which the polynomial approximation
+ * is valid, and as the polynomial is evaluated using
+ * finite-precision arithmetic.
+ *
+ * PROGRAMMER
+ *
+ * Fred Fish
+ *
+ * INTERNALS
+ *
+ * Computes sin(x) from:
+ *
+ * (1) Reduce argument x to range -PI to PI.
+ *
+ * (2) If x > PI/2 then call sin recursively
+ * using relation sin(x) = -sin(x - PI).
+ *
+ * (3) If x < -PI/2 then call sin recursively
+ * using relation sin(x) = -sin(x + PI).
+ *
+ * (4) If x > PI/4 then call cos using
+ * relation sin(x) = cos(PI/2 - x).
+ *
+ * (5) If x < -PI/4 then call cos using
+ * relation sin(x) = -cos(PI/2 + x).
+ *
+ * (6) If x is small enough that polynomial
+ * evaluation would cause underflow
+ * then return x, since sin(x)
+ * approaches x as x approaches zero.
+ *
+ * (7) By now x has been reduced to range
+ * -PI/4 to PI/4 and the approximation
+ * from HART pg. 118 can be used:
+ *
+ * sin(x) = y * ( p(y) / q(y) )
+ * Where:
+ *
+ * y = x * (4/PI)
+ *
+ * p(y) = SUM [ Pj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * q(y) = SUM [ Qj * (y**(2*j)) ]
+ * over j = {0,1,2,3}
+ *
+ * P0 = 0.206643433369958582409167054e+7
+ * P1 = -0.18160398797407332550219213e+6
+ * P2 = 0.359993069496361883172836e+4
+ * P3 = -0.2010748329458861571949e+2
+ * Q0 = 0.263106591026476989637710307e+7
+ * Q1 = 0.3927024277464900030883986e+5
+ * Q2 = 0.27811919481083844087953e+3
+ * Q3 = 1.0000...
+ * (coefficients from HART table #3063 pg 234)
+ *
+ *
+ * **** NOTE **** The range reduction relations used in
+ * this routine depend on the final approximation being valid
+ * over the negative argument range in addition to the positive
+ * argument range. The particular approximation chosen from
+ * HART satisfies this requirement, although not explicitly
+ * stated in the text. This may not be true of other
+ * approximations given in the reference.
+ *
+ */
+
+double
+_XcmsSine (x)
+double x;
+{
+ double y;
+ double yt2;
+ double retval;
+
+ if (x < -XCMS_PI || x > XCMS_PI) {
+ x = _XcmsModulo (x, XCMS_TWOPI);
+ if (x > XCMS_PI) {
+ x = x - XCMS_TWOPI;
+ } else if (x < -XCMS_PI) {
+ x = x + XCMS_TWOPI;
+ }
+ }
+ if (x > XCMS_HALFPI) {
+ retval = -(_XcmsSine (x - XCMS_PI));
+ } else if (x < -XCMS_HALFPI) {
+ retval = -(_XcmsSine (x + XCMS_PI));
+ } else if (x > XCMS_FOURTHPI) {
+ retval = _XcmsCosine (XCMS_HALFPI - x);
+ } else if (x < -XCMS_FOURTHPI) {
+ retval = -(_XcmsCosine (XCMS_HALFPI + x));
+ } else if (x < XCMS_X6_UNDERFLOWS && x > -XCMS_X6_UNDERFLOWS) {
+ retval = x;
+ } else {
+ y = x / XCMS_FOURTHPI;
+ yt2 = y * y;
+ retval = y * (_XcmsPolynomial (3, sin_pcoeffs, yt2) / _XcmsPolynomial(3, sin_qcoeffs, yt2));
+ }
+ return(retval);
+}
+
+
+/*
+ * NAME
+ * _XcmsArcTangent
+ *
+ * SYNOPSIS
+ */
+double
+_XcmsArcTangent(x)
+ double x;
+/*
+ * DESCRIPTION
+ * Computes the arctangent.
+ * This is an implementation of the Gauss algorithm as
+ * described in:
+ * Forman S. Acton, Numerical Methods That Work,
+ * New York, NY, Harper & Row, 1970.
+ *
+ * RETURNS
+ * Returns the arctangent
+ */
+{
+ double ai, a1, bi, b1, l, d;
+ double maxerror;
+ int i;
+
+ if (x == 0.0) {
+ return (0.0);
+ }
+ if (x < 1.0) {
+ maxerror = x * XCMS_MAXERROR;
+ } else {
+ maxerror = XCMS_MAXERROR;
+ }
+ ai = _XcmsSquareRoot( 1.0 / (1.0 + (x * x)) );
+ bi = 1.0;
+ for (i = 0; i < XCMS_MAXITER; i++) {
+ a1 = (ai + bi) / 2.0;
+ b1 = _XcmsSquareRoot((a1 * bi));
+ if (a1 == b1)
+ break;
+ d = XCMS_FABS(a1 - b1);
+ if (d < maxerror)
+ break;
+ ai = a1;
+ bi = b1;
+ }
+
+ l = ((a1 > b1) ? b1 : a1);
+
+ a1 = _XcmsSquareRoot(1 + (x * x));
+ return (x / (a1 * l));
+}
diff --git a/src/xcms/uvY.c b/src/xcms/uvY.c
new file mode 100644
index 00000000..3438d88d
--- /dev/null
+++ b/src/xcms/uvY.c
@@ -0,0 +1,409 @@
+/* $Xorg: uvY.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of XCMS based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ *
+ * NAME
+ * CIEuvy.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE u'v'Y
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+
+/*
+ * EXTERNS
+ */
+extern char _XcmsCIEuvY_prefix[];
+
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIEuvY_ParseString();
+Status _XcmsCIEuvY_ValidSpec();
+/*
+ * DEFINES
+ * Internal definitions that need NOT be exported to any package
+ * or program using this package.
+ */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIEuvY to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIEuvY_to_CIEXYZ[] = {
+ XcmsCIEuvYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIEuvY
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIEuvY[] = {
+ XcmsCIEXYZToCIEuvY,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE uvY Color Space
+ */
+XcmsColorSpace XcmsCIEuvYColorSpace =
+ {
+ _XcmsCIEuvY_prefix, /* prefix */
+ XcmsCIEuvYFormat, /* id */
+ CIEuvY_ParseString, /* parseString */
+ Fl_CIEuvY_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIEuvY, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIEuvY_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIEuvY_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIEuvYFormat.
+ * The assumed CIEuvY string syntax is:
+ * CIEuvY:<u>/<v>/<Y>
+ * Where u, v, and Y are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIEuvY_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIEuvY.u_prime,
+ &pColor->spec.CIEuvY.v_prime,
+ &pColor->spec.CIEuvY.Y) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIEuvYFormat;
+ pColor->pixel = 0;
+ return(_XcmsCIEuvY_ValidSpec(pColor));
+}
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * XcmsCIEuvY_ValidSpec
+ *
+ * SYNOPSIS
+ */
+Status
+_XcmsCIEuvY_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks if color specification valid for CIE u'v'Y.
+ *
+ * RETURNS
+ * XcmsFailure if invalid,
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIEuvYFormat
+ ||
+ (pColor->spec.CIEuvY.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIEuvY.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEuvYToCIEXYZ - convert CIEuvY to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEuvYToCIEXYZ(ccc, puvY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *puvY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEuvY format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEXYZ XYZ_return;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsFloat div, x, y, z, Y;
+
+ /*
+ * Check arguments
+ * Postpone checking puvY_WhitePt until it is actually needed
+ * otherwise converting between XYZ and uvY will fail.
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIEuvY */
+ if (!_XcmsCIEuvY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Convert to CIEXYZ
+ */
+
+ Y = pColor->spec.CIEuvY.Y;
+
+ /* Convert color u'v' to xyz space */
+ div = (6.0 * pColor->spec.CIEuvY.u_prime) - (16.0 * pColor->spec.CIEuvY.v_prime) + 12.0;
+ if (div == 0.0) {
+ /* use white point since div == 0 */
+ if (puvY_WhitePt == NULL ) {
+ return(XcmsFailure);
+ }
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (puvY_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)puvY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ puvY_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (puvY_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ div = (6.0 * puvY_WhitePt->spec.CIEuvY.u_prime) -
+ (16.0 * puvY_WhitePt->spec.CIEuvY.v_prime) + 12.0;
+ if (div == 0) {
+ /* internal error */
+ return(XcmsFailure);
+ }
+ x = 9.0 * puvY_WhitePt->spec.CIEuvY.u_prime / div;
+ y = 4.0 * puvY_WhitePt->spec.CIEuvY.v_prime / div;
+ } else {
+ x = 9.0 * pColor->spec.CIEuvY.u_prime / div;
+ y = 4.0 * pColor->spec.CIEuvY.v_prime / div;
+ }
+ z = 1.0 - x - y;
+
+ /* Convert from xyz to XYZ */
+ /* Conversion uses color normalized lightness based on Y */
+ if (y != 0.0) {
+ XYZ_return.X = x * Y / y;
+ } else {
+ XYZ_return.X = x;
+ }
+ XYZ_return.Y = Y;
+ if (y != 0.0) {
+ XYZ_return.Z = z * Y / y;
+ } else {
+ XYZ_return.Z = z;
+ }
+
+ memcpy((char *)&pColor->spec.CIEXYZ, (char *)&XYZ_return, sizeof(XcmsCIEXYZ));
+ /* Identify that format is now CIEXYZ */
+ pColor->format = XcmsCIEXYZFormat;
+ }
+
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIEuvY - convert CIEXYZ to CIEuvY
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIEXYZToCIEuvY(ccc, puvY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *puvY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIEuvY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsCIEuvY uvY_return;
+ XcmsColor whitePt;
+ int i;
+ XcmsColor *pColor = pColors_in_out;
+ XcmsFloat div;
+
+ /*
+ * Check arguments
+ * Postpone checking puvY_WhitePt until it is actually needed
+ * otherwise converting between XYZ and uvY will fail.
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEuvY form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ /* Make sure original format is CIEXYZ */
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ /* Convert to CIEuvY */
+ div = pColor->spec.CIEXYZ.X + (15.0 * pColor->spec.CIEXYZ.Y) +
+ (3.0 * pColor->spec.CIEXYZ.Z);
+ if (div == 0.0) {
+ /* Use white point since div == 0.0 */
+ if (puvY_WhitePt == NULL ) {
+ return(XcmsFailure);
+ }
+ /*
+ * Make sure white point is in CIEuvY form
+ */
+ if (puvY_WhitePt->format != XcmsCIEuvYFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)puvY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEuvYFormat)) {
+ return(XcmsFailure);
+ }
+ puvY_WhitePt = &whitePt;
+ }
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (puvY_WhitePt->spec.CIEuvY.Y != 1.0) {
+ return(XcmsFailure);
+ }
+ uvY_return.Y = pColor->spec.CIEXYZ.Y;
+ uvY_return.u_prime = puvY_WhitePt->spec.CIEuvY.u_prime;
+ uvY_return.v_prime = puvY_WhitePt->spec.CIEuvY.v_prime;
+ } else {
+ uvY_return.u_prime = 4.0 * pColor->spec.CIEXYZ.X / div;
+ uvY_return.v_prime = 9.0 * pColor->spec.CIEXYZ.Y / div;
+ uvY_return.Y = pColor->spec.CIEXYZ.Y;
+ }
+
+ memcpy((char *)&pColor->spec.CIEuvY, (char *)&uvY_return, sizeof(XcmsCIEuvY));
+ /* Identify that format is now CIEuvY */
+ pColor->format = XcmsCIEuvYFormat;
+ }
+
+ return(XcmsSuccess);
+}
diff --git a/src/xcms/xyY.c b/src/xcms/xyY.c
new file mode 100644
index 00000000..00bd8413
--- /dev/null
+++ b/src/xcms/xyY.c
@@ -0,0 +1,381 @@
+/* $Xorg: xyY.c,v 1.3 2000/08/17 19:45:23 cpqbld Exp $ */
+
+/*
+ * Code and supporting documentation (c) Copyright 1990 1991 Tektronix, Inc.
+ * All Rights Reserved
+ *
+ * This file is a component of an X Window System-specific implementation
+ * of Xcms based on the TekColor Color Management System. Permission is
+ * hereby granted to use, copy, modify, sell, and otherwise distribute this
+ * software and its documentation for any purpose and without fee, provided
+ * that this copyright, permission, and disclaimer notice is reproduced in
+ * all copies of this software and in supporting documentation. TekColor
+ * is a trademark of Tektronix, Inc.
+ *
+ * Tektronix makes no representation about the suitability of this software
+ * for any purpose. It is provided "as is" and with all faults.
+ *
+ * TEKTRONIX DISCLAIMS ALL WARRANTIES APPLICABLE TO THIS SOFTWARE,
+ * INCLUDING THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE. IN NO EVENT SHALL TEKTRONIX 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 THE PERFORMANCE OF THIS SOFTWARE.
+ *
+ * NAME
+ * CIExyY.c
+ *
+ * DESCRIPTION
+ * This file contains routines that support the CIE xyY
+ * color space to include conversions to and from the CIE
+ * XYZ space.
+ *
+ * DOCUMENTATION
+ * "TekColor Color Management System, System Implementor's Manual"
+ */
+
+#include <stdio.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+#include "Xcmsint.h"
+
+/*
+ * DEFINES
+ */
+#define EPS 0.00001 /* some extremely small number */
+#ifdef DBL_EPSILON
+# define XMY_DBL_EPSILON DBL_EPSILON
+#else
+# define XMY_DBL_EPSILON 0.00001
+#endif
+
+/*
+ * EXTERNS
+ */
+
+extern char _XcmsCIExyY_prefix[];
+
+/*
+ * FORWARD DECLARATIONS
+ */
+
+static int CIExyY_ParseString();
+static Status XcmsCIExyY_ValidSpec();
+
+
+/*
+ * LOCAL VARIABLES
+ */
+
+ /*
+ * NULL terminated list of functions applied to get from CIExyY to CIEXYZ
+ */
+static XcmsConversionProc Fl_CIExyY_to_CIEXYZ[] = {
+ XcmsCIExyYToCIEXYZ,
+ NULL
+};
+
+ /*
+ * NULL terminated list of functions applied to get from CIEXYZ to CIExyY
+ */
+static XcmsConversionProc Fl_CIEXYZ_to_CIExyY[] = {
+ XcmsCIEXYZToCIExyY,
+ NULL
+};
+
+
+/*
+ * GLOBALS
+ */
+
+ /*
+ * CIE xyY Color Space
+ */
+XcmsColorSpace XcmsCIExyYColorSpace =
+ {
+ _XcmsCIExyY_prefix, /* prefix */
+ XcmsCIExyYFormat, /* id */
+ CIExyY_ParseString, /* parseString */
+ Fl_CIExyY_to_CIEXYZ, /* to_CIEXYZ */
+ Fl_CIEXYZ_to_CIExyY, /* from_CIEXYZ */
+ 1
+ };
+
+
+
+/************************************************************************
+ * *
+ * PRIVATE ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIExyY_ParseString
+ *
+ * SYNOPSIS
+ */
+static int
+CIExyY_ParseString(spec, pColor)
+ register char *spec;
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * This routines takes a string and attempts to convert
+ * it into a XcmsColor structure with XcmsCIExyYFormat.
+ * The assumed CIExyY string syntax is:
+ * CIExyY:<x>/<y>/<Y>
+ * Where x, y, and Y are in string input format for floats
+ * consisting of:
+ * a. an optional sign
+ * b. a string of numbers possibly containing a decimal point,
+ * c. an optional exponent field containing an 'E' or 'e'
+ * followed by a possibly signed integer string.
+ *
+ * RETURNS
+ * 0 if failed, non-zero otherwise.
+ */
+{
+ int n;
+ char *pchar;
+
+ if ((pchar = strchr(spec, ':')) == NULL) {
+ return(XcmsFailure);
+ }
+ n = (int)(pchar - spec);
+
+ /*
+ * Check for proper prefix.
+ */
+ if (strncmp(spec, _XcmsCIExyY_prefix, n) != 0) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Attempt to parse the value portion.
+ */
+ if (sscanf(spec + n + 1, "%lf/%lf/%lf",
+ &pColor->spec.CIExyY.x,
+ &pColor->spec.CIExyY.y,
+ &pColor->spec.CIExyY.Y) != 3) {
+ return(XcmsFailure);
+ }
+ pColor->format = XcmsCIExyYFormat;
+ pColor->pixel = 0;
+ return(XcmsCIExyY_ValidSpec(pColor));
+}
+
+
+
+/************************************************************************
+ * *
+ * PUBLIC ROUTINES *
+ * *
+ ************************************************************************/
+
+/*
+ * NAME
+ * CIExyY_ValidSpec()
+ *
+ * SYNOPSIS
+ */
+static Status
+XcmsCIExyY_ValidSpec(pColor)
+ XcmsColor *pColor;
+/*
+ * DESCRIPTION
+ * Checks a valid CIExyY color specification.
+ *
+ * RETURNS
+ * XcmsFailure if invalid.
+ * XcmsSuccess if valid.
+ *
+ */
+{
+ if (pColor->format != XcmsCIExyYFormat
+ ||
+ (pColor->spec.CIExyY.x < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.x > 1.0 + XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.y > 1.0 + XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.Y < 0.0 - XMY_DBL_EPSILON)
+ ||
+ (pColor->spec.CIExyY.Y > 1.0 + XMY_DBL_EPSILON)) {
+ return(XcmsFailure);
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIExyYToCIEXYZ - convert CIExyY to CIEXYZ
+ *
+ * SYNOPSIS
+ */
+Status
+XcmsCIExyYToCIEXYZ(ccc, pxyY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pxyY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIExyY format to CIEXYZ format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsColor whitePt;
+ XcmsCIEXYZ XYZ_return;
+ XcmsFloat div; /* temporary storage in case divisor is zero */
+ XcmsFloat u, v, x, y, z; /* temporary storage */
+ register int i;
+
+ /*
+ * Check arguments
+ */
+ if (pxyY_WhitePt == NULL || pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+ /* Make sure original format is CIExyY and valid */
+ if (!XcmsCIExyY_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+
+ if ((div = (-2 * pColor->spec.CIExyY.x) + (12 * pColor->spec.CIExyY.y) + 3) == 0.0) {
+ /* Note that the divisor is zero */
+ /* This return is abitrary. */
+ XYZ_return.X = 0;
+ XYZ_return.Y = 0;
+ XYZ_return.Z = 0;
+ } else {
+ /*
+ * Make sure white point is in CIEXYZ form
+ */
+ if (pxyY_WhitePt->format != XcmsCIEXYZFormat) {
+ /* Make copy of the white point because we're going to modify it */
+ memcpy((char *)&whitePt, (char *)pxyY_WhitePt, sizeof(XcmsColor));
+ if (!_XcmsDIConvertColors(ccc, &whitePt, (XcmsColor *)NULL, 1,
+ XcmsCIEXYZFormat)) {
+ return(XcmsFailure);
+ }
+ pxyY_WhitePt = &whitePt;
+ }
+
+ /* Make sure it is a white point, i.e., Y == 1.0 */
+ if (pxyY_WhitePt->spec.CIEXYZ.Y != 1.0) {
+ return(XcmsFailure);
+ }
+
+ /* Convert from xyY to uvY to XYZ */
+ u = (4 * pColor->spec.CIExyY.x) / div;
+ v = (9 * pColor->spec.CIExyY.y) / div;
+ div = (6.0 * u) - (16.0 * v) + 12.0;
+ if (div == 0.0) {
+ /* Note that the divisor is zero */
+ /* This return is abitrary. */
+ if ((div = (6.0 * whitePt.spec.CIEuvY.u_prime) -
+ (16.0 * whitePt.spec.CIEuvY.v_prime) + 12.0) == 0.0) {
+ div = EPS;
+ }
+ x = 9.0 * whitePt.spec.CIEuvY.u_prime / div;
+ y = 4.0 * whitePt.spec.CIEuvY.u_prime / div;
+ } else {
+ /* convert u, v to small xyz */
+ x = 9.0 * u / div;
+ y = 4.0 * v / div;
+ }
+ z = 1.0 - x - y;
+ if (y == 0.0) y = EPS; /* Have to worry about divide by 0 */
+ XYZ_return.Y = pColor->spec.CIExyY.Y;
+ XYZ_return.X = x * XYZ_return.Y / y;
+ XYZ_return.Z = z * XYZ_return.Y / y;
+ }
+
+ /* Copy result to pColor */
+ memcpy ((char *)&pColor->spec, (char *)&XYZ_return, sizeof(XcmsCIEXYZ));
+
+ /* Identify that the format is now CIEXYZ */
+ pColor->format = XcmsCIEXYZFormat;
+ }
+ return(XcmsSuccess);
+}
+
+
+/*
+ * NAME
+ * XcmsCIEXYZToCIExyY - convert CIEXYZ to CIExyY
+ *
+ * SYNOPSIS
+ */
+/* ARGSUSED */
+Status
+XcmsCIEXYZToCIExyY(ccc, pxyY_WhitePt, pColors_in_out, nColors)
+ XcmsCCC ccc;
+ XcmsColor *pxyY_WhitePt;
+ XcmsColor *pColors_in_out;
+ unsigned int nColors;
+/*
+ * DESCRIPTION
+ * Converts color specifications in an array of XcmsColor
+ * structures from CIEXYZ format to CIExyY format.
+ *
+ * RETURNS
+ * XcmsFailure if failed,
+ * XcmsSuccess if succeeded.
+ *
+ */
+{
+ XcmsColor *pColor = pColors_in_out;
+ XcmsCIExyY xyY_return;
+ XcmsFloat div; /* temporary storage in case divisor is zero */
+ register int i;
+
+ /*
+ * Check arguments
+ * pxyY_WhitePt ignored
+ */
+ if (pColors_in_out == NULL) {
+ return(XcmsFailure);
+ }
+
+ /*
+ * Now convert each XcmsColor structure to CIEXYZ form
+ */
+ for (i = 0; i < nColors; i++, pColor++) {
+
+ if (!_XcmsCIEXYZ_ValidSpec(pColor)) {
+ return(XcmsFailure);
+ }
+ /* Now convert for XYZ to xyY */
+ if ((div = pColor->spec.CIEXYZ.X + pColor->spec.CIEXYZ.Y + pColor->spec.CIEXYZ.Z) == 0.0) {
+ div = EPS;
+ }
+ xyY_return.x = pColor->spec.CIEXYZ.X / div;
+ xyY_return.y = pColor->spec.CIEXYZ.Y / div;
+ xyY_return.Y = pColor->spec.CIEXYZ.Y;
+
+ /* Copy result to pColor */
+ memcpy ((char *)&pColor->spec, (char *)&xyY_return, sizeof(XcmsCIExyY));
+
+ /* Identify that the format is now CIEXYZ */
+ pColor->format = XcmsCIExyYFormat;
+ }
+ return(XcmsSuccess);
+}
diff --git a/src/xkb/XKB.c b/src/xkb/XKB.c
new file mode 100644
index 00000000..22a8731f
--- /dev/null
+++ b/src/xkb/XKB.c
@@ -0,0 +1,926 @@
+/* $Xorg: XKB.c,v 1.3 2000/08/17 19:44:59 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+XkbInternAtomFunc _XkbInternAtomFunc= XInternAtom;
+XkbGetAtomNameFunc _XkbGetAtomNameFunc= XGetAtomName;
+
+Bool
+#if NeedFunctionPrototypes
+XkbQueryExtension( Display *dpy,
+ int * opcodeReturn,
+ int * eventBaseReturn,
+ int * errorBaseReturn,
+ int * majorReturn,
+ int * minorReturn)
+#else
+XkbQueryExtension(dpy,opcodeReturn,eventBaseReturn,errorBaseReturn,
+ majorReturn,minorReturn)
+ Display *dpy;
+ int *opcodeReturn;
+ int *eventBaseReturn;
+ int *errorBaseReturn;
+ int *majorReturn;
+ int *minorReturn;
+#endif
+{
+ if (!XkbUseExtension(dpy,majorReturn,minorReturn))
+ return False;
+ if (opcodeReturn)
+ *opcodeReturn = dpy->xkb_info->codes->major_opcode;
+ if (eventBaseReturn)
+ *eventBaseReturn = dpy->xkb_info->codes->first_event;
+ if (errorBaseReturn)
+ *errorBaseReturn = dpy->xkb_info->codes->first_error;
+ if (majorReturn)
+ *majorReturn = dpy->xkb_info->srv_major;
+ if (minorReturn)
+ *minorReturn = dpy->xkb_info->srv_minor;
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLibraryVersion(int *libMajorRtrn,int *libMinorRtrn)
+#else
+XkbLibraryVersion(libMajorRtrn,libMinorRtrn)
+ int *libMajorRtrn;
+ int *libMinorRtrn;
+#endif
+{
+int supported;
+
+ if (*libMajorRtrn != XkbMajorVersion) {
+ /* version 0.65 is (almost) compatible with 1.00 */
+ if ((XkbMajorVersion==1)&&(((*libMajorRtrn)==0)&&((*libMinorRtrn)==65)))
+ supported= True;
+ else supported= False;
+ }
+ else {
+ supported = True;
+ }
+
+ *libMajorRtrn = XkbMajorVersion;
+ *libMinorRtrn = XkbMinorVersion;
+ return supported;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSelectEvents( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int selectAll)
+#else
+XkbSelectEvents(dpy,deviceSpec,affect,selectAll)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int affect;
+ unsigned int selectAll;
+#endif
+{
+ register xkbSelectEventsReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ xkbi->selected_events&= ~affect;
+ xkbi->selected_events|= (affect&selectAll);
+ GetReq(kbSelectEvents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSelectEvents;
+ req->deviceSpec = deviceSpec;
+ req->affectWhich = (CARD16)affect;
+ req->clear = affect&(~selectAll);
+ req->selectAll = affect&selectAll;
+ if (affect&XkbMapNotifyMask) {
+ req->affectMap= XkbAllMapComponentsMask;
+ /* the implicit support needs the client info */
+ /* even if the client itself doesn't want it */
+ if (selectAll&XkbMapNotifyMask)
+ req->map= XkbAllMapEventsMask;
+ else req->map= XkbAllClientInfoMask;
+ if (selectAll&XkbMapNotifyMask)
+ xkbi->selected_map_details= XkbAllMapEventsMask;
+ else xkbi->selected_map_details= 0;
+ }
+ if (affect&XkbNewKeyboardNotifyMask) {
+ if (selectAll&XkbNewKeyboardNotifyMask)
+ xkbi->selected_nkn_details= XkbAllNewKeyboardEventsMask;
+ else xkbi->selected_nkn_details= 0;
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
+ /* we want it, even if the client doesn't. Don't mess */
+ /* around with details -- ask for all of them and throw */
+ /* away the ones we don't need */
+ req->selectAll|= XkbNewKeyboardNotifyMask;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSelectEventDetails( Display * dpy,
+ unsigned deviceSpec,
+ unsigned eventType,
+ unsigned long int affect,
+ unsigned long int details)
+#else
+XkbSelectEventDetails(dpy,deviceSpec,eventType,affect,details)
+ Display *dpy;
+ unsigned deviceSpec;
+ unsigned eventType;
+ unsigned long int affect;
+ unsigned long int details;
+#endif
+{
+ register xkbSelectEventsReq *req;
+ XkbInfoPtr xkbi;
+ int size;
+ char *out;
+ union {
+ CARD8 *c8;
+ CARD16 *c16;
+ CARD32 *c32;
+ } u;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (affect&details) xkbi->selected_events|= (1<<eventType);
+ else xkbi->selected_events&= ~(1<<eventType);
+ GetReq(kbSelectEvents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSelectEvents;
+ req->deviceSpec = deviceSpec;
+ req->clear= req->selectAll= 0;
+ if (eventType==XkbMapNotify) {
+ /* we need all of the client info, even if the application */
+ /* doesn't. Make sure that we always request the stuff */
+ /* that the implicit support needs, and just filter out anything */
+ /* the client doesn't want later */
+ req->affectWhich = 0;
+ req->selectAll = 0;
+ req->clear = 0;
+ req->affectMap = (CARD16)affect;
+ req->map = (CARD16)details|(XkbAllClientInfoMask&affect);
+ req->affectWhich = XkbMapNotifyMask;
+ xkbi->selected_map_details&= ~affect;
+ xkbi->selected_map_details|= (details&affect);
+ }
+ else {
+ req->affectMap = req->map = 0;
+ req->affectWhich= (1<<eventType);
+ switch (eventType) {
+ case XkbNewKeyboardNotify:
+ xkbi->selected_nkn_details&= ~affect;
+ xkbi->selected_nkn_details|= (details&affect);
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards))
+ details= (affect&XkbAllNewKeyboardEventsMask);
+ case XkbStateNotify:
+ case XkbNamesNotify:
+ case XkbAccessXNotify:
+ case XkbExtensionDeviceNotify:
+ size= 2;
+ req->length+= 1;
+ break;
+ case XkbControlsNotify:
+ case XkbIndicatorStateNotify:
+ case XkbIndicatorMapNotify:
+ size= 4;
+ req->length+= 2;
+ break;
+ case XkbBellNotify:
+ case XkbActionMessage:
+ case XkbCompatMapNotify:
+ size= 1;
+ req->length+= 1;
+ break;
+ }
+ BufAlloc(char *,out,(((size*2)+(unsigned)3)/4)*4);
+ u.c8= (CARD8 *)out;
+ if (size==2) {
+ u.c16[0]= (CARD16)affect;
+ u.c16[1]= (CARD16)details;
+ }
+ else if (size==4) {
+ u.c32[0]= (CARD32)affect;
+ u.c32[1]= (CARD32)details;
+ }
+ else {
+ u.c8[0]= (CARD8)affect;
+ u.c8[1]= (CARD8)details;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLockModifiers( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
+#else
+XkbLockModifiers(dpy,deviceSpec,affect,values)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int affect;
+ unsigned int values;
+#endif
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+ req->affectModLocks= affect;
+ req->modLocks = values;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ req->affectModLatches = req->modLatches = 0;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLatchModifiers( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int affect,
+ unsigned int values)
+#else
+XkbLatchModifiers(dpy,deviceSpec,affect,values)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int affect;
+ unsigned int values;
+#endif
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+
+ req->affectModLatches= affect;
+ req->modLatches = values;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+
+ req->affectModLocks = req->modLocks = 0;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLockGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+#else
+XkbLockGroup(dpy,deviceSpec,group)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int group;
+#endif
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+ req->affectModLocks= 0;
+ req->modLocks = 0;
+ req->lockGroup = True;
+ req->groupLock = group;
+
+ req->affectModLatches = req->modLatches = 0;
+ req->latchGroup = False;
+ req->groupLatch = 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLatchGroup(Display *dpy,unsigned int deviceSpec,unsigned int group)
+#else
+XkbLatchGroup(dpy,deviceSpec,group)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int group;
+#endif
+{
+ register xkbLatchLockStateReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbLatchLockState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbLatchLockState;
+ req->deviceSpec = deviceSpec;
+
+ req->affectModLatches= 0;
+ req->modLatches = 0;
+ req->latchGroup = True;
+ req->groupLatch = group;
+
+ req->affectModLocks = req->modLocks = 0;
+ req->lockGroup = False;
+ req->groupLock = 0;
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+unsigned
+#if NeedFunctionPrototypes
+XkbSetXlibControls(Display *dpy,unsigned affect,unsigned values)
+#else
+XkbSetXlibControls(dpy,affect,values)
+ Display * dpy;
+ unsigned affect;
+ unsigned values;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ affect&= XkbLC_AllControls;
+ dpy->xkb_info->xlib_ctrls&= ~affect;
+ dpy->xkb_info->xlib_ctrls|= (affect&values);
+ return dpy->xkb_info->xlib_ctrls;
+}
+
+unsigned
+#if NeedFunctionPrototypes
+XkbGetXlibControls(Display *dpy)
+#else
+XkbGetXlibControls(dpy)
+ Display * dpy;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return 0;
+ return dpy->xkb_info->xlib_ctrls;
+}
+
+unsigned int
+#if NeedFunctionPrototypes
+XkbXlibControlsImplemented(void)
+#else
+XkbXlibControlsImplemented()
+#endif
+{
+#ifdef __sgi
+ return XkbLC_AllControls;
+#else
+ return XkbLC_AllControls&~XkbLC_AllComposeControls;
+#endif
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetDebuggingFlags( Display * dpy,
+ unsigned int mask,
+ unsigned int flags,
+ char * msg,
+ unsigned int ctrls_mask,
+ unsigned int ctrls,
+ unsigned int * rtrn_flags,
+ unsigned int * rtrn_ctrls)
+#else
+XkbSetDebuggingFlags(dpy,mask,flags,msg,ctrls_mask,ctrls,rtrn_flags,rtrn_ctrls)
+ Display * dpy;
+ unsigned int mask;
+ unsigned int flags;
+ char * msg;
+ unsigned int ctrls_mask;
+ unsigned int ctrls;
+ unsigned int * rtrn_flags;
+ unsigned int * rtrn_ctrls;
+#endif
+{
+ register xkbSetDebuggingFlagsReq *req;
+ xkbSetDebuggingFlagsReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDebuggingFlags, req);
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDebuggingFlags;
+ req->affectFlags= mask;
+ req->flags= flags;
+ req->affectCtrls= ctrls_mask;
+ req->ctrls= ctrls;
+
+ if (msg) {
+ char *out;
+ req->msgLength= (unsigned short)strlen(msg)+1;
+ req->length+= (req->msgLength+(unsigned)3)>>2;
+ BufAlloc(char *,out,((req->msgLength+(unsigned)3)/4)*4);
+ memcpy(out,msg,req->msgLength);
+ }
+ else req->msgLength= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if (rtrn_flags)
+ *rtrn_flags= rep.currentFlags;
+ if (rtrn_ctrls)
+ *rtrn_ctrls= rep.currentCtrls;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbComputeEffectiveMap( XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned char * map_rtrn)
+#else
+XkbComputeEffectiveMap(xkb,type,map_rtrn)
+ XkbDescPtr xkb;
+ XkbKeyTypePtr type;
+ unsigned char * map_rtrn;
+#endif
+{
+register int i;
+unsigned tmp;
+XkbKTMapEntryPtr entry;
+
+ if ((!xkb)||(!type)||(!xkb->server))
+ return False;
+
+ if (type->mods.vmods!=0) {
+ if (!XkbVirtualModsToReal(xkb,type->mods.vmods,&tmp))
+ return False;
+
+ type->mods.mask= tmp|type->mods.real_mods;
+ entry= type->map;
+ for (i=0;i<type->map_count;i++,entry++) {
+ tmp= 0;
+ if (entry->mods.vmods!=0) {
+ if (!XkbVirtualModsToReal(xkb,entry->mods.vmods,&tmp))
+ return False;
+ if (tmp==0) {
+ entry->active= False;
+ continue;
+ }
+ }
+ entry->active= True;
+ entry->mods.mask= (entry->mods.real_mods|tmp)&type->mods.mask;
+ }
+ }
+ else {
+ type->mods.mask= type->mods.real_mods;
+ }
+ if (map_rtrn!=NULL) {
+ bzero(map_rtrn,type->mods.mask+1);
+ for (i=0;i<type->map_count;i++) {
+ if (entry->active) {
+ map_rtrn[type->map[i].mods.mask]= type->map[i].level;
+ }
+ }
+ }
+ return True;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetState(Display *dpy,unsigned deviceSpec,XkbStatePtr rtrn)
+#else
+XkbGetState(dpy,deviceSpec,rtrn)
+ Display * dpy;
+ unsigned deviceSpec;
+ XkbStatePtr rtrn;
+#endif
+{
+ register xkbGetStateReq *req;
+ xkbGetStateReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetState;
+ req->deviceSpec = deviceSpec;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+ rtrn->mods= rep.mods;
+ rtrn->base_mods= rep.baseMods;
+ rtrn->latched_mods= rep.latchedMods;
+ rtrn->locked_mods= rep.lockedMods;
+ rtrn->group= rep.group;
+ rtrn->base_group= rep.baseGroup;
+ rtrn->latched_group= rep.latchedGroup;
+ rtrn->locked_group= rep.lockedGroup;
+ rtrn->compat_state= rep.compatState;
+ rtrn->grab_mods= rep.grabMods;
+ rtrn->compat_grab_mods= rep.compatGrabMods;
+ rtrn->lookup_mods= rep.lookupMods;
+ rtrn->compat_lookup_mods= rep.compatLookupMods;
+ rtrn->ptr_buttons= rep.ptrBtnState;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetDetectableAutoRepeat(Display *dpy,Bool detectable,Bool *supported)
+#else
+XkbSetDetectableAutoRepeat(dpy,detectable,supported)
+ Display * dpy;
+ Bool detectable;
+ Bool * supported;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = XkbPCF_DetectableAutoRepeatMask;
+ if (detectable)
+ req->value = XkbPCF_DetectableAutoRepeatMask;
+ else req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (supported!=NULL)
+ *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
+ return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetDetectableAutoRepeat(Display *dpy,Bool *supported)
+#else
+XkbGetDetectableAutoRepeat(dpy,supported)
+ Display * dpy;
+ Bool * supported;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (supported!=NULL)
+ *supported= ((rep.supported&XkbPCF_DetectableAutoRepeatMask)!=0);
+ return ((rep.value&XkbPCF_DetectableAutoRepeatMask)!=0);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetAutoResetControls( Display * dpy,
+ unsigned changes,
+ unsigned * auto_ctrls,
+ unsigned * auto_values)
+#else
+XkbSetAutoResetControls(dpy,changes,auto_ctrls,auto_values)
+ Display * dpy;
+ unsigned changes;
+ unsigned * auto_ctrls;
+ unsigned * auto_values;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->change = XkbPCF_AutoResetControlsMask;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->value = XkbPCF_AutoResetControlsMask;
+ req->ctrlsToChange= changes;
+ req->autoCtrls= *auto_ctrls;
+ req->autoCtrlValues= *auto_values;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *auto_ctrls= rep.autoCtrls;
+ *auto_values= rep.autoCtrlValues;
+ return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetAutoResetControls( Display * dpy,
+ unsigned * auto_ctrls,
+ unsigned * auto_ctrl_values)
+#else
+XkbGetAutoResetControls(dpy,auto_ctrls,auto_ctrl_values)
+ Display * dpy;
+ unsigned * auto_ctrls;
+ unsigned * auto_ctrl_values;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (auto_ctrls)
+ *auto_ctrls= rep.autoCtrls;
+ if (auto_ctrl_values)
+ *auto_ctrl_values= rep.autoCtrlValues;
+ return ((rep.value&XkbPCF_AutoResetControlsMask)!=0);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetPerClientControls( Display * dpy,
+ unsigned change,
+ unsigned * values)
+#else
+XkbSetPerClientControls(dpy,change,values)
+ Display * dpy;
+ unsigned change;
+ unsigned * values;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+unsigned value_hold = *values;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (change & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->change = change;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->value = *values;
+ req->ctrlsToChange = req->autoCtrls = req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *values = rep.value;
+ return ((rep.value&value_hold)!=0);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetPerClientControls( Display * dpy,
+ unsigned * ctrls)
+#else
+XkbGetPerClientControls(dpy,ctrls)
+ Display * dpy;
+ unsigned * ctrls;
+#endif
+{
+register xkbPerClientFlagsReq * req;
+xkbPerClientFlagsReply rep;
+XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (*ctrls & ~(XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbPerClientFlags, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbPerClientFlags;
+ req->deviceSpec = XkbUseCoreKbd;
+ req->change = 0;
+ req->value = 0;
+ req->ctrlsToChange = req->autoCtrls= req->autoCtrlValues= 0;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ if (ctrls)
+ *ctrls= (rep.value&XkbPCF_GrabsUseXKBStateMask|XkbPCF_LookupStateWhenGrabbed|XkbPCF_SendEventUsesXKBState);
+ return (True);
+}
+
+Display *
+#if NeedFunctionPrototypes
+XkbOpenDisplay( char * name,
+ int * ev_rtrn,
+ int * err_rtrn,
+ int * major_rtrn,
+ int * minor_rtrn,
+ int * reason)
+#else
+XkbOpenDisplay(name,ev_rtrn,err_rtrn,major_rtrn,minor_rtrn,reason)
+ char * name;
+ int * ev_rtrn;
+ int * err_rtrn;
+ int * major_rtrn;
+ int * minor_rtrn;
+ int * reason;
+#endif
+{
+ Display* dpy;
+ int major_num,minor_num;
+
+ if ((major_rtrn!=NULL) && (minor_rtrn!=NULL)) {
+ if (!XkbLibraryVersion(major_rtrn,minor_rtrn)) {
+ if (reason!=NULL)
+ *reason= XkbOD_BadLibraryVersion;
+ return NULL;
+ }
+ }
+ else {
+ major_num= XkbMajorVersion;
+ minor_num= XkbMinorVersion;
+ major_rtrn= &major_num;
+ minor_rtrn= &minor_num;
+ }
+ dpy= XOpenDisplay(name);
+ if (dpy==NULL) {
+ if (reason!=NULL)
+ *reason= XkbOD_ConnectionRefused;
+ return NULL;
+ }
+ if (!XkbQueryExtension(dpy,NULL,ev_rtrn,err_rtrn,major_rtrn,minor_rtrn)) {
+ if (reason!=NULL) {
+ if ((*major_rtrn!=0)||(*minor_rtrn!=0))
+ *reason= XkbOD_BadServerVersion;
+ else *reason= XkbOD_NonXkbServer;
+ }
+ XCloseDisplay(dpy);
+ return NULL;
+ }
+ if (reason!=NULL)
+ *reason= XkbOD_Success;
+ return dpy;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbSetAtomFuncs(XkbInternAtomFunc getAtom,XkbGetAtomNameFunc getName)
+#else
+XkbSetAtomFuncs(getAtom,getName)
+ XkbInternAtomFunc getAtom;
+ XkbGetAtomNameFunc getName;
+#endif
+{
+ _XkbInternAtomFunc= (getAtom?getAtom:XInternAtom);
+ _XkbGetAtomNameFunc= (getName?getName:XGetAtomName);
+ return;
+}
diff --git a/src/xkb/XKBAlloc.c b/src/xkb/XKBAlloc.c
new file mode 100644
index 00000000..82e98f4b
--- /dev/null
+++ b/src/xkb/XKBAlloc.c
@@ -0,0 +1,587 @@
+/* $Xorg: XKBAlloc.c,v 1.4 2000/08/17 19:44:59 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include "X.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xproto.h"
+#include "misc.h"
+#include "inputstr.h"
+#include "XKBsrv.h"
+#include "XKBgeom.h"
+
+#endif /* XKB_IN_SERVER */
+
+/***===================================================================***/
+
+/*ARGSUSED*/
+Status
+#if NeedFunctionPrototypes
+XkbAllocCompatMap(XkbDescPtr xkb,unsigned which,unsigned nSI)
+#else
+XkbAllocCompatMap(xkb,which,nSI)
+ XkbDescPtr xkb;
+ unsigned which;
+ unsigned nSI;
+#endif
+{
+XkbCompatMapPtr compat;
+XkbSymInterpretRec *prev_interpret;
+
+ if (!xkb)
+ return BadMatch;
+ if (xkb->compat) {
+ if (xkb->compat->size_si>=nSI)
+ return Success;
+ compat= xkb->compat;
+ compat->size_si= nSI;
+ if (compat->sym_interpret==NULL)
+ compat->num_si= 0;
+ prev_interpret = compat->sym_interpret;
+ compat->sym_interpret= _XkbTypedRealloc(compat->sym_interpret,
+ nSI,XkbSymInterpretRec);
+ if (compat->sym_interpret==NULL) {
+ _XkbFree(prev_interpret);
+ compat->size_si= compat->num_si= 0;
+ return BadAlloc;
+ }
+ if (compat->num_si!=0) {
+ _XkbClearElems(compat->sym_interpret,compat->num_si,
+ compat->size_si-1,XkbSymInterpretRec);
+ }
+ return Success;
+ }
+ compat= _XkbTypedCalloc(1,XkbCompatMapRec);
+ if (compat==NULL)
+ return BadAlloc;
+ if (nSI>0) {
+ compat->sym_interpret= _XkbTypedCalloc(nSI,XkbSymInterpretRec);
+ if (!compat->sym_interpret) {
+ _XkbFree(compat);
+ return BadAlloc;
+ }
+ }
+ compat->size_si= nSI;
+ compat->num_si= 0;
+ bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ xkb->compat= compat;
+ return Success;
+}
+
+
+void
+#if NeedFunctionPrototypes
+XkbFreeCompatMap(XkbDescPtr xkb,unsigned which,Bool freeMap)
+#else
+XkbFreeCompatMap(xkb,which,freeMap)
+ XkbDescPtr xkb;
+ unsigned which;
+ Bool freeMap;
+#endif
+{
+register XkbCompatMapPtr compat;
+
+ if ((xkb==NULL)||(xkb->compat==NULL))
+ return;
+ compat= xkb->compat;
+ if (freeMap)
+ which= XkbAllCompatMask;
+ if (which&XkbGroupCompatMask)
+ bzero((char *)&compat->groups[0],XkbNumKbdGroups*sizeof(XkbModsRec));
+ if (which&XkbSymInterpMask) {
+ if ((compat->sym_interpret)&&(compat->size_si>0))
+ _XkbFree(compat->sym_interpret);
+ compat->size_si= compat->num_si= 0;
+ compat->sym_interpret= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(compat);
+ xkb->compat= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocNames(XkbDescPtr xkb,unsigned which,int nTotalRG,int nTotalAliases)
+#else
+XkbAllocNames(xkb,which,nTotalRG,nTotalAliases)
+ XkbDescPtr xkb;
+ unsigned which;
+ int nTotalRG;
+ int nTotalAliases;
+#endif
+{
+XkbNamesPtr names;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->names==NULL) {
+ xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
+ if (xkb->names==NULL)
+ return BadAlloc;
+ }
+ names= xkb->names;
+ if ((which&XkbKTLevelNamesMask)&&(xkb->map!=NULL)&&(xkb->map->types!=NULL)){
+ register int i;
+ XkbKeyTypePtr type;
+
+ type= xkb->map->types;
+ for (i=0;i<xkb->map->num_types;i++,type++) {
+ if (type->level_names==NULL) {
+ type->level_names= _XkbTypedCalloc(type->num_levels,Atom);
+ if (type->level_names==NULL)
+ return BadAlloc;
+ }
+ }
+ }
+ if ((which&XkbKeyNamesMask)&&(names->keys==NULL)) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadValue;
+ names->keys= _XkbTypedCalloc((xkb->max_key_code+1),XkbKeyNameRec);
+ if (names->keys==NULL)
+ return BadAlloc;
+ }
+ if ((which&XkbKeyAliasesMask)&&(nTotalAliases>0)) {
+ if (names->key_aliases==NULL) {
+ names->key_aliases= _XkbTypedCalloc(nTotalAliases,XkbKeyAliasRec);
+ }
+ else if (nTotalAliases>names->num_key_aliases) {
+ XkbKeyAliasRec *prev_aliases = names->key_aliases;
+
+ names->key_aliases= _XkbTypedRealloc(names->key_aliases,
+ nTotalAliases,XkbKeyAliasRec);
+ if (names->key_aliases!=NULL) {
+ _XkbClearElems(names->key_aliases,names->num_key_aliases,
+ nTotalAliases-1,XkbKeyAliasRec);
+ } else {
+ _XkbFree(prev_aliases);
+ }
+ }
+ if (names->key_aliases==NULL) {
+ names->num_key_aliases= 0;
+ return BadAlloc;
+ }
+ names->num_key_aliases= nTotalAliases;
+ }
+ if ((which&XkbRGNamesMask)&&(nTotalRG>0)) {
+ if (names->radio_groups==NULL) {
+ names->radio_groups= _XkbTypedCalloc(nTotalRG,Atom);
+ }
+ else if (nTotalRG>names->num_rg) {
+ Atom *prev_radio_groups = names->radio_groups;
+
+ names->radio_groups= _XkbTypedRealloc(names->radio_groups,nTotalRG,
+ Atom);
+ if (names->radio_groups!=NULL) {
+ _XkbClearElems(names->radio_groups,names->num_rg,nTotalRG-1,
+ Atom);
+ } else {
+ _XkbFree(prev_radio_groups);
+ }
+ }
+ if (names->radio_groups==NULL)
+ return BadAlloc;
+ names->num_rg= nTotalRG;
+ }
+ return Success;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeNames(XkbDescPtr xkb,unsigned which,Bool freeMap)
+#else
+XkbFreeNames(xkb,which,freeMap)
+ XkbDescPtr xkb;
+ unsigned which;
+ Bool freeMap;
+#endif
+{
+XkbNamesPtr names;
+
+ if ((xkb==NULL)||(xkb->names==NULL))
+ return;
+ names= xkb->names;
+ if (freeMap)
+ which= XkbAllNamesMask;
+ if (which&XkbKTLevelNamesMask) {
+ XkbClientMapPtr map= xkb->map;
+ if ((map!=NULL)&&(map->types!=NULL)) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= map->types;
+ for (i=0;i<map->num_types;i++,type++) {
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ }
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ _XkbFree(names->keys);
+ names->keys= NULL;
+ names->num_keys= 0;
+ }
+ if ((which&XkbKeyAliasesMask)&&(names->key_aliases)){
+ _XkbFree(names->key_aliases);
+ names->key_aliases=NULL;
+ names->num_key_aliases=0;
+ }
+ if ((which&XkbRGNamesMask)&&(names->radio_groups)) {
+ _XkbFree(names->radio_groups);
+ names->radio_groups= NULL;
+ names->num_rg= 0;
+ }
+ if (freeMap) {
+ _XkbFree(names);
+ xkb->names= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+/*ARGSUSED*/
+Status
+#if NeedFunctionPrototypes
+XkbAllocControls(XkbDescPtr xkb,unsigned which)
+#else
+XkbAllocControls(xkb,which)
+ XkbDescPtr xkb;
+ unsigned which;
+#endif
+{
+ if (xkb==NULL)
+ return BadMatch;
+
+ if (xkb->ctrls==NULL) {
+ xkb->ctrls= _XkbTypedCalloc(1,XkbControlsRec);
+ if (!xkb->ctrls)
+ return BadAlloc;
+ }
+ return Success;
+}
+
+/*ARGSUSED*/
+void
+#if NeedFunctionPrototypes
+XkbFreeControls(XkbDescPtr xkb,unsigned which,Bool freeMap)
+#else
+XkbFreeControls(xkb,which,freeMap)
+ XkbDescPtr xkb;
+ unsigned which;
+ Bool freeMap;
+#endif
+{
+ if (freeMap && (xkb!=NULL) && (xkb->ctrls!=NULL)) {
+ _XkbFree(xkb->ctrls);
+ xkb->ctrls= NULL;
+ }
+ return;
+}
+
+/***===================================================================***/
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocIndicatorMaps(XkbDescPtr xkb)
+#else
+XkbAllocIndicatorMaps(xkb)
+ XkbDescPtr xkb;
+#endif
+{
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->indicators==NULL) {
+ xkb->indicators= _XkbTypedCalloc(1,XkbIndicatorRec);
+ if (!xkb->indicators)
+ return BadAlloc;
+ }
+ return Success;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeIndicatorMaps(XkbDescPtr xkb)
+#else
+XkbFreeIndicatorMaps(xkb)
+ XkbDescPtr xkb;
+#endif
+{
+ if ((xkb!=NULL)&&(xkb->indicators!=NULL)) {
+ _XkbFree(xkb->indicators);
+ xkb->indicators= NULL;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+XkbDescRec *
+#if NeedFunctionPrototypes
+XkbAllocKeyboard(void)
+#else
+XkbAllocKeyboard()
+#endif
+{
+XkbDescRec *xkb;
+
+ xkb = _XkbTypedCalloc(1,XkbDescRec);
+ if (xkb)
+ xkb->device_spec= XkbUseCoreKbd;
+ return xkb;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeKeyboard(XkbDescPtr xkb,unsigned which,Bool freeAll)
+#else
+XkbFreeKeyboard(xkb,which,freeAll)
+ XkbDescPtr xkb;
+ unsigned which;
+ Bool freeAll;
+#endif
+{
+ if (xkb==NULL)
+ return;
+ if (freeAll)
+ which= XkbAllComponentsMask;
+ if (which&XkbClientMapMask)
+ XkbFreeClientMap(xkb,XkbAllClientInfoMask,True);
+ if (which&XkbServerMapMask)
+ XkbFreeServerMap(xkb,XkbAllServerInfoMask,True);
+ if (which&XkbCompatMapMask)
+ XkbFreeCompatMap(xkb,XkbAllCompatMask,True);
+ if (which&XkbIndicatorMapMask)
+ XkbFreeIndicatorMaps(xkb);
+ if (which&XkbNamesMask)
+ XkbFreeNames(xkb,XkbAllNamesMask,True);
+ if ((which&XkbGeometryMask) && (xkb->geom!=NULL))
+ XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
+ if (which&XkbControlsMask)
+ XkbFreeControls(xkb,XkbAllControlsMask,True);
+ if (freeAll)
+ _XkbFree(xkb);
+ return;
+}
+
+/***====================================================================***/
+
+XkbDeviceLedInfoPtr
+#if NeedFunctionPrototypes
+XkbAddDeviceLedInfo(XkbDeviceInfoPtr devi,unsigned ledClass,unsigned ledId)
+#else
+XkbAddDeviceLedInfo(devi,ledClass,ledId)
+ XkbDeviceInfoPtr devi;
+ unsigned ledClass;
+ unsigned ledId;
+#endif
+{
+XkbDeviceLedInfoPtr devli;
+register int i;
+
+ if ((!devi)||(!XkbSingleXIClass(ledClass))||(!XkbSingleXIId(ledId)))
+ return NULL;
+ for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
+ if ((devli->led_class==ledClass)&&(devli->led_id==ledId))
+ return devli;
+ }
+ if (devi->num_leds>=devi->sz_leds) {
+ XkbDeviceLedInfoRec *prev_leds = devi->leds;
+
+ if (devi->sz_leds>0) devi->sz_leds*= 2;
+ else devi->sz_leds= 1;
+ devi->leds= _XkbTypedRealloc(devi->leds,devi->sz_leds,
+ XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ _XkbFree(prev_leds);
+ devi->sz_leds= devi->num_leds= 0;
+ return NULL;
+ }
+ i= devi->num_leds;
+ for (devli=&devi->leds[i];i<devi->sz_leds;i++,devli++) {
+ bzero(devli,sizeof(XkbDeviceLedInfoRec));
+ devli->led_class= XkbXINone;
+ devli->led_id= XkbXINone;
+ }
+ }
+ devli= &devi->leds[devi->num_leds++];
+ bzero(devli,sizeof(XkbDeviceLedInfoRec));
+ devli->led_class= ledClass;
+ devli->led_id= ledId;
+ return devli;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbResizeDeviceButtonActions(XkbDeviceInfoPtr devi,unsigned newTotal)
+#else
+XkbResizeDeviceButtonActions(devi,newTotal)
+ XkbDeviceInfoPtr devi;
+ unsigned newTotal;
+#endif
+{
+ XkbAction *prev_btn_acts;
+
+ if ((!devi)||(newTotal>255))
+ return BadValue;
+ if ((devi->btn_acts!=NULL)&&(newTotal==devi->num_btns))
+ return Success;
+ if (newTotal==0) {
+ if (devi->btn_acts!=NULL) {
+ _XkbFree(devi->btn_acts);
+ devi->btn_acts= NULL;
+ }
+ devi->num_btns= 0;
+ return Success;
+ }
+ prev_btn_acts = devi->btn_acts;
+ devi->btn_acts= _XkbTypedRealloc(devi->btn_acts,newTotal,XkbAction);
+ if (devi->btn_acts==NULL) {
+ _XkbFree(prev_btn_acts);
+ devi->num_btns= 0;
+ return BadAlloc;
+ }
+ if (newTotal>devi->num_btns) {
+ XkbAction *act;
+ act= &devi->btn_acts[devi->num_btns];
+ bzero((char *)act,(newTotal-devi->num_btns)*sizeof(XkbAction));
+ }
+ devi->num_btns= newTotal;
+ return Success;
+}
+
+/*ARGSUSED*/
+XkbDeviceInfoPtr
+#if NeedFunctionPrototypes
+XkbAllocDeviceInfo(unsigned deviceSpec,unsigned nButtons,unsigned szLeds)
+#else
+XkbAllocDeviceInfo(deviceSpec,nButtons,szLeds)
+ unsigned deviceSpec;
+ unsigned nButtons;
+ unsigned szLeds;
+#endif
+{
+XkbDeviceInfoPtr devi;
+
+ devi= _XkbTypedCalloc(1,XkbDeviceInfoRec);
+ if (devi!=NULL) {
+ devi->device_spec= deviceSpec;
+ devi->has_own_state= False;
+ devi->num_btns= 0;
+ devi->btn_acts= NULL;
+ if (nButtons>0) {
+ devi->num_btns= nButtons;
+ devi->btn_acts= _XkbTypedCalloc(nButtons,XkbAction);
+ if (!devi->btn_acts) {
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
+ devi->dflt_kbd_fb= XkbXINone;
+ devi->dflt_led_fb= XkbXINone;
+ devi->num_leds= 0;
+ devi->sz_leds= 0;
+ devi->leds= NULL;
+ if (szLeds>0) {
+ devi->sz_leds= szLeds;
+ devi->leds= _XkbTypedCalloc(szLeds,XkbDeviceLedInfoRec);
+ if (!devi->leds) {
+ if (devi->btn_acts)
+ _XkbFree(devi->btn_acts);
+ _XkbFree(devi);
+ return NULL;
+ }
+ }
+ }
+ return devi;
+}
+
+
+void
+#if NeedFunctionPrototypes
+XkbFreeDeviceInfo(XkbDeviceInfoPtr devi,unsigned which,Bool freeDevI)
+#else
+XkbFreeDeviceInfo(devi,which,freeDevI)
+ XkbDeviceInfoPtr devi;
+ unsigned which;
+ Bool freeDevI;
+#endif
+{
+ if (devi) {
+ if (freeDevI) {
+ which= XkbXI_AllDeviceFeaturesMask;
+ if (devi->name) {
+ _XkbFree(devi->name);
+ devi->name= NULL;
+ }
+ }
+ if ((which&XkbXI_ButtonActionsMask)&&(devi->btn_acts)) {
+ _XkbFree(devi->btn_acts);
+ devi->num_btns= 0;
+ devi->btn_acts= NULL;
+ }
+ if ((which&XkbXI_IndicatorsMask)&&(devi->leds)) {
+ register int i;
+ if ((which&XkbXI_IndicatorsMask)==XkbXI_IndicatorsMask) {
+ _XkbFree(devi->leds);
+ devi->sz_leds= devi->num_leds= 0;
+ devi->leds= NULL;
+ }
+ else {
+ XkbDeviceLedInfoPtr devli;
+ for (i=0,devli=devi->leds;i<devi->num_leds;i++,devli++) {
+ if (which&XkbXI_IndicatorMapsMask)
+ bzero((char *)&devli->maps[0],sizeof(devli->maps));
+ else bzero((char *)&devli->names[0],sizeof(devli->names));
+ }
+ }
+ }
+ if (freeDevI)
+ _XkbFree(devi);
+ }
+ return;
+}
diff --git a/src/xkb/XKBBell.c b/src/xkb/XKBBell.c
new file mode 100644
index 00000000..3b6bb850
--- /dev/null
+++ b/src/xkb/XKBBell.c
@@ -0,0 +1,231 @@
+/* $Xorg: XKBBell.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+Bool
+#if NeedFunctionPrototypes
+XkbDeviceBell( Display * dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
+#else
+XkbDeviceBell(dpy,window,deviceID,bellClass,bellID,percent,name)
+ Display *dpy;
+ Window window;
+ int deviceID;
+ int bellClass;
+ int bellID;
+ int percent;
+ Atom name;
+#endif
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)window;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = False;
+ req->eventOnly = False;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = (CARD32)name;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbForceDeviceBell( Display * dpy,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent)
+#else
+XkbForceDeviceBell(dpy,deviceID,bellClass,bellID,percent)
+ Display *dpy;
+ int deviceID;
+ int bellClass;
+ int bellID;
+ int percent;
+#endif
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)None;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = True;
+ req->eventOnly = False;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = None;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbDeviceBellEvent( Display * dpy,
+ Window window,
+ int deviceID,
+ int bellClass,
+ int bellID,
+ int percent,
+ Atom name)
+#else
+XkbDeviceBellEvent(dpy,window,deviceID,bellClass,bellID,percent,name)
+ Display *dpy;
+ Window window;
+ int deviceID;
+ int bellClass;
+ int bellID;
+ int percent;
+ Atom name;
+#endif
+{
+ register xkbBellReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbBell,req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbBell;
+ req->deviceSpec = deviceID;
+ req->window = (CARD32)window;
+ req->bellClass = (CARD16)bellClass;
+ req->bellID = (CARD16)bellID;
+ req->percent = percent;
+ req->forceSound = False;
+ req->eventOnly = True;
+ req->pitch = 0;
+ req->duration = 0;
+ req->name = (CARD32)name;
+ req->pad1= 0; req->pad2= 0;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbBell(Display *dpy,Window window,int percent,Atom name)
+#else
+XkbBell(dpy,window,percent,name)
+ Display *dpy;
+ Window window;
+ int percent;
+ Atom name;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ XBell(dpy,percent);
+ return False;
+ }
+ return XkbDeviceBell(dpy,window,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
+ percent,name);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbForceBell(Display *dpy,int percent)
+#else
+XkbForceBell(dpy,percent)
+ Display * dpy;
+ int percent;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ XBell(dpy,percent);
+ return False;
+ }
+ return XkbForceDeviceBell(dpy,XkbUseCoreKbd,XkbDfltXIClass,XkbDfltXIId,
+ percent);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbBellEvent(Display *dpy,Window window,int percent,Atom name)
+#else
+XkbBellEvent(dpy,window,percent,name)
+ Display *dpy;
+ Window window;
+ int percent;
+ Atom name;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))) {
+ return False;
+ }
+ /* class 0 = KbdFeedbackClass (X Input Extension) */
+ return XkbDeviceBellEvent(dpy,window,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ percent,name);
+}
+
diff --git a/src/xkb/XKBBind.c b/src/xkb/XKBBind.c
new file mode 100644
index 00000000..4c6334a7
--- /dev/null
+++ b/src/xkb/XKBBind.c
@@ -0,0 +1,963 @@
+/* $Xorg: XKBBind.c,v 1.4 2001/02/09 02:03:37 xorgcvs Exp $ */
+/*
+
+Copyright 1985, 1987, 1994, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+ /* the new monsters ate the old ones */
+
+#define NEED_EVENTS
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/keysym.h>
+#include <stdio.h>
+#include <ctype.h>
+
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#ifdef USE_OWN_COMPOSE
+#define COMPOSE_NO_CONST_MEMBERS
+#include "imComp.h"
+#endif
+
+#define AllMods (ShiftMask|LockMask|ControlMask| \
+ Mod1Mask|Mod2Mask|Mod3Mask|Mod4Mask|Mod5Mask)
+
+static int _XkbLoadDpy(
+#if NeedFunctionPrototypes
+ Display *dpy
+#endif
+);
+
+struct _XKeytrans {
+ struct _XKeytrans *next;/* next on list */
+ char *string; /* string to return when the time comes */
+ int len; /* length of string (since NULL is legit)*/
+ KeySym key; /* keysym rebound */
+ unsigned int state; /* modifier state */
+ KeySym *modifiers; /* modifier keysyms you want */
+ int mlen; /* length of modifier list */
+};
+
+KeySym
+#if NeedFunctionPrototypes
+XkbKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int group,
+ int level)
+#else
+XkbKeycodeToKeysym(dpy, kc, group, level)
+ Display *dpy;
+ KeyCode kc;
+ int group;
+ int level;
+#endif
+{
+ XkbDescRec *xkb;
+
+ if (_XkbUnavailable(dpy))
+ return NoSymbol;
+
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ xkb = dpy->xkb_info->desc;
+ if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
+ return NoSymbol;
+
+ if ((group<0)||(level<0)||(group>=XkbKeyNumGroups(xkb,kc)))
+ return NoSymbol;
+ if (level>=XkbKeyGroupWidth(xkb,kc,group)) {
+ /* for compatibility with the core protocol, _always_ allow */
+ /* two symbols in the first two groups. If either of the */
+ /* two is of type ONE_LEVEL, just replicate the first symbol */
+ if ((group>XkbGroup2Index)||(XkbKeyGroupWidth(xkb,kc,group)!=1)||
+ (level!=1)) {
+ return NoSymbol;
+ }
+ level= 0;
+ }
+ return XkbKeySymEntry(xkb,kc,level,group);
+}
+
+KeySym
+#if NeedFunctionPrototypes
+XKeycodeToKeysym(Display *dpy,
+#if NeedWidePrototypes
+ unsigned int kc,
+#else
+ KeyCode kc,
+#endif
+ int col)
+#else
+XKeycodeToKeysym(dpy, kc, col)
+ Display *dpy;
+ KeyCode kc;
+ int col;
+#endif
+{
+ XkbDescRec *xkb;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeycodeToKeysym(dpy, kc, col);
+
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ xkb = dpy->xkb_info->desc;
+ if ((kc<xkb->min_key_code)||(kc>xkb->max_key_code))
+ return NoSymbol;
+
+ if (col>3) {
+ int lastSym,tmp,nGrp;
+
+ lastSym= 3;
+ nGrp= XkbKeyNumGroups(xkb,kc);
+ if ((nGrp>0)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup1Index))>2)) {
+ if (col<=(lastSym+tmp-2))
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup1Index,col-lastSym+2);
+ lastSym+= tmp-2;
+ }
+ if ((nGrp>1)&&((tmp=XkbKeyGroupWidth(xkb,kc,XkbGroup2Index))>2)) {
+ if (col<=(lastSym+tmp-2))
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup2Index,col-lastSym+2);
+ lastSym+= tmp-2;
+ }
+ if (nGrp>2) {
+ tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup3Index);
+ if (col<=lastSym+tmp)
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup3Index,col-lastSym);
+ lastSym+= tmp;
+ }
+ if (nGrp>3) {
+ tmp= XkbKeyGroupWidth(xkb,kc,XkbGroup4Index);
+ if (col<=lastSym+tmp)
+ return XkbKeycodeToKeysym(dpy,kc,XkbGroup4Index,col-lastSym);
+ }
+ return NoSymbol;
+ }
+ return XkbKeycodeToKeysym(dpy,kc,(col>>1),(col&1));
+}
+
+KeyCode
+#if NeedFunctionPrototypes
+XKeysymToKeycode(Display *dpy, KeySym ks)
+#else
+XKeysymToKeycode(dpy, ks)
+ Display *dpy;
+ KeySym ks;
+#endif
+{
+ register int i, j, gotOne;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeysymToKeycode(dpy,ks);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ j= 0;
+ do {
+ register XkbDescRec *xkb = dpy->xkb_info->desc;
+ gotOne= 0;
+ for (i = dpy->min_keycode; i <= dpy->max_keycode; i++) {
+ if ( j<(int)XkbKeyNumSyms(xkb,i) ) {
+ gotOne = 1;
+ if ((XkbKeySym(xkb,i,j)==ks))
+ return i;
+ }
+ }
+ j++;
+ } while (gotOne);
+ return 0;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbComputeModmap(Display *dpy)
+#else
+_XkbComputeModmap(dpy)
+ Display *dpy;
+#endif
+{
+register XkbDescPtr xkb;
+
+ xkb= dpy->xkb_info->desc;
+ if (XkbGetUpdatedMap(dpy,XkbModifierMapMask,xkb)==Success)
+ return 1;
+ return 0;
+}
+
+unsigned
+#if NeedFunctionPrototypes
+XkbKeysymToModifiers(Display *dpy,KeySym ks)
+#else
+XkbKeysymToModifiers(dpy,ks)
+ Display *dpy;
+ KeySym ks;
+#endif
+{
+ XkbDescRec *xkb;
+ register int i,j;
+ register KeySym *pSyms;
+ CARD8 mods;
+
+ if (_XkbUnavailable(dpy))
+ return _XKeysymToModifiers(dpy,ks);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ if (_XkbNeedModmap(dpy->xkb_info)&&(!_XkbComputeModmap(dpy)))
+ return _XKeysymToModifiers(dpy,ks);
+
+ xkb= dpy->xkb_info->desc;
+ mods= 0;
+ for (i = xkb->min_key_code; i <= (int)xkb->max_key_code; i++) {
+ pSyms= XkbKeySymsPtr(xkb,i);
+ for (j=XkbKeyNumSyms(xkb,i)-1;j>=0;j--) {
+ if (pSyms[j]==ks) {
+ mods|= xkb->map->modmap[i];
+ break;
+ }
+ }
+ }
+ return mods;
+}
+
+KeySym
+#if NeedFunctionPrototypes
+XLookupKeysym(register XKeyEvent *event, int col)
+#else
+XLookupKeysym(event, col)
+ register XKeyEvent *event;
+ int col;
+#endif
+{
+ Display *dpy = event->display;
+ if (_XkbUnavailable(dpy))
+ return _XLookupKeysym(event, col);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return XKeycodeToKeysym(dpy, event->keycode, col);
+}
+
+ /*
+ * Not a public entry point -- XkbTranslateKey is an obsolete name
+ * that is preserved here so that functions linked against the old
+ * version will continue to work in a shared library environment.
+ */
+int
+#if NeedFunctionPrototypes
+XkbTranslateKey( register Display * dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+#else
+XkbTranslateKey(dpy, key, mods, mods_rtrn, keysym_rtrn)
+ register Display *dpy;
+ KeyCode key;
+ register unsigned int mods;
+ unsigned int *mods_rtrn;
+ KeySym *keysym_rtrn;
+#endif
+{
+ return XkbLookupKeySym(dpy,key,mods,mods_rtrn,keysym_rtrn);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbLookupKeySym( register Display * dpy,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+#else
+XkbLookupKeySym(dpy, key, mods, mods_rtrn, keysym_rtrn)
+ register Display *dpy;
+ KeyCode key;
+ register unsigned int mods;
+ unsigned int *mods_rtrn;
+ KeySym *keysym_rtrn;
+#endif
+{
+ if (_XkbUnavailable(dpy))
+ return _XTranslateKey(dpy, key, mods, mods_rtrn, keysym_rtrn);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+ return XkbTranslateKeyCode(dpy->xkb_info->desc,key,mods,mods_rtrn,
+ keysym_rtrn);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbTranslateKeyCode( register XkbDescPtr xkb,
+ KeyCode key,
+ register unsigned int mods,
+ unsigned int * mods_rtrn,
+ KeySym * keysym_rtrn)
+#else
+XkbTranslateKeyCode(xkb, key, mods, mods_rtrn, keysym_rtrn)
+ register XkbDescPtr xkb;
+ KeyCode key;
+ register unsigned int mods;
+ unsigned int *mods_rtrn;
+ KeySym *keysym_rtrn;
+#endif
+{
+ XkbKeyTypeRec *type;
+ int col,nKeyGroups;
+ unsigned preserve,effectiveGroup;
+ KeySym *syms;
+
+ if (mods_rtrn!=NULL)
+ *mods_rtrn = 0;
+
+ nKeyGroups= XkbKeyNumGroups(xkb,key);
+ if ((!XkbKeycodeInRange(xkb,key))||(nKeyGroups==0)) {
+ if (keysym_rtrn!=NULL)
+ *keysym_rtrn = NoSymbol;
+ return False;
+ }
+
+ syms = XkbKeySymsPtr(xkb,key);
+
+ /* find the offset of the effective group */
+ col = 0;
+ effectiveGroup= XkbGroupForCoreState(mods);
+ if ( effectiveGroup>=nKeyGroups ) {
+ unsigned groupInfo= XkbKeyGroupInfo(xkb,key);
+ switch (XkbOutOfRangeGroupAction(groupInfo)) {
+ default:
+ effectiveGroup %= nKeyGroups;
+ break;
+ case XkbClampIntoRange:
+ effectiveGroup = nKeyGroups-1;
+ break;
+ case XkbRedirectIntoRange:
+ effectiveGroup = XkbOutOfRangeGroupNumber(groupInfo);
+ if (effectiveGroup>=nKeyGroups)
+ effectiveGroup= 0;
+ break;
+ }
+ }
+ col= effectiveGroup*XkbKeyGroupsWidth(xkb,key);
+ type = XkbKeyKeyType(xkb,key,effectiveGroup);
+
+ preserve= 0;
+ if (type->map) { /* find the column (shift level) within the group */
+ register int i;
+ register XkbKTMapEntryPtr entry;
+ for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+ if ((entry->active)&&((mods&type->mods.mask)==entry->mods.mask)) {
+ col+= entry->level;
+ if (type->preserve)
+ preserve= type->preserve[i].mask;
+ break;
+ }
+ }
+ }
+
+ if (keysym_rtrn!=NULL)
+ *keysym_rtrn= syms[col];
+ if (mods_rtrn) {
+ *mods_rtrn= type->mods.mask&(~preserve);
+ /* The Motif VTS doesn't get the help callback called if help
+ * is bound to Shift+<whatever>, and it appears as though it
+ * is XkbTranslateKeyCode that is causing the problem. The
+ * core X version of XTranslateKey always OR's in ShiftMask
+ * and LockMask for mods_rtrn, so this "fix" keeps this behavior
+ * and solves the VTS problem.
+ */
+ if ((xkb->dpy)&&(xkb->dpy->xkb_info)&&
+ (xkb->dpy->xkb_info->xlib_ctrls&XkbLC_AlwaysConsumeShiftAndLock)) {
+ *mods_rtrn|= (ShiftMask|LockMask);
+ }
+ }
+ return (syms[col]!=NoSymbol);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbRefreshKeyboardMapping(register XkbMapNotifyEvent *event)
+#else
+XkbRefreshKeyboardMapping(event)
+ register XkbMapNotifyEvent *event;
+#endif
+{
+ Display *dpy = event->display;
+ XkbInfoPtr xkbi;
+
+ if (_XkbUnavailable(dpy)) {
+ _XRefreshKeyboardMapping((XMappingEvent *)event);
+ return Success;
+ }
+ xkbi= dpy->xkb_info;
+
+ if (((event->type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
+ return BadMatch;
+ if (event->xkb_type==XkbNewKeyboardNotify) {
+ _XkbReloadDpy(dpy);
+ return Success;
+ }
+ if (event->xkb_type==XkbMapNotify) {
+ XkbMapChangesRec changes;
+ Status rtrn;
+
+ if (xkbi->flags&XkbMapPending)
+ changes= xkbi->changes;
+ else bzero(&changes,sizeof(XkbChangesRec));
+ XkbNoteMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
+ LockDisplay(dpy);
+ if ((rtrn=XkbGetMapChanges(dpy,xkbi->desc,&changes))!=Success) {
+#ifdef DEBUG
+ fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
+#endif
+ xkbi->changes= changes;
+ }
+ else if (xkbi->flags&XkbMapPending) {
+ xkbi->flags&= ~XkbMapPending;
+ bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
+ }
+ UnlockDisplay(dpy);
+ return rtrn;
+ }
+ return BadMatch;
+}
+
+int
+#if NeedFunctionPrototypes
+XRefreshKeyboardMapping(register XMappingEvent *event)
+#else
+XRefreshKeyboardMapping(event)
+ register XMappingEvent *event;
+#endif
+{
+ XkbEvent *xkbevent = (XkbEvent *)event;
+ Display *dpy = event->display;
+ XkbMapChangesRec changes;
+ XkbInfoPtr xkbi;
+
+ if (_XkbUnavailable(dpy))
+ return _XRefreshKeyboardMapping(event);
+
+ xkbi = dpy->xkb_info;
+
+ if (((event->type&0x7f)-xkbi->codes->first_event)==XkbEventCode)
+ return XkbRefreshKeyboardMapping(&xkbevent->map);
+
+ if (xkbi->flags&XkbXlibNewKeyboard) {
+ _XkbReloadDpy(dpy);
+ return 1;
+ }
+
+ if ((xkbi->flags&XkbMapPending)||(event->request==MappingKeyboard)) {
+ if (xkbi->flags&XkbMapPending) {
+ changes= xkbi->changes;
+ _XkbNoteCoreMapChanges(&changes,event,XKB_XLIB_MAP_MASK);
+ }
+ else {
+ bzero(&changes,sizeof(changes));
+ changes.changed= XkbKeySymsMask;
+ if (xkbi->desc->min_key_code<xkbi->desc->max_key_code) {
+ changes.first_key_sym= xkbi->desc->min_key_code;
+ changes.num_key_syms= xkbi->desc->max_key_code-
+ xkbi->desc->min_key_code+1;
+ }
+ else {
+ changes.first_key_sym= event->first_keycode;
+ changes.num_key_syms= event->count;
+ }
+ }
+
+ if (XkbGetMapChanges(dpy,xkbi->desc, &changes)!=Success) {
+#ifdef DEBUG
+ fprintf(stderr,"Internal Error! XkbGetMapChanges failed:\n");
+ if (changes.changed&XkbKeyTypesMask) {
+ int first= changes.first_type;
+ int last= changes.first_type+changes.num_types-1;
+ fprintf(stderr," types: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeySymsMask) {
+ int first= changes.first_key_sym;
+ int last= changes.first_key_sym+changes.num_key_syms-1;
+ fprintf(stderr," symbols: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeyActionsMask) {
+ int last,first= changes.first_key_act;
+ last= changes.first_key_act+changes.num_key_acts-1;
+ fprintf(stderr," acts: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbKeyBehaviorsMask) {
+ int last,first= changes.first_key_behavior;
+ last= first+changes.num_key_behaviors-1;
+ fprintf(stderr," behaviors: %d..%d\n",first,last);
+ }
+ if (changes.changed&XkbVirtualModsMask) {
+ fprintf(stderr,"virtual mods: 0x%04x\n",
+ changes.vmods);
+ }
+ if (changes.changed&XkbExplicitComponentsMask) {
+ int last,first= changes.first_key_explicit;
+ last= first+changes.num_key_explicit-1;
+ fprintf(stderr," explicit: %d..%d\n",first,last);
+ }
+#endif
+ }
+ LockDisplay(dpy);
+ if (xkbi->flags&XkbMapPending) {
+ xkbi->flags&= ~XkbMapPending;
+ bzero(&xkbi->changes,sizeof(XkbMapChangesRec));
+ }
+ UnlockDisplay(dpy);
+ }
+ if (event->request==MappingModifier) {
+ if (xkbi->desc->map->modmap) {
+ _XkbFree(xkbi->desc->map->modmap);
+ xkbi->desc->map->modmap= NULL;
+ }
+ if (dpy->key_bindings) {
+ register struct _XKeytrans *p;
+ for (p = dpy->key_bindings; p; p = p->next) {
+ register int i;
+ p->state= 0;
+ if (p->mlen>0) {
+ for (i = 0; i < p->mlen; i++) {
+ p->state|= XkbKeysymToModifiers(dpy,p->modifiers[i]);
+ }
+ if (p->state) p->state &= AllMods;
+ else p->state = AnyModifier;
+ }
+ }
+ }
+ UnlockDisplay(dpy);
+ }
+ return 1;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbLoadDpy(Display *dpy)
+#else
+_XkbLoadDpy(dpy)
+ Display *dpy;
+#endif
+{
+ XkbInfoPtr xkbi;
+ unsigned query,oldEvents;
+ XkbDescRec *desc;
+
+ if (!XkbUseExtension(dpy,NULL,NULL))
+ return 0;
+
+ xkbi = dpy->xkb_info;
+ query = XkbAllClientInfoMask;
+ desc = XkbGetMap(dpy,query,XkbUseCoreKbd);
+ if (!desc) {
+#ifdef DEBUG
+ fprintf(stderr,"Warning! XkbGetMap failed!\n");
+#endif
+ return 0;
+ }
+ LockDisplay(dpy);
+ xkbi->desc = desc;
+
+ _XkbGetConverters(_XkbGetCharset(),&xkbi->cvt);
+ _XkbGetConverters("ISO8859-1",&xkbi->latin1cvt);
+ UnlockDisplay(dpy);
+ oldEvents= xkbi->selected_events;
+ if (!(xkbi->xlib_ctrls&XkbLC_IgnoreNewKeyboards)) {
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbNewKeyboardNotify,
+ XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask,
+ XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask);
+ }
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
+ XkbAllClientInfoMask,XkbAllClientInfoMask);
+ LockDisplay(dpy);
+ xkbi->selected_events= oldEvents;
+ UnlockDisplay(dpy);
+ return 1;
+}
+
+void
+#if NeedFunctionPrototypes
+_XkbReloadDpy(Display *dpy)
+#else
+_XkbReloadDpy(dpy)
+ Display *dpy;
+#endif
+{
+ XkbInfoPtr xkbi;
+ XkbDescRec *desc;
+ unsigned oldDeviceID;
+
+ if (_XkbUnavailable(dpy))
+ return;
+
+ xkbi = dpy->xkb_info;
+ LockDisplay(dpy);
+ if (xkbi->desc) {
+ oldDeviceID= xkbi->desc->device_spec;
+ XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
+ xkbi->desc= NULL;
+ xkbi->flags&= ~(XkbMapPending|XkbXlibNewKeyboard);
+ xkbi->changes.changed= 0;
+ }
+ else oldDeviceID= XkbUseCoreKbd;
+ UnlockDisplay(dpy);
+ desc = XkbGetMap(dpy,XkbAllClientInfoMask,XkbUseCoreKbd);
+ if (!desc)
+ return;
+ LockDisplay(dpy);
+ xkbi->desc = desc;
+ UnlockDisplay(dpy);
+
+ if (desc->device_spec!=oldDeviceID) {
+ /* transfer(?) event masks here */
+#ifdef NOTYET
+ unsigned oldEvents;
+ oldEvents= xkbi->selected_events;
+ XkbSelectEventDetails(dpy,xkbi->desc->device_spec,XkbMapNotify,
+ XkbAllMapComponentsMask,XkbAllClientInfoMask);
+ LockDisplay(dpy);
+ xkbi->selected_events= oldEvents;
+ UnlockDisplay(dpy);
+#endif
+ }
+ return;
+}
+
+int
+#if NeedFunctionPrototypes
+XkbTranslateKeySym( register Display * dpy,
+ register KeySym * sym_rtrn,
+ unsigned int mods,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+#else
+XkbTranslateKeySym(dpy, sym_rtrn, mods, buffer, nbytes, extra_rtrn)
+ register Display *dpy;
+ register KeySym *sym_rtrn;
+ unsigned int mods;
+ char *buffer;
+ int nbytes;
+ int *extra_rtrn;
+#endif
+{
+ register XkbInfoPtr xkb;
+ XkbKSToMBFunc cvtr;
+ XPointer priv;
+ char tmp[4];
+ register struct _XKeytrans *p;
+ int n;
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+
+ if (_XkbUnavailable(dpy))
+ return _XTranslateKeySym(dpy, *sym_rtrn, mods, buffer, nbytes);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ xkb= dpy->xkb_info;
+ if ((buffer==NULL)||(nbytes==0)) {
+ buffer= tmp;
+ nbytes= 4;
+ }
+
+ /* see if symbol rebound, if so, return that string. */
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((mods & AllMods) == p->state) && (*sym_rtrn == p->key)) {
+ int tmp = p->len;
+ if (tmp > nbytes) {
+ if (extra_rtrn)
+ *extra_rtrn= tmp-nbytes;
+ tmp = nbytes;
+ }
+ memcpy (buffer, p->string, tmp);
+ return tmp;
+ }
+ }
+
+ if ( nbytes>0 )
+ buffer[0]= '\0';
+
+ if ( xkb->cvt.KSToUpper && (mods&LockMask) ) {
+ *sym_rtrn = (*xkb->cvt.KSToUpper)(*sym_rtrn);
+ }
+ if (xkb->xlib_ctrls & XkbLC_ForceLatin1Lookup) {
+ cvtr = xkb->latin1cvt.KSToMB;
+ priv = xkb->latin1cvt.KSToMBPriv;
+ } else {
+ cvtr = xkb->cvt.KSToMB;
+ priv = xkb->cvt.KSToMBPriv;
+ }
+
+ n = (*cvtr)(priv,*sym_rtrn,buffer,nbytes,extra_rtrn);
+
+ if ((!xkb->cvt.KSToUpper)&&( mods&LockMask )) {
+ register int i;
+
+ if (!xkb->cvt.KSToUpper) {
+ int change;
+ char ch;
+ for (i=change=0;i<n;i++) {
+ ch= toupper(buffer[i]);
+ change= (change||(buffer[i]!=ch));
+ buffer[i] = ch;
+ }
+ if (change) {
+ if (n==1)
+ *sym_rtrn=(*xkb->cvt.MBToKS)(xkb->cvt.MBToKSPriv,
+ buffer,n,0);
+ else *sym_rtrn= NoSymbol;
+ }
+ }
+ }
+
+ if ( mods&ControlMask ) {
+ if ( n==1 ) {
+ register char c = buffer[0];
+
+ if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
+ else if (c == '2') c = '\000';
+ else if (c >= '3' && c <= '7') c -= ('3' - '\033');
+ else if (c == '8') c = '\177';
+ else if (c == '/') c = '_' & 0x1F;
+
+ buffer[0]= c;
+ if ( nbytes>1 )
+ buffer[1]= '\0';
+ return 1;
+ }
+ if ( nbytes > 0 )
+ buffer[0]= '\0';
+ return 0;
+ }
+ return n;
+}
+
+int
+#if NeedFunctionPrototypes
+XLookupString ( register XKeyEvent * event,
+ char * buffer,
+ int nbytes,
+ KeySym * keysym,
+ XComposeStatus * status)
+#else
+XLookupString (event, buffer, nbytes, keysym, status)
+ register XKeyEvent *event;
+ char *buffer; /* buffer */
+ int nbytes; /* space in buffer for characters */
+ KeySym *keysym;
+ XComposeStatus *status;
+#endif
+{
+ KeySym dummy;
+ int rtrnLen;
+ unsigned int new_mods;
+ Display *dpy = event->display;
+ XkbDescPtr xkb;
+
+ if (_XkbUnavailable(dpy))
+ return _XLookupString(event, buffer, nbytes, keysym, status);
+ _XkbCheckPendingRefresh(dpy,dpy->xkb_info);
+
+ if (keysym==NULL)
+ keysym= &dummy;
+ xkb= dpy->xkb_info->desc;
+ if (!XkbTranslateKeyCode(xkb,event->keycode,event->state, &new_mods,keysym))
+ return 0;
+ new_mods= (event->state&(~new_mods));
+
+#ifdef USE_OWN_COMPOSE
+ if ( status ) {
+ static int been_here= 0;
+ if ( !been_here ) {
+ XimCompInitTables();
+ been_here = 1;
+ }
+ if ( !XimCompLegalStatus(status) ) {
+ status->compose_ptr = NULL;
+ status->chars_matched = 0;
+ }
+ if ( ((status->chars_matched>0)&&(status->compose_ptr!=NULL)) ||
+ XimCompIsComposeKey(*keysym,event->keycode,status) ) {
+ XimCompRtrn rtrn;
+
+ switch (XimCompProcessSym(status,*keysym,&rtrn)) {
+ case XIM_COMP_IGNORE:
+ break;
+ case XIM_COMP_IN_PROGRESS:
+ if ( keysym!=NULL )
+ *keysym = NoSymbol;
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,True,False,NULL);
+ }
+#endif
+ return 0;
+ case XIM_COMP_FAIL:
+ {
+ static Atom _ComposeFail= None;
+ int n = 0, len= 0;
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,False,False,NULL);
+ }
+#endif
+#ifndef NO_BELL_ON_COMPOSE_FAIL
+ if (dpy->xkb_info->xlib_ctrls&XkbLC_BeepOnComposeFail) {
+ if (_ComposeFail==None)
+ _ComposeFail= XInternAtom(dpy,"ComposeFail",0);
+ XkbBell(dpy,event->window,0,_ComposeFail);
+ }
+#endif
+ for (n=len=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],new_mods,
+ buffer+len,nbytes-len,
+ NULL);
+ }
+ }
+ if ( keysym!=NULL ) {
+ if ( n==1 ) *keysym = rtrn.sym[0];
+ else *keysym = NoSymbol;
+ }
+ return len;
+ }
+ case XIM_COMP_SUCCEED:
+ {
+ int len,n = 0;
+
+#ifndef NO_COMPOSE_LED
+ if ( dpy->xkb_info->xlib_ctrls&XkbLC_ComposeLED ) {
+ XkbSetNamedIndicator(dpy,dpy->xkb_info->composeLED,
+ True,False,False,NULL);
+ }
+#endif
+ *keysym = rtrn.matchSym;
+ if ( rtrn.str[0]!='\0' ) {
+ strncpy(buffer,rtrn.str,nbytes-1);
+ buffer[nbytes-1]= '\0';
+ len = (int)strlen(buffer);
+ }
+ else {
+ len = XkbTranslateKeySym(dpy,keysym,new_mods,
+ buffer,nbytes,
+ NULL);
+ }
+ for (n=0;rtrn.sym[n]!=XK_VoidSymbol;n++) {
+ if ( nbytes-len > 0 ) {
+ len+= XkbTranslateKeySym(dpy,&rtrn.sym[n],
+ event->state,
+ buffer+len,nbytes-len,
+ NULL);
+ }
+ }
+ return len;
+ }
+ }
+ }
+ }
+#endif
+
+ /* We *should* use the new_mods (which does not contain any modifiers */
+ /* that were used to compute the symbol here, but pre-XKB XLookupString */
+ /* did not and we have to remain compatible. Sigh. */
+ if ((dpy->xkb_info->flags&XkbLC_ConsumeLookupMods)==0)
+ new_mods= event->state;
+
+ rtrnLen= XkbLookupKeyBinding(dpy,*keysym,new_mods,buffer,nbytes,NULL);
+ if (rtrnLen>0)
+ return rtrnLen;
+
+ rtrnLen = XkbTranslateKeySym(dpy,keysym,new_mods,buffer,nbytes,NULL);
+ if ((event->state&ControlMask)&&(nbytes>0)&&
+ ((rtrnLen==0)||((rtrnLen==1)&&(buffer[0]>=' ')))&&
+ (XkbGroupForCoreState(event->state)!=XkbGroup1Index)&&
+ (dpy->xkb_info->xlib_ctrls&XkbLC_ControlFallback)) {
+ XKeyEvent tmp_ev;
+ tmp_ev= *event;
+ tmp_ev.state= XkbBuildCoreState(event->state,XkbGroup1Index);
+ return XLookupString (&tmp_ev, buffer, nbytes, keysym, status);
+ }
+ return rtrnLen;
+}
+
+
+int
+#if NeedFunctionPrototypes
+XkbLookupKeyBinding( Display * dpy,
+ register KeySym sym,
+ unsigned int mods,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+#else
+XkbLookupKeyBinding(dpy, sym, mods, buffer, nbytes, extra_rtrn)
+ Display *dpy;
+ register KeySym sym;
+ unsigned int mods;
+ char *buffer;
+ int nbytes;
+ int * extra_rtrn;
+#endif
+{
+ register struct _XKeytrans *p;
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+ for (p = dpy->key_bindings; p; p = p->next) {
+ if (((mods & AllMods) == p->state) && (sym == p->key)) {
+ int tmp = p->len;
+ if (tmp > nbytes) {
+ if (extra_rtrn)
+ *extra_rtrn= (tmp-nbytes);
+ tmp = nbytes;
+ }
+ memcpy (buffer, p->string, tmp);
+ if (tmp < nbytes) buffer[tmp]= '\0';
+ return tmp;
+ }
+ }
+ return 0;
+}
+
+char
+#if NeedFunctionPrototypes
+XkbToControl( char c )
+#else
+XkbToControl( c )
+ char c;
+#endif
+{
+ if ((c >= '@' && c < '\177') || c == ' ') c &= 0x1F;
+ else if (c == '2') c = '\000';
+ else if (c >= '3' && c <= '7') c -= ('3' - '\033');
+ else if (c == '8') c = '\177';
+ else if (c == '/') c = '_' & 0x1F;
+ return c;
+}
diff --git a/src/xkb/XKBCompat.c b/src/xkb/XKBCompat.c
new file mode 100644
index 00000000..73c7d76d
--- /dev/null
+++ b/src/xkb/XKBCompat.c
@@ -0,0 +1,277 @@
+/* $Xorg: XKBCompat.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+Status
+#if NeedFunctionPrototypes
+_XkbReadGetCompatMapReply( Display * dpy,
+ xkbGetCompatMapReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+#else
+_XkbReadGetCompatMapReply(dpy,rep,xkb,nread_rtrn)
+ Display * dpy;
+ xkbGetCompatMapReply * rep;
+ XkbDescPtr xkb;
+ int * nread_rtrn;
+#endif
+{
+register int i;
+XkbReadBufferRec buf;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+
+ i= rep->firstSI+rep->nSI;
+ if ((!xkb->compat)&&
+ (XkbAllocCompatMap(xkb,XkbAllCompatMask,i)!=Success))
+ return BadAlloc;
+
+ if (rep->nSI!=0) {
+ XkbSymInterpretRec *syms;
+ xkbSymInterpretWireDesc *wire;
+
+ wire= (xkbSymInterpretWireDesc *)_XkbGetReadBufferPtr(&buf,
+ rep->nSI*SIZEOF(xkbSymInterpretWireDesc));
+ if (wire==NULL)
+ goto BAILOUT;
+ syms= &xkb->compat->sym_interpret[rep->firstSI];
+
+ for (i=0;i<rep->nSI;i++,syms++,wire++) {
+ syms->sym= wire->sym;
+ syms->mods= wire->mods;
+ syms->match= wire->match;
+ syms->virtual_mod= wire->virtualMod;
+ syms->flags= wire->flags;
+ syms->act= *((XkbAnyAction *)&wire->act);
+ }
+ xkb->compat->num_si+= rep->nSI;
+ }
+
+ if (rep->groups&XkbAllGroupsMask) {
+ register unsigned bit,nGroups;
+ xkbModsWireDesc * wire;
+ for (i=0,nGroups=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (rep->groups&bit)
+ nGroups++;
+ }
+ wire= (xkbModsWireDesc *)_XkbGetReadBufferPtr(&buf,
+ nGroups*SIZEOF(xkbModsWireDesc));
+ if (wire==NULL)
+ goto BAILOUT;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if ((rep->groups&bit)==0)
+ continue;
+ xkb->compat->groups[i].mask= wire->mask;
+ xkb->compat->groups[i].real_mods= wire->realMods;
+ xkb->compat->groups[i].vmods= wire->virtualMods;
+ wire++;
+ }
+ }
+ i= _XkbFreeReadBuffer(&buf);
+ if (i)
+ fprintf(stderr,"CompatMapReply! Bad length (%d extra bytes)\n",i);
+ if (i || buf.error)
+ return BadLength;
+ return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+#else
+XkbGetCompatMap(dpy,which,xkb)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetCompatMapReq *req;
+ xkbGetCompatMapReply rep;
+ Status status;
+ XkbInfoPtr xkbi;
+
+ if ( (!dpy) || (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ ((xkb->dpy!=NULL)&&(xkb->dpy!=dpy)) ||
+ (!dpy->xkb_info && (!XkbUseExtension(dpy,NULL,NULL))))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetCompatMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetCompatMap;
+ req->deviceSpec = xkb->device_spec;
+ if (which&XkbSymInterpMask)
+ req->getAllSI= True;
+ else req->getAllSI= False;
+ req->firstSI= req->nSI= 0;
+
+ if (which&XkbGroupCompatMask)
+ req->groups= XkbAllGroupsMask;
+ else req->groups= 0;
+
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ if (xkb->dpy==NULL)
+ xkb->dpy= dpy;
+ if (xkb->device_spec==XkbUseCoreKbd)
+ xkb->device_spec= rep.deviceID;
+
+ status = _XkbReadGetCompatMapReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+static Bool
+#if NeedFunctionPrototypes
+_XkbWriteSetCompatMap(Display *dpy,xkbSetCompatMapReq *req,XkbDescPtr xkb)
+#else
+_XkbWriteSetCompatMap(dpy,req,xkb)
+ Display * dpy;
+ xkbSetCompatMapReq *req;
+ XkbDescPtr xkb;
+#endif
+{
+CARD16 firstSI;
+CARD16 nSI;
+int size;
+register int i,nGroups;
+register unsigned bit;
+unsigned groups;
+char * buf;
+
+ firstSI = req->firstSI;
+ nSI = req->nSI;
+ size= nSI*SIZEOF(xkbSymInterpretWireDesc);
+ nGroups= 0;
+ groups= req->groups;
+ if (groups&XkbAllGroupsMask) {
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if (groups&bit)
+ nGroups++;
+ }
+ size+= SIZEOF(xkbModsWireDesc)*nGroups;
+ }
+ req->length+= size/4;
+ BufAlloc(char *,buf,size);
+ if (!buf)
+ return False;
+
+ if (nSI) {
+ XkbSymInterpretPtr sym= &xkb->compat->sym_interpret[firstSI];
+ xkbSymInterpretWireDesc *wire= (xkbSymInterpretWireDesc *)buf;
+ for (i=0;i<nSI;i++,wire++,sym++) {
+ wire->sym= (CARD32)sym->sym;
+ wire->mods= sym->mods;
+ wire->match= sym->match;
+ wire->flags= sym->flags;
+ wire->virtualMod= sym->virtual_mod;
+ memcpy(&wire->act,&sym->act,sz_xkbActionWireDesc);
+ }
+ buf+= nSI*SIZEOF(xkbSymInterpretWireDesc);
+ }
+ if (groups&XkbAllGroupsMask) {
+ xkbModsWireDesc * out;
+
+ out= (xkbModsWireDesc *)buf;
+ for (i=0,bit=1;i<XkbNumKbdGroups;i++,bit<<=1) {
+ if ((groups&bit)!=0) {
+ out->mask= xkb->compat->groups[i].mask;
+ out->realMods= xkb->compat->groups[i].real_mods;
+ out->virtualMods= xkb->compat->groups[i].vmods;
+ out++;
+ }
+ }
+ buf+= nGroups*SIZEOF(xkbModsWireDesc);
+ }
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetCompatMap(Display *dpy,unsigned which,XkbDescPtr xkb,Bool updateActions)
+#else
+XkbSetCompatMap(dpy,which,xkb,updateActions)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+ Bool updateActions;
+#endif
+{
+ register xkbSetCompatMapReq *req;
+ Status ok;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (dpy!=xkb->dpy) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb->compat) ||
+ ((which&XkbSymInterpMask)&&(!xkb->compat->sym_interpret)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetCompatMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetCompatMap;
+ req->deviceSpec = xkb->device_spec;
+ req->recomputeActions = updateActions;
+ if (which&XkbSymInterpMask) {
+ req->truncateSI = True;
+ req->firstSI= 0;
+ req->nSI= xkb->compat->num_si;
+ }
+ else {
+ req->truncateSI = False;
+ req->firstSI= 0;
+ req->nSI= 0;
+ }
+ if (which&XkbGroupCompatMask)
+ req->groups= XkbAllGroupsMask;
+ else req->groups= 0;
+ ok= _XkbWriteSetCompatMap(dpy,req,xkb);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ok;
+}
+
diff --git a/src/xkb/XKBCtrls.c b/src/xkb/XKBCtrls.c
new file mode 100644
index 00000000..2e08e50e
--- /dev/null
+++ b/src/xkb/XKBCtrls.c
@@ -0,0 +1,418 @@
+/* $Xorg: XKBCtrls.c,v 1.3 2000/08/17 19:45:00 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+static xkbSetControlsReq *
+#if NeedFunctionPrototypes
+_XkbGetSetControlsReq(Display *dpy,XkbInfoPtr xkbi,unsigned int deviceSpec)
+#else
+_XkbGetSetControlsReq(dpy,xkbi,deviceSpec)
+ Display * dpy;
+ XkbInfoPtr xkbi;
+ unsigned int deviceSpec;
+#endif
+{
+xkbSetControlsReq *req;
+
+ GetReq(kbSetControls,req);
+ bzero(req,SIZEOF(xkbSetControlsReq));
+ req->reqType = xkbi->codes->major_opcode;
+ req->length = (SIZEOF(xkbSetControlsReq)>>2);
+ req->xkbReqType = X_kbSetControls;
+ req->deviceSpec = deviceSpec;
+ return req;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetAutoRepeatRate( Display *dpy,
+ unsigned int deviceSpec,
+ unsigned int timeout,
+ unsigned int interval)
+#else
+XkbSetAutoRepeatRate(dpy, deviceSpec, timeout, interval)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int timeout;
+ unsigned int interval;
+#endif
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->changeCtrls = XkbRepeatKeysMask;
+ req->repeatDelay = timeout;
+ req->repeatInterval = interval;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetAutoRepeatRate( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned int * timeoutp,
+ unsigned int * intervalp)
+#else
+XkbGetAutoRepeatRate(dpy, deviceSpec, timeoutp, intervalp)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned int *timeoutp;
+ unsigned int *intervalp;
+#endif
+{
+ register xkbGetControlsReq *req;
+ xkbGetControlsReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetControls, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetControls;
+ req->deviceSpec = deviceSpec;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ *timeoutp = rep.repeatDelay;
+ *intervalp = rep.repeatInterval;
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetServerInternalMods( Display * dpy,
+ unsigned deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
+#else
+XkbSetServerInternalMods(dpy,deviceSpec,
+ affectReal,realValues,affectVirtual,virtualValues)
+ Display *dpy;
+ unsigned deviceSpec;
+ unsigned affectReal;
+ unsigned realValues;
+ unsigned affectVirtual;
+ unsigned virtualValues;
+#endif
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectInternalMods = affectReal;
+ req->internalMods = realValues;
+ req->affectInternalVMods= affectVirtual;
+ req->internalVMods= virtualValues;
+ req->changeCtrls = XkbInternalModsMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetIgnoreLockMods( Display * dpy,
+ unsigned int deviceSpec,
+ unsigned affectReal,
+ unsigned realValues,
+ unsigned affectVirtual,
+ unsigned virtualValues)
+#else
+XkbSetIgnoreLockMods(dpy,deviceSpec,
+ affectReal,realValues,affectVirtual,virtualValues)
+ Display *dpy;
+ unsigned int deviceSpec;
+ unsigned affectReal;
+ unsigned realValues;
+ unsigned affectVirtual;
+ unsigned virtualValues;
+#endif
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectIgnoreLockMods= affectReal;
+ req->ignoreLockMods = realValues;
+ req->affectIgnoreLockVMods= affectVirtual;
+ req->ignoreLockVMods= virtualValues;
+ req->changeCtrls = XkbIgnoreLockModsMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbChangeEnabledControls( Display * dpy,
+ unsigned deviceSpec,
+ unsigned affect,
+ unsigned values)
+#else
+XkbChangeEnabledControls(dpy,deviceSpec,affect,values)
+ Display * dpy;
+ unsigned deviceSpec;
+ unsigned affect;
+ unsigned values;
+#endif
+{
+ register xkbSetControlsReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,deviceSpec);
+ req->affectEnabledCtrls= affect;
+ req->enabledCtrls= (affect&values);
+ req->changeCtrls = XkbControlsEnabledMask;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
+#else
+XkbGetControls(dpy, which, xkb)
+ Display *dpy;
+ unsigned long which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetControlsReq *req;
+ xkbGetControlsReply rep;
+ XkbControlsPtr ctrls;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((!xkb) || (!which))
+ return BadMatch;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetControls, req);
+ if (!xkb->ctrls) {
+ xkb->ctrls = _XkbTypedCalloc(1,XkbControlsRec);
+ if (!xkb->ctrls) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetControls;
+ req->deviceSpec = xkb->device_spec;
+ if (!_XReply(dpy, (xReply *)&rep,
+ (SIZEOF(xkbGetControlsReply)-SIZEOF(xReply))>>2, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+ if (xkb->device_spec==XkbUseCoreKbd)
+ xkb->device_spec= rep.deviceID;
+ ctrls= xkb->ctrls;
+ if (which&XkbControlsEnabledMask)
+ ctrls->enabled_ctrls = rep.enabledCtrls;
+ ctrls->num_groups= rep.numGroups;
+ if (which&XkbGroupsWrapMask)
+ ctrls->groups_wrap= rep.groupsWrap;
+ if (which&XkbInternalModsMask) {
+ ctrls->internal.mask = rep.internalMods;
+ ctrls->internal.real_mods = rep.internalRealMods;
+ ctrls->internal.vmods = rep.internalVMods;
+ }
+ if (which&XkbIgnoreLockModsMask) {
+ ctrls->ignore_lock.mask = rep.ignoreLockMods;
+ ctrls->ignore_lock.real_mods = rep.ignoreLockRealMods;
+ ctrls->ignore_lock.vmods = rep.ignoreLockVMods;
+ }
+ if (which&XkbRepeatKeysMask) {
+ ctrls->repeat_delay = rep.repeatDelay;
+ ctrls->repeat_interval = rep.repeatInterval;
+ }
+ if (which&XkbSlowKeysMask)
+ ctrls->slow_keys_delay = rep.slowKeysDelay;
+ if (which&XkbBounceKeysMask)
+ ctrls->debounce_delay = rep.debounceDelay;
+ if (which&XkbMouseKeysMask) {
+ ctrls->mk_dflt_btn = rep.mkDfltBtn;
+ }
+ if (which&XkbMouseKeysAccelMask) {
+ ctrls->mk_delay = rep.mkDelay;
+ ctrls->mk_interval = rep.mkInterval;
+ ctrls->mk_time_to_max = rep.mkTimeToMax;
+ ctrls->mk_max_speed = rep.mkMaxSpeed;
+ ctrls->mk_curve = rep.mkCurve;
+ }
+ if (which&XkbAccessXKeysMask)
+ ctrls->ax_options= rep.axOptions;
+ if (which&XkbAccessXTimeoutMask) {
+ ctrls->ax_timeout = rep.axTimeout;
+ ctrls->axt_ctrls_mask = rep.axtCtrlsMask;
+ ctrls->axt_ctrls_values = rep.axtCtrlsValues;
+ ctrls->axt_opts_mask = rep.axtOptsMask;
+ ctrls->axt_opts_values= rep.axtOptsValues;
+ }
+ if (which&XkbPerKeyRepeatMask) {
+ memcpy(ctrls->per_key_repeat,rep.perKeyRepeat,
+ XkbPerKeyBitArraySize);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return Success;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetControls(Display *dpy, unsigned long which, XkbDescPtr xkb)
+#else
+XkbSetControls(dpy, which, xkb)
+ Display * dpy;
+ unsigned long which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbSetControlsReq *req;
+ XkbControlsPtr ctrls;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->ctrls))
+ return False;
+
+ ctrls= xkb->ctrls;
+ LockDisplay(dpy);
+ req= _XkbGetSetControlsReq(dpy,dpy->xkb_info,xkb->device_spec);
+ req->changeCtrls = (CARD32)which;
+ if (which&XkbInternalModsMask) {
+ req->affectInternalMods= ~0;
+ req->internalMods= ctrls->internal.real_mods;
+ req->affectInternalVMods = ~0;
+ req->internalVMods= ctrls->internal.vmods;
+ }
+ if (which&XkbIgnoreLockModsMask) {
+ req->affectIgnoreLockMods= ~0;
+ req->ignoreLockMods= ctrls->ignore_lock.real_mods;
+ req->affectIgnoreLockVMods= ~0;
+ req->ignoreLockVMods= ctrls->ignore_lock.vmods;
+ }
+ if (which&XkbControlsEnabledMask) {
+ req->affectEnabledCtrls= XkbAllBooleanCtrlsMask;
+ req->enabledCtrls= ctrls->enabled_ctrls;
+ }
+ if (which&XkbRepeatKeysMask) {
+ req->repeatDelay = ctrls->repeat_delay;
+ req->repeatInterval = ctrls->repeat_interval;
+ }
+ if (which&XkbSlowKeysMask)
+ req->slowKeysDelay = ctrls->slow_keys_delay;
+ if (which&XkbBounceKeysMask)
+ req->debounceDelay = ctrls->debounce_delay;
+ if (which&XkbMouseKeysMask) {
+ req->mkDfltBtn = ctrls->mk_dflt_btn;
+ }
+ if (which&XkbGroupsWrapMask)
+ req->groupsWrap= ctrls->groups_wrap;
+ if (which&(XkbAccessXKeysMask|XkbStickyKeysMask|XkbAccessXFeedbackMask))
+ req->axOptions= ctrls->ax_options;
+ if (which&XkbMouseKeysAccelMask) {
+ req->mkDelay = ctrls->mk_delay;
+ req->mkInterval = ctrls->mk_interval;
+ req->mkTimeToMax = ctrls->mk_time_to_max;
+ req->mkMaxSpeed = ctrls->mk_max_speed;
+ req->mkCurve = ctrls->mk_curve;
+ }
+ if (which&XkbAccessXTimeoutMask) {
+ req->axTimeout = ctrls->ax_timeout;
+ req->axtCtrlsMask = ctrls->axt_ctrls_mask;
+ req->axtCtrlsValues = ctrls->axt_ctrls_values;
+ req->axtOptsMask = ctrls->axt_opts_mask;
+ req->axtOptsValues=ctrls->axt_opts_values;
+ }
+ if (which&XkbPerKeyRepeatMask) {
+ memcpy(req->perKeyRepeat,ctrls->per_key_repeat,
+ XkbPerKeyBitArraySize);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+}
+
+/***====================================================================***/
+
+void
+#if NeedFunctionPrototypes
+XkbNoteControlsChanges( XkbControlsChangesPtr old,
+ XkbControlsNotifyEvent * new,
+ unsigned int wanted)
+#else
+XkbNoteControlsChanges(old,new,wanted)
+ XkbControlsChangesPtr old;
+ XkbControlsNotifyEvent * new;
+ unsigned int wanted;
+#endif
+{
+ old->changed_ctrls|= (new->changed_ctrls&wanted);
+ if (new->changed_ctrls&XkbControlsEnabledMask&wanted)
+ old->enabled_ctrls_changes^= new->enabled_ctrl_changes;
+ /* num_groups_changed?? */
+ return;
+}
diff --git a/src/xkb/XKBCvt.c b/src/xkb/XKBCvt.c
new file mode 100644
index 00000000..bd965d24
--- /dev/null
+++ b/src/xkb/XKBCvt.c
@@ -0,0 +1,642 @@
+/* $Xorg: XKBCvt.c,v 1.5 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1988, 1989, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include <X11/X.h>
+#include <X11/Xlib.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPubI.h"
+#include <X11/Xutil.h>
+#include <X11/Xmd.h>
+#define XK_LATIN1
+#define XK_PUBLISHING
+#include <X11/keysym.h>
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+#include <X11/Xlocale.h>
+#include <ctype.h>
+#include <X11/Xos.h>
+
+#ifdef __sgi_not_xconsortium
+#define XKB_EXTEND_LOOKUP_STRING
+#endif
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+#if defined(__STDC__) && !defined(NORCONST)
+#define RConst const
+#else
+#define RConst /**/
+#endif
+
+/* bit (1<<i) means character is in codeset i at the same codepoint */
+extern unsigned int _Xlatin1[];
+
+/* bit (1<<i) means character is in codeset i at the same codepoint */
+extern unsigned int _Xlatin2[];
+
+/* maps Cyrillic keysyms to KOI8-R */
+extern unsigned char _Xkoi8[];
+
+extern unsigned short _Xkoi8_size;
+
+#define sLatin1 0
+#define sLatin2 1
+#define sLatin3 2
+#define sLatin4 3
+#define sKana 4
+#define sX0201 0x01000004
+#define sArabic 5
+#define sCyrillic 6
+#define sGreek 7
+#define sAPL 11
+#define sHebrew 12
+#define sThai 13
+#define sKorean 14
+#define sLatin5 15
+#define sLatin6 16
+#define sLatin7 17
+#define sLatin8 18
+#define sLatin9 19
+#define sCurrency 32
+
+
+static unsigned long WantLatin1 = sLatin1;
+static unsigned long WantLatin2 = sLatin2;
+static unsigned long WantLatin3 = sLatin3;
+static unsigned long WantLatin4 = sLatin4;
+static unsigned long WantLatin5 = sLatin5;
+static unsigned long WantLatin6 = sLatin6;
+static unsigned long WantKana = sKana;
+static unsigned long WantX0201 = sX0201;
+static unsigned long WantArabic = sArabic;
+static unsigned long WantCyrillic = sCyrillic;
+static unsigned long WantGreek = sGreek;
+static unsigned long WantAPL = sAPL;
+static unsigned long WantHebrew = sHebrew;
+
+static int
+#if NeedFunctionPrototypes
+_XkbHandleSpecialSym(KeySym keysym, char *buffer, int nbytes, int *extra_rtrn)
+#else
+_XkbHandleSpecialSym(keysym, buffer, nbytes, extra_rtrn)
+ KeySym keysym;
+ char *buffer;
+ int nbytes;
+ int * extra_rtrn;
+#endif
+{
+
+ /* try to convert to Latin-1, handling ctrl */
+ if (!(((keysym >= XK_BackSpace) && (keysym <= XK_Clear)) ||
+ (keysym == XK_Return) || (keysym == XK_Escape) ||
+ (keysym == XK_KP_Space) || (keysym == XK_KP_Tab) ||
+ (keysym == XK_KP_Enter) ||
+ ((keysym >= XK_KP_Multiply) && (keysym <= XK_KP_9)) ||
+ (keysym == XK_KP_Equal) ||
+ (keysym == XK_Delete)))
+ return 0;
+
+ if (nbytes<1) {
+ if (extra_rtrn)
+ *extra_rtrn= 1;
+ return 0;
+ }
+ /* if X keysym, convert to ascii by grabbing low 7 bits */
+ if (keysym == XK_KP_Space)
+ buffer[0] = XK_space & 0x7F; /* patch encoding botch */
+ else if (keysym == XK_hyphen)
+ buffer[0] = (char)(XK_minus & 0xFF); /* map to equiv character */
+ else buffer[0] = (char)(keysym & 0x7F);
+ return 1;
+}
+
+extern int
+_XGetCharCode (
+#if NeedFunctionPrototypes
+ unsigned long, KeySym, char*, int
+#endif
+);
+
+/*ARGSUSED*/
+int
+#if NeedFunctionPrototypes
+_XkbKSToKnownSet ( XPointer priv,
+ KeySym keysym,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+#else
+_XkbKSToKnownSet (priv, keysym, buffer, nbytes, extra_rtrn)
+ XPointer priv;
+ KeySym keysym;
+ char *buffer;
+ int nbytes;
+ int *extra_rtrn;
+#endif
+{
+ unsigned long kset,keysymSet;
+ int count,isLatin1;
+ char tbuf[8],*buf;
+
+ if (extra_rtrn)
+ *extra_rtrn= 0;
+
+ keysymSet = *((unsigned long *)priv);
+ kset = keysymSet&0xffffff;
+
+ /* convert "dead" diacriticals for dumb applications */
+ if ( (keysym&0xffffff00)== 0xfe00 ) {
+ switch ( keysym ) {
+ case XK_dead_grave: keysym = XK_grave; break;
+ case XK_dead_acute: keysym = XK_acute; break;
+ case XK_dead_circumflex: keysym = XK_asciicircum; break;
+ case XK_dead_tilde: keysym = XK_asciitilde; break;
+ case XK_dead_macron: keysym = XK_macron; break;
+ case XK_dead_breve: keysym = XK_breve; break;
+ case XK_dead_abovedot: keysym = XK_abovedot; break;
+ case XK_dead_diaeresis: keysym = XK_diaeresis; break;
+ case XK_dead_abovering: keysym = XK_degree; break;
+ case XK_dead_doubleacute: keysym = XK_doubleacute; break;
+ case XK_dead_caron: keysym = XK_caron; break;
+ case XK_dead_cedilla: keysym = XK_cedilla; break;
+ case XK_dead_ogonek : keysym = XK_ogonek; break;
+ case XK_dead_iota: keysym = XK_Greek_iota; break;
+#ifdef XK_KATAKANA
+ case XK_dead_voiced_sound: keysym = XK_voicedsound; break;
+ case XK_dead_semivoiced_sound:keysym = XK_semivoicedsound; break;
+#endif
+ }
+ }
+
+ isLatin1 = ((keysym&0xffffff00)==0);
+ count = 0;
+
+ if (nbytes<1) buf= tbuf;
+ else buf= buffer;
+
+ if ((keysym&0xffffff00)==0xff00) {
+ return _XkbHandleSpecialSym(keysym, buf, nbytes, extra_rtrn);
+ }
+ return _XGetCharCode (keysymSet, keysym, buf, nbytes);
+}
+
+typedef struct _XkbToKS {
+ unsigned prefix;
+ char *map;
+} XkbToKS;
+
+/*ARGSUSED*/
+static KeySym
+#if NeedFunctionPrototypes
+_XkbKnownSetToKS(XPointer priv,char *buffer,int nbytes,Status *status)
+#else
+_XkbKnownSetToKS(priv,buffer,nbytes,status)
+ XPointer priv;
+ char *buffer;
+ int nbytes;
+ Status *status;
+#endif
+{
+ if (nbytes!=1)
+ return NoSymbol;
+ if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
+ return buffer[0];
+ else if ((buffer[0]&0x7f)>=32) {
+ XkbToKS *map= (XkbToKS *)priv;
+ if ( map ) {
+ if ( map->map ) return map->prefix|map->map[buffer[0]&0x7f];
+ else return map->prefix|buffer[0];
+ }
+ return buffer[0];
+ }
+ return NoSymbol;
+}
+
+/*ARGSUSED*/
+int
+#if NeedFunctionPrototypes
+_XkbKSToThai ( XPointer priv,
+ KeySym keysym,
+ char * buffer,
+ int nbytes,
+ int * extra_rtrn)
+#else
+_XkbKSToThai (priv, keysym, buffer, nbytes, extra_rtrn)
+ XPointer priv;
+ KeySym keysym;
+ char *buffer;
+ int nbytes;
+ int *extra_rtrn;
+#endif
+{
+
+ if ((keysym&0xffffff00)==0xff00) {
+ return _XkbHandleSpecialSym(keysym, buffer, nbytes, extra_rtrn);
+ }
+ else if (((keysym&0xffffff80)==0xd80)||((keysym&0xffffff80)==0)) {
+ if (nbytes>0) {
+ buffer[0]= (char)(keysym&0xff);
+ if (nbytes>1)
+ buffer[1]= '\0';
+ return 1;
+ }
+ if (extra_rtrn)
+ *extra_rtrn= 1;
+ }
+ return 0;
+}
+
+/*ARGSUSED*/
+static KeySym
+#if NeedFunctionPrototypes
+_XkbThaiToKS(XPointer priv,char *buffer,int nbytes,Status *status)
+#else
+_XkbThaiToKS(priv,buffer,nbytes,status)
+ XPointer priv;
+ char *buffer;
+ int nbytes;
+ Status *status;
+#endif
+{
+ if (nbytes!=1)
+ return NoSymbol;
+ if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
+ return buffer[0];
+ else if ((buffer[0]&0x7f)>=32) {
+ return 0xd00|buffer[0];
+ }
+ return NoSymbol;
+}
+
+static KeySym
+#if NeedFunctionPrototypes
+__XkbDefaultToUpper(KeySym sym)
+#else
+__XkbDefaultToUpper(sym)
+ KeySym sym;
+#endif
+{
+ KeySym lower,upper;
+
+ XConvertCase(sym, &lower, &upper);
+ return upper;
+}
+
+int _XkbKSToKoi8 (priv, keysym, buffer, nbytes, status)
+ XPointer priv;
+ KeySym keysym;
+ char *buffer;
+ int nbytes;
+ Status *status;
+{
+ if ((keysym&0xffffff00)==0xff00) {
+ return _XkbHandleSpecialSym(keysym, buffer, nbytes, status);
+ }
+ else if (((keysym&0xffffff80)==0x680)||((keysym&0xffffff80)==0)) {
+ if (nbytes>0) {
+ if ( (keysym&0x80)==0 )
+ buffer[0] = keysym&0x7f;
+ else buffer[0] = _Xkoi8[keysym & 0x7f];
+ if (nbytes>1)
+ buffer[1]= '\0';
+ return 1;
+ }
+ }
+ return 0;
+}
+
+static KeySym
+_XkbKoi8ToKS(priv,buffer,nbytes,status)
+ XPointer priv;
+ char *buffer;
+ int nbytes;
+ Status *status;
+{
+ if (nbytes!=1)
+ return NoSymbol;
+ if (((buffer[0]&0x80)==0)&&(buffer[0]>=32))
+ return buffer[0];
+ else if ((buffer[0]&0x7f)>=32) {
+ register int i;
+ for (i=0;i<_Xkoi8_size;i++) {
+ if (_Xkoi8[i]==buffer[0])
+ return 0x680|i;
+ }
+ }
+ return NoSymbol;
+}
+
+/***====================================================================***/
+
+
+static XkbConverters RConst cvt_ascii = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin1,_XkbKnownSetToKS,NULL,__XkbDefaultToUpper
+};
+
+static XkbConverters RConst cvt_latin1 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin1,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_latin2 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin2,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_latin3 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin3,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_latin4 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin4,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_latin5 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin5,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_latin6 = {
+ _XkbKSToKnownSet,(XPointer)&WantLatin6,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_kana = {
+ _XkbKSToKnownSet,(XPointer)&WantKana,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_X0201 = {
+ _XkbKSToKnownSet,(XPointer)&WantX0201,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_Arabic = {
+ _XkbKSToKnownSet,(XPointer)&WantArabic,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_Cyrillic = {
+ _XkbKSToKnownSet,(XPointer)&WantCyrillic,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_Greek = {
+ _XkbKSToKnownSet,(XPointer)&WantGreek,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_APL = {
+ _XkbKSToKnownSet,(XPointer)&WantAPL,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters RConst cvt_Hebrew = {
+ _XkbKSToKnownSet,(XPointer)&WantHebrew,_XkbKnownSetToKS,NULL,NULL
+};
+
+static XkbConverters cvt_Thai = {
+ _XkbKSToThai, NULL, _XkbThaiToKS, NULL, NULL
+};
+
+static XkbConverters cvt_Koi8 = {
+ _XkbKSToKoi8, NULL, _XkbKoi8ToKS, NULL, NULL
+};
+
+static int
+#if NeedFunctionPrototypes
+Strcmp(char *str1, char *str2)
+#else
+Strcmp(str1, str2)
+ char *str1, *str2;
+#endif
+{
+ char str[256];
+ char c, *s;
+
+ if (strlen (str1) >= sizeof str) /* almost certain it's a mismatch */
+ return 1;
+
+ for (s = str; (c = *str1++); ) {
+ if (isupper(c))
+ c = tolower(c);
+ *s++ = c;
+ }
+ *s = '\0';
+ return (strcmp(str, str2));
+}
+
+int
+#if NeedFunctionPrototypes
+_XkbGetConverters(char *encoding_name, XkbConverters *cvt_rtrn)
+#else
+_XkbGetConverters(encoding_name, cvt_rtrn)
+ char *encoding_name;
+ XkbConverters *cvt_rtrn;
+#endif
+{
+ if ( cvt_rtrn ) {
+ if ( (encoding_name==NULL) ||
+ (Strcmp(encoding_name,"ascii")==0) ||
+ (Strcmp(encoding_name,"string")==0) )
+ *cvt_rtrn = cvt_ascii;
+ else if (Strcmp(encoding_name,"iso8859-1")==0)
+ *cvt_rtrn = cvt_latin1;
+ else if (Strcmp(encoding_name, "iso8859-2")==0)
+ *cvt_rtrn = cvt_latin2;
+ else if (Strcmp(encoding_name, "iso8859-3")==0)
+ *cvt_rtrn = cvt_latin3;
+ else if (Strcmp(encoding_name, "iso8859-4")==0)
+ *cvt_rtrn = cvt_latin4;
+ else if (Strcmp(encoding_name, "iso8859-5")==0)
+ *cvt_rtrn = cvt_Cyrillic;
+ else if (Strcmp(encoding_name, "iso8859-6")==0)
+ *cvt_rtrn = cvt_Arabic;
+ else if (Strcmp(encoding_name, "iso8859-7")==0)
+ *cvt_rtrn = cvt_Greek;
+ else if (Strcmp(encoding_name, "iso8859-8")==0)
+ *cvt_rtrn = cvt_Hebrew;
+ else if (Strcmp(encoding_name, "iso8859-9")==0)
+ *cvt_rtrn = cvt_latin5;
+ else if (Strcmp(encoding_name, "iso8859-10")==0)
+ *cvt_rtrn = cvt_latin6;
+ else if (Strcmp(encoding_name, "apl")==0)
+ *cvt_rtrn = cvt_APL;
+#if 0
+ else if (Strcmp(encoding_name, "ja.euc")==0)
+ *cvt_rtrn = ???;
+ else if (Strcmp(encoding_name, "ja.jis")==0)
+ *cvt_rtrn = ???;
+ else if (Strcmp(encoding_name, "ja.sjis")==0)
+ *cvt_rtrn = ???;
+#endif
+ else if (Strcmp(encoding_name, "jisx0201")==0) /* ??? */
+ *cvt_rtrn = cvt_X0201;
+ else if (Strcmp(encoding_name, "kana")==0) /* ??? */
+ *cvt_rtrn = cvt_kana;
+ else if ((Strcmp(encoding_name, "tactis")==0) ||
+ (Strcmp(encoding_name, "tis620.2533-1")==0))
+ *cvt_rtrn = cvt_Thai;
+ else if (Strcmp(encoding_name, "koi8-r")==0)
+ *cvt_rtrn = cvt_Koi8;
+ /* other codesets go here */
+ else *cvt_rtrn = cvt_latin1;
+ return 1;
+ }
+ *cvt_rtrn= cvt_latin1;
+ return 1;
+}
+
+/***====================================================================***/
+
+/*
+ * The function _XkbGetCharset seems to be missnamed as what it seems to
+ * be used for is to determine the encoding-name for the locale. ???
+ */
+
+#ifdef XKB_EXTEND_LOOKUP_STRING
+
+/*
+ * XKB_EXTEND_LOOKUP_STRING is not used by the SI. It is used by various
+ * X Consortium/X Project Team members, so we leave it in the source as
+ * an simplify integration by these companies.
+ */
+
+#define CHARSET_FILE "/usr/lib/X11/input/charsets"
+static char *_XkbKnownLanguages = "c=ascii:da,de,en,es,fi,fr,is,it,nl,no,pt,sv=iso8859-1:hu,pl,cs=iso8859-2:bg,ru=iso8859-5:ar,ara=iso8859-6:el=iso8859-7:th,th_TH,th_TH.TACTIS=tactis";
+
+char *
+_XkbGetCharset()
+{
+ /*
+ * PAGE USAGE TUNING: explicitly initialize to move these to data
+ * instead of bss
+ */
+ static char buf[100] = { 0 };
+ char lang[256];
+ char *start,*tmp,*end,*next,*set;
+ char *country,*charset;
+ char *locale;
+
+ tmp = getenv( "_XKB_CHARSET" );
+ if ( tmp )
+ return tmp;
+ locale = setlocale(LC_CTYPE,NULL);
+
+ if ( locale == NULL )
+ return NULL;
+
+ for (tmp = lang; *tmp = *locale++; tmp++) {
+ if (isupper(*tmp))
+ *tmp = tolower(*tmp);
+ }
+ country = strchr( lang, '_');
+ if ( country ) {
+ *country++ = '\0';
+ charset = strchr( country, '.' );
+ if ( charset ) *charset++ = '\0';
+ if ( charset ) {
+ strncpy(buf,charset,99);
+ buf[99] = '\0';
+ return buf;
+ }
+ }
+ else {
+ charset = NULL;
+ }
+
+ if ((tmp = getenv("_XKB_LOCALE_CHARSETS"))!=NULL) {
+ start = _XkbAlloc(strlen(tmp) + 1);
+ strcpy(start, tmp);
+ tmp = start;
+ } else {
+ struct stat sbuf;
+ FILE *file;
+ if ( (stat(CHARSET_FILE,&sbuf)==0) && (sbuf.st_mode&S_IFREG) &&
+ (file = fopen(CHARSET_FILE,"r")) ) {
+ tmp = _XkbAlloc(sbuf.st_size+1);
+ if (tmp!=NULL) {
+ sbuf.st_size = (long)fread(tmp,1,sbuf.st_size,file);
+ tmp[sbuf.st_size] = '\0';
+ }
+ fclose(file);
+ }
+ }
+
+ if ( tmp == NULL ) {
+ tmp = _XkbAlloc(strlen(_XkbKnownLanguages) + 1);
+ if (!tmp)
+ return NULL;
+ strcpy(tmp, _XkbKnownLanguages);
+ }
+ start = tmp;
+ do {
+ if ( (set=strchr(tmp,'=')) == NULL )
+ break;
+ *set++ = '\0';
+ if ( (next=strchr(set,':')) != NULL )
+ *next++ = '\0';
+ while ( tmp && *tmp ) {
+ if ( (end=strchr(tmp,',')) != NULL )
+ *end++ = '\0';
+ if ( Strcmp( tmp, lang ) == 0 ) {
+ strncpy(buf,set,100);
+ buf[99] = '\0';
+ Xfree(start);
+ return buf;
+ }
+ tmp = end;
+ }
+ tmp = next;
+ } while ( tmp && *tmp );
+ Xfree(start);
+ return NULL;
+}
+#else
+char *
+_XkbGetCharset()
+{
+ char *tmp;
+ XLCd lcd;
+
+ tmp = getenv( "_XKB_CHARSET" );
+ if ( tmp )
+ return tmp;
+
+ lcd = _XlcCurrentLC();
+ if ( lcd )
+ return XLC_PUBLIC(lcd,encoding_name);
+
+ return NULL;
+}
+#endif
+
diff --git a/src/xkb/XKBExtDev.c b/src/xkb/XKBExtDev.c
new file mode 100644
index 00000000..c4d99681
--- /dev/null
+++ b/src/xkb/XKBExtDev.c
@@ -0,0 +1,953 @@
+/* $Xorg: XKBExtDev.c,v 1.3 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+#include <X11/extensions/XI.h>
+
+/***====================================================================***/
+
+extern void
+#if NeedFunctionPrototypes
+XkbNoteDeviceChanges( XkbDeviceChangesPtr old,
+ XkbExtensionDeviceNotifyEvent * new,
+ unsigned int wanted)
+#else
+XkbNoteDeviceChanges(old,new,wanted)
+ XkbDeviceChangesPtr old;
+ XkbExtensionDeviceNotifyEvent * new;
+ unsigned int wanted;
+#endif
+{
+ if ((!old)||(!new)||(!wanted)||((new->reason&wanted)==0))
+ return;
+ if ((wanted&new->reason)&XkbXI_ButtonActionsMask) {
+ if (old->changed&XkbXI_ButtonActionsMask) {
+ int first,last,newLast;
+ if (new->first_btn<old->first_btn)
+ first= new->first_btn;
+ else first= old->first_btn;
+ last= old->first_btn+old->num_btns-1;
+ newLast= new->first_btn+new->num_btns-1;
+ if (newLast>last)
+ last= newLast;
+ old->first_btn= first;
+ old->num_btns= (last-first)+1;
+ }
+ else {
+ old->changed|= XkbXI_ButtonActionsMask;
+ old->first_btn= new->first_btn;
+ old->num_btns= new->num_btns;
+ }
+ }
+ if ((wanted&new->reason)&XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr this;
+ if (old->changed&XkbXI_IndicatorsMask) {
+ XkbDeviceLedChangesPtr found;
+ found= NULL;
+ for (this= &old->leds;this&&(!found);this=this->next) {
+ if ((this->led_class==new->led_class)&&
+ (this->led_id==new->led_id)) {
+ found= this;
+ }
+ }
+ if (!found) {
+ found= _XkbTypedCalloc(1,XkbDeviceLedChangesRec);
+ if (!found)
+ return;
+ found->next= old->leds.next;
+ found->led_class= new->led_class;
+ found->led_id= new->led_id;
+ old->leds.next= found;
+ }
+ if ((wanted&new->reason)&XkbXI_IndicatorNamesMask)
+ found->defined= new->leds_defined;
+ }
+ else {
+ old->changed|= ((wanted&new->reason)&XkbXI_IndicatorsMask);
+ old->leds.led_class= new->led_class;
+ old->leds.led_id= new->led_id;
+ old->leds.defined= new->leds_defined;
+ if (old->leds.next) {
+ XkbDeviceLedChangesPtr next;
+ for (this=old->leds.next;this;this=next) {
+ next= this->next;
+ _XkbFree(this);
+ }
+ old->leds.next= NULL;
+ }
+ }
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadDeviceLedInfo( XkbReadBufferPtr buf,
+ unsigned present,
+ XkbDeviceInfoPtr devi)
+#else
+_XkbReadDeviceLedInfo(buf,present,devi)
+ XkbReadBufferPtr buf;
+ unsigned present;
+ XkbDeviceInfoPtr devi;
+#endif
+{
+register unsigned i,bit;
+XkbDeviceLedInfoPtr devli;
+xkbDeviceLedsWireDesc * wireli;
+
+ wireli= _XkbGetTypedRdBufPtr(buf,1,xkbDeviceLedsWireDesc);
+ if (!wireli)
+ return BadLength;
+ devli= XkbAddDeviceLedInfo(devi,wireli->ledClass,wireli->ledID);
+ if (!devli)
+ return BadAlloc;
+ devli->phys_indicators= wireli->physIndicators;
+
+ if (present&XkbXI_IndicatorStateMask)
+ devli->state= wireli->state;
+
+ if (present&XkbXI_IndicatorNamesMask) {
+ devli->names_present= wireli->namesPresent;
+ if (devli->names_present) {
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (wireli->namesPresent&bit) {
+ if (!_XkbCopyFromReadBuffer(buf,(char *)&devli->names[i],4))
+ return BadLength;
+ }
+ }
+ }
+ }
+
+ if (present&XkbXI_IndicatorMapsMask) {
+ devli->maps_present= wireli->mapsPresent;
+ if (devli->maps_present) {
+ XkbIndicatorMapPtr im;
+ xkbIndicatorMapWireDesc * wireim;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (wireli->mapsPresent&bit) {
+ wireim= _XkbGetTypedRdBufPtr(buf,1,xkbIndicatorMapWireDesc);
+ if (!wireim)
+ return BadAlloc;
+ im= &devli->maps[i];
+ im->flags= wireim->flags;
+ im->which_groups= wireim->whichGroups;
+ im->groups= wireim->groups;
+ im->which_mods= wireim->whichMods;
+ im->mods.mask= wireim->mods;
+ im->mods.real_mods= wireim->realMods;
+ im->mods.vmods= wireim->virtualMods;
+ im->ctrls= wireim->ctrls;
+ }
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGetDeviceInfoReply( Display * dpy,
+ xkbGetDeviceInfoReply * rep,
+ XkbDeviceInfoPtr devi)
+#else
+_XkbReadGetDeviceInfoReply(dpy,rep,devi)
+ Display * dpy;
+ xkbGetDeviceInfoReply * rep;
+ XkbDeviceInfoPtr devi;
+#endif
+{
+XkbReadBufferRec buf;
+XkbAction * act;
+int tmp;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+
+ if ((rep->totalBtns>0)&&(rep->totalBtns!=devi->num_btns)) {
+ tmp= XkbResizeDeviceButtonActions(devi,rep->totalBtns);
+ if (tmp!=Success)
+ return tmp;
+ }
+ if (rep->nBtnsWanted>0) {
+ act= &devi->btn_acts[rep->firstBtnWanted];
+ bzero((char *)act,(rep->nBtnsWanted*sizeof(XkbAction)));
+ }
+ if (devi->name!=NULL)
+ _XkbFree(devi->name);
+ if (!_XkbGetReadBufferCountedString(&buf,&devi->name))
+ goto BAILOUT;
+ if (rep->nBtnsRtrn>0) {
+ int size;
+ act= &devi->btn_acts[rep->firstBtnRtrn];
+ size= rep->nBtnsRtrn*SIZEOF(xkbActionWireDesc);
+ if (!_XkbCopyFromReadBuffer(&buf,(char *)act,size))
+ goto BAILOUT;
+ }
+ if (rep->nDeviceLedFBs>0) {
+ register int i;
+ for (i=0;i<rep->nDeviceLedFBs;i++) {
+ if ((tmp= _XkbReadDeviceLedInfo(&buf,rep->present,devi))!=Success)
+ return tmp;
+ }
+ }
+ tmp= _XkbFreeReadBuffer(&buf);
+ if (tmp)
+ fprintf(stderr,"GetDeviceInfo! Bad length (%d extra bytes)\n",tmp);
+ if (tmp || buf.error)
+ return BadLength;
+ return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+XkbDeviceInfoPtr
+#if NeedFunctionPrototypes
+XkbGetDeviceInfo( Display * dpy,
+ unsigned which,
+ unsigned deviceSpec,
+ unsigned class,
+ unsigned id)
+#else
+XkbGetDeviceInfo(dpy,which,deviceSpec,class,id)
+ Display * dpy;
+ unsigned which;
+ unsigned deviceSpec;
+ unsigned class;
+ unsigned id;
+#endif
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+ XkbDeviceInfoPtr devi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return NULL;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = deviceSpec;
+ req->wanted= which;
+ req->allBtns= ((which&XkbXI_ButtonActionsMask)!=0);
+ req->firstBtn= req->nBtns= 0;
+ req->ledClass= class;
+ req->ledID= id;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+ }
+ devi= XkbAllocDeviceInfo(rep.deviceID,rep.totalBtns,rep.nDeviceLedFBs);
+ if (devi) {
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ devi->type= rep.devType;
+ devi->has_own_state= rep.hasOwnState;
+ devi->dflt_kbd_fb = rep.dfltKbdFB;
+ devi->dflt_led_fb = rep.dfltLedFB;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ if (status!=Success) {
+ XkbFreeDeviceInfo(devi,XkbXI_AllDeviceFeaturesMask,True);
+ devi= NULL;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return devi;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetDeviceInfoChanges( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
+#else
+XkbGetDeviceInfoChanges(dpy,devi,changes)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ XkbDeviceChangesPtr changes;
+#endif
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if ((changes->changed&XkbXI_AllDeviceFeaturesMask)==0)
+ return Success;
+ changes->changed&= ~XkbXI_AllDeviceFeaturesMask;
+ status= Success;
+ LockDisplay(dpy);
+ while ((changes->changed)&&(status==Success)) {
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= changes->changed;
+ req->allBtns= False;
+ if (changes->changed&XkbXI_ButtonActionsMask) {
+ req->firstBtn= changes->first_btn;
+ req->nBtns= changes->num_btns;
+ changes->changed&= ~XkbXI_ButtonActionsMask;
+ }
+ else req->firstBtn= req->nBtns= 0;
+ if (changes->changed&XkbXI_IndicatorsMask) {
+ req->ledClass= changes->leds.led_class;
+ req->ledID= changes->leds.led_id;
+ if (changes->leds.next==NULL)
+ changes->changed&= ~XkbXI_IndicatorsMask;
+ else {
+ XkbDeviceLedChangesPtr next;
+ next= changes->leds.next;
+ changes->leds= *next;
+ _XkbFree(next);
+ }
+ }
+ else {
+ req->ledClass= XkbDfltXIClass;
+ req->ledID= XkbDfltXIId;
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ status= BadLength;
+ break;
+ }
+ devi->supported|= rep.supported;
+ devi->unsupported|= rep.unsupported;
+ devi->type= rep.devType;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetDeviceButtonActions( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ Bool all,
+ unsigned int first,
+ unsigned int num)
+#else
+XkbGetDeviceButtonActions(dpy,devi,all,first,num)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ Bool all;
+ unsigned int first;
+ unsigned int num;
+#endif
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if (!devi)
+ return BadValue;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= XkbXI_ButtonActionsMask;
+ req->allBtns= all;
+ req->firstBtn= first;
+ req->nBtns= num;
+ req->ledClass= XkbDfltXIClass;
+ req->ledID= XkbDfltXIId;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ devi->type= rep.devType;
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetDeviceLedInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int ledClass,
+ unsigned int ledId,
+ unsigned int which)
+#else
+XkbGetDeviceLedInfo(dpy,devi,ledClass,ledId,which)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ unsigned int ledClass;
+ unsigned int ledId;
+ unsigned int which;
+#endif
+{
+ register xkbGetDeviceInfoReq * req;
+ xkbGetDeviceInfoReply rep;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadMatch;
+ if (((which&XkbXI_IndicatorsMask)==0)||(which&(~XkbXI_IndicatorsMask)))
+ return BadMatch;
+ if (!devi)
+ return BadValue;
+ LockDisplay(dpy);
+ GetReq(kbGetDeviceInfo, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetDeviceInfo;
+ req->deviceSpec = devi->device_spec;
+ req->wanted= which;
+ req->allBtns= False;
+ req->firstBtn= req->nBtns= 0;
+ req->ledClass= ledClass;
+ req->ledID= ledId;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadLength;
+ }
+ devi->type= rep.devType;
+ devi->supported= rep.supported;
+ devi->unsupported= rep.unsupported;
+ status= _XkbReadGetDeviceInfoReply(dpy,&rep,devi);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+/***====================================================================***/
+
+typedef struct _LedInfoStuff {
+ Bool used;
+ XkbDeviceLedInfoPtr devli;
+} LedInfoStuff;
+
+typedef struct _SetLedStuff {
+ unsigned wanted;
+ int num_info;
+ int dflt_class;
+ LedInfoStuff * dflt_kbd_fb;
+ LedInfoStuff * dflt_led_fb;
+ LedInfoStuff * info;
+} SetLedStuff;
+
+static void
+#if NeedFunctionPrototypes
+_InitLedStuff(SetLedStuff *stuff,unsigned wanted,XkbDeviceInfoPtr devi)
+#else
+_InitLedStuff(stuff,wanted,devi)
+ SetLedStuff * stuff;
+ unsigned wanted;
+ XkbDeviceInfoPtr devi;
+#endif
+{
+int i;
+register XkbDeviceLedInfoPtr devli;
+
+ bzero(stuff,sizeof(SetLedStuff));
+ stuff->wanted= wanted;
+ stuff->dflt_class= XkbXINone;
+ if ((devi->num_leds<1)||((wanted&XkbXI_IndicatorsMask)==0))
+ return;
+ stuff->info= _XkbTypedCalloc(devi->num_leds,LedInfoStuff);
+ if (!stuff->info)
+ return;
+ stuff->num_info= devi->num_leds;
+ for (devli=&devi->leds[0],i=0;i<devi->num_leds;i++,devli++) {
+ stuff->info[i].devli= devli;
+ if (devli->led_class==KbdFeedbackClass) {
+ stuff->dflt_class= KbdFeedbackClass;
+ if (stuff->dflt_kbd_fb==NULL)
+ stuff->dflt_kbd_fb= &stuff->info[i];
+ }
+ else if (devli->led_class==LedFeedbackClass) {
+ if (stuff->dflt_class==XkbXINone)
+ stuff->dflt_class= LedFeedbackClass;
+ if (stuff->dflt_led_fb==NULL)
+ stuff->dflt_led_fb= &stuff->info[i];
+ }
+ }
+ return;
+}
+
+static void
+#if NeedFunctionPrototypes
+_FreeLedStuff(SetLedStuff *stuff)
+#else
+_FreeLedStuff(stuff)
+ SetLedStuff *stuff;
+#endif
+{
+ if ((stuff->num_info>0)&&(stuff->info!=NULL))
+ _XkbFree(stuff->info);
+ bzero(stuff,sizeof(SetLedStuff));
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeLedInfo(unsigned changed,XkbDeviceLedInfoPtr devli)
+#else
+_XkbSizeLedInfo(changed,devli)
+ unsigned changed;
+ XkbDeviceLedInfoPtr devli;
+#endif
+{
+register int i,size;
+register unsigned bit,namesNeeded,mapsNeeded;
+
+ size= SIZEOF(xkbDeviceLedsWireDesc);
+ namesNeeded= mapsNeeded= 0;
+ if (changed&XkbXI_IndicatorNamesMask)
+ namesNeeded= devli->names_present;
+ if (changed&XkbXI_IndicatorMapsMask)
+ mapsNeeded= devli->maps_present;
+ if ((namesNeeded)||(mapsNeeded)) {
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (namesNeeded&bit)
+ size+= 4; /* atoms are 4 bytes on the wire */
+ if (mapsNeeded&bit)
+ size+= SIZEOF(xkbIndicatorMapWireDesc);
+ }
+ }
+ return size;
+}
+
+static Bool
+#if NeedFunctionPrototypes
+_SizeMatches( SetLedStuff * stuff,
+ XkbDeviceLedChangesPtr changes,
+ int * sz_rtrn,
+ int * nleds_rtrn)
+#else
+_SizeMatches(stuff,changes,sz_rtrn,nleds_rtrn)
+ SetLedStuff * stuff;
+ XkbDeviceLedChangesPtr changes;
+ int * sz_rtrn;
+ int * nleds_rtrn;
+#endif
+{
+int i,nMatch,class,id;
+LedInfoStuff * linfo;
+Bool match;
+
+ nMatch= 0;
+ class= changes->led_class;
+ id= changes->led_id;
+ if (class==XkbDfltXIClass)
+ class= stuff->dflt_class;
+ for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
+ XkbDeviceLedInfoPtr devli;
+ LedInfoStuff * dflt;
+
+ devli= linfo->devli;
+ match= ((class==devli->led_class)||(class==XkbAllXIClasses));
+ if (devli->led_class==KbdFeedbackClass) dflt= stuff->dflt_kbd_fb;
+ else dflt= stuff->dflt_led_fb;
+ match= match && (id==devli->led_id) || (id==XkbAllXIIds) ||
+ ((id==XkbDfltXIId)&&(linfo==dflt));
+ if (match) {
+ if (!linfo->used) {
+ *sz_rtrn+= _XkbSizeLedInfo(stuff->wanted,devli);
+ *nleds_rtrn+= 1;
+ linfo->used= True;
+ if ((class!=XkbAllXIClasses)&&(id!=XkbAllXIIds))
+ return True;
+ }
+ nMatch++;
+ linfo->used= True;
+ }
+ }
+ return (nMatch>0);
+}
+
+/***====================================================================***/
+
+
+static Status
+#if NeedFunctionPrototypes
+_XkbSetDeviceInfoSize( XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff * stuff,
+ int * sz_rtrn,
+ int * num_leds_rtrn)
+#else
+_XkbSetDeviceInfoSize(devi,changes,stuff,sz_rtrn,num_leds_rtrn)
+ XkbDeviceInfoPtr devi;
+ XkbDeviceChangesPtr changes;
+ SetLedStuff * stuff;
+ int * sz_rtrn;
+ int * num_leds_rtrn;
+#endif
+{
+ *sz_rtrn= 0;
+ if ((changes->changed&XkbXI_ButtonActionsMask)&&(changes->num_btns>0)) {
+ if (!XkbXI_LegalDevBtn(devi,(changes->first_btn+changes->num_btns-1)))
+ return BadMatch;
+ *sz_rtrn+= changes->num_btns*SIZEOF(xkbActionWireDesc);
+ }
+ else {
+ changes->changed&= ~XkbXI_ButtonActionsMask;
+ changes->first_btn= changes->num_btns= 0;
+ }
+ if ((changes->changed&XkbXI_IndicatorsMask)&&
+ XkbLegalXILedClass(changes->leds.led_class)) {
+ XkbDeviceLedChangesPtr leds;
+
+ for (leds=&changes->leds;leds!=NULL;leds= leds->next) {
+ if (!_SizeMatches(stuff,leds,sz_rtrn,num_leds_rtrn))
+ return BadMatch;
+ }
+ }
+ else {
+ changes->changed&= ~XkbXI_IndicatorsMask;
+ *num_leds_rtrn= 0;
+ }
+ return Success;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_XkbWriteLedInfo(char *wire,unsigned changed,XkbDeviceLedInfoPtr devli)
+#else
+_XkbWriteLedInfo(wire,changed,devli)
+ char * wire;
+ unsigned changed;
+ XkbDeviceLedInfoPtr devli;
+#endif
+{
+register int i;
+register unsigned bit,namesNeeded,mapsNeeded;
+xkbDeviceLedsWireDesc * lwire;
+
+ namesNeeded= mapsNeeded= 0;
+ if (changed&XkbXI_IndicatorNamesMask)
+ namesNeeded= devli->names_present;
+ if (changed&XkbXI_IndicatorMapsMask)
+ mapsNeeded= devli->maps_present;
+
+ lwire= (xkbDeviceLedsWireDesc *)wire;
+ lwire->ledClass= devli->led_class;
+ lwire->ledID= devli->led_id;
+ lwire->namesPresent= namesNeeded;
+ lwire->mapsPresent= mapsNeeded;
+ lwire->physIndicators= devli->phys_indicators;
+ lwire->state= devli->state;
+ wire= (char *)&lwire[1];
+ if (namesNeeded) {
+ CARD32 *awire;
+ awire= (CARD32 *)wire;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (namesNeeded&bit) {
+ *awire= (CARD32)devli->names[i];
+ awire++;
+ }
+ }
+ wire= (char *)awire;
+ }
+ if (mapsNeeded) {
+ xkbIndicatorMapWireDesc *mwire;
+
+ mwire= (xkbIndicatorMapWireDesc *)wire;
+ for (i=0,bit=1;i<XkbNumIndicators;i++,bit<<=1) {
+ if (mapsNeeded&bit) {
+ XkbIndicatorMapPtr map;
+ map= &devli->maps[i];
+ mwire->flags= map->flags;
+ mwire->whichGroups= map->which_groups;
+ mwire->groups= map->groups;
+ mwire->whichMods= map->which_mods;
+ mwire->mods= map->mods.mask;
+ mwire->realMods= map->mods.real_mods;
+ mwire->virtualMods= map->mods.vmods;
+ mwire->ctrls= map->ctrls;
+ mwire++;
+ }
+ }
+ wire= (char *)mwire;
+ }
+ return wire;
+}
+
+
+static int
+#if NeedFunctionPrototypes
+_XkbWriteSetDeviceInfo( char * wire,
+ XkbDeviceChangesPtr changes,
+ SetLedStuff * stuff,
+ XkbDeviceInfoPtr devi)
+#else
+_XkbWriteSetDeviceInfo(wire,changes,stuff,devi)
+ char * wire;
+ XkbDeviceChangesPtr changes;
+ SetLedStuff * stuff;
+ XkbDeviceInfoPtr devi;
+#endif
+{
+char *start;
+
+ start= wire;
+ if (changes->changed&XkbXI_ButtonActionsMask) {
+ int size;
+ size= changes->num_btns*SIZEOF(xkbActionWireDesc);
+ memcpy(wire,(char *)&devi->btn_acts[changes->first_btn],size);
+ wire+= size;
+ }
+ if (changes->changed&XkbXI_IndicatorsMask) {
+ register int i;
+ register LedInfoStuff *linfo;
+
+ for (i=0,linfo=&stuff->info[0];i<stuff->num_info;i++,linfo++) {
+ if (linfo->used) {
+ register char *new_wire;
+ new_wire= _XkbWriteLedInfo(wire,stuff->wanted,linfo->devli);
+ if (!new_wire)
+ return wire-start;
+ wire= new_wire;
+ }
+ }
+ }
+ return wire-start;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetDeviceInfo( Display * dpy,
+ unsigned which,
+ XkbDeviceInfoPtr devi)
+#else
+XkbSetDeviceInfo(dpy,which,devi)
+ Display * dpy;
+ unsigned which;
+ XkbDeviceInfoPtr devi;
+#endif
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi) || (which&(~XkbXI_AllDeviceFeaturesMask)) ||
+ ((which&XkbXI_ButtonActionsMask)&&(!XkbXI_DevHasBtnActs(devi)))||
+ ((which&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
+ changes.changed= which;
+ changes.first_btn= 0;
+ changes.num_btns= devi->num_btns;
+ changes.leds.led_class= XkbAllXIClasses;
+ changes.leds.led_id= XkbAllXIIds;
+ changes.leds.defined= 0;
+ size= nLeds= 0;
+ _InitLedStuff(&lstuff,changes.changed,devi);
+ if (_XkbSetDeviceInfoSize(devi,&changes,&lstuff,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes.first_btn;
+ req->nBtns= changes.num_btns;
+ req->change= changes.changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _FreeLedStuff(&lstuff);
+ /* 12/11/95 (ef) -- XXX!! should clear changes here */
+ return ok;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbChangeDeviceInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ XkbDeviceChangesPtr changes)
+#else
+XkbChangeDeviceInfo(dpy,devi,changes)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ XkbDeviceChangesPtr changes;
+#endif
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi) || (changes->changed&(~XkbXI_AllDeviceFeaturesMask)) ||
+ ((changes->changed&XkbXI_ButtonActionsMask)&&
+ (!XkbXI_DevHasBtnActs(devi)))||
+ ((changes->changed&XkbXI_IndicatorsMask)&&(!XkbXI_DevHasLeds(devi))))
+ return False;
+
+ size= nLeds= 0;
+ _InitLedStuff(&lstuff,changes->changed,devi);
+ if (_XkbSetDeviceInfoSize(devi,changes,&lstuff,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes->first_btn;
+ req->nBtns= changes->num_btns;
+ req->change= changes->changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ _FreeLedStuff(&lstuff);
+ /* 12/11/95 (ef) -- XXX!! should clear changes here */
+ return ok;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetDeviceLedInfo( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned ledClass,
+ unsigned ledID,
+ unsigned which)
+#else
+XkbSetDeviceLedInfo(dpy,devi,ledClass,ledID,which)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ unsigned ledClass;
+ unsigned ledID;
+ unsigned which;
+#endif
+{
+ return False;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetDeviceButtonActions( Display * dpy,
+ XkbDeviceInfoPtr devi,
+ unsigned int first,
+ unsigned int nBtns)
+#else
+XkbSetDeviceButtonActions(dpy,devi,first,nBtns)
+ Display * dpy;
+ XkbDeviceInfoPtr devi;
+ unsigned int first;
+ unsigned int nBtns;
+#endif
+{
+ register xkbSetDeviceInfoReq *req;
+ Status ok;
+ int size,nLeds;
+ XkbInfoPtr xkbi;
+ XkbDeviceChangesRec changes;
+ SetLedStuff lstuff;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!devi)||(!XkbXI_DevHasBtnActs(devi))||(first+nBtns>devi->num_btns))
+ return False;
+ if (nBtns==0)
+ return True;
+
+ bzero((char *)&changes,sizeof(XkbDeviceChangesRec));
+ changes.changed= XkbXI_ButtonActionsMask;
+ changes.first_btn= first;
+ changes.num_btns= nBtns;
+ changes.leds.led_class= XkbXINone;
+ changes.leds.led_id= XkbXINone;
+ changes.leds.defined= 0;
+ size= nLeds= 0;
+ if (_XkbSetDeviceInfoSize(devi,&changes,NULL,&size,&nLeds)!=Success)
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetDeviceInfo, req);
+ req->length+= size/4;
+ req->reqType= xkbi->codes->major_opcode;
+ req->xkbReqType= X_kbSetDeviceInfo;
+ req->deviceSpec= devi->device_spec;
+ req->firstBtn= changes.first_btn;
+ req->nBtns= changes.num_btns;
+ req->change= changes.changed;
+ req->nDeviceLedFBs= nLeds;
+ if (size>0) {
+ char * wire;
+ BufAlloc(char *,wire,size);
+ ok= (wire!=NULL)&&
+ (_XkbWriteSetDeviceInfo(wire,&changes,&lstuff,devi)==size);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ok;
+}
diff --git a/src/xkb/XKBGAlloc.c b/src/xkb/XKBGAlloc.c
new file mode 100644
index 00000000..c89e1197
--- /dev/null
+++ b/src/xkb/XKBGAlloc.c
@@ -0,0 +1,1377 @@
+/* $Xorg: XKBGAlloc.c,v 1.3 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+
+#else
+
+#include <stdio.h>
+#include "X.h"
+#include "Xproto.h"
+#include "misc.h"
+#include "inputstr.h"
+#include "XKBsrv.h"
+#include "XKBgeom.h"
+
+#endif /* XKB_IN_SERVER */
+
+#ifdef X_NOT_POSIX
+#define Size_t unsigned int
+#else
+#define Size_t size_t
+#endif
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbFreeGeomLeafElems( Bool freeAll,
+ int first,
+ int count,
+ unsigned short * num_inout,
+ unsigned short * sz_inout,
+ char ** elems,
+ unsigned int elem_sz)
+#else
+_XkbFreeGeomLeafElems(freeAll,first,count,num_inout,sz_inout,elems,elem_sz)
+ Bool freeAll;
+ int first;
+ int count;
+ unsigned short * num_inout;
+ unsigned short * sz_inout;
+ char ** elems;
+ unsigned int elem_sz;
+#endif
+{
+ if ((freeAll)||(*elems==NULL)) {
+ *num_inout= *sz_inout= 0;
+ if (*elems!=NULL) {
+ _XkbFree(*elems);
+ *elems= NULL;
+ }
+ return;
+ }
+
+ if ((first>=(*num_inout))||(first<0)||(count<1))
+ return;
+
+ if (first+count>=(*num_inout)) {
+ /* truncating the array is easy */
+ (*num_inout)= first;
+ }
+ else {
+ char * ptr;
+ int extra;
+ ptr= *elems;
+ extra= ((*num_inout)-(first+count))*elem_sz;
+ if (extra>0)
+ memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],extra);
+ (*num_inout)-= count;
+ }
+ return;
+}
+
+typedef void (*ContentsClearFunc)(
+#if NeedFunctionPrototypes
+ char * /* priv */
+#endif
+);
+
+static void
+#if NeedFunctionPrototypes
+_XkbFreeGeomNonLeafElems( Bool freeAll,
+ int first,
+ int count,
+ unsigned short * num_inout,
+ unsigned short * sz_inout,
+ char ** elems,
+ unsigned int elem_sz,
+ ContentsClearFunc freeFunc)
+#else
+_XkbFreeGeomNonLeafElems(freeAll,first,count,num_inout,sz_inout,elems,elem_sz,
+ freeFunc)
+ Bool freeAll;
+ int first;
+ int count;
+ unsigned short * num_inout;
+ unsigned short * sz_inout;
+ char ** elems;
+ unsigned int elem_sz;
+ ContentsClearFunc freeFunc;
+#endif
+{
+register int i;
+register char *ptr;
+
+ if (freeAll) {
+ first= 0;
+ count= (*num_inout);
+ }
+ else if ((first>=(*num_inout))||(first<0)||(count<1))
+ return;
+ else if (first+count>(*num_inout))
+ count= (*num_inout)-first;
+ if (*elems==NULL)
+ return;
+
+ if (freeFunc) {
+ ptr= *elems;
+ ptr+= first*elem_sz;
+ for (i=0;i<count;i++) {
+ (*freeFunc)(ptr);
+ ptr+= elem_sz;
+ }
+ }
+ if (freeAll) {
+ (*num_inout)= (*sz_inout)= 0;
+ if (*elems) {
+ _XkbFree(*elems);
+ *elems= NULL;
+ }
+ }
+ else if (first+count>=(*num_inout))
+ *num_inout= first;
+ else {
+ i= ((*num_inout)-(first+count))*elem_sz;
+ ptr= *elems;
+ memmove(&ptr[first*elem_sz],&ptr[(first+count)*elem_sz],i);
+ (*num_inout)-= count;
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearProperty(char *prop_in)
+#else
+_XkbClearProperty(prop_in)
+ char * prop_in;
+#endif
+{
+XkbPropertyPtr prop= (XkbPropertyPtr)prop_in;
+
+ if (prop->name) {
+ _XkbFree(prop->name);
+ prop->name= NULL;
+ }
+ if (prop->value) {
+ _XkbFree(prop->value);
+ prop->value= NULL;
+ }
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomProperties( XkbGeometryPtr geom,
+ int first,
+ int count,
+ Bool freeAll)
+#else
+XkbFreeGeomProperties(geom,first,count,freeAll)
+ XkbGeometryPtr geom;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_properties,&geom->sz_properties,
+ (char **)&geom->properties,
+ sizeof(XkbPropertyRec),_XkbClearProperty);
+ return;
+}
+
+/***====================================================================***/
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomKeyAliases( XkbGeometryPtr geom,
+ int first,
+ int count,
+ Bool freeAll)
+#else
+XkbFreeGeomKeyAliases(geom,first,count,freeAll)
+ XkbGeometryPtr geom;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &geom->num_key_aliases,&geom->sz_key_aliases,
+ (char **)&geom->key_aliases,
+ sizeof(XkbKeyAliasRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearColor(char *color_in)
+#else
+_XkbClearColor(color_in)
+ char * color_in;
+#endif
+{
+XkbColorPtr color= (XkbColorPtr)color_in;
+
+ if (color->spec)
+ _XkbFree(color->spec);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomColors(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomColors(geom,first,count,freeAll)
+ XkbGeometryPtr geom;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_colors,&geom->sz_colors,
+ (char **)&geom->colors,
+ sizeof(XkbColorRec),_XkbClearColor);
+ return;
+}
+
+/***====================================================================***/
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomPoints(XkbOutlinePtr outline,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomPoints(outline,first,count,freeAll)
+ XkbOutlinePtr outline;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &outline->num_points,&outline->sz_points,
+ (char **)&outline->points,
+ sizeof(XkbPointRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearOutline(char *outline_in)
+#else
+_XkbClearOutline(outline_in)
+ char * outline_in;
+#endif
+{
+XkbOutlinePtr outline= (XkbOutlinePtr)outline_in;
+
+ if (outline->points!=NULL)
+ XkbFreeGeomPoints(outline,0,outline->num_points,True);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomOutlines(XkbShapePtr shape,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomOutlines(shape,first,count,freeAll)
+ XkbShapePtr shape;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &shape->num_outlines,&shape->sz_outlines,
+ (char **)&shape->outlines,
+ sizeof(XkbOutlineRec),_XkbClearOutline);
+
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearShape(char *shape_in)
+#else
+_XkbClearShape(shape_in)
+ char * shape_in;
+#endif
+{
+XkbShapePtr shape= (XkbShapePtr)shape_in;
+
+ if (shape->outlines)
+ XkbFreeGeomOutlines(shape,0,shape->num_outlines,True);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomShapes(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomShapes(geom,first,count,freeAll)
+ XkbGeometryPtr geom;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_shapes,&geom->sz_shapes,
+ (char **)&geom->shapes,
+ sizeof(XkbShapeRec),_XkbClearShape);
+ return;
+}
+
+/***====================================================================***/
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomOverlayKeys(XkbOverlayRowPtr row,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomOverlayKeys(row,first,count,freeAll)
+ XkbOverlayRowPtr row;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &row->num_keys,&row->sz_keys,
+ (char **)&row->keys,
+ sizeof(XkbOverlayKeyRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearOverlayRow(char *row_in)
+#else
+_XkbClearOverlayRow(row_in)
+ char * row_in;
+#endif
+{
+XkbOverlayRowPtr row= (XkbOverlayRowPtr)row_in;
+
+ if (row->keys!=NULL)
+ XkbFreeGeomOverlayKeys(row,0,row->num_keys,True);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomOverlayRows(XkbOverlayPtr overlay,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomOverlayRows(overlay,first,count,freeAll)
+ XkbOverlayPtr overlay;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &overlay->num_rows,&overlay->sz_rows,
+ (char **)&overlay->rows,
+ sizeof(XkbOverlayRowRec),_XkbClearOverlayRow);
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearOverlay(char *overlay_in)
+#else
+_XkbClearOverlay(overlay_in)
+ char * overlay_in;
+#endif
+{
+XkbOverlayPtr overlay= (XkbOverlayPtr)overlay_in;
+
+ if (overlay->rows!=NULL)
+ XkbFreeGeomOverlayRows(overlay,0,overlay->num_rows,True);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomOverlays(XkbSectionPtr section,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomOverlays(section,first,count,freeAll)
+ XkbSectionPtr section;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &section->num_overlays,&section->sz_overlays,
+ (char **)&section->overlays,
+ sizeof(XkbOverlayRec),_XkbClearOverlay);
+ return;
+}
+
+/***====================================================================***/
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomKeys(XkbRowPtr row,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomKeys(row,first,count,freeAll)
+ XkbRowPtr row;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomLeafElems(freeAll,first,count,
+ &row->num_keys,&row->sz_keys,
+ (char **)&row->keys,
+ sizeof(XkbKeyRec));
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearRow(char *row_in)
+#else
+_XkbClearRow(row_in)
+ char * row_in;
+#endif
+{
+XkbRowPtr row= (XkbRowPtr)row_in;
+
+ if (row->keys!=NULL)
+ XkbFreeGeomKeys(row,0,row->num_keys,True);
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomRows(XkbSectionPtr section,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomRows(section,first,count,freeAll)
+ XkbSectionPtr section;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &section->num_rows,&section->sz_rows,
+ (char **)&section->rows,
+ sizeof(XkbRowRec),_XkbClearRow);
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearSection(char *section_in)
+#else
+_XkbClearSection(section_in)
+ char * section_in;
+#endif
+{
+XkbSectionPtr section= (XkbSectionPtr)section_in;
+
+ if (section->rows!=NULL)
+ XkbFreeGeomRows(section,0,section->num_rows,True);
+ if (section->doodads!=NULL) {
+ XkbFreeGeomDoodads(section->doodads,section->num_doodads,True);
+ section->doodads= NULL;
+ }
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomSections(XkbGeometryPtr geom,int first,int count,Bool freeAll)
+#else
+XkbFreeGeomSections(geom,first,count,freeAll)
+ XkbGeometryPtr geom;
+ int first;
+ int count;
+ Bool freeAll;
+#endif
+{
+ _XkbFreeGeomNonLeafElems(freeAll,first,count,
+ &geom->num_sections,&geom->sz_sections,
+ (char **)&geom->sections,
+ sizeof(XkbSectionRec),_XkbClearSection);
+ return;
+}
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbClearDoodad(char *doodad_in)
+#else
+_XkbClearDoodad(doodad_in)
+ char * doodad_in;
+#endif
+{
+XkbDoodadPtr doodad= (XkbDoodadPtr)doodad_in;
+
+ switch (doodad->any.type) {
+ case XkbTextDoodad:
+ {
+ if (doodad->text.text!=NULL) {
+ _XkbFree(doodad->text.text);
+ doodad->text.text= NULL;
+ }
+ if (doodad->text.font!=NULL) {
+ _XkbFree(doodad->text.font);
+ doodad->text.font= NULL;
+ }
+ }
+ break;
+ case XkbLogoDoodad:
+ {
+ if (doodad->logo.logo_name!=NULL) {
+ _XkbFree(doodad->logo.logo_name);
+ doodad->logo.logo_name= NULL;
+ }
+ }
+ break;
+ }
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeomDoodads(XkbDoodadPtr doodads,int nDoodads,Bool freeAll)
+#else
+XkbFreeGeomDoodads(doodads,nDoodads,freeAll)
+ XkbDoodadPtr doodads;
+ int nDoodads;
+ Bool freeAll;
+#endif
+{
+register int i;
+register XkbDoodadPtr doodad;
+
+ if (doodads) {
+ for (i=0,doodad= doodads;i<nDoodads;i++,doodad++) {
+ _XkbClearDoodad((char *)doodad);
+ }
+ if (freeAll)
+ _XkbFree(doodads);
+ }
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeGeometry(XkbGeometryPtr geom,unsigned which,Bool freeMap)
+#else
+XkbFreeGeometry(geom,which,freeMap)
+ XkbGeometryPtr geom;
+ unsigned which;
+ Bool freeMap;
+#endif
+{
+ if (geom==NULL)
+ return;
+ if (freeMap)
+ which= XkbGeomAllMask;
+ if ((which&XkbGeomPropertiesMask)&&(geom->properties!=NULL))
+ XkbFreeGeomProperties(geom,0,geom->num_properties,True);
+ if ((which&XkbGeomColorsMask)&&(geom->colors!=NULL))
+ XkbFreeGeomColors(geom,0,geom->num_colors,True);
+ if ((which&XkbGeomShapesMask)&&(geom->shapes!=NULL))
+ XkbFreeGeomShapes(geom,0,geom->num_shapes,True);
+ if ((which&XkbGeomSectionsMask)&&(geom->sections!=NULL))
+ XkbFreeGeomSections(geom,0,geom->num_sections,True);
+ if ((which&XkbGeomDoodadsMask)&&(geom->doodads!= NULL)) {
+ XkbFreeGeomDoodads(geom->doodads,geom->num_doodads,True);
+ geom->doodads= NULL;
+ geom->num_doodads= geom->sz_doodads= 0;
+ }
+ if ((which&XkbGeomKeyAliasesMask)&&(geom->key_aliases!=NULL))
+ XkbFreeGeomKeyAliases(geom,0,geom->num_key_aliases,True);
+ if (freeMap) {
+ if (geom->label_font!=NULL) {
+ _XkbFree(geom->label_font);
+ geom->label_font= NULL;
+ }
+ _XkbFree(geom);
+ }
+ return;
+}
+
+/***====================================================================***/
+
+static Status
+#if NeedFunctionPrototypes
+_XkbGeomAlloc( XPointer * old,
+ unsigned short * num,
+ unsigned short * total,
+ int num_new,
+ Size_t sz_elem)
+#else
+_XkbGeomAlloc(old,num,total,num_new,sz_elem)
+ XPointer * old;
+ unsigned short * num;
+ unsigned short * total;
+ int num_new;
+ Size_t sz_elem;
+#endif
+{
+ if (num_new<1)
+ return Success;
+ if ((*old)==NULL)
+ *num= *total= 0;
+
+ if ((*num)+num_new<=(*total))
+ return Success;
+
+ *total= (*num)+num_new;
+ if ((*old)!=NULL)
+ (*old)= (XPointer)_XkbRealloc((*old),(*total)*sz_elem);
+ else (*old)= (XPointer)_XkbCalloc((*total),sz_elem);
+ if ((*old)==NULL) {
+ *total= *num= 0;
+ return BadAlloc;
+ }
+
+ if (*num>0) {
+ char *tmp= (char *)(*old);
+ bzero(&tmp[sz_elem*(*num)],(num_new*sz_elem));
+ }
+ return Success;
+}
+
+#define _XkbAllocProps(g,n) _XkbGeomAlloc((XPointer *)&(g)->properties,\
+ &(g)->num_properties,&(g)->sz_properties,\
+ (n),sizeof(XkbPropertyRec))
+#define _XkbAllocColors(g,n) _XkbGeomAlloc((XPointer *)&(g)->colors,\
+ &(g)->num_colors,&(g)->sz_colors,\
+ (n),sizeof(XkbColorRec))
+#define _XkbAllocShapes(g,n) _XkbGeomAlloc((XPointer *)&(g)->shapes,\
+ &(g)->num_shapes,&(g)->sz_shapes,\
+ (n),sizeof(XkbShapeRec))
+#define _XkbAllocSections(g,n) _XkbGeomAlloc((XPointer *)&(g)->sections,\
+ &(g)->num_sections,&(g)->sz_sections,\
+ (n),sizeof(XkbSectionRec))
+#define _XkbAllocDoodads(g,n) _XkbGeomAlloc((XPointer *)&(g)->doodads,\
+ &(g)->num_doodads,&(g)->sz_doodads,\
+ (n),sizeof(XkbDoodadRec))
+#define _XkbAllocKeyAliases(g,n) _XkbGeomAlloc((XPointer *)&(g)->key_aliases,\
+ &(g)->num_key_aliases,&(g)->sz_key_aliases,\
+ (n),sizeof(XkbKeyAliasRec))
+
+#define _XkbAllocOutlines(s,n) _XkbGeomAlloc((XPointer *)&(s)->outlines,\
+ &(s)->num_outlines,&(s)->sz_outlines,\
+ (n),sizeof(XkbOutlineRec))
+#define _XkbAllocRows(s,n) _XkbGeomAlloc((XPointer *)&(s)->rows,\
+ &(s)->num_rows,&(s)->sz_rows,\
+ (n),sizeof(XkbRowRec))
+#define _XkbAllocPoints(o,n) _XkbGeomAlloc((XPointer *)&(o)->points,\
+ &(o)->num_points,&(o)->sz_points,\
+ (n),sizeof(XkbPointRec))
+#define _XkbAllocKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
+ &(r)->num_keys,&(r)->sz_keys,\
+ (n),sizeof(XkbKeyRec))
+#define _XkbAllocOverlays(s,n) _XkbGeomAlloc((XPointer *)&(s)->overlays,\
+ &(s)->num_overlays,&(s)->sz_overlays,\
+ (n),sizeof(XkbOverlayRec))
+#define _XkbAllocOverlayRows(o,n) _XkbGeomAlloc((XPointer *)&(o)->rows,\
+ &(o)->num_rows,&(o)->sz_rows,\
+ (n),sizeof(XkbOverlayRowRec))
+#define _XkbAllocOverlayKeys(r,n) _XkbGeomAlloc((XPointer *)&(r)->keys,\
+ &(r)->num_keys,&(r)->sz_keys,\
+ (n),sizeof(XkbOverlayKeyRec))
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomProps(XkbGeometryPtr geom,int nProps)
+#else
+XkbAllocGeomProps(geom,nProps)
+ XkbGeometryPtr geom;
+ int nProps;
+#endif
+{
+ return _XkbAllocProps(geom,nProps);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomColors(XkbGeometryPtr geom,int nColors)
+#else
+XkbAllocGeomColors(geom,nColors)
+ XkbGeometryPtr geom;
+ int nColors;
+#endif
+{
+ return _XkbAllocColors(geom,nColors);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomKeyAliases(XkbGeometryPtr geom,int nKeyAliases)
+#else
+XkbAllocGeomKeyAliases(geom,nKeyAliases)
+ XkbGeometryPtr geom;
+ int nKeyAliases;
+#endif
+{
+ return _XkbAllocKeyAliases(geom,nKeyAliases);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomShapes(XkbGeometryPtr geom,int nShapes)
+#else
+XkbAllocGeomShapes(geom,nShapes)
+ XkbGeometryPtr geom;
+ int nShapes;
+#endif
+{
+ return _XkbAllocShapes(geom,nShapes);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomSections(XkbGeometryPtr geom,int nSections)
+#else
+XkbAllocGeomSections(geom,nSections)
+ XkbGeometryPtr geom;
+ int nSections;
+#endif
+{
+ return _XkbAllocSections(geom,nSections);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomOverlays(XkbSectionPtr section,int nOverlays)
+#else
+XkbAllocGeomOverlays(section,nOverlays)
+ XkbSectionPtr section;
+ int nOverlays;
+#endif
+{
+ return _XkbAllocOverlays(section,nOverlays);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomOverlayRows(XkbOverlayPtr overlay,int nRows)
+#else
+XkbAllocGeomOverlayRows(overlay,nRows)
+ XkbOverlayPtr overlay;
+ int nRows;
+#endif
+{
+ return _XkbAllocOverlayRows(overlay,nRows);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomOverlayKeys(XkbOverlayRowPtr row,int nKeys)
+#else
+XkbAllocGeomOverlayKeys(row,nKeys)
+ XkbOverlayRowPtr row;
+ int nKeys;
+#endif
+{
+ return _XkbAllocOverlayKeys(row,nKeys);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomDoodads(XkbGeometryPtr geom,int nDoodads)
+#else
+XkbAllocGeomDoodads(geom,nDoodads)
+ XkbGeometryPtr geom;
+ int nDoodads;
+#endif
+{
+ return _XkbAllocDoodads(geom,nDoodads);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomSectionDoodads(XkbSectionPtr section,int nDoodads)
+#else
+XkbAllocGeomSectionDoodads(section,nDoodads)
+ XkbSectionPtr section;
+ int nDoodads;
+#endif
+{
+ return _XkbAllocDoodads(section,nDoodads);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomOutlines(XkbShapePtr shape,int nOL)
+#else
+XkbAllocGeomOutlines(shape,nOL)
+ XkbShapePtr shape;
+ int nOL;
+#endif
+{
+ return _XkbAllocOutlines(shape,nOL);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomRows(XkbSectionPtr section,int nRows)
+#else
+XkbAllocGeomRows(section,nRows)
+ XkbSectionPtr section;
+ int nRows;
+#endif
+{
+ return _XkbAllocRows(section,nRows);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomPoints(XkbOutlinePtr ol,int nPts)
+#else
+XkbAllocGeomPoints(ol,nPts)
+ XkbOutlinePtr ol;
+ int nPts;
+#endif
+{
+ return _XkbAllocPoints(ol,nPts);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeomKeys(XkbRowPtr row,int nKeys)
+#else
+XkbAllocGeomKeys(row,nKeys)
+ XkbRowPtr row;
+ int nKeys;
+#endif
+{
+ return _XkbAllocKeys(row,nKeys);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocGeometry(XkbDescPtr xkb,XkbGeometrySizesPtr sizes)
+#else
+XkbAllocGeometry(xkb,sizes)
+ XkbDescPtr xkb;
+ XkbGeometrySizesPtr sizes;
+#endif
+{
+XkbGeometryPtr geom;
+Status rtrn;
+
+ if (xkb->geom==NULL) {
+ xkb->geom= _XkbTypedCalloc(1,XkbGeometryRec);
+ if (!xkb->geom)
+ return BadAlloc;
+ }
+ geom= xkb->geom;
+ if ((sizes->which&XkbGeomPropertiesMask)&&
+ ((rtrn=_XkbAllocProps(geom,sizes->num_properties))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomColorsMask)&&
+ ((rtrn=_XkbAllocColors(geom,sizes->num_colors))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomShapesMask)&&
+ ((rtrn=_XkbAllocShapes(geom,sizes->num_shapes))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomSectionsMask)&&
+ ((rtrn=_XkbAllocSections(geom,sizes->num_sections))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomDoodadsMask)&&
+ ((rtrn=_XkbAllocDoodads(geom,sizes->num_doodads))!=Success)) {
+ goto BAIL;
+ }
+ if ((sizes->which&XkbGeomKeyAliasesMask)&&
+ ((rtrn=_XkbAllocKeyAliases(geom,sizes->num_key_aliases))!=Success)) {
+ goto BAIL;
+ }
+ return Success;
+BAIL:
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return rtrn;
+}
+
+/***====================================================================***/
+
+XkbPropertyPtr
+#if NeedFunctionPrototypes
+XkbAddGeomProperty(XkbGeometryPtr geom,char *name,char *value)
+#else
+XkbAddGeomProperty(geom,name,value)
+ XkbGeometryPtr geom;
+ char * name;
+ char * value;
+#endif
+{
+register int i;
+register XkbPropertyPtr prop;
+
+ if ((!geom)||(!name)||(!value))
+ return NULL;
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ if ((prop->name)&&(strcmp(name,prop->name)==0)) {
+ if (prop->value)
+ _XkbFree(prop->value);
+ prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ if (prop->value)
+ strcpy(prop->value,value);
+ return prop;
+ }
+ }
+ if ((geom->num_properties>=geom->sz_properties)&&
+ (_XkbAllocProps(geom,1)!=Success)) {
+ return NULL;
+ }
+ prop= &geom->properties[geom->num_properties];
+ prop->name= (char *)_XkbAlloc(strlen(name)+1);
+ if (!name)
+ return NULL;
+ strcpy(prop->name,name);
+ prop->value= (char *)_XkbAlloc(strlen(value)+1);
+ if (!value) {
+ _XkbFree(prop->name);
+ prop->name= NULL;
+ return NULL;
+ }
+ strcpy(prop->value,value);
+ geom->num_properties++;
+ return prop;
+}
+
+XkbKeyAliasPtr
+#if NeedFunctionPrototypes
+XkbAddGeomKeyAlias(XkbGeometryPtr geom,char *aliasStr,char *realStr)
+#else
+XkbAddGeomKeyAlias(geom,aliasStr,realStr)
+ XkbGeometryPtr geom;
+ char * aliasStr;
+ char * realStr;
+#endif
+{
+register int i;
+register XkbKeyAliasPtr alias;
+
+ if ((!geom)||(!aliasStr)||(!realStr)||(!aliasStr[0])||(!realStr[0]))
+ return NULL;
+ for (i=0,alias=geom->key_aliases;i<geom->num_key_aliases;i++,alias++) {
+ if (strncmp(alias->alias,aliasStr,XkbKeyNameLength)==0) {
+ bzero(alias->real,XkbKeyNameLength);
+ strncpy(alias->real,realStr,XkbKeyNameLength);
+ return alias;
+ }
+ }
+ if ((geom->num_key_aliases>=geom->sz_key_aliases)&&
+ (_XkbAllocKeyAliases(geom,1)!=Success)) {
+ return NULL;
+ }
+ alias= &geom->key_aliases[geom->num_key_aliases];
+ bzero(alias,sizeof(XkbKeyAliasRec));
+ strncpy(alias->alias,aliasStr,XkbKeyNameLength);
+ strncpy(alias->real,realStr,XkbKeyNameLength);
+ geom->num_key_aliases++;
+ return alias;
+}
+
+XkbColorPtr
+#if NeedFunctionPrototypes
+XkbAddGeomColor(XkbGeometryPtr geom,char *spec,unsigned int pixel)
+#else
+XkbAddGeomColor(geom,spec,pixel)
+ XkbGeometryPtr geom;
+ char * spec;
+ unsigned int pixel;
+#endif
+{
+register int i;
+register XkbColorPtr color;
+
+ if ((!geom)||(!spec))
+ return NULL;
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ if ((color->spec)&&(strcmp(color->spec,spec)==0)) {
+ color->pixel= pixel;
+ return color;
+ }
+ }
+ if ((geom->num_colors>=geom->sz_colors)&&
+ (_XkbAllocColors(geom,1)!=Success)) {
+ return NULL;
+ }
+ color= &geom->colors[geom->num_colors];
+ color->pixel= pixel;
+ color->spec= (char *)_XkbAlloc(strlen(spec)+1);
+ if (!color->spec)
+ return NULL;
+ strcpy(color->spec,spec);
+ geom->num_colors++;
+ return color;
+}
+
+XkbOutlinePtr
+#if NeedFunctionPrototypes
+XkbAddGeomOutline(XkbShapePtr shape,int sz_points)
+#else
+XkbAddGeomOutline(shape,sz_points)
+ XkbShapePtr shape;
+ int sz_points;
+#endif
+{
+XkbOutlinePtr outline;
+
+ if ((!shape)||(sz_points<0))
+ return NULL;
+ if ((shape->num_outlines>=shape->sz_outlines)&&
+ (_XkbAllocOutlines(shape,1)!=Success)) {
+ return NULL;
+ }
+ outline= &shape->outlines[shape->num_outlines];
+ bzero(outline,sizeof(XkbOutlineRec));
+ if ((sz_points>0)&&(_XkbAllocPoints(outline,sz_points)!=Success))
+ return NULL;
+ shape->num_outlines++;
+ return outline;
+}
+
+XkbShapePtr
+#if NeedFunctionPrototypes
+XkbAddGeomShape(XkbGeometryPtr geom,Atom name,int sz_outlines)
+#else
+XkbAddGeomShape(geom,name,sz_outlines)
+ XkbGeometryPtr geom;
+ Atom name;
+ int sz_outlines;
+#endif
+{
+XkbShapePtr shape;
+register int i;
+
+ if ((!geom)||(!name)||(sz_outlines<0))
+ return NULL;
+ if (geom->num_shapes>0) {
+ for (shape=geom->shapes,i=0;i<geom->num_shapes;i++,shape++) {
+ if (name==shape->name)
+ return shape;
+ }
+ }
+ if ((geom->num_shapes>=geom->sz_shapes)&&
+ (_XkbAllocShapes(geom,1)!=Success))
+ return NULL;
+ shape= &geom->shapes[geom->num_shapes];
+ bzero(shape,sizeof(XkbShapeRec));
+ if ((sz_outlines>0)&&(_XkbAllocOutlines(shape,sz_outlines)!=Success))
+ return NULL;
+ shape->name= name;
+ shape->primary= shape->approx= NULL;
+ geom->num_shapes++;
+ return shape;
+}
+
+XkbKeyPtr
+#if NeedFunctionPrototypes
+XkbAddGeomKey(XkbRowPtr row)
+#else
+XkbAddGeomKey(row)
+ XkbRowPtr row;
+#endif
+{
+XkbKeyPtr key;
+ if (!row)
+ return NULL;
+ if ((row->num_keys>=row->sz_keys)&&(_XkbAllocKeys(row,1)!=Success))
+ return NULL;
+ key= &row->keys[row->num_keys++];
+ bzero(key,sizeof(XkbKeyRec));
+ return key;
+}
+
+XkbRowPtr
+#if NeedFunctionPrototypes
+XkbAddGeomRow(XkbSectionPtr section,int sz_keys)
+#else
+XkbAddGeomRow(section,sz_keys)
+ XkbSectionPtr section;
+ int sz_keys;
+#endif
+{
+XkbRowPtr row;
+
+ if ((!section)||(sz_keys<0))
+ return NULL;
+ if ((section->num_rows>=section->sz_rows)&&
+ (_XkbAllocRows(section,1)!=Success))
+ return NULL;
+ row= &section->rows[section->num_rows];
+ bzero(row,sizeof(XkbRowRec));
+ if ((sz_keys>0)&&(_XkbAllocKeys(row,sz_keys)!=Success))
+ return NULL;
+ section->num_rows++;
+ return row;
+}
+
+XkbSectionPtr
+#if NeedFunctionPrototypes
+XkbAddGeomSection( XkbGeometryPtr geom,
+ Atom name,
+ int sz_rows,
+ int sz_doodads,
+ int sz_over)
+#else
+XkbAddGeomSection(geom,name,sz_rows,sz_doodads,sz_over)
+ XkbGeometryPtr geom;
+ Atom name;
+ int sz_rows;
+ int sz_doodads;
+ int sz_over;
+#endif
+{
+register int i;
+XkbSectionPtr section;
+
+ if ((!geom)||(name==None)||(sz_rows<0))
+ return NULL;
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ if (section->name!=name)
+ continue;
+ if (((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))||
+ ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success))||
+ ((sz_over>0)&&(_XkbAllocOverlays(section,sz_over)!=Success)))
+ return NULL;
+ return section;
+ }
+ if ((geom->num_sections>=geom->sz_sections)&&
+ (_XkbAllocSections(geom,1)!=Success))
+ return NULL;
+ section= &geom->sections[geom->num_sections];
+ if ((sz_rows>0)&&(_XkbAllocRows(section,sz_rows)!=Success))
+ return NULL;
+ if ((sz_doodads>0)&&(_XkbAllocDoodads(section,sz_doodads)!=Success)) {
+ if (section->rows) {
+ _XkbFree(section->rows);
+ section->rows= NULL;
+ section->sz_rows= section->num_rows= 0;
+ }
+ return NULL;
+ }
+ section->name= name;
+ geom->num_sections++;
+ return section;
+}
+
+XkbDoodadPtr
+#if NeedFunctionPrototypes
+XkbAddGeomDoodad(XkbGeometryPtr geom,XkbSectionPtr section,Atom name)
+#else
+XkbAddGeomDoodad(geom,section,name)
+ XkbGeometryPtr geom;
+ XkbSectionPtr section;
+ Atom name;
+#endif
+{
+XkbDoodadPtr old,doodad;
+register int i,nDoodads;
+
+ if ((!geom)||(name==None))
+ return NULL;
+ if ((section!=NULL)&&(section->num_doodads>0)) {
+ old= section->doodads;
+ nDoodads= section->num_doodads;
+ }
+ else {
+ old= geom->doodads;
+ nDoodads= geom->num_doodads;
+ }
+ for (i=0,doodad=old;i<nDoodads;i++,doodad++) {
+ if (doodad->any.name==name)
+ return doodad;
+ }
+ if (section) {
+ if ((section->num_doodads>=geom->sz_doodads)&&
+ (_XkbAllocDoodads(section,1)!=Success)) {
+ return NULL;
+ }
+ doodad= &section->doodads[section->num_doodads++];
+ }
+ else {
+ if ((geom->num_doodads>=geom->sz_doodads)&&
+ (_XkbAllocDoodads(geom,1)!=Success))
+ return NULL;
+ doodad= &geom->doodads[geom->num_doodads++];
+ }
+ bzero(doodad,sizeof(XkbDoodadRec));
+ doodad->any.name= name;
+ return doodad;
+}
+
+XkbOverlayKeyPtr
+#if NeedFunctionPrototypes
+XkbAddGeomOverlayKey( XkbOverlayPtr overlay,
+ XkbOverlayRowPtr row,
+ char * over,
+ char * under)
+#else
+XkbAddGeomOverlayKey(overlay,row,over,under)
+ XkbOverlayPtr overlay;
+ XkbOverlayRowPtr row;
+ char * over;
+ char * under;
+#endif
+{
+register int i;
+XkbOverlayKeyPtr key;
+XkbSectionPtr section;
+XkbRowPtr row_under;
+Bool found;
+
+ if ((!overlay)||(!row)||(!over)||(!under))
+ return NULL;
+ section= overlay->section_under;
+ if (row->row_under>=section->num_rows)
+ return NULL;
+ row_under= &section->rows[row->row_under];
+ for (i=0,found=False;i<row_under->num_keys;i++) {
+ if (strncmp(under,row_under->keys[i].name.name,XkbKeyNameLength)==0) {
+ found= True;
+ break;
+ }
+ }
+ if (!found)
+ return NULL;
+ if ((row->num_keys>=row->sz_keys)&&(_XkbAllocOverlayKeys(row,1)!=Success))
+ return NULL;
+ key= &row->keys[row->num_keys];
+ strncpy(key->under.name,under,XkbKeyNameLength);
+ strncpy(key->over.name,over,XkbKeyNameLength);
+ row->num_keys++;
+ return key;
+}
+
+XkbOverlayRowPtr
+#if NeedFunctionPrototypes
+XkbAddGeomOverlayRow(XkbOverlayPtr overlay,int row_under,int sz_keys)
+#else
+XkbAddGeomOverlayRow(overlay,row_under,sz_keys)
+ XkbOverlayPtr overlay;
+ int row_under;
+ int sz_keys;
+#endif
+{
+register int i;
+XkbOverlayRowPtr row;
+
+ if ((!overlay)||(sz_keys<0))
+ return NULL;
+ if (row_under>=overlay->section_under->num_rows)
+ return NULL;
+ for (i=0;i<overlay->num_rows;i++) {
+ if (overlay->rows[i].row_under==row_under) {
+ row= &overlay->rows[i];
+ if ((row->sz_keys<sz_keys)&&
+ (_XkbAllocOverlayKeys(row,sz_keys)!=Success)) {
+ return NULL;
+ }
+ return &overlay->rows[i];
+ }
+ }
+ if ((overlay->num_rows>=overlay->sz_rows)&&
+ (_XkbAllocOverlayRows(overlay,1)!=Success))
+ return NULL;
+ row= &overlay->rows[overlay->num_rows];
+ bzero(row,sizeof(XkbOverlayRowRec));
+ if ((sz_keys>0)&&(_XkbAllocOverlayKeys(row,sz_keys)!=Success))
+ return NULL;
+ row->row_under= row_under;
+ overlay->num_rows++;
+ return row;
+}
+
+XkbOverlayPtr
+#if NeedFunctionPrototypes
+XkbAddGeomOverlay(XkbSectionPtr section,Atom name,int sz_rows)
+#else
+XkbAddGeomOverlay(section,name,sz_rows)
+ XkbSectionPtr section;
+ Atom name;
+ int sz_rows;
+#endif
+{
+register int i;
+XkbOverlayPtr overlay;
+
+ if ((!section)||(name==None)||(sz_rows==0))
+ return NULL;
+
+ for (i=0,overlay=section->overlays;i<section->num_overlays;i++,overlay++) {
+ if (overlay->name==name) {
+ if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
+ return NULL;
+ return overlay;
+ }
+ }
+ if ((section->num_overlays>=section->sz_overlays)&&
+ (_XkbAllocOverlays(section,1)!=Success))
+ return NULL;
+ overlay= &section->overlays[section->num_overlays];
+ if ((sz_rows>0)&&(_XkbAllocOverlayRows(overlay,sz_rows)!=Success))
+ return NULL;
+ overlay->name= name;
+ overlay->section_under= section;
+ section->num_overlays++;
+ return overlay;
+}
diff --git a/src/xkb/XKBGeom.c b/src/xkb/XKBGeom.c
new file mode 100644
index 00000000..5cdd6b99
--- /dev/null
+++ b/src/xkb/XKBGeom.c
@@ -0,0 +1,779 @@
+/* $Xorg: XKBGeom.c,v 1.4 2000/08/17 19:45:01 cpqbld Exp $ */
+/************************************************************
+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 DEBUG
+#include <stdio.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+
+#ifndef MINSHORT
+#define MINSHORT -32768
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT 32767
+#endif
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_XkbCheckBounds(XkbBoundsPtr bounds,int x,int y)
+#else
+_XkbCheckBounds(bounds,x,y)
+ XkbBoundsPtr bounds;
+ int x,y;
+#endif
+{
+ if (x<bounds->x1) bounds->x1= x;
+ if (x>bounds->x2) bounds->x2= x;
+ if (y<bounds->y1) bounds->y1= y;
+ if (y>bounds->y2) bounds->y2= y;
+ return;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbComputeShapeBounds(XkbShapePtr shape)
+#else
+XkbComputeShapeBounds(shape)
+ XkbShapePtr shape;
+#endif
+{
+register int o,p;
+XkbOutlinePtr outline;
+XkbPointPtr pt;
+
+ if ((!shape)||(shape->num_outlines<1))
+ return False;
+ shape->bounds.x1= shape->bounds.y1= MAXSHORT;
+ shape->bounds.x2= shape->bounds.y2= MINSHORT;
+ for (outline=shape->outlines,o=0;o<shape->num_outlines;o++,outline++) {
+ for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
+ _XkbCheckBounds(&shape->bounds,pt->x,pt->y);
+ }
+ }
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbComputeShapeTop(XkbShapePtr shape,XkbBoundsPtr bounds)
+#else
+XkbComputeShapeTop(shape,bounds)
+ XkbShapePtr shape;
+ XkbBoundsPtr bounds;
+#endif
+{
+register int p;
+XkbOutlinePtr outline;
+XkbPointPtr pt;
+
+ if ((!shape)||(shape->num_outlines<1))
+ return False;
+ if (shape->approx) outline= shape->approx;
+ else outline= &shape->outlines[shape->num_outlines-1];
+ if (outline->num_points<2) {
+ bounds->x1= bounds->y1= 0;
+ bounds->x2= bounds->y2= 0;
+ }
+ else {
+ bounds->x1= bounds->y1= MAXSHORT;
+ bounds->x2= bounds->y2= MINSHORT;
+ }
+ for (pt=outline->points,p=0;p<outline->num_points;p++,pt++) {
+ _XkbCheckBounds(bounds,pt->x,pt->y);
+ }
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbComputeRowBounds(XkbGeometryPtr geom,XkbSectionPtr section,XkbRowPtr row)
+#else
+XkbComputeRowBounds(geom,section,row)
+ XkbGeometryPtr geom;
+ XkbSectionPtr section;
+ XkbRowPtr row;
+#endif
+{
+register int k,pos;
+XkbKeyPtr key;
+XkbBoundsPtr bounds,sbounds;
+
+ if ((!geom)||(!section)||(!row))
+ return False;
+ pos= 0;
+ bounds= &row->bounds;
+ bzero(bounds,sizeof(XkbBoundsRec));
+ for (key=row->keys,pos=k=0;k<row->num_keys;k++,key++) {
+ sbounds= &XkbKeyShape(geom,key)->bounds;
+ _XkbCheckBounds(bounds,pos,0);
+ if (!row->vertical) {
+ if (key->gap!=0) {
+ pos+= key->gap;
+ _XkbCheckBounds(bounds,pos,0);
+ }
+ _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
+ _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
+ pos+= sbounds->x2;
+ }
+ else {
+ if (key->gap!=0) {
+ pos+= key->gap;
+ _XkbCheckBounds(bounds,0,pos);
+ }
+ _XkbCheckBounds(bounds,pos+sbounds->x1,sbounds->y1);
+ _XkbCheckBounds(bounds,pos+sbounds->x2,sbounds->y2);
+ pos+= sbounds->y2;
+ }
+ }
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbComputeSectionBounds(XkbGeometryPtr geom,XkbSectionPtr section)
+#else
+XkbComputeSectionBounds(geom,section)
+ XkbGeometryPtr geom;
+ XkbSectionPtr section;
+#endif
+{
+register int i;
+XkbShapePtr shape;
+XkbRowPtr row;
+XkbDoodadPtr doodad;
+XkbBoundsPtr bounds,rbounds;
+
+ if ((!geom)||(!section))
+ return False;
+ bounds= &section->bounds;
+ bzero(bounds,sizeof(XkbBoundsRec));
+ for (i=0,row=section->rows;i<section->num_rows;i++,row++) {
+ if (!XkbComputeRowBounds(geom,section,row))
+ return False;
+ rbounds= &row->bounds;
+ _XkbCheckBounds(bounds,row->left+rbounds->x1,row->top+rbounds->y1);
+ _XkbCheckBounds(bounds,row->left+rbounds->x2,row->top+rbounds->y2);
+ }
+ for (i=0,doodad=section->doodads;i<section->num_doodads;i++,doodad++) {
+ static XkbBoundsRec tbounds;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ shape= XkbShapeDoodadShape(geom,&doodad->shape);
+ rbounds= &shape->bounds;
+ break;
+ case XkbTextDoodad:
+ tbounds.x1= doodad->text.left;
+ tbounds.y1= doodad->text.top;
+ tbounds.x2= tbounds.x1+doodad->text.width;
+ tbounds.y2= tbounds.y1+doodad->text.height;
+ rbounds= &tbounds;
+ break;
+ case XkbIndicatorDoodad:
+ shape= XkbIndicatorDoodadShape(geom,&doodad->indicator);
+ rbounds= &shape->bounds;
+ break;
+ case XkbLogoDoodad:
+ shape= XkbLogoDoodadShape(geom,&doodad->logo);
+ rbounds= &shape->bounds;
+ break;
+ default:
+ tbounds.x1= tbounds.x2= doodad->any.left;
+ tbounds.y1= tbounds.y2= doodad->any.top;
+ break;
+ }
+ _XkbCheckBounds(bounds,rbounds->x1,rbounds->y1);
+ _XkbCheckBounds(bounds,rbounds->x2,rbounds->y2);
+ }
+ return True;
+}
+
+/***====================================================================***/
+
+char *
+#if NeedFunctionPrototypes
+XkbFindOverlayForKey(XkbGeometryPtr geom,XkbSectionPtr wanted,char *under)
+#else
+XkbFindOverlayForKey(geom,wanted,under)
+ XkbGeometryPtr geom;
+ XkbSectionPtr wanted;
+ char * under;
+#endif
+{
+int s;
+XkbSectionPtr section;
+
+ if ((geom==NULL)||(under==NULL)||(geom->num_sections<1))
+ return NULL;
+
+ if (wanted)
+ section= wanted;
+ else section= geom->sections;
+
+ for (s=0;s<geom->num_sections;s++,section++) {
+ XkbOverlayPtr ol;
+ int o;
+
+ if (section->num_overlays<1)
+ continue;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ XkbOverlayRowPtr row;
+ int r;
+
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ XkbOverlayKeyPtr key;
+ int k;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ if (strncmp(under,key->under.name,XkbKeyNameLength)==0)
+ return key->over.name;
+ }
+ }
+ }
+ if (wanted!=NULL)
+ break;
+ }
+ return NULL;
+}
+
+/***====================================================================***/
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomProperties( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomProperties(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+Status rtrn;
+
+ if (rep->nProperties<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomProps(geom,rep->nProperties))==Success) {
+ register int i;
+ register Bool ok;
+ char *name,*value;
+ ok= True;
+ for (i=0;(i<rep->nProperties)&&ok;i++) {
+ ok= _XkbGetReadBufferCountedString(buf,&name)&&ok;
+ ok= _XkbGetReadBufferCountedString(buf,&value)&&ok;
+ ok= ok&&(XkbAddGeomProperty(geom,name,value)!=NULL);
+ }
+ if (ok) rtrn= Success;
+ else rtrn= BadLength;
+ }
+ return rtrn;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomKeyAliases( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomKeyAliases(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+Status rtrn;
+
+ if (rep->nKeyAliases<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomKeyAliases(geom,rep->nKeyAliases))==Success) {
+ if (!_XkbCopyFromReadBuffer(buf,(char *)geom->key_aliases,
+ (rep->nKeyAliases*XkbKeyNameLength*2)))
+ return BadLength;
+ geom->num_key_aliases= rep->nKeyAliases;
+ return Success;
+ }
+ else { /* alloc failed, just skip the aliases */
+ _XkbSkipReadBufferData(buf,(rep->nKeyAliases*XkbKeyNameLength*2));
+ }
+ return rtrn;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomColors( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomColors(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+Status rtrn;
+
+ if (rep->nColors<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomColors(geom,rep->nColors))==Success) {
+ register int i;
+ char *spec;
+ for (i=0;i<rep->nColors;i++) {
+ if (!_XkbGetReadBufferCountedString(buf,&spec))
+ return BadLength;
+ if (XkbAddGeomColor(geom,spec,geom->num_colors)==NULL)
+ return BadAlloc;
+ }
+ return Success;
+ }
+ return rtrn;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomShapes( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomShapes(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+register int i;
+Status rtrn;
+
+ if (rep->nShapes<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomShapes(geom,rep->nShapes))!=Success)
+ return rtrn;
+ for (i=0;i<rep->nShapes;i++) {
+ xkbShapeWireDesc *shapeWire;
+ XkbShapePtr shape;
+ register int o;
+ shapeWire= (xkbShapeWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbShapeWireDesc));
+ if (!shapeWire)
+ return BadLength;
+ shape= XkbAddGeomShape(geom,shapeWire->name,shapeWire->nOutlines);
+ if (!shape)
+ return BadAlloc;
+ for (o=0;o<shapeWire->nOutlines;o++) {
+ xkbOutlineWireDesc *olWire;
+ XkbOutlinePtr ol;
+ register int p;
+ XkbPointPtr pt;
+ olWire= (xkbOutlineWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOutlineWireDesc));
+ if (!olWire)
+ return BadLength;
+ ol= XkbAddGeomOutline(shape,olWire->nPoints);
+ if (!ol)
+ return BadAlloc;
+ ol->corner_radius= olWire->cornerRadius;
+ for (p=0,pt=ol->points;p<olWire->nPoints;p++,pt++) {
+ xkbPointWireDesc * ptWire;
+ ptWire= (xkbPointWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbPointWireDesc));
+ if (!ptWire)
+ return BadLength;
+ pt->x= ptWire->x;
+ pt->y= ptWire->y;
+ }
+ ol->num_points= olWire->nPoints;
+ }
+ if (shapeWire->primaryNdx!=XkbNoShape)
+ shape->primary= &shape->outlines[shapeWire->primaryNdx];
+ else shape->primary= NULL;
+ if (shapeWire->approxNdx!=XkbNoShape)
+ shape->approx= &shape->outlines[shapeWire->approxNdx];
+ else shape->approx= NULL;
+ XkbComputeShapeBounds(shape);
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomDoodad( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+#else
+_XkbReadGeomDoodad(buf,geom,section)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ XkbSectionPtr section;
+#endif
+{
+XkbDoodadPtr doodad;
+xkbDoodadWireDesc * doodadWire;
+
+ doodadWire= (xkbDoodadWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbDoodadWireDesc));
+ if (!doodadWire)
+ return BadLength;
+ doodad= XkbAddGeomDoodad(geom,section,doodadWire->any.name);
+ if (!doodad)
+ return BadAlloc;
+ doodad->any.type= doodadWire->any.type;
+ doodad->any.priority= doodadWire->any.priority;
+ doodad->any.top= doodadWire->any.top;
+ doodad->any.left= doodadWire->any.left;
+ doodad->any.angle= doodadWire->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodad->shape.color_ndx= doodadWire->shape.colorNdx;
+ doodad->shape.shape_ndx= doodadWire->shape.shapeNdx;
+ break;
+ case XkbTextDoodad:
+ doodad->text.width= doodadWire->text.width;
+ doodad->text.height= doodadWire->text.height;
+ doodad->text.color_ndx= doodadWire->text.colorNdx;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->text.text))
+ return BadLength;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->text.font))
+ return BadLength;
+ break;
+ case XkbIndicatorDoodad:
+ doodad->indicator.shape_ndx= doodadWire->indicator.shapeNdx;
+ doodad->indicator.on_color_ndx= doodadWire->indicator.onColorNdx;
+ doodad->indicator.off_color_ndx= doodadWire->indicator.offColorNdx;
+ break;
+ case XkbLogoDoodad:
+ doodad->logo.color_ndx= doodadWire->logo.colorNdx;
+ doodad->logo.shape_ndx= doodadWire->logo.shapeNdx;
+ if (!_XkbGetReadBufferCountedString(buf,&doodad->logo.logo_name))
+ return BadLength;
+ break;
+ default:
+ return BadValue;
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomOverlay( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ XkbSectionPtr section)
+#else
+_XkbReadGeomOverlay(buf,geom,section)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ XkbSectionPtr section;
+#endif
+{
+XkbOverlayPtr ol;
+xkbOverlayWireDesc * olWire;
+register int r;
+
+ olWire= (xkbOverlayWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayWireDesc));
+ if (olWire==NULL)
+ return BadLength;
+ ol= XkbAddGeomOverlay(section,olWire->name,olWire->nRows);
+ if (ol==NULL)
+ return BadLength;
+ for (r=0;r<olWire->nRows;r++) {
+ register int k;
+ XkbOverlayRowPtr row;
+ xkbOverlayRowWireDesc * rowWire;
+ xkbOverlayKeyWireDesc * keyWire;
+ rowWire= (xkbOverlayRowWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbOverlayRowWireDesc));
+ if (rowWire==NULL)
+ return BadLength;
+ row= XkbAddGeomOverlayRow(ol,rowWire->rowUnder,rowWire->nKeys);
+ row->row_under= rowWire->rowUnder;
+ if (!row)
+ return BadAlloc;
+ if (rowWire->nKeys<1)
+ continue;
+ keyWire= (xkbOverlayKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbOverlayKeyWireDesc)*rowWire->nKeys);
+ if (keyWire==NULL)
+ return BadLength;
+ for (k=0;k<rowWire->nKeys;k++,keyWire++,row->num_keys++) {
+ memcpy(row->keys[row->num_keys].over.name,keyWire->over,
+ XkbKeyNameLength);
+ memcpy(row->keys[row->num_keys].under.name,keyWire->under,
+ XkbKeyNameLength);
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomSections( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomSections(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+register int s;
+XkbSectionPtr section;
+xkbSectionWireDesc * sectionWire;
+Status rtrn;
+
+ if (rep->nSections<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomSections(geom,rep->nSections))!=Success)
+ return rtrn;
+ for (s=0;s<rep->nSections;s++) {
+ sectionWire= (xkbSectionWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSectionWireDesc));
+ if (!sectionWire)
+ return BadLength;
+ section= XkbAddGeomSection(geom,sectionWire->name,sectionWire->nRows,
+ sectionWire->nDoodads,
+ sectionWire->nOverlays);
+ if (!section)
+ return BadAlloc;
+ section->top= sectionWire->top;
+ section->left= sectionWire->left;
+ section->width= sectionWire->width;
+ section->height= sectionWire->height;
+ section->angle= sectionWire->angle;
+ section->priority= sectionWire->priority;
+ if (sectionWire->nRows>0) {
+ register int r;
+ XkbRowPtr row;
+ xkbRowWireDesc * rowWire;
+ for (r=0;r<sectionWire->nRows;r++) {
+ rowWire= (xkbRowWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbRowWireDesc));
+ if (!rowWire)
+ return BadLength;
+ row= XkbAddGeomRow(section,rowWire->nKeys);
+ if (!row)
+ return BadAlloc;
+ row->top= rowWire->top;
+ row->left= rowWire->left;
+ row->vertical= rowWire->vertical;
+ if (rowWire->nKeys>0) {
+ register int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc * keyWire;
+ for (k=0;k<rowWire->nKeys;k++) {
+ keyWire= (xkbKeyWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbKeyWireDesc));
+ if (!keyWire)
+ return BadLength;
+ key= XkbAddGeomKey(row);
+ if (!key)
+ return BadAlloc;
+ memcpy(key->name.name,keyWire->name,XkbKeyNameLength);
+ key->gap= keyWire->gap;
+ key->shape_ndx= keyWire->shapeNdx;
+ key->color_ndx= keyWire->colorNdx;
+ }
+ }
+ }
+ }
+ if (sectionWire->nDoodads>0) {
+ register int d;
+ for (d=0;d<sectionWire->nDoodads;d++) {
+ if ((rtrn=_XkbReadGeomDoodad(buf,geom,section))!=Success)
+ return rtrn;
+ }
+ }
+ if (sectionWire->nOverlays>0) {
+ register int o;
+ for (o=0;o<sectionWire->nOverlays;o++) {
+ if ((rtrn=_XkbReadGeomOverlay(buf,geom,section))!=Success)
+ return rtrn;
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadGeomDoodads( XkbReadBufferPtr buf,
+ XkbGeometryPtr geom,
+ xkbGetGeometryReply * rep)
+#else
+_XkbReadGeomDoodads(buf,geom,rep)
+ XkbReadBufferPtr buf;
+ XkbGeometryPtr geom;
+ xkbGetGeometryReply * rep;
+#endif
+{
+register int d;
+Status rtrn;
+
+ if (rep->nDoodads<1)
+ return Success;
+ if ((rtrn=XkbAllocGeomDoodads(geom,rep->nDoodads))!=Success)
+ return rtrn;
+ for (d=0;d<rep->nDoodads;d++) {
+ if ((rtrn=_XkbReadGeomDoodad(buf,geom,NULL))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XkbReadGetGeometryReply( Display * dpy,
+ xkbGetGeometryReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+#else
+_XkbReadGetGeometryReply(dpy,rep,xkb,nread_rtrn)
+ Display * dpy;
+ xkbGetGeometryReply * rep;
+ XkbDescPtr xkb;
+ int * nread_rtrn;
+#endif
+{
+XkbGeometryPtr geom;
+
+ geom= _XkbTypedCalloc(1,XkbGeometryRec);
+ if (!geom)
+ return BadAlloc;
+ if (xkb->geom)
+ XkbFreeGeometry(xkb->geom,XkbGeomAllMask,True);
+ xkb->geom= geom;
+
+ geom->name= rep->name;
+ geom->width_mm= rep->widthMM;
+ geom->height_mm= rep->heightMM;
+ if (rep->length) {
+ XkbReadBufferRec buf;
+ int left;
+ if (_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4)) {
+ Status status= Success;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+ if (!_XkbGetReadBufferCountedString(&buf,&geom->label_font))
+ status= BadLength;
+ if (status==Success)
+ status= _XkbReadGeomProperties(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomColors(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomShapes(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomSections(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomDoodads(&buf,geom,rep);
+ if (status==Success)
+ status= _XkbReadGeomKeyAliases(&buf,geom,rep);
+ left= _XkbFreeReadBuffer(&buf);
+ if ((status!=Success) || left || buf.error) {
+ if (status==Success)
+ status= BadLength;
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return status;
+ }
+ geom->base_color= &geom->colors[rep->baseColorNdx];
+ geom->label_color= &geom->colors[rep->labelColorNdx];
+ }
+ else {
+ XkbFreeGeometry(geom,XkbGeomAllMask,True);
+ xkb->geom= NULL;
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetGeometry(Display *dpy,XkbDescPtr xkb)
+#else
+XkbGetGeometry(dpy,xkb)
+ Display * dpy;
+ XkbDescPtr xkb;
+#endif
+{
+xkbGetGeometryReq *req;
+xkbGetGeometryReply rep;
+
+ if ( (!xkb) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ GetReq(kbGetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetGeometry;
+ req->deviceSpec = xkb->device_spec;
+ req->name= None;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ return BadImplementation;
+ if (!rep.found)
+ return BadName;
+ return _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetNamedGeometry(Display *dpy,XkbDescPtr xkb,Atom name)
+#else
+XkbGetNamedGeometry(dpy,xkb,name)
+ Display * dpy;
+ XkbDescPtr xkb;
+ Atom name;
+#endif
+{
+xkbGetGeometryReq *req;
+xkbGetGeometryReply rep;
+
+ if ( (name==None) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
+ return BadAccess;
+
+ GetReq(kbGetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetGeometry;
+ req->deviceSpec = xkb->device_spec;
+ req->name= (CARD32)name;
+ if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.found))
+ return BadImplementation;
+ if (!rep.found)
+ return BadName;
+ return _XkbReadGetGeometryReply(dpy,&rep,xkb,NULL);
+}
+
diff --git a/src/xkb/XKBGetByName.c b/src/xkb/XKBGetByName.c
new file mode 100644
index 00000000..411be961
--- /dev/null
+++ b/src/xkb/XKBGetByName.c
@@ -0,0 +1,231 @@
+/* $Xorg: XKBGetByName.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+/***====================================================================***/
+
+XkbDescPtr
+#if NeedFunctionPrototypes
+XkbGetKeyboardByName( Display * dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr names,
+ unsigned want,
+ unsigned need,
+ Bool load)
+#else
+XkbGetKeyboardByName(dpy,deviceSpec,names,want,need,load)
+ Display * dpy;
+ unsigned deviceSpec;
+ XkbComponentNamesPtr names;
+ unsigned want;
+ unsigned need;
+ Bool load;
+#endif
+{
+ register xkbGetKbdByNameReq * req;
+ xkbGetKbdByNameReply rep;
+ int len,extraLen;
+ char * str;
+ XkbDescPtr xkb;
+ int mapLen,codesLen,typesLen,compatLen;
+ int symsLen,geomLen;
+ XkbInfoPtr xkbi;
+
+ if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) )
+ return NULL;
+
+ xkbi= dpy->xkb_info;
+ xkb = (XkbDescRec *)_XkbCalloc(1,sizeof(XkbDescRec));
+ if (!xkb)
+ return NULL;
+ xkb->device_spec = deviceSpec;
+ xkb->map = (XkbClientMapRec *)_XkbCalloc(1,sizeof(XkbClientMapRec));
+ xkb->dpy = dpy;
+
+ LockDisplay(dpy);
+ GetReq(kbGetKbdByName, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetKbdByName;
+ req->deviceSpec = xkb->device_spec;
+ req->want= want;
+ req->need= need;
+ req->load= load;
+
+ mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ if (names) {
+ if (names->keymap)
+ mapLen= (int)strlen(names->keymap);
+ if (names->keycodes)
+ codesLen= (int)strlen(names->keycodes);
+ if (names->types)
+ typesLen= (int)strlen(names->types);
+ if (names->compat)
+ compatLen= (int)strlen(names->compat);
+ if (names->symbols)
+ symsLen= (int)strlen(names->symbols);
+ if (names->geometry)
+ geomLen= (int)strlen(names->geometry);
+ if (mapLen>255) mapLen= 255;
+ if (codesLen>255) codesLen= 255;
+ if (typesLen>255) typesLen= 255;
+ if (compatLen>255) compatLen= 255;
+ if (symsLen>255) symsLen= 255;
+ if (geomLen>255) geomLen= 255;
+ }
+ else mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+
+ len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
+ len= XkbPaddedSize(len);
+ req->length+= len/4;
+ BufAlloc(char *,str,len);
+ *str++= mapLen;
+ if (mapLen>0) {
+ memcpy(str,names->keymap,mapLen);
+ str+= mapLen;
+ }
+ *str++= codesLen;
+ if (codesLen>0) {
+ memcpy(str,names->keycodes,codesLen);
+ str+= codesLen;
+ }
+ *str++= typesLen;
+ if (typesLen>0) {
+ memcpy(str,names->types,typesLen);
+ str+= typesLen;
+ }
+ *str++= compatLen;
+ if (compatLen>0) {
+ memcpy(str,names->compat,compatLen);
+ str+= compatLen;
+ }
+ *str++= symsLen;
+ if (symsLen>0) {
+ memcpy(str,names->symbols,symsLen);
+ str+= symsLen;
+ }
+ *str++= geomLen;
+ if (geomLen>0) {
+ memcpy(str,names->geometry,geomLen);
+ str+= geomLen;
+ }
+ if ((!_XReply(dpy, (xReply *)&rep, 0, xFalse))||(!rep.reported))
+ goto BAILOUT;
+ extraLen= (int)rep.length*4;
+
+ xkb->device_spec= rep.deviceID;
+ xkb->min_key_code = rep.minKeyCode;
+ xkb->max_key_code = rep.maxKeyCode;
+ if (rep.reported&(XkbGBN_SymbolsMask|XkbGBN_TypesMask)) {
+ xkbGetMapReply mrep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&mrep, SIZEOF(xkbGetMapReply));
+ extraLen-= SIZEOF(xkbGetMapReply);
+ status= _XkbReadGetMapReply(dpy,&mrep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_CompatMapMask) {
+ xkbGetCompatMapReply crep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&crep, SIZEOF(xkbGetCompatMapReply));
+ extraLen-= SIZEOF(xkbGetCompatMapReply);
+ status= _XkbReadGetCompatMapReply(dpy,&crep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_IndicatorMapMask) {
+ xkbGetIndicatorMapReply irep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&irep, SIZEOF(xkbGetIndicatorMapReply));
+ extraLen-= SIZEOF(xkbGetIndicatorMapReply);
+ status= _XkbReadGetIndicatorMapReply(dpy,&irep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&(XkbGBN_KeyNamesMask|XkbGBN_OtherNamesMask)) {
+ xkbGetNamesReply nrep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&nrep, SIZEOF(xkbGetNamesReply));
+ extraLen-= SIZEOF(xkbGetNamesReply);
+ status= _XkbReadGetNamesReply(dpy,&nrep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ if (rep.reported&XkbGBN_GeometryMask) {
+ xkbGetGeometryReply grep;
+ Status status;
+ int nread= 0;
+
+ _XRead(dpy, (char *)&grep, SIZEOF(xkbGetGeometryReply));
+ extraLen-= SIZEOF(xkbGetGeometryReply);
+ status= _XkbReadGetGeometryReply(dpy,&grep,xkb,&nread);
+ extraLen-= nread;
+ if (status!=Success)
+ goto BAILOUT;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return xkb;
+BAILOUT:
+ if (xkb!=NULL)
+ XkbFreeKeyboard(xkb,XkbAllComponentsMask,xTrue);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+}
+
+XkbDescPtr
+#if NeedFunctionPrototypes
+XkbGetKeyboard(Display *dpy,unsigned which,unsigned deviceSpec)
+#else
+XkbGetKeyboard(dpy,which,deviceSpec)
+ Display * dpy;
+ unsigned which;
+ unsigned deviceSpec;
+#endif
+{
+ return XkbGetKeyboardByName(dpy,deviceSpec,NULL,which,which,False);
+}
diff --git a/src/xkb/XKBGetMap.c b/src/xkb/XKBGetMap.c
new file mode 100644
index 00000000..8975ba39
--- /dev/null
+++ b/src/xkb/XKBGetMap.c
@@ -0,0 +1,975 @@
+/* $Xorg: XKBGetMap.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadKeyTypes(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadKeyTypes(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+int i,n,lastMapCount;
+XkbKeyTypePtr type;
+
+ if ( rep->nTypes>0 ) {
+ n = rep->firstType+rep->nTypes;
+ if (xkb->map->num_types>=n)
+ n= xkb->map->num_types;
+ else if (XkbAllocClientMap(xkb,XkbKeyTypesMask,n)!=Success)
+ return BadAlloc;
+
+ type = &xkb->map->types[rep->firstType];
+ for (i=0;i<(int)rep->nTypes;i++,type++) {
+ xkbKeyTypeWireDesc *desc;
+ register int ndx;
+
+ ndx= i+rep->firstType;
+ if (ndx>=xkb->map->num_types)
+ xkb->map->num_types= ndx+1;
+
+ desc= (xkbKeyTypeWireDesc *)_XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbKeyTypeWireDesc));
+ if (desc==NULL)
+ return BadLength;
+
+ lastMapCount= type->map_count;
+ if ( desc->nMapEntries>0 ) {
+ if ((type->map==NULL)||(desc->nMapEntries>type->map_count)) {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ type->map= _XkbTypedRealloc(type->map,desc->nMapEntries,
+ XkbKTMapEntryRec);
+ if (type->map==NULL) {
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->map!=NULL) {
+ Xfree(type->map);
+ type->map_count= 0;
+ type->map= NULL;
+ }
+
+ if ( desc->preserve && (desc->nMapEntries>0) ) {
+ if ((!type->preserve)||
+ (desc->nMapEntries>lastMapCount)) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ type->preserve= _XkbTypedRealloc(type->preserve,
+ desc->nMapEntries,
+ XkbModsRec);
+ if (type->preserve==NULL) {
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ }
+ else if (type->preserve!=NULL) {
+ Xfree(type->preserve);
+ type->preserve= NULL;
+ }
+
+ type->mods.mask = desc->mask;
+ type->mods.real_mods = desc->realMods;
+ type->mods.vmods = desc->virtualMods;
+ type->num_levels = desc->numLevels;
+ type->map_count = desc->nMapEntries;
+ if (desc->nMapEntries>0) {
+ register xkbKTMapEntryWireDesc *wire;
+ register XkbKTMapEntryPtr entry;
+ register int size;
+
+ size= type->map_count*SIZEOF(xkbKTMapEntryWireDesc);
+ wire= (xkbKTMapEntryWireDesc *)_XkbGetReadBufferPtr(buf,size);
+ if (wire==NULL)
+ return BadLength;
+ entry= type->map;
+ for (n=0;n<type->map_count;n++,wire++,entry++) {
+ entry->active= wire->active;
+ entry->level= wire->level;
+ entry->mods.mask= wire->mask;
+ entry->mods.real_mods= wire->realMods;
+ entry->mods.vmods= wire->virtualMods;
+ }
+
+ if (desc->preserve) {
+ register xkbModsWireDesc * pwire;
+ register XkbModsPtr preserve;
+ register int sz;
+
+ sz= desc->nMapEntries*SIZEOF(xkbModsWireDesc);
+ pwire=(xkbModsWireDesc *)_XkbGetReadBufferPtr(buf,sz);
+ if (pwire==NULL)
+ return BadLength;
+ preserve= type->preserve;
+ for (n=0;n<desc->nMapEntries;n++,pwire++,preserve++) {
+ preserve->mask= pwire->mask;
+ preserve->vmods= pwire->virtualMods;
+ preserve->real_mods= pwire->realMods;
+ }
+ }
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadKeySyms(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadKeySyms(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+register int i;
+XkbClientMapPtr map;
+
+ map= xkb->map;
+ if (map->key_sym_map==NULL) {
+ register int offset;
+ XkbSymMapPtr oldMap;
+ xkbSymMapWireDesc *newMap;
+ map->key_sym_map= _XkbTypedCalloc((xkb->max_key_code+1),XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ if (map->syms==NULL) {
+ int sz;
+ sz= (rep->totalSyms*12)/10;
+ sz= ((sz+(unsigned)128)/128)*128;
+ map->syms = _XkbTypedCalloc(sz,KeySym);
+ if (map->syms==NULL)
+ return BadAlloc;
+ map->size_syms = sz;
+ }
+ offset = 1;
+ oldMap = &map->key_sym_map[rep->firstKeySym];
+ for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
+ newMap= (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
+ if (newMap==NULL)
+ return BadLength;
+ oldMap->kt_index[0]= newMap->ktIndex[0];
+ oldMap->kt_index[1]= newMap->ktIndex[1];
+ oldMap->kt_index[2]= newMap->ktIndex[2];
+ oldMap->kt_index[3]= newMap->ktIndex[3];
+ oldMap->group_info= newMap->groupInfo;
+ oldMap->width= newMap->width;
+ oldMap->offset= offset;
+ if (offset+newMap->nSyms>=map->size_syms) {
+ register int sz;
+ KeySym *prev_syms = map->syms;
+
+ sz= map->size_syms+128;
+ map->syms= _XkbTypedRealloc(map->syms,sz,KeySym);
+ if (map->syms==NULL) {
+ _XkbFree(prev_syms);
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->size_syms= sz;
+ }
+ if (newMap->nSyms>0) {
+ _XkbReadBufferCopyKeySyms(buf,(KeySym *)&map->syms[offset],
+ newMap->nSyms);
+ offset+= newMap->nSyms;
+ }
+ else {
+ map->syms[offset]= 0;
+ }
+ }
+ map->num_syms= offset;
+ }
+ else {
+ xkbSymMapWireDesc * newMap;
+ XkbSymMapPtr oldMap;
+ KeySym * newSyms;
+ int tmp;
+
+ oldMap = &map->key_sym_map[rep->firstKeySym];
+ for (i=0;i<(int)rep->nKeySyms;i++,oldMap++) {
+ newMap= (xkbSymMapWireDesc *)
+ _XkbGetReadBufferPtr(buf,SIZEOF(xkbSymMapWireDesc));
+ if (newMap==NULL)
+ return BadLength;
+
+ if (newMap->nSyms>0)
+ tmp= newMap->nSyms;
+ else tmp= 0;
+
+ newSyms = XkbResizeKeySyms(xkb,i+rep->firstKeySym,tmp);
+ if (newSyms==NULL)
+ return BadAlloc;
+ if (newMap->nSyms>0)
+ _XkbReadBufferCopyKeySyms(buf,newSyms,newMap->nSyms);
+ else newSyms[0]= NoSymbol;
+ oldMap->kt_index[0] = newMap->ktIndex[0];
+ oldMap->kt_index[1] = newMap->ktIndex[1];
+ oldMap->kt_index[2] = newMap->ktIndex[2];
+ oldMap->kt_index[3] = newMap->ktIndex[3];
+ oldMap->group_info = newMap->groupInfo;
+ oldMap->width = newMap->width;
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadKeyActions(XkbReadBufferPtr buf,XkbDescPtr info,xkbGetMapReply *rep)
+#else
+_XkbReadKeyActions(buf,info,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr info;
+ xkbGetMapReply * rep;
+#endif
+{
+int i;
+CARD8 numDescBuf[248];
+CARD8* numDesc = NULL;
+register int nKeyActs;
+Status ret = Success;
+
+ if ( (nKeyActs=rep->nKeyActs)>0 ) {
+ XkbSymMapPtr symMap;
+
+ if (nKeyActs < sizeof numDescBuf) numDesc = numDescBuf;
+ else numDesc = Xmalloc (nKeyActs * sizeof(CARD8));
+
+ if (!_XkbCopyFromReadBuffer(buf, (char *)numDesc, nKeyActs)) {
+ ret = BadLength;
+ goto done;
+ }
+ i= XkbPaddedSize(nKeyActs)-nKeyActs;
+ if ((i>0)&&(!_XkbSkipReadBufferData(buf,i))) {
+ ret = BadLength;
+ goto done;
+ }
+ symMap = &info->map->key_sym_map[rep->firstKeyAct];
+ for (i=0;i<(int)rep->nKeyActs;i++,symMap++) {
+ if (numDesc[i]==0) {
+ info->server->key_acts[i+rep->firstKeyAct]= 0;
+ }
+ else {
+ XkbAction *newActs;
+ /* 8/16/93 (ef) -- XXX! Verify size here (numdesc must be */
+ /* either zero or XkbKeyNumSyms(info,key) */
+ newActs=XkbResizeKeyActions(info,i+rep->firstKeyAct,
+ numDesc[i]);
+ if (newActs==NULL) {
+ ret = BadAlloc;
+ goto done;
+ }
+ if (!_XkbCopyFromReadBuffer(buf,(char *)newActs,
+ (int)(numDesc[i]*sizeof(XkbAction)))) {
+ ret = BadLength;
+ goto done;
+ }
+ }
+ }
+ }
+done:
+ if (numDesc != NULL && numDesc != numDescBuf) Xfree (numDesc);
+ return ret;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadKeyBehaviors(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadKeyBehaviors(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+register int i;
+xkbBehaviorWireDesc *wire;
+
+ if ( rep->totalKeyBehaviors>0 ) {
+ if ( xkb->server->behaviors == NULL ) {
+ int size = xkb->max_key_code+1;
+ xkb->server->behaviors = _XkbTypedCalloc(size,XkbBehavior);
+ if (xkb->server->behaviors==NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->behaviors[rep->firstKeyBehavior],
+ (rep->nKeyBehaviors*sizeof(XkbBehavior)));
+ }
+ for (i=0;i<rep->totalKeyBehaviors;i++) {
+ wire= (xkbBehaviorWireDesc *)_XkbGetReadBufferPtr(buf,
+ SIZEOF(xkbBehaviorWireDesc));
+ if (wire==NULL)
+ return BadLength;
+ xkb->server->behaviors[wire->key].type= wire->type;
+ xkb->server->behaviors[wire->key].data= wire->data;
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadVirtualMods(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadVirtualMods(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+ if ( rep->virtualMods ) {
+ register int i,bit,nVMods;
+ register char *data;
+
+ for (i=nVMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (rep->virtualMods&bit)
+ nVMods++;
+ }
+ data= _XkbGetReadBufferPtr(buf,XkbPaddedSize(nVMods));
+ if (data==NULL)
+ return BadLength;
+ for (i=0,bit=1;(i<XkbNumVirtualMods)&&(nVMods>0);i++,bit<<=1) {
+ if (rep->virtualMods&bit) {
+ xkb->server->vmods[i]= *data++;
+ nVMods--;
+ }
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadExplicitComponents( XkbReadBufferPtr buf,
+ XkbDescPtr xkb,
+ xkbGetMapReply * rep)
+#else
+_XkbReadExplicitComponents(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+register int i;
+unsigned char *wire;
+
+ if ( rep->totalKeyExplicit>0 ) {
+ if ( xkb->server->explicit == NULL ) {
+ int size = xkb->max_key_code+1;
+ xkb->server->explicit = _XkbTypedCalloc(size,unsigned char);
+ if (xkb->server->explicit==NULL)
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->server->explicit[rep->firstKeyExplicit],
+ rep->nKeyExplicit);
+ }
+ i= XkbPaddedSize(2*rep->totalKeyExplicit);
+ wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalKeyExplicit;i++,wire+=2) {
+ xkb->server->explicit[wire[0]]= wire[1];
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadModifierMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadModifierMap(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+register int i;
+unsigned char *wire;
+
+ if ( rep->totalModMapKeys>0 ) {
+ if ((xkb->map->modmap==NULL)&&
+ (XkbAllocClientMap(xkb,XkbModifierMapMask,0)!=Success)) {
+ return BadAlloc;
+ }
+ else {
+ bzero(&xkb->map->modmap[rep->firstModMapKey],rep->nModMapKeys);
+ }
+ i= XkbPaddedSize(2*rep->totalModMapKeys);
+ wire=(unsigned char *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalModMapKeys;i++,wire+=2) {
+ xkb->map->modmap[wire[0]]= wire[1];
+ }
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadVirtualModMap(XkbReadBufferPtr buf,XkbDescPtr xkb,xkbGetMapReply *rep)
+#else
+_XkbReadVirtualModMap(buf,xkb,rep)
+ XkbReadBufferPtr buf;
+ XkbDescPtr xkb;
+ xkbGetMapReply * rep;
+#endif
+{
+register int i;
+xkbVModMapWireDesc * wire;
+XkbServerMapPtr srv;
+
+ if ( rep->totalVModMapKeys>0 ) {
+ if (((xkb->server==NULL)||(xkb->server->vmodmap==NULL))&&
+ (XkbAllocServerMap(xkb,XkbVirtualModMapMask,0)!=Success)) {
+ return BadAlloc;
+ }
+ else {
+ srv= xkb->server;
+ bzero((char *)&srv->vmodmap[rep->firstVModMapKey],
+ rep->nVModMapKeys*sizeof(unsigned short));
+ }
+ srv= xkb->server;
+ i= rep->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
+ wire=(xkbVModMapWireDesc *)_XkbGetReadBufferPtr(buf,i);
+ if (!wire)
+ return BadLength;
+ for (i=0;i<rep->totalVModMapKeys;i++,wire++) {
+ if ((wire->key>=xkb->min_key_code)&&(wire->key<=xkb->max_key_code))
+ srv->vmodmap[wire->key]= wire->vmods;
+ }
+ }
+ return Success;
+}
+
+static xkbGetMapReq *
+#if NeedFunctionPrototypes
+_XkbGetGetMapReq(Display *dpy,XkbDescPtr xkb)
+#else
+_XkbGetGetMapReq(dpy,xkb)
+ Display * dpy;
+ XkbDescPtr xkb;
+#endif
+{
+xkbGetMapReq *req;
+
+ GetReq(kbGetMap, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbGetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->full = req->partial = 0;
+ req->firstType = req->nTypes = 0;
+ req->firstKeySym = req->nKeySyms = 0;
+ req->firstKeyAct = req->nKeyActs = 0;
+ req->firstKeyBehavior = req->nKeyBehaviors = 0;
+ req->virtualMods = 0;
+ req->firstKeyExplicit = req->nKeyExplicit = 0;
+ req->firstModMapKey = req->nModMapKeys = 0;
+ req->firstVModMapKey = req->nVModMapKeys = 0;
+ return req;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XkbReadGetMapReply( Display * dpy,
+ xkbGetMapReply *rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+#else
+_XkbReadGetMapReply(dpy,rep,xkb,nread_rtrn)
+ Display * dpy;
+ xkbGetMapReply * rep;
+ XkbDescPtr xkb;
+ int * nread_rtrn;
+#endif
+{
+int extraData;
+unsigned mask;
+
+ if ( xkb->device_spec == XkbUseCoreKbd )
+ xkb->device_spec= rep->deviceID;
+ xkb->min_key_code = rep->minKeyCode;
+ xkb->max_key_code = rep->maxKeyCode;
+
+ if (!xkb->map) {
+ mask= rep->present&XkbAllClientInfoMask;
+ if (mask&&(XkbAllocClientMap(xkb,mask,rep->nTypes)!=Success))
+ return BadAlloc;
+ }
+ if (!xkb->server) {
+ mask= rep->present&XkbAllServerInfoMask;
+ if (mask&&(XkbAllocServerMap(xkb,mask,rep->totalActs)!=Success))
+ return BadAlloc;
+ }
+ extraData= (int)(rep->length*4);
+ extraData-= (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply));
+ if (rep->length) {
+ XkbReadBufferRec buf;
+ int left;
+ if (_XkbInitReadBuffer(dpy,&buf,extraData)) {
+ Status status= Success;
+ if (nread_rtrn!=NULL)
+ *nread_rtrn= extraData;
+ if (status==Success)
+ status= _XkbReadKeyTypes(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeySyms(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeyActions(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadKeyBehaviors(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadVirtualMods(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadExplicitComponents(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadModifierMap(&buf,xkb,rep);
+ if (status==Success)
+ status= _XkbReadVirtualModMap(&buf,xkb,rep);
+ left= _XkbFreeReadBuffer(&buf);
+ if (status!=Success) return status;
+ else if ( left || buf.error ) return BadLength;
+ }
+ else return BadAlloc;
+ }
+ return Success;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XkbHandleGetMapReply(Display *dpy,XkbDescPtr xkb)
+#else
+_XkbHandleGetMapReply(dpy,xkb)
+ Display * dpy;
+ XkbDescPtr xkb;
+#endif
+{
+xkbGetMapReply rep;
+
+ if (!_XReply(dpy, (xReply *)&rep,
+ ( (SIZEOF(xkbGetMapReply)-SIZEOF(xGenericReply)) >> 2 ),
+ xFalse)) {
+ return BadImplementation;
+ }
+ return _XkbReadGetMapReply(dpy,&rep,xkb,NULL);
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetUpdatedMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+#else
+XkbGetUpdatedMap(dpy,which,xkb)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+#endif
+{
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if (which) {
+ register xkbGetMapReq *req;
+ Status status;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = which;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+ }
+ return Success;
+}
+
+XkbDescPtr
+#if NeedFunctionPrototypes
+XkbGetMap(Display *dpy,unsigned which,unsigned deviceSpec)
+#else
+XkbGetMap(dpy,which,deviceSpec)
+ Display *dpy;
+ unsigned which;
+ unsigned deviceSpec;
+#endif
+{
+XkbDescPtr xkb;
+
+ xkb = _XkbTypedCalloc(1,XkbDescRec);
+ if (xkb) {
+ xkb->device_spec = deviceSpec;
+ xkb->map = _XkbTypedCalloc(1,XkbClientMapRec);
+ if ((xkb->map==NULL)||
+ ((which)&&(XkbGetUpdatedMap(dpy,which,xkb)!=Success))) {
+ if (xkb->map) {
+ Xfree(xkb->map);
+ xkb->map= NULL;
+ }
+ Xfree(xkb);
+ return NULL;
+ }
+ xkb->dpy= dpy;
+ }
+ return xkb;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyTypes(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeyTypes(dpy,first,num,xkb)
+ Display *dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((num<1)||(num>XkbMaxKeyTypes))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstType = first;
+ req->nTypes = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyActions(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeyActions(dpy,first,num,xkb)
+ Display *dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyAct = first;
+ req->nKeyActs = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeySyms(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeySyms(dpy,first,num,xkb)
+ Display *dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeySym = first;
+ req->nKeySyms = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyBehaviors(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeyBehaviors(dpy,first,num,xkb)
+ Display * dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyBehavior = first;
+ req->nKeyBehaviors = num;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetVirtualMods(Display *dpy,unsigned which,XkbDescPtr xkb)
+#else
+XkbGetVirtualMods(dpy,which,xkb)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->virtualMods = which;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyExplicitComponents( Display * dpy,
+ unsigned first,
+ unsigned num,
+ XkbDescPtr xkb)
+#else
+XkbGetKeyExplicitComponents(dpy,first,num,xkb)
+ Display *dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstKeyExplicit = first;
+ req->nKeyExplicit = num;
+ if ((xkb!=NULL) && (xkb->server!=NULL) && (xkb->server->explicit!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->server->explicit[first],num);
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyModifierMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeyModifierMap(dpy,first,num,xkb)
+ Display * dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstModMapKey = first;
+ req->nModMapKeys = num;
+ if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->map->modmap[first],num);
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetKeyVirtualModMap(Display *dpy,unsigned first,unsigned num,XkbDescPtr xkb)
+#else
+XkbGetKeyVirtualModMap(dpy,first,num,xkb)
+ Display *dpy;
+ unsigned first;
+ unsigned num;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetMapReq *req;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ if ((num<1)||(num>XkbMaxKeyCount))
+ return BadValue;
+
+ LockDisplay(dpy);
+
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->firstVModMapKey = first;
+ req->nVModMapKeys = num;
+ if ((xkb!=NULL) && (xkb->map!=NULL) && (xkb->map->modmap!=NULL)) {
+ if ((num>0)&&(first>=xkb->min_key_code)&&(first+num<=xkb->max_key_code))
+ bzero(&xkb->server->vmodmap[first],num*sizeof(unsigned short));
+ }
+ status= _XkbHandleGetMapReply(dpy, xkb);
+
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetMapChanges(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+#else
+XkbGetMapChanges(dpy,xkb,changes)
+ Display * dpy;
+ XkbDescPtr xkb;
+ XkbMapChangesPtr changes;
+#endif
+{
+ xkbGetMapReq *req;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ if (changes->changed) {
+ Status status= Success;
+ req = _XkbGetGetMapReq(dpy, xkb);
+ req->full = 0;
+ req->partial = changes->changed;
+ req->firstType = changes->first_type;
+ req->nTypes = changes->num_types;
+ req->firstKeySym = changes->first_key_sym;
+ req->nKeySyms = changes->num_key_syms;
+ req->firstKeyAct = changes->first_key_act;
+ req->nKeyActs = changes->num_key_acts;
+ req->firstKeyBehavior = changes->first_key_behavior;
+ req->nKeyBehaviors = changes->num_key_behaviors;
+ req->virtualMods = changes->vmods;
+ req->firstKeyExplicit = changes->first_key_explicit;
+ req->nKeyExplicit = changes->num_key_explicit;
+ req->firstModMapKey = changes->first_modmap_key;
+ req->nModMapKeys = changes->num_modmap_keys;
+ req->firstVModMapKey = changes->first_vmodmap_key;
+ req->nVModMapKeys = changes->num_vmodmap_keys;
+ status= _XkbHandleGetMapReply(dpy, xkb);
+ SyncHandle();
+ UnlockDisplay(dpy);
+ return status;
+ }
+ return Success;
+}
+
diff --git a/src/xkb/XKBList.c b/src/xkb/XKBList.c
new file mode 100644
index 00000000..9f521a60
--- /dev/null
+++ b/src/xkb/XKBList.c
@@ -0,0 +1,273 @@
+/* $Xorg: XKBList.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+Copyright (c) 1995 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.
+
+********************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#define NEED_MAP_READERS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+/***====================================================================***/
+
+static void
+#if NeedFunctionPrototypes
+_FreeComponentNames(int num,XkbComponentNamePtr names)
+#else
+_FreeComponentNames(num,names)
+ int num;
+ XkbComponentNamePtr names;
+#endif
+{
+int i;
+XkbComponentNamePtr tmp;
+
+ if ((num<1)||(names==NULL))
+ return;
+ for (i=0,tmp=names;i<num;i++,tmp++) {
+ if (tmp->name) {
+ _XkbFree(tmp->name);
+ tmp->name= NULL;
+ }
+ }
+ _XkbFree(names);
+ return;
+}
+
+/***====================================================================***/
+
+static XkbComponentNamePtr
+#if NeedFunctionPrototypes
+_ReadListing(XkbReadBufferPtr buf,int count,Status *status_rtrn)
+#else
+_ReadListing(buf,count,status_rtrn)
+ XkbReadBufferPtr buf;
+ int count;
+ Status * status_rtrn;
+#endif
+{
+XkbComponentNamePtr first,this;
+register int i;
+CARD16 * flags;
+int slen,wlen;
+char * str;
+
+ if (count<1)
+ return NULL;
+ first= _XkbTypedCalloc(count,XkbComponentNameRec);
+ if (!first)
+ return NULL;
+ for (this=first,i=0;i<count;i++,this++) {
+ flags= (CARD16 *)_XkbGetReadBufferPtr(buf,2*sizeof(CARD16));
+ if (!flags)
+ goto BAILOUT;
+ this->flags= flags[0];
+ slen= flags[1];
+ wlen= ((slen+1)/2)*2; /* pad to 2 byte boundary */
+ this->name= _XkbTypedCalloc(slen+1,char);
+ if (!this->name)
+ goto BAILOUT;
+ str= (char *)_XkbGetReadBufferPtr(buf,wlen);
+ memcpy(this->name,str,slen);
+ }
+ return first;
+BAILOUT:
+ *status_rtrn= BadAlloc;
+ _FreeComponentNames(i,first);
+ return NULL;
+}
+
+/***====================================================================***/
+
+XkbComponentListPtr
+#if NeedFunctionPrototypes
+XkbListComponents( Display * dpy,
+ unsigned deviceSpec,
+ XkbComponentNamesPtr ptrns,
+ int * max_inout)
+#else
+XkbListComponents(dpy,deviceSpec,ptrns,max_inout)
+ Display * dpy;
+ unsigned deviceSpec;
+ XkbComponentNamesPtr ptrns;
+ int * max_inout;
+#endif
+{
+register xkbListComponentsReq* req;
+xkbListComponentsReply rep;
+XkbInfoPtr xkbi;
+XkbComponentListPtr list;
+XkbReadBufferRec buf;
+int left;
+char * str;
+int extraLen,len,mapLen,codesLen,typesLen,compatLen,symsLen,geomLen;
+
+ if ( (dpy==NULL) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (ptrns==NULL) || (max_inout==NULL))
+ return NULL;
+
+ xkbi= dpy->xkb_info;
+ LockDisplay(dpy);
+ GetReq(kbListComponents, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbListComponents;
+ req->deviceSpec = deviceSpec;
+ req->maxNames = *max_inout;
+
+ mapLen= codesLen= typesLen= compatLen= symsLen= geomLen= 0;
+ if (ptrns->keymap)
+ mapLen= (int)strlen(ptrns->keymap);
+ if (ptrns->keycodes)
+ codesLen= (int)strlen(ptrns->keycodes);
+ if (ptrns->types)
+ typesLen= (int)strlen(ptrns->types);
+ if (ptrns->compat)
+ compatLen= (int)strlen(ptrns->compat);
+ if (ptrns->symbols)
+ symsLen= (int)strlen(ptrns->symbols);
+ if (ptrns->geometry)
+ geomLen= (int)strlen(ptrns->geometry);
+ if (mapLen>255) mapLen= 255;
+ if (codesLen>255) codesLen= 255;
+ if (typesLen>255) typesLen= 255;
+ if (compatLen>255) compatLen= 255;
+ if (symsLen>255) symsLen= 255;
+ if (geomLen>255) geomLen= 255;
+
+ len= mapLen+codesLen+typesLen+compatLen+symsLen+geomLen+6;
+ len= XkbPaddedSize(len);
+ req->length+= len/4;
+ BufAlloc(char *,str,len);
+ *str++= mapLen;
+ if (mapLen>0) {
+ memcpy(str,ptrns->keymap,mapLen);
+ str+= mapLen;
+ }
+ *str++= codesLen;
+ if (codesLen>0) {
+ memcpy(str,ptrns->keycodes,codesLen);
+ str+= codesLen;
+ }
+ *str++= typesLen;
+ if (typesLen>0) {
+ memcpy(str,ptrns->types,typesLen);
+ str+= typesLen;
+ }
+ *str++= compatLen;
+ if (compatLen>0) {
+ memcpy(str,ptrns->compat,compatLen);
+ str+= compatLen;
+ }
+ *str++= symsLen;
+ if (symsLen>0) {
+ memcpy(str,ptrns->symbols,symsLen);
+ str+= symsLen;
+ }
+ *str++= geomLen;
+ if (geomLen>0) {
+ memcpy(str,ptrns->geometry,geomLen);
+ str+= geomLen;
+ }
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse))
+ goto BAILOUT;
+ extraLen= (int)rep.length*4;
+ *max_inout= rep.extra;
+ if (extraLen==0) { /* no matches, but we don't want to report a failure */
+ list= _XkbTypedCalloc(1,XkbComponentListRec);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+ }
+ if (_XkbInitReadBuffer(dpy,&buf,extraLen)) {
+ Status status;
+
+ status= Success;
+ list= _XkbTypedCalloc(1,XkbComponentListRec);
+ if (!list) {
+ _XkbFreeReadBuffer(&buf);
+ goto BAILOUT;
+ }
+ list->num_keymaps= rep.nKeymaps;
+ list->num_keycodes= rep.nKeycodes;
+ list->num_types= rep.nTypes;
+ list->num_compat= rep.nCompatMaps;
+ list->num_symbols= rep.nSymbols;
+ list->num_geometry= rep.nGeometries;
+ if ((status==Success)&&(list->num_keymaps>0))
+ list->keymaps= _ReadListing(&buf,list->num_keymaps,&status);
+ if ((status==Success)&&(list->num_keycodes>0))
+ list->keycodes= _ReadListing(&buf,list->num_keycodes,&status);
+ if ((status==Success)&&(list->num_types>0))
+ list->types= _ReadListing(&buf,list->num_types,&status);
+ if ((status==Success)&&(list->num_compat>0))
+ list->compat= _ReadListing(&buf,list->num_compat,&status);
+ if ((status==Success)&&(list->num_symbols>0))
+ list->symbols= _ReadListing(&buf,list->num_symbols,&status);
+ if ((status==Success)&&(list->num_geometry>0))
+ list->geometry= _ReadListing(&buf,list->num_geometry,&status);
+ left= _XkbFreeReadBuffer(&buf);
+ if ((status!=Success)||(buf.error)||(left>2)) {
+ XkbFreeComponentList(list);
+ goto BAILOUT;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return list;
+ }
+BAILOUT:
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return NULL;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeComponentList(XkbComponentListPtr list)
+#else
+XkbFreeComponentList(list)
+ XkbComponentListPtr list;
+#endif
+{
+ if (list) {
+ if (list->keymaps)
+ _FreeComponentNames(list->num_keymaps,list->keymaps);
+ if (list->keycodes)
+ _FreeComponentNames(list->num_keycodes,list->keycodes);
+ if (list->types)
+ _FreeComponentNames(list->num_types,list->types);
+ if (list->compat)
+ _FreeComponentNames(list->num_compat,list->compat);
+ if (list->symbols)
+ _FreeComponentNames(list->num_symbols,list->symbols);
+ if (list->geometry)
+ _FreeComponentNames(list->num_geometry,list->geometry);
+ bzero((char *)list,sizeof(XkbComponentListRec));
+ _XkbFree(list);
+ }
+ return;
+}
diff --git a/src/xkb/XKBMAlloc.c b/src/xkb/XKBMAlloc.c
new file mode 100644
index 00000000..ba2a7076
--- /dev/null
+++ b/src/xkb/XKBMAlloc.c
@@ -0,0 +1,1077 @@
+/* $Xorg: XKBMAlloc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include "X.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xproto.h"
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include "XKBsrv.h"
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocClientMap(XkbDescPtr xkb,unsigned which,unsigned nTotalTypes)
+#else
+XkbAllocClientMap(xkb,which,nTotalTypes)
+ XkbDescPtr xkb;
+ unsigned which;
+ unsigned nTotalTypes;
+#endif
+{
+register int i;
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||((nTotalTypes>0)&&(nTotalTypes<XkbNumRequiredTypes)))
+ return BadValue;
+ if ((which&XkbKeySymsMask)&&
+ ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))) {
+#ifdef DEBUG
+fprintf(stderr,"bad keycode (%d,%d) in XkbAllocClientMap\n",
+ xkb->min_key_code,xkb->max_key_code);
+#endif
+ return BadValue;
+ }
+
+ if (xkb->map==NULL) {
+ map= _XkbTypedCalloc(1,XkbClientMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ xkb->map= map;
+ }
+ else map= xkb->map;
+
+ if ((which&XkbKeyTypesMask)&&(nTotalTypes>0)) {
+ if (map->types==NULL) {
+ map->types= _XkbTypedCalloc(nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL)
+ return BadAlloc;
+ map->num_types= 0;
+ map->size_types= nTotalTypes;
+ }
+ else if (map->size_types<nTotalTypes) {
+ XkbKeyTypeRec *prev_types = map->types;
+
+ map->types= _XkbTypedRealloc(map->types,nTotalTypes,XkbKeyTypeRec);
+ if (map->types==NULL) {
+ _XkbFree(prev_types);
+ map->num_types= map->size_types= 0;
+ return BadAlloc;
+ }
+ map->size_types= nTotalTypes;
+ bzero(&map->types[map->num_types],
+ ((map->size_types-map->num_types)*sizeof(XkbKeyTypeRec)));
+ }
+ }
+ if (which&XkbKeySymsMask) {
+ int nKeys= XkbNumKeys(xkb);
+ if (map->syms==NULL) {
+ map->size_syms= (nKeys*15)/10;
+ map->syms= _XkbTypedCalloc(map->size_syms,KeySym);
+ if (!map->syms) {
+ map->size_syms= 0;
+ return BadAlloc;
+ }
+ map->num_syms= 1;
+ map->syms[0]= NoSymbol;
+ }
+ if (map->key_sym_map==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_sym_map= _XkbTypedCalloc(i,XkbSymMapRec);
+ if (map->key_sym_map==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbModifierMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->modmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->modmap= _XkbTypedCalloc(i,unsigned char);
+ if (map->modmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbAllocServerMap(XkbDescPtr xkb,unsigned which,unsigned nNewActions)
+#else
+XkbAllocServerMap(xkb,which,nNewActions)
+ XkbDescPtr xkb;
+ unsigned which;
+ unsigned nNewActions;
+#endif
+{
+register int i;
+XkbServerMapPtr map;
+
+ if (xkb==NULL)
+ return BadMatch;
+ if (xkb->server==NULL) {
+ map= _XkbTypedCalloc(1,XkbServerMapRec);
+ if (map==NULL)
+ return BadAlloc;
+ for (i=0;i<XkbNumVirtualMods;i++) {
+ map->vmods[i]= XkbNoModifierMask;
+ }
+ xkb->server= map;
+ }
+ else map= xkb->server;
+ if (which&XkbExplicitComponentsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->explicit==NULL) {
+ i= xkb->max_key_code+1;
+ map->explicit= _XkbTypedCalloc(i,unsigned char);
+ if (map->explicit==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyActionsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (nNewActions<1)
+ nNewActions= 1;
+ if (map->acts==NULL) {
+ map->acts= _XkbTypedCalloc((nNewActions+1),XkbAction);
+ if (map->acts==NULL)
+ return BadAlloc;
+ map->num_acts= 1;
+ map->size_acts= nNewActions+1;
+ }
+ else if ((map->size_acts-map->num_acts)<nNewActions) {
+ unsigned need;
+ XkbAction *prev_acts = map->acts;
+ need= map->num_acts+nNewActions;
+ map->acts= _XkbTypedRealloc(map->acts,need,XkbAction);
+ if (map->acts==NULL) {
+ _XkbFree(prev_acts);
+ map->num_acts= map->size_acts= 0;
+ return BadAlloc;
+ }
+ map->size_acts= need;
+ bzero(&map->acts[map->num_acts],
+ ((map->size_acts-map->num_acts)*sizeof(XkbAction)));
+ }
+ if (map->key_acts==NULL) {
+ i= xkb->max_key_code+1;
+ map->key_acts= _XkbTypedCalloc(i,unsigned short);
+ if (map->key_acts==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->behaviors==NULL) {
+ i= xkb->max_key_code+1;
+ map->behaviors= _XkbTypedCalloc(i,XkbBehavior);
+ if (map->behaviors==NULL)
+ return BadAlloc;
+ }
+ }
+ if (which&XkbVirtualModMapMask) {
+ if ((!XkbIsLegalKeycode(xkb->min_key_code))||
+ (!XkbIsLegalKeycode(xkb->max_key_code))||
+ (xkb->max_key_code<xkb->min_key_code))
+ return BadMatch;
+ if (map->vmodmap==NULL) {
+ i= xkb->max_key_code+1;
+ map->vmodmap= _XkbTypedCalloc(i,unsigned short);
+ if (map->vmodmap==NULL)
+ return BadAlloc;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+#if NeedFunctionPrototypes
+XkbCopyKeyType(XkbKeyTypePtr from,XkbKeyTypePtr into)
+#else
+XkbCopyKeyType(from,into)
+ XkbKeyTypePtr from;
+ XkbKeyTypePtr into;
+#endif
+{
+ if ((!from)||(!into))
+ return BadMatch;
+ if (into->map) {
+ _XkbFree(into->map);
+ into->map= NULL;
+ }
+ if (into->preserve) {
+ _XkbFree(into->preserve);
+ into->preserve= NULL;
+ }
+ if (into->level_names) {
+ _XkbFree(into->level_names);
+ into->level_names= NULL;
+ }
+ *into= *from;
+ if ((from->map)&&(into->map_count>0)) {
+ into->map= _XkbTypedCalloc(into->map_count,XkbKTMapEntryRec);
+ if (!into->map)
+ return BadAlloc;
+ memcpy(into->map,from->map,into->map_count*sizeof(XkbKTMapEntryRec));
+ }
+ if ((from->preserve)&&(into->map_count>0)) {
+ into->preserve= _XkbTypedCalloc(into->map_count,XkbModsRec);
+ if (!into->preserve)
+ return BadAlloc;
+ memcpy(into->preserve,from->preserve,
+ into->map_count*sizeof(XkbModsRec));
+ }
+ if ((from->level_names)&&(into->num_levels>0)) {
+ into->level_names= _XkbTypedCalloc(into->num_levels,Atom);
+ if (!into->level_names)
+ return BadAlloc;
+ memcpy(into->level_names,from->level_names,
+ into->num_levels*sizeof(Atom));
+ }
+ return Success;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbCopyKeyTypes(XkbKeyTypePtr from,XkbKeyTypePtr into,int num_types)
+#else
+XkbCopyKeyTypes(from,into,num_types)
+ XkbKeyTypePtr from;
+ XkbKeyTypePtr into;
+ int num_types;
+#endif
+{
+register int i,rtrn;
+
+ if ((!from)||(!into)||(num_types<0))
+ return BadMatch;
+ for (i=0;i<num_types;i++) {
+ if ((rtrn= XkbCopyKeyType(from++,into++))!=Success)
+ return rtrn;
+ }
+ return Success;
+}
+
+XkbKeyTypePtr
+#if NeedFunctionPrototypes
+XkbAddKeyType( XkbDescPtr xkb,
+ Atom name,
+ int map_count,
+ Bool want_preserve,
+ int num_lvls)
+#else
+XkbAddKeyType(xkb,name,map_count,want_preserve,num_lvls)
+ XkbDescPtr xkb;
+ Atom name;
+ int map_count;
+ Bool want_preserve;
+ int num_lvls;
+#endif
+{
+register int i;
+unsigned tmp;
+XkbKeyTypePtr type;
+XkbClientMapPtr map;
+
+ if ((!xkb)||(num_lvls<1))
+ return NULL;
+ map= xkb->map;
+ if ((map)&&(map->types)) {
+ for (i=0;i<map->num_types;i++) {
+ if (map->types[i].name==name) {
+ Status status;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((!map)||(!map->types)||(!map->num_types<XkbNumRequiredTypes)) {
+ tmp= XkbNumRequiredTypes+1;
+ if (XkbAllocClientMap(xkb,XkbKeyTypesMask,tmp)!=Success)
+ return NULL;
+ tmp= 0;
+ if (map->num_types<=XkbKeypadIndex)
+ tmp|= XkbKeypadMask;
+ if (map->num_types<=XkbAlphabeticIndex)
+ tmp|= XkbAlphabeticMask;
+ if (map->num_types<=XkbTwoLevelIndex)
+ tmp|= XkbTwoLevelMask;
+ if (map->num_types<=XkbOneLevelIndex)
+ tmp|= XkbOneLevelMask;
+ if (XkbInitCanonicalKeyTypes(xkb,tmp,XkbNoModifier)==Success) {
+ for (i=0;i<map->num_types;i++) {
+ Status status;
+ if (map->types[i].name!=name)
+ continue;
+ status=XkbResizeKeyType(xkb,i,map_count,want_preserve,num_lvls);
+ return (status==Success?&map->types[i]:NULL);
+ }
+ }
+ }
+ if ((map->num_types<=map->size_types)&&
+ (XkbAllocClientMap(xkb,XkbKeyTypesMask,map->num_types+1)!=Success)) {
+ return NULL;
+ }
+ type= &map->types[map->num_types];
+ map->num_types++;
+ bzero((char *)type,sizeof(XkbKeyTypeRec));
+ type->num_levels= num_lvls;
+ type->map_count= map_count;
+ type->name= name;
+ if (map_count>0) {
+ type->map= _XkbTypedCalloc(map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ map->num_types--;
+ return NULL;
+ }
+ if (want_preserve) {
+ type->preserve= _XkbTypedCalloc(map_count,XkbModsRec);
+ if (!type->preserve) {
+ _XkbFree(type->map);
+ map->num_types--;
+ return NULL;
+ }
+ }
+ }
+ return type;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbResizeKeyType( XkbDescPtr xkb,
+ int type_ndx,
+ int map_count,
+ Bool want_preserve,
+ int new_num_lvls)
+#else
+XkbResizeKeyType(xkb,type_ndx,map_count,want_preserve,new_num_lvls)
+ XkbDescPtr xkb;
+ int type_ndx;
+ int map_count;
+ Bool want_preserve;
+ int new_num_lvls;
+#endif
+{
+XkbKeyTypePtr type;
+KeyCode matchingKeys[XkbMaxKeyCount],nMatchingKeys;
+
+ if ((type_ndx<0)||(type_ndx>=xkb->map->num_types)||(map_count<0)||
+ (new_num_lvls<1))
+ return BadValue;
+ switch (type_ndx) {
+ case XkbOneLevelIndex:
+ if (new_num_lvls!=1)
+ return BadMatch;
+ break;
+ case XkbTwoLevelIndex:
+ case XkbAlphabeticIndex:
+ case XkbKeypadIndex:
+ if (new_num_lvls!=2)
+ return BadMatch;
+ break;
+ }
+ type= &xkb->map->types[type_ndx];
+ if (map_count==0) {
+ if (type->map!=NULL)
+ _XkbFree(type->map);
+ type->map= NULL;
+ if (type->preserve!=NULL)
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ type->map_count= 0;
+ }
+ else {
+ XkbKTMapEntryRec *prev_map = type->map;
+
+ if ((map_count>type->map_count)||(type->map==NULL))
+ type->map=_XkbTypedRealloc(type->map,map_count,XkbKTMapEntryRec);
+ if (!type->map) {
+ if (prev_map)
+ _XkbFree(prev_map);
+ return BadAlloc;
+ }
+ if (want_preserve) {
+ XkbModsRec *prev_preserve = type->preserve;
+
+ if ((map_count>type->map_count)||(type->preserve==NULL)) {
+ type->preserve= _XkbTypedRealloc(type->preserve,map_count,
+ XkbModsRec);
+ }
+ if (!type->preserve) {
+ if (prev_preserve)
+ _XkbFree(prev_preserve);
+ return BadAlloc;
+ }
+ }
+ else if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= map_count;
+ }
+
+ if ((new_num_lvls>type->num_levels)||(type->level_names==NULL)) {
+ Atom * prev_level_names = type->level_names;
+
+ type->level_names=_XkbTypedRealloc(type->level_names,new_num_lvls,Atom);
+ if (!type->level_names) {
+ if (prev_level_names)
+ _XkbFree(prev_level_names);
+ return BadAlloc;
+ }
+ }
+ /*
+ * Here's the theory:
+ * If the width of the type changed, we might have to resize the symbol
+ * maps for any keys that use the type for one or more groups. This is
+ * expensive, so we'll try to cull out any keys that are obviously okay:
+ * In any case:
+ * - keys that have a group width <= the old width are okay (because
+ * they could not possibly have been associated with the old type)
+ * If the key type increased in size:
+ * - keys that already have a group width >= to the new width are okay
+ * + keys that have a group width >= the old width but < the new width
+ * might have to be enlarged.
+ * If the key type decreased in size:
+ * - keys that have a group width > the old width don't have to be
+ * resized (because they must have some other wider type associated
+ * with some group).
+ * + keys that have a group width == the old width might have to be
+ * shrunk.
+ * The possibilities marked with '+' require us to examine the key types
+ * associated with each group for the key.
+ */
+ bzero(matchingKeys,XkbMaxKeyCount*sizeof(KeyCode));
+ nMatchingKeys= 0;
+ if (new_num_lvls>type->num_levels) {
+ int nTotal;
+ KeySym * newSyms;
+ int width,match,nResize;
+ register int i,g,nSyms;
+
+ nResize= 0;
+ for (nTotal=1,i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ if ((!match)||(width>=new_num_lvls))
+ nTotal+= XkbKeyNumSyms(xkb,i);
+ else {
+ nTotal+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ nResize++;
+ }
+ }
+ if (nResize>0) {
+ int nextMatch;
+ xkb->map->size_syms= (nTotal*12)/10;
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return BadAlloc;
+ nextMatch= 0;
+ nSyms= 1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (matchingKeys[nextMatch]==i) {
+ KeySym *pOld;
+ nextMatch++;
+ width= XkbKeyGroupsWidth(xkb,i);
+ pOld= XkbKeySymsPtr(xkb,i);
+ for (g=XkbKeyNumGroups(xkb,i)-1;g>=0;g--) {
+ memcpy(&newSyms[nSyms+(new_num_lvls*g)],&pOld[width*g],
+ width*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumGroups(xkb,i)*new_num_lvls;
+ }
+ else {
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),
+ XkbKeyNumSyms(xkb,i)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset= nSyms;
+ nSyms+= XkbKeyNumSyms(xkb,i);
+ }
+ }
+ type->num_levels= new_num_lvls;
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms= newSyms;
+ xkb->map->num_syms= nSyms;
+ return Success;
+ }
+ }
+ else if (new_num_lvls<type->num_levels) {
+ int width,match;
+ register int g,i;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ width= XkbKeyGroupsWidth(xkb,i);
+ if (width<type->num_levels)
+ continue;
+ for (match=0,g=XkbKeyNumGroups(xkb,i)-1;(g>=0)&&(!match);g--) {
+ if (XkbKeyKeyTypeIndex(xkb,i,g)==type_ndx) {
+ matchingKeys[nMatchingKeys++]= i;
+ match= 1;
+ }
+ }
+ }
+ }
+ if (nMatchingKeys>0) {
+ int key,firstClear;
+ register int i,g;
+ if (new_num_lvls>type->num_levels)
+ firstClear= type->num_levels;
+ else firstClear= new_num_lvls;
+ for (i=0;i<nMatchingKeys;i++) {
+ KeySym * pSyms;
+ int width,nClear;
+
+ key= matchingKeys[i];
+ width= XkbKeyGroupsWidth(xkb,key);
+ nClear= width-firstClear;
+ pSyms= XkbKeySymsPtr(xkb,key);
+ for (g=XkbKeyNumGroups(xkb,key)-1;g>=0;g--) {
+ if (XkbKeyKeyTypeIndex(xkb,key,g)==type_ndx) {
+ if (nClear>0)
+ bzero(&pSyms[g*width+firstClear],nClear*sizeof(KeySym));
+ }
+ }
+ }
+ }
+ type->num_levels= new_num_lvls;
+ return Success;
+}
+
+KeySym *
+#if NeedFunctionPrototypes
+XkbResizeKeySyms(XkbDescPtr xkb,int key,int needed)
+#else
+XkbResizeKeySyms(xkb,key,needed)
+ XkbDescPtr xkb;
+ int key;
+ int needed;
+#endif
+{
+register int i,nSyms,nKeySyms;
+unsigned nOldSyms;
+KeySym *newSyms;
+
+ if (needed==0) {
+ xkb->map->key_sym_map[key].offset= 0;
+ return xkb->map->syms;
+ }
+ nOldSyms= XkbKeyNumSyms(xkb,key);
+ if (nOldSyms>=(unsigned)needed) {
+ return XkbKeySymsPtr(xkb,key);
+ }
+ if (xkb->map->size_syms-xkb->map->num_syms>=(unsigned)needed) {
+ if (nOldSyms>0) {
+ memcpy(&xkb->map->syms[xkb->map->num_syms],XkbKeySymsPtr(xkb,key),
+ nOldSyms*sizeof(KeySym));
+ }
+ if ((needed-nOldSyms)>0) {
+ bzero(&xkb->map->syms[xkb->map->num_syms+XkbKeyNumSyms(xkb,key)],
+ (needed-nOldSyms)*sizeof(KeySym));
+ }
+ xkb->map->key_sym_map[key].offset = xkb->map->num_syms;
+ xkb->map->num_syms+= needed;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+ }
+ xkb->map->size_syms+= (needed>32?needed:32);
+ newSyms = _XkbTypedCalloc(xkb->map->size_syms,KeySym);
+ if (newSyms==NULL)
+ return NULL;
+ newSyms[0]= NoSymbol;
+ nSyms = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nCopy;
+
+ nCopy= nKeySyms= XkbKeyNumSyms(xkb,i);
+ if ((nKeySyms==0)&&(i!=key))
+ continue;
+ if (i==key)
+ nKeySyms= needed;
+ if (nCopy!=0)
+ memcpy(&newSyms[nSyms],XkbKeySymsPtr(xkb,i),nCopy*sizeof(KeySym));
+ if (nKeySyms>nCopy)
+ bzero(&newSyms[nSyms+nCopy],(nKeySyms-nCopy)*sizeof(KeySym));
+ xkb->map->key_sym_map[i].offset = nSyms;
+ nSyms+= nKeySyms;
+ }
+ _XkbFree(xkb->map->syms);
+ xkb->map->syms = newSyms;
+ xkb->map->num_syms = nSyms;
+ return &xkb->map->syms[xkb->map->key_sym_map[key].offset];
+}
+
+static unsigned
+#if NeedFunctionPrototypes
+_ExtendRange( unsigned int old_flags,
+ unsigned int flag,
+ KeyCode newKC,
+ KeyCode * old_min,
+ unsigned char * old_num)
+#else
+_ExtendRange(old_flags,flag,newKC,old_min,old_num)
+ unsigned int old_flags;
+ unsigned int flag;
+ KeyCode newKC;
+ KeyCode * old_min;
+ unsigned char * old_num;
+#endif
+{
+ if ((old_flags&flag)==0) {
+ old_flags|= flag;
+ *old_min= newKC;
+ *old_num= 1;
+ }
+ else {
+ int last= (*old_min)+(*old_num)-1;
+ if (newKC<*old_min) {
+ *old_min= newKC;
+ *old_num= (last-newKC)+1;
+ }
+ else if (newKC>last) {
+ *old_num= (newKC-(*old_min))+1;
+ }
+ }
+ return old_flags;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbChangeKeycodeRange( XkbDescPtr xkb,
+ int minKC,
+ int maxKC,
+ XkbChangesPtr changes)
+#else
+XkbChangeKeycodeRange(xkb,minKC,maxKC,changes)
+ XkbDescPtr xkb;
+ int minKC;
+ int maxKC;
+ XkbChangesPtr changes;
+#endif
+{
+int tmp;
+
+ if ((!xkb)||(minKC<XkbMinLegalKeyCode)||(maxKC>XkbMaxLegalKeyCode))
+ return BadValue;
+ if (minKC>maxKC)
+ return BadMatch;
+ if (minKC<xkb->min_key_code) {
+ if (changes)
+ changes->map.min_key_code= minKC;
+ tmp= xkb->min_key_code-minKC;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ bzero((char *)&xkb->map->key_sym_map[minKC],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,minKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ bzero((char *)&xkb->map->modmap[minKC],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ bzero((char *)&xkb->server->behaviors[minKC],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,minKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ bzero((char *)&xkb->server->key_acts[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,minKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ bzero((char *)&xkb->server->vmodmap[minKC],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,minKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ bzero((char *)&xkb->names->keys[minKC],tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,minKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->min_key_code= minKC;
+ }
+ if (maxKC>xkb->max_key_code) {
+ if (changes)
+ changes->map.max_key_code= maxKC;
+ tmp= maxKC-xkb->max_key_code;
+ if (xkb->map) {
+ if (xkb->map->key_sym_map) {
+ XkbSymMapRec *prev_key_sym_map = xkb->map->key_sym_map;
+
+ xkb->map->key_sym_map= _XkbTypedRealloc(xkb->map->key_sym_map,
+ (maxKC+1),XkbSymMapRec);
+ if (!xkb->map->key_sym_map) {
+ _XkbFree(prev_key_sym_map);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->map->key_sym_map[xkb->max_key_code],
+ tmp*sizeof(XkbSymMapRec));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeySymsMask,maxKC,
+ &changes->map.first_key_sym,
+ &changes->map.num_key_syms);
+ }
+ }
+ if (xkb->map->modmap) {
+ unsigned char *prev_modmap = xkb->map->modmap;
+
+ xkb->map->modmap= _XkbTypedRealloc(xkb->map->modmap,
+ (maxKC+1),unsigned char);
+ if (!xkb->map->modmap) {
+ _XkbFree(prev_modmap);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->map->modmap[xkb->max_key_code],tmp);
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbModifierMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_modmap_keys);
+ }
+ }
+ }
+ if (xkb->server) {
+ if (xkb->server->behaviors) {
+ XkbBehavior *prev_behaviors = xkb->server->behaviors;
+
+ xkb->server->behaviors=_XkbTypedRealloc(xkb->server->behaviors,
+ (maxKC+1),XkbBehavior);
+ if (!xkb->server->behaviors) {
+ _XkbFree(prev_behaviors);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->behaviors[xkb->max_key_code],
+ tmp*sizeof(XkbBehavior));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyBehaviorsMask,maxKC,
+ &changes->map.first_key_behavior,
+ &changes->map.num_key_behaviors);
+ }
+ }
+ if (xkb->server->key_acts) {
+ unsigned short *prev_key_acts = xkb->server->key_acts;
+
+ xkb->server->key_acts= _XkbTypedRealloc(xkb->server->key_acts,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->key_acts) {
+ _XkbFree(prev_key_acts);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->key_acts[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbKeyActionsMask,maxKC,
+ &changes->map.first_key_act,
+ &changes->map.num_key_acts);
+ }
+ }
+ if (xkb->server->vmodmap) {
+ unsigned short *prev_vmodmap = xkb->server->vmodmap;
+
+ xkb->server->vmodmap= _XkbTypedRealloc(xkb->server->vmodmap,
+ (maxKC+1),unsigned short);
+ if (!xkb->server->vmodmap) {
+ _XkbFree(prev_vmodmap);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->server->vmodmap[xkb->max_key_code],
+ tmp*sizeof(unsigned short));
+ if (changes) {
+ changes->map.changed= _ExtendRange(changes->map.changed,
+ XkbVirtualModMapMask,maxKC,
+ &changes->map.first_modmap_key,
+ &changes->map.num_vmodmap_keys);
+ }
+ }
+ }
+ if ((xkb->names)&&(xkb->names->keys)) {
+ XkbKeyNameRec *prev_keys = xkb->names->keys;
+
+ xkb->names->keys= _XkbTypedRealloc(xkb->names->keys,
+ (maxKC+1),XkbKeyNameRec);
+ if (!xkb->names->keys) {
+ _XkbFree(prev_keys);
+ return BadAlloc;
+ }
+ bzero((char *)&xkb->names->keys[xkb->max_key_code],
+ tmp*sizeof(XkbKeyNameRec));
+ if (changes) {
+ changes->names.changed= _ExtendRange(changes->names.changed,
+ XkbKeyNamesMask,maxKC,
+ &changes->names.first_key,
+ &changes->names.num_keys);
+ }
+ }
+ xkb->max_key_code= maxKC;
+ }
+ return Success;
+}
+
+XkbAction *
+#if NeedFunctionPrototypes
+XkbResizeKeyActions(XkbDescPtr xkb,int key,int needed)
+#else
+XkbResizeKeyActions(xkb,key,needed)
+ XkbDescPtr xkb;
+ int key;
+ int needed;
+#endif
+{
+register int i,nActs;
+XkbAction *newActs;
+
+ if (needed==0) {
+ xkb->server->key_acts[key]= 0;
+ return NULL;
+ }
+ if (XkbKeyHasActions(xkb,key)&&(XkbKeyNumSyms(xkb,key)>=(unsigned)needed))
+ return XkbKeyActionsPtr(xkb,key);
+ if (xkb->server->size_acts-xkb->server->num_acts>=(unsigned)needed) {
+ xkb->server->key_acts[key]= xkb->server->num_acts;
+ xkb->server->num_acts+= needed;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+ }
+ xkb->server->size_acts= xkb->server->num_acts+needed+8;
+ newActs = _XkbTypedCalloc(xkb->server->size_acts,XkbAction);
+ if (newActs==NULL)
+ return NULL;
+ newActs[0].type = XkbSA_NoAction;
+ nActs = 1;
+ for (i=xkb->min_key_code;i<=(int)xkb->max_key_code;i++) {
+ int nKeyActs,nCopy;
+
+ if ((xkb->server->key_acts[i]==0)&&(i!=key))
+ continue;
+
+ nCopy= nKeyActs= XkbKeyNumActions(xkb,i);
+ if (i==key) {
+ nKeyActs= needed;
+ if (needed<nCopy)
+ nCopy= needed;
+ }
+
+ if (nCopy>0)
+ memcpy(&newActs[nActs],XkbKeyActionsPtr(xkb,i),
+ nCopy*sizeof(XkbAction));
+ if (nCopy<nKeyActs)
+ bzero(&newActs[nActs+nCopy],(nKeyActs-nCopy)*sizeof(XkbAction));
+ xkb->server->key_acts[i]= nActs;
+ nActs+= nKeyActs;
+ }
+ _XkbFree(xkb->server->acts);
+ xkb->server->acts = newActs;
+ xkb->server->num_acts= nActs;
+ return &xkb->server->acts[xkb->server->key_acts[key]];
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeClientMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+#else
+XkbFreeClientMap(xkb,what,freeMap)
+ XkbDescPtr xkb;
+ unsigned what;
+ Bool freeMap;
+#endif
+{
+XkbClientMapPtr map;
+
+ if ((xkb==NULL)||(xkb->map==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllClientInfoMask;
+ map= xkb->map;
+ if (what&XkbKeyTypesMask) {
+ if (map->types!=NULL) {
+ if (map->num_types>0) {
+ register int i;
+ XkbKeyTypePtr type;
+ for (i=0,type=map->types;i<map->num_types;i++,type++) {
+ if (type->map!=NULL) {
+ _XkbFree(type->map);
+ type->map= NULL;
+ }
+ if (type->preserve!=NULL) {
+ _XkbFree(type->preserve);
+ type->preserve= NULL;
+ }
+ type->map_count= 0;
+ if (type->level_names!=NULL) {
+ _XkbFree(type->level_names);
+ type->level_names= NULL;
+ }
+ }
+ }
+ _XkbFree(map->types);
+ map->num_types= map->size_types= 0;
+ map->types= NULL;
+ }
+ }
+ if (what&XkbKeySymsMask) {
+ if (map->key_sym_map!=NULL) {
+ _XkbFree(map->key_sym_map);
+ map->key_sym_map= NULL;
+ }
+ if (map->syms!=NULL) {
+ _XkbFree(map->syms);
+ map->size_syms= map->num_syms= 0;
+ map->syms= NULL;
+ }
+ }
+ if ((what&XkbModifierMapMask)&&(map->modmap!=NULL)) {
+ _XkbFree(map->modmap);
+ map->modmap= NULL;
+ }
+ if (freeMap) {
+ _XkbFree(xkb->map);
+ xkb->map= NULL;
+ }
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbFreeServerMap(XkbDescPtr xkb,unsigned what,Bool freeMap)
+#else
+XkbFreeServerMap(xkb,what,freeMap)
+ XkbDescPtr xkb;
+ unsigned what;
+ Bool freeMap;
+#endif
+{
+XkbServerMapPtr map;
+
+ if ((xkb==NULL)||(xkb->server==NULL))
+ return;
+ if (freeMap)
+ what= XkbAllServerInfoMask;
+ map= xkb->server;
+ if ((what&XkbExplicitComponentsMask)&&(map->explicit!=NULL)) {
+ _XkbFree(map->explicit);
+ map->explicit= NULL;
+ }
+ if (what&XkbKeyActionsMask) {
+ if (map->key_acts!=NULL) {
+ _XkbFree(map->key_acts);
+ map->key_acts= NULL;
+ }
+ if (map->acts!=NULL) {
+ _XkbFree(map->acts);
+ map->num_acts= map->size_acts= 0;
+ map->acts= NULL;
+ }
+ }
+ if ((what&XkbKeyBehaviorsMask)&&(map->behaviors!=NULL)) {
+ _XkbFree(map->behaviors);
+ map->behaviors= NULL;
+ }
+ if ((what&XkbVirtualModMapMask)&&(map->vmodmap!=NULL)) {
+ _XkbFree(map->vmodmap);
+ map->vmodmap= NULL;
+ }
+
+ if (freeMap) {
+ _XkbFree(xkb->server);
+ xkb->server= NULL;
+ }
+ return;
+}
diff --git a/src/xkb/XKBMisc.c b/src/xkb/XKBMisc.c
new file mode 100644
index 00000000..45c00692
--- /dev/null
+++ b/src/xkb/XKBMisc.c
@@ -0,0 +1,1071 @@
+/* $Xorg: XKBMisc.c,v 1.4 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#ifndef XKB_IN_SERVER
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include <X11/keysym.h>
+#include "XKBlibint.h"
+
+#else
+
+#include <stdio.h>
+#include "X.h"
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xproto.h"
+#include "misc.h"
+#include "inputstr.h"
+#include <X11/keysym.h>
+#define XKBSRV_NEED_FILE_FUNCS
+#include "XKBsrv.h"
+
+#endif /* XKB_IN_SERVER */
+
+/***====================================================================***/
+
+#define mapSize(m) (sizeof(m)/sizeof(XkbKTMapEntryRec))
+static XkbKTMapEntryRec map2Level[]= {
+ { True, ShiftMask, 1, ShiftMask, 0 }
+};
+
+static XkbKTMapEntryRec mapAlpha[]= {
+ { True, ShiftMask, 1, ShiftMask, 0 },
+ { True, LockMask, 0, LockMask, 0 }
+};
+
+static XkbModsRec preAlpha[]= {
+ { 0, 0, 0 },
+ { LockMask, LockMask, 0 }
+};
+
+#define NL_VMOD_MASK 0
+static XkbKTMapEntryRec mapKeypad[]= {
+ { True, ShiftMask, 1, ShiftMask, 0 },
+ { False, 0, 1, 0, NL_VMOD_MASK }
+};
+
+static XkbKeyTypeRec canonicalTypes[XkbNumRequiredTypes] = {
+ { { 0, 0, 0 },
+ 1, /* num_levels */
+ 0, /* map_count */
+ NULL, NULL,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, 0 },
+ 2, /* num_levels */
+ mapSize(map2Level), /* map_count */
+ map2Level, NULL,
+ None, NULL
+ },
+ { { ShiftMask|LockMask, ShiftMask|LockMask, 0 },
+ 2, /* num_levels */
+ mapSize(mapAlpha), /* map_count */
+ mapAlpha, preAlpha,
+ None, NULL
+ },
+ { { ShiftMask, ShiftMask, NL_VMOD_MASK },
+ 2, /* num_levels */
+ mapSize(mapKeypad), /* map_count */
+ mapKeypad, NULL,
+ None, NULL
+ }
+};
+
+Status
+#if NeedFunctionPrototypes
+XkbInitCanonicalKeyTypes(XkbDescPtr xkb,unsigned which,int keypadVMod)
+#else
+XkbInitCanonicalKeyTypes(xkb,which,keypadVMod)
+ XkbDescPtr xkb;
+ unsigned which;
+ int keypadVMod;
+#endif
+{
+XkbClientMapPtr map;
+XkbKeyTypePtr from,to;
+Status rtrn;
+
+ if (!xkb)
+ return BadMatch;
+ rtrn= XkbAllocClientMap(xkb,XkbKeyTypesMask,XkbNumRequiredTypes);
+ if (rtrn!=Success)
+ return rtrn;
+ map= xkb->map;
+ if ((which&XkbAllRequiredTypes)==0)
+ return Success;
+ rtrn= Success;
+ from= canonicalTypes;
+ to= map->types;
+ if (which&XkbOneLevelMask)
+ rtrn= XkbCopyKeyType(&from[XkbOneLevelIndex],&to[XkbOneLevelIndex]);
+ if ((which&XkbTwoLevelMask)&&(rtrn==Success))
+ rtrn= XkbCopyKeyType(&from[XkbTwoLevelIndex],&to[XkbTwoLevelIndex]);
+ if ((which&XkbAlphabeticMask)&&(rtrn==Success))
+ rtrn= XkbCopyKeyType(&from[XkbAlphabeticIndex],&to[XkbAlphabeticIndex]);
+ if ((which&XkbKeypadMask)&&(rtrn==Success)) {
+ XkbKeyTypePtr type;
+ rtrn= XkbCopyKeyType(&from[XkbKeypadIndex],&to[XkbKeypadIndex]);
+ type= &to[XkbKeypadIndex];
+ if ((keypadVMod>=0)&&(keypadVMod<XkbNumVirtualMods)&&(rtrn==Success)) {
+ type->mods.vmods= (1<<keypadVMod);
+ type->map[0].active= True;
+ type->map[0].mods.mask= ShiftMask;
+ type->map[0].mods.real_mods= ShiftMask;
+ type->map[0].mods.vmods= 0;
+ type->map[0].level= 1;
+ type->map[1].active= False;
+ type->map[1].mods.mask= 0;
+ type->map[1].mods.real_mods= 0;
+ type->map[1].mods.vmods= (1<<keypadVMod);
+ type->map[1].level= 1;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+#define CORE_SYM(i) (i<map_width?core_syms[i]:NoSymbol)
+#define XKB_OFFSET(g,l) (((g)*groupsWidth)+(l))
+
+int
+#if NeedFunctionPrototypes
+XkbKeyTypesForCoreSymbols( XkbDescPtr xkb,
+ int map_width,
+ KeySym * core_syms,
+ unsigned int protected,
+ int * types_inout,
+ KeySym * xkb_syms_rtrn)
+#else
+XkbKeyTypesForCoreSymbols(xkb,map_width,core_syms,protected,types_inout,
+ xkb_syms_rtrn)
+ XkbDescPtr xkb;
+ int map_width;
+ KeySym * core_syms;
+ unsigned int protected;
+ int * types_inout;
+ KeySym * xkb_syms_rtrn;
+#endif
+{
+register int i;
+unsigned int empty;
+int nSyms[XkbNumKbdGroups];
+int nGroups,tmp,groupsWidth;
+
+ /* Section 12.2 of the protocol describes this process in more detail */
+ /* Step 1: find the # of symbols in the core mapping per group */
+ groupsWidth= 2;
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ if ((protected&(1<<i))&&(types_inout[i]<xkb->map->num_types)) {
+ nSyms[i]= xkb->map->types[types_inout[i]].num_levels;
+ if (nSyms[i]>groupsWidth)
+ groupsWidth= nSyms[i];
+ }
+ else {
+ types_inout[i]= XkbTwoLevelIndex; /* don't really know, yet */
+ nSyms[i]= 2;
+ }
+ }
+ if (nSyms[XkbGroup1Index]<2)
+ nSyms[XkbGroup1Index]= 2;
+ if (nSyms[XkbGroup2Index]<2)
+ nSyms[XkbGroup2Index]= 2;
+ /* Step 2: Copy the symbols from the core ordering to XKB ordering */
+ /* symbols in the core are in the order: */
+ /* G1L1 G1L2 G2L1 G2L2 [G1L[3-n]] [G2L[3-n]] [G3L*] [G3L*] */
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,0)]= CORE_SYM(0);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,1)]= CORE_SYM(1);
+ for (i=2;i<nSyms[XkbGroup1Index];i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup1Index,i)]= CORE_SYM(2+i);
+ }
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,0)]= CORE_SYM(2);
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,1)]= CORE_SYM(3);
+ tmp= 2+(nSyms[XkbGroup1Index]-2); /* offset to extra group2 syms */
+ for (i=2;i<nSyms[XkbGroup2Index];i++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup2Index,i)]= CORE_SYM(tmp+i);
+ }
+ tmp= nSyms[XkbGroup1Index]+nSyms[XkbGroup2Index];
+ if ((tmp>=map_width)&&
+ ((protected&(XkbExplicitKeyType3Mask|XkbExplicitKeyType4Mask))==0)) {
+ nSyms[XkbGroup3Index]= 0;
+ nSyms[XkbGroup4Index]= 0;
+ nGroups= 2;
+ }
+ else {
+ nGroups= 3;
+ for (i=0;i<nSyms[XkbGroup3Index];i++,tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup3Index,i)]= CORE_SYM(tmp);
+ }
+ if ((tmp<map_width)||(protected&XkbExplicitKeyType4Mask)) {
+ nGroups= 4;
+ for (i=0;i<nSyms[XkbGroup4Index];i++,tmp++) {
+ xkb_syms_rtrn[XKB_OFFSET(XkbGroup4Index,i)]= CORE_SYM(tmp);
+ }
+ }
+ else {
+ nSyms[XkbGroup4Index]= 0;
+ }
+ }
+ /* steps 3&4: alphanumeric expansion, assign canonical types */
+ empty= 0;
+ for (i=0;i<nGroups;i++) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
+ if ((nSyms[i]>1)&&(syms[1]==NoSymbol)&&(syms[0]!=NoSymbol)) {
+ KeySym upper,lower;
+ XConvertCase(syms[0],&lower,&upper);
+ if (upper!=lower) {
+ xkb_syms_rtrn[XKB_OFFSET(i,0)]= lower;
+ xkb_syms_rtrn[XKB_OFFSET(i,1)]= upper;
+ if ((protected&(1<<i))==0)
+ types_inout[i]= XkbAlphabeticIndex;
+ }
+ else if ((protected&(1<<i))==0) {
+ types_inout[i]= XkbOneLevelIndex;
+ /* nSyms[i]= 1;*/
+ }
+ }
+ if (((protected&(1<<i))==0)&&(types_inout[i]==XkbTwoLevelIndex)) {
+ if (IsKeypadKey(syms[0])||IsKeypadKey(syms[1]))
+ types_inout[i]= XkbKeypadIndex;
+ else {
+ KeySym upper,lower;
+ XConvertCase(syms[0],&lower,&upper);
+ if ((syms[0]==lower)&&(syms[1]==upper))
+ types_inout[i]= XkbAlphabeticIndex;
+ }
+ }
+ if (syms[0]==NoSymbol) {
+ register int n;
+ Bool found;
+ for (n=1,found=False;(!found)&&(n<nSyms[i]);n++) {
+ found= (syms[n]!=NoSymbol);
+ }
+ if (!found)
+ empty|= (1<<i);
+ }
+ }
+ /* step 5: squoosh out empty groups */
+ if (empty) {
+ for (i=nGroups-1;i>=0;i--) {
+ if (((empty&(1<<i))==0)||(protected&(1<<i)))
+ break;
+ nGroups--;
+ }
+ }
+ if (nGroups<1)
+ return 0;
+
+ /* step 6: replicate group 1 into group two, if necessary */
+ if ((nGroups>1)&&((empty&(XkbGroup1Mask|XkbGroup2Mask))==XkbGroup2Mask)) {
+ if ((protected&(XkbExplicitKeyType1Mask|XkbExplicitKeyType2Mask))==0) {
+ nSyms[XkbGroup2Index]= nSyms[XkbGroup1Index];
+ types_inout[XkbGroup2Index]= types_inout[XkbGroup1Index];
+ memcpy((char *)&xkb_syms_rtrn[2],(char *)xkb_syms_rtrn,
+ 2*sizeof(KeySym));
+ }
+ else if (types_inout[XkbGroup1Index]==types_inout[XkbGroup2Index]) {
+ memcpy((char *)&xkb_syms_rtrn[nSyms[XkbGroup1Index]],
+ (char *)xkb_syms_rtrn,
+ nSyms[XkbGroup1Index]*sizeof(KeySym));
+ }
+ }
+
+ /* step 7: check for all groups identical or all width 1 */
+ if (nGroups>1) {
+ Bool sameType,allOneLevel;
+ allOneLevel= (xkb->map->types[types_inout[0]].num_levels==1);
+ for (i=1,sameType=True;(allOneLevel||sameType)&&(i<nGroups);i++) {
+ sameType=(sameType&&(types_inout[i]==types_inout[XkbGroup1Index]));
+ if (allOneLevel)
+ allOneLevel= (xkb->map->types[types_inout[i]].num_levels==1);
+ }
+ if ((sameType)&&
+ (!(protected&(XkbExplicitKeyTypesMask&~XkbExplicitKeyType1Mask)))){
+ register int s;
+ Bool identical;
+ for (i=1,identical=True;identical&&(i<nGroups);i++) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[XKB_OFFSET(i,0)];
+ for (s=0;identical&&(s<nSyms[i]);s++) {
+ if (syms[s]!=xkb_syms_rtrn[s])
+ identical= False;
+ }
+ }
+ if (identical)
+ nGroups= 1;
+ }
+ if (allOneLevel && (nGroups>1)) {
+ KeySym *syms;
+ syms= &xkb_syms_rtrn[nSyms[XkbGroup1Index]];
+ nSyms[XkbGroup1Index]= 1;
+ for (i=1;i<nGroups;i++) {
+ xkb_syms_rtrn[i]= syms[0];
+ syms+= nSyms[i];
+ nSyms[i]= 1;
+ }
+ }
+ }
+ return nGroups;
+}
+
+static XkbSymInterpretPtr
+#if NeedFunctionPrototypes
+_XkbFindMatchingInterp( XkbDescPtr xkb,
+ KeySym sym,
+ unsigned int real_mods,
+ unsigned int level)
+#else
+_XkbFindMatchingInterp(xkb,sym,real_mods,level)
+ XkbDescPtr xkb;
+ KeySym sym;
+ unsigned int real_mods;
+ unsigned int level;
+#endif
+{
+register unsigned i;
+XkbSymInterpretPtr interp,rtrn;
+CARD8 mods;
+
+ rtrn= NULL;
+ interp= xkb->compat->sym_interpret;
+ for (i=0;i<xkb->compat->num_si;i++,interp++) {
+ if ((interp->sym==NoSymbol)||(sym==interp->sym)) {
+ int match;
+ if ((level==0)||((interp->match&XkbSI_LevelOneOnly)==0))
+ mods= real_mods;
+ else mods= 0;
+ switch (interp->match&XkbSI_OpMask) {
+ case XkbSI_NoneOf:
+ match= ((interp->mods&mods)==0);
+ break;
+ case XkbSI_AnyOfOrNone:
+ match= ((mods==0)||((interp->mods&mods)!=0));
+ break;
+ case XkbSI_AnyOf:
+ match= ((interp->mods&mods)!=0);
+ break;
+ case XkbSI_AllOf:
+ match= ((interp->mods&mods)==interp->mods);
+ break;
+ case XkbSI_Exactly:
+ match= (interp->mods==mods);
+ break;
+ default:
+ match= 0;
+ break;
+ }
+ if (match) {
+ if (interp->sym!=NoSymbol) {
+ return interp;
+ }
+ else if (rtrn==NULL) {
+ rtrn= interp;
+ }
+ }
+ }
+ }
+ return rtrn;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbAddKeyChange(KeyCode *pFirst,unsigned char *pNum,KeyCode newKey)
+#else
+_XkbAddKeyChange(pFirst,pNum,newKey)
+ KeyCode * pFirst;
+ unsigned char * pNum;
+ KeyCode newKey;
+#endif
+{
+KeyCode last;
+
+ last= (*pFirst)+(*pNum);
+ if (newKey<*pFirst) {
+ *pFirst= newKey;
+ *pNum= (last-newKey)+1;
+ }
+ else if (newKey>last) {
+ *pNum= (last-*pFirst)+1;
+ }
+ return;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbSetActionKeyMods(XkbDescPtr xkb,XkbAction *act,unsigned mods)
+#else
+_XkbSetActionKeyMods(xkb,act,mods)
+ XkbDescPtr xkb;
+ XkbAction * act;
+ unsigned mods;
+#endif
+{
+unsigned tmp;
+
+ switch (act->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
+ if (act->mods.flags&XkbSA_UseModMapMods)
+ act->mods.real_mods= act->mods.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->mods))!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->mods.mask|= tmp;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if (act->iso.flags&XkbSA_UseModMapMods)
+ act->iso.real_mods= act->iso.mask= mods;
+ if ((tmp= XkbModActionVMods(&act->iso))!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->iso.mask|= tmp;
+ }
+ break;
+ }
+ return;
+}
+
+#define IBUF_SIZE 8
+
+Bool
+#if NeedFunctionPrototypes
+XkbApplyCompatMapToKey(XkbDescPtr xkb,KeyCode key,XkbChangesPtr changes)
+#else
+XkbApplyCompatMapToKey(xkb,key,changes)
+ XkbDescPtr xkb;
+ KeyCode key;
+ XkbChangesPtr changes;
+#endif
+{
+KeySym * syms;
+unsigned char explicit,mods;
+XkbSymInterpretPtr *interps,ibuf[IBUF_SIZE];
+int n,nSyms,found;
+unsigned changed,tmp;
+
+ if ((!xkb)||(!xkb->map)||(!xkb->map->key_sym_map)||
+ (!xkb->compat)||(!xkb->compat->sym_interpret)||
+ (key<xkb->min_key_code)||(key>xkb->max_key_code)) {
+ return False;
+ }
+ if (((!xkb->server)||(!xkb->server->key_acts))&&
+ (XkbAllocServerMap(xkb,XkbAllServerInfoMask,0)!=Success)) {
+ return False;
+ }
+ changed= 0; /* keeps track of what has changed in _this_ call */
+ explicit= xkb->server->explicit[key];
+ if (explicit&XkbExplicitInterpretMask) /* nothing to do */
+ return True;
+ mods= (xkb->map->modmap?xkb->map->modmap[key]:0);
+ nSyms= XkbKeyNumSyms(xkb,key);
+ syms= XkbKeySymsPtr(xkb,key);
+ if (nSyms>IBUF_SIZE) {
+ interps= _XkbTypedCalloc(nSyms,XkbSymInterpretPtr);
+ if (interps==NULL) {
+ interps= ibuf;
+ nSyms= IBUF_SIZE;
+ }
+ }
+ else {
+ interps= ibuf;
+ }
+ found= 0;
+ for (n=0;n<nSyms;n++) {
+ unsigned level= (n%XkbKeyGroupsWidth(xkb,key));
+ interps[n]= NULL;
+ if (syms[n]!=NoSymbol) {
+ interps[n]= _XkbFindMatchingInterp(xkb,syms[n],mods,level);
+ if (interps[n]&&interps[n]->act.type!=XkbSA_NoAction)
+ found++;
+ else interps[n]= NULL;
+ }
+ }
+ /* 1/28/96 (ef) -- XXX! WORKING HERE */
+ if (!found) {
+ if (xkb->server->key_acts[key]!=0) {
+ xkb->server->key_acts[key]= 0;
+ changed|= XkbKeyActionsMask;
+ }
+ }
+ else {
+ XkbAction *pActs;
+ unsigned int new_vmodmask;
+ changed|= XkbKeyActionsMask;
+ pActs= XkbResizeKeyActions(xkb,key,nSyms);
+ if (!pActs)
+ return False;
+ new_vmodmask= 0;
+ for (n=0;n<nSyms;n++) {
+ if (interps[n]) {
+ unsigned effMods;
+
+ pActs[n]= *((XkbAction *)&interps[n]->act);
+ if ((n==0)||((interps[n]->match&XkbSI_LevelOneOnly)==0)) {
+ effMods= mods;
+ if (interps[n]->virtual_mod!=XkbNoModifier)
+ new_vmodmask|= (1<<interps[n]->virtual_mod);
+ }
+ else effMods= 0;
+ _XkbSetActionKeyMods(xkb,&pActs[n],effMods);
+ }
+ else pActs[n].type= XkbSA_NoAction;
+ }
+ if (((explicit&XkbExplicitVModMapMask)==0)&&
+ (xkb->server->vmodmap[key]!=new_vmodmask)) {
+ changed|= XkbVirtualModMapMask;
+ xkb->server->vmodmap[key]= new_vmodmask;
+ }
+ if (interps[0]) {
+ if ((interps[0]->flags&XkbSI_LockingKey)&&
+ ((explicit&XkbExplicitBehaviorMask)==0)) {
+ xkb->server->behaviors[key].type= XkbKB_Lock;
+ changed|= XkbKeyBehaviorsMask;
+ }
+ if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
+ CARD8 old;
+ old= xkb->ctrls->per_key_repeat[key/8];
+ if (interps[0]->flags&XkbSI_AutoRepeat)
+ xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
+ else xkb->ctrls->per_key_repeat[key/8]&= ~(1<<(key%8));
+ if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
+ changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
+ }
+ }
+ }
+ if ((!found)||(interps[0]==NULL)) {
+ if (((explicit&XkbExplicitAutoRepeatMask)==0)&&(xkb->ctrls)) {
+ CARD8 old;
+ old= xkb->ctrls->per_key_repeat[key/8];
+#if RETURN_SHOULD_REPEAT
+ if (*XkbKeySymsPtr(xkb,key) != XK_Return)
+#endif
+ xkb->ctrls->per_key_repeat[key/8]|= (1<<(key%8));
+ if (changes && (old!=xkb->ctrls->per_key_repeat[key/8]))
+ changes->ctrls.changed_ctrls|= XkbPerKeyRepeatMask;
+ }
+ if (((explicit&XkbExplicitBehaviorMask)==0)&&
+ (xkb->server->behaviors[key].type==XkbKB_Lock)) {
+ xkb->server->behaviors[key].type= XkbKB_Default;
+ changed|= XkbKeyBehaviorsMask;
+ }
+ }
+ if (changes) {
+ XkbMapChangesPtr mc;
+ mc= &changes->map;
+ tmp= (changed&mc->changed);
+ if (tmp&XkbKeyActionsMask)
+ _XkbAddKeyChange(&mc->first_key_act,&mc->num_key_acts,key);
+ else if (changed&XkbKeyActionsMask) {
+ mc->changed|= XkbKeyActionsMask;
+ mc->first_key_act= key;
+ mc->num_key_acts= 1;
+ }
+ if (tmp&XkbKeyBehaviorsMask) {
+ _XkbAddKeyChange(&mc->first_key_behavior,&mc->num_key_behaviors,
+ key);
+ }
+ else if (changed&XkbKeyBehaviorsMask) {
+ mc->changed|= XkbKeyBehaviorsMask;
+ mc->first_key_behavior= key;
+ mc->num_key_behaviors= 1;
+ }
+ if (tmp&XkbVirtualModMapMask)
+ _XkbAddKeyChange(&mc->first_vmodmap_key,&mc->num_vmodmap_keys,key);
+ else if (changed&XkbVirtualModMapMask) {
+ mc->changed|= XkbVirtualModMapMask;
+ mc->first_vmodmap_key= key;
+ mc->num_vmodmap_keys= 1;
+ }
+ mc->changed|= changed;
+ }
+ if (interps!=ibuf)
+ _XkbFree(interps);
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbUpdateMapFromCore( XkbDescPtr xkb,
+ KeyCode first_key,
+ int num_keys,
+ int map_width,
+ KeySym * core_keysyms,
+ XkbChangesPtr changes)
+#else
+XkbUpdateMapFromCore(xkb,first_key,num_keys,map_width,core_keysyms,changes)
+ XkbDescPtr xkb;
+ KeyCode first_key;
+ int num_keys;
+ int map_width;
+ KeySym * core_keysyms;
+ XkbChangesPtr changes;
+#endif
+{
+register int key,last_key;
+KeySym * syms;
+
+ syms= &core_keysyms[(first_key-xkb->min_key_code)*map_width];
+ if (changes) {
+ if (changes->map.changed&XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms,first_key);
+ if (num_keys>1) {
+ _XkbAddKeyChange(&changes->map.first_key_sym,
+ &changes->map.num_key_syms,
+ first_key+num_keys-1);
+ }
+ }
+ else {
+ changes->map.changed|= XkbKeySymsMask;
+ changes->map.first_key_sym= first_key;
+ changes->map.num_key_syms= num_keys;
+ }
+ }
+ last_key= first_key+num_keys-1;
+ for (key=first_key;key<=last_key;key++,syms+= map_width) {
+ XkbMapChangesPtr mc;
+ unsigned explicit;
+ KeySym tsyms[XkbMaxSymsPerKey];
+ int types[XkbNumKbdGroups];
+ int nG;
+
+ explicit= xkb->server->explicit[key]&XkbExplicitKeyTypesMask;
+ types[XkbGroup1Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
+ types[XkbGroup2Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup2Index);
+ types[XkbGroup3Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup3Index);
+ types[XkbGroup4Index]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup4Index);
+ nG= XkbKeyTypesForCoreSymbols(xkb,map_width,syms,explicit,types,tsyms);
+ if (changes)
+ mc= &changes->map;
+ else mc= NULL;
+ XkbChangeTypesOfKey(xkb,key,nG,XkbAllGroupsMask,types,mc);
+ memcpy((char *)XkbKeySymsPtr(xkb,key),(char *)tsyms,
+ XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
+ XkbApplyCompatMapToKey(xkb,key,changes);
+ }
+
+ if ((xkb->server->vmods!=NULL)&&(xkb->map->modmap!=NULL)&&(changes)&&
+ (changes->map.changed&(XkbVirtualModMapMask|XkbModifierMapMask))) {
+ unsigned char newVMods[XkbNumVirtualMods];
+ register unsigned bit,i;
+ unsigned present;
+
+ bzero(newVMods,XkbNumVirtualMods);
+ present= 0;
+ for (key=xkb->min_key_code;key<=xkb->max_key_code;key++) {
+ if (xkb->server->vmodmap[key]==0)
+ continue;
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (bit&xkb->server->vmodmap[key]) {
+ present|= bit;
+ newVMods[i]|= xkb->map->modmap[key];
+ }
+ }
+ }
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if ((bit&present)&&(newVMods[i]!=xkb->server->vmods[i])) {
+ changes->map.changed|= XkbVirtualModsMask;
+ changes->map.vmods|= bit;
+ xkb->server->vmods[i]= newVMods[i];
+ }
+ }
+ }
+ if (changes && (changes->map.changed&XkbVirtualModsMask))
+ XkbApplyVirtualModChanges(xkb,changes->map.vmods,changes);
+ return True;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbChangeTypesOfKey( XkbDescPtr xkb,
+ int key,
+ int nGroups,
+ unsigned groups,
+ int * newTypesIn,
+ XkbMapChangesPtr changes)
+#else
+XkbChangeTypesOfKey(xkb,key,nGroups,groups,newTypesIn,changes)
+ XkbDescPtr xkb;
+ int key;
+ int nGroups;
+ unsigned groups;
+ int * newTypesIn;
+ XkbMapChangesPtr changes;
+#endif
+{
+XkbKeyTypePtr pOldType,pNewType;
+register int i;
+int width,nOldGroups,oldWidth,newTypes[XkbNumKbdGroups];
+
+ if ((!xkb) || (!XkbKeycodeInRange(xkb,key)) || (!xkb->map) ||
+ (!xkb->map->types)||(!newTypes)||((groups&XkbAllGroupsMask)==0)||
+ (nGroups>XkbNumKbdGroups)) {
+ return BadMatch;
+ }
+ if (nGroups==0) {
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= XkbOneLevelIndex;
+ }
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,0);
+ xkb->map->key_sym_map[key].group_info= i;
+ XkbResizeKeySyms(xkb,key,0);
+ return Success;
+ }
+
+ nOldGroups= XkbKeyNumGroups(xkb,key);
+ oldWidth= XkbKeyGroupsWidth(xkb,key);
+ for (width=i=0;i<nGroups;i++) {
+ if (groups&(1<<i))
+ newTypes[i]= newTypesIn[i];
+ else if (i<nOldGroups)
+ newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,i);
+ else if (nOldGroups>0)
+ newTypes[i]= XkbKeyKeyTypeIndex(xkb,key,XkbGroup1Index);
+ else newTypes[i]= XkbTwoLevelIndex;
+ if (newTypes[i]>xkb->map->num_types)
+ return BadMatch;
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>width)
+ width= pNewType->num_levels;
+ }
+ if ((xkb->ctrls)&&(nGroups>xkb->ctrls->num_groups))
+ xkb->ctrls->num_groups= nGroups;
+ if ((width!=oldWidth)||(nGroups!=nOldGroups)) {
+ KeySym oldSyms[XkbMaxSymsPerKey],*pSyms;
+ int nCopy;
+
+ if (nOldGroups==0) {
+ pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
+ if (pSyms!=NULL) {
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,nGroups);
+ xkb->map->key_sym_map[key].group_info= i;
+ xkb->map->key_sym_map[key].width= width;
+ for (i=0;i<nGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
+ }
+ return Success;
+ }
+ return BadAlloc;
+ }
+ pSyms= XkbKeySymsPtr(xkb,key);
+ memcpy(oldSyms,pSyms,XkbKeyNumSyms(xkb,key)*sizeof(KeySym));
+ pSyms= XkbResizeKeySyms(xkb,key,width*nGroups);
+ if (pSyms==NULL)
+ return BadAlloc;
+ bzero(pSyms,width*nGroups*sizeof(KeySym));
+ for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
+ pOldType= XkbKeyKeyType(xkb,key,i);
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>pOldType->num_levels)
+ nCopy= pOldType->num_levels;
+ else nCopy= pNewType->num_levels;
+ memcpy(&pSyms[i*width],&oldSyms[i*oldWidth],nCopy*sizeof(KeySym));
+ }
+ if (XkbKeyHasActions(xkb,key)) {
+ XkbAction oldActs[XkbMaxSymsPerKey],*pActs;
+ pActs= XkbKeyActionsPtr(xkb,key);
+ memcpy(oldActs,pActs,XkbKeyNumSyms(xkb,key)*sizeof(XkbAction));
+ pActs= XkbResizeKeyActions(xkb,key,width*nGroups);
+ if (pActs==NULL)
+ return BadAlloc;
+ bzero(pActs,width*nGroups*sizeof(XkbAction));
+ for (i=0;(i<nGroups)&&(i<nOldGroups);i++) {
+ pOldType= XkbKeyKeyType(xkb,key,i);
+ pNewType= &xkb->map->types[newTypes[i]];
+ if (pNewType->num_levels>pOldType->num_levels)
+ nCopy= pOldType->num_levels;
+ else nCopy= pNewType->num_levels;
+ memcpy(&pActs[i*width],&oldActs[i*oldWidth],
+ nCopy*sizeof(XkbAction));
+ }
+ }
+ i= xkb->map->key_sym_map[key].group_info;
+ i= XkbSetNumGroups(i,nGroups);
+ xkb->map->key_sym_map[key].group_info= i;
+ xkb->map->key_sym_map[key].width= width;
+ }
+ width= 0;
+ for (i=0;i<nGroups;i++) {
+ xkb->map->key_sym_map[key].kt_index[i]= newTypes[i];
+ if (xkb->map->types[newTypes[i]].num_levels>width)
+ width= xkb->map->types[newTypes[i]].num_levels;
+ }
+ xkb->map->key_sym_map[key].width= width;
+ if (changes!=NULL) {
+ if (changes->changed&XkbKeySymsMask) {
+ _XkbAddKeyChange(&changes->first_key_sym,&changes->num_key_syms,
+ key);
+ }
+ else {
+ changes->changed|= XkbKeySymsMask;
+ changes->first_key_sym= key;
+ changes->num_key_syms= 1;
+ }
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Bool
+#if NeedFunctionPrototypes
+XkbVirtualModsToReal(XkbDescPtr xkb,unsigned virtual_mask,unsigned *mask_rtrn)
+#else
+XkbVirtualModsToReal(xkb,virtual_mask,mask_rtrn)
+ XkbDescPtr xkb;
+ unsigned virtual_mask;
+ unsigned * mask_rtrn;
+#endif
+{
+register int i,bit;
+register unsigned mask;
+
+ if (xkb==NULL)
+ return False;
+ if (virtual_mask==0) {
+ *mask_rtrn= 0;
+ return True;
+ }
+ if (xkb->server==NULL)
+ return False;
+ for (i=mask=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (virtual_mask&bit)
+ mask|= xkb->server->vmods[i];
+ }
+ *mask_rtrn= mask;
+ return True;
+}
+
+/***====================================================================***/
+
+Bool
+#if NeedFunctionPrototypes
+XkbUpdateActionVirtualMods(XkbDescPtr xkb,XkbAction *act,unsigned changed)
+#else
+XkbUpdateActionVirtualMods(xkb,act,changed)
+ XkbDescPtr xkb;
+ XkbAction * act;
+ unsigned changed;
+#endif
+{
+unsigned int tmp;
+
+ switch (act->type) {
+ case XkbSA_SetMods: case XkbSA_LatchMods: case XkbSA_LockMods:
+ if (((tmp= XkbModActionVMods(&act->mods))&changed)!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->mods.mask= act->mods.real_mods;
+ act->mods.mask|= tmp;
+ return True;
+ }
+ break;
+ case XkbSA_ISOLock:
+ if ((((tmp= XkbModActionVMods(&act->iso))!=0)&changed)!=0) {
+ XkbVirtualModsToReal(xkb,tmp,&tmp);
+ act->iso.mask= act->iso.real_mods;
+ act->iso.mask|= tmp;
+ return True;
+ }
+ break;
+ }
+ return False;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbUpdateKeyTypeVirtualMods( XkbDescPtr xkb,
+ XkbKeyTypePtr type,
+ unsigned int changed,
+ XkbChangesPtr changes)
+#else
+XkbUpdateKeyTypeVirtualMods(xkb,type,changed,changes)
+ XkbDescPtr xkb;
+ XkbKeyTypePtr type;
+ unsigned int changed;
+ XkbChangesPtr changes;
+#endif
+{
+register unsigned int i;
+unsigned int mask;
+
+ XkbVirtualModsToReal(xkb,type->mods.vmods,&mask);
+ type->mods.mask= type->mods.real_mods|mask;
+ if ((type->map_count>0)&&(type->mods.vmods!=0)) {
+ XkbKTMapEntryPtr entry;
+ for (i=0,entry=type->map;i<type->map_count;i++,entry++) {
+ if (entry->mods.vmods!=0) {
+ XkbVirtualModsToReal(xkb,entry->mods.vmods,&mask);
+ entry->mods.mask=entry->mods.real_mods|mask;
+ /* entry is active if vmods are bound*/
+ entry->active= (mask!=0);
+ }
+ else entry->active= 1;
+ }
+ }
+ if (changes) {
+ int type_ndx;
+ type_ndx= type-xkb->map->types;
+ if ((type_ndx<0)||(type_ndx>xkb->map->num_types))
+ return;
+ if (changes->map.changed&XkbKeyTypesMask) {
+ int last;
+ last= changes->map.first_type+changes->map.num_types-1;
+ if (type_ndx<changes->map.first_type) {
+ changes->map.first_type= type_ndx;
+ changes->map.num_types= (last-type_ndx)+1;
+ }
+ else if (type_ndx>last) {
+ changes->map.num_types= (type_ndx-changes->map.first_type)+1;
+ }
+ }
+ else {
+ changes->map.changed|= XkbKeyTypesMask;
+ changes->map.first_type= type_ndx;
+ changes->map.num_types= 1;
+ }
+ }
+ return;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbApplyVirtualModChanges(XkbDescPtr xkb,unsigned changed,XkbChangesPtr changes)
+#else
+XkbApplyVirtualModChanges(xkb,changed,changes)
+ XkbDescPtr xkb;
+ unsigned changed;
+ XkbChangesPtr changes;
+#endif
+{
+register int i;
+unsigned checkState;
+
+ if ((!xkb) || (!xkb->map) || (changed==0))
+ return False;
+ for (i=0;i<xkb->map->num_types;i++) {
+ if (xkb->map->types[i].mods.vmods & changed)
+ XkbUpdateKeyTypeVirtualMods(xkb,&xkb->map->types[i],changed,changes);
+ }
+ if (changed&xkb->ctrls->internal.vmods) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,xkb->ctrls->internal.vmods,&newMask);
+ newMask|= xkb->ctrls->internal.real_mods;
+ if (xkb->ctrls->internal.mask!=newMask) {
+ xkb->ctrls->internal.mask= newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls|= XkbInternalModsMask;
+ checkState= True;
+ }
+ }
+ }
+ if (changed&xkb->ctrls->ignore_lock.vmods) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,xkb->ctrls->ignore_lock.vmods,&newMask);
+ newMask|= xkb->ctrls->ignore_lock.real_mods;
+ if (xkb->ctrls->ignore_lock.mask!=newMask) {
+ xkb->ctrls->ignore_lock.mask= newMask;
+ if (changes) {
+ changes->ctrls.changed_ctrls|= XkbIgnoreLockModsMask;
+ checkState= True;
+ }
+ }
+ }
+ if (xkb->indicators!=NULL) {
+ XkbIndicatorMapPtr map;
+ map= &xkb->indicators->maps[0];
+ for (i=0;i<XkbNumIndicators;i++,map++) {
+ if (map->mods.vmods&changed) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,map->mods.vmods,&newMask);
+ newMask|= map->mods.real_mods;
+ if (newMask!=map->mods.mask) {
+ map->mods.mask= newMask;
+ if (changes) {
+ changes->indicators.map_changes|= (1<<i);
+ checkState= True;
+ }
+ }
+ }
+ }
+ }
+ if (xkb->compat!=NULL) {
+ XkbCompatMapPtr compat;
+ compat= xkb->compat;
+ for (i=0;i<XkbNumKbdGroups;i++) {
+ unsigned int newMask;
+ XkbVirtualModsToReal(xkb,compat->groups[i].vmods,&newMask);
+ newMask|= compat->groups[i].real_mods;
+ if (compat->groups[i].mask!=newMask) {
+ compat->groups[i].mask= newMask;
+ if (changes) {
+ changes->compat.changed_groups|= (1<<i);
+ checkState= True;
+ }
+ }
+ }
+ }
+ if (xkb->map && xkb->server) {
+ int highChange,lowChange;
+ lowChange= -1;
+ for (i=xkb->min_key_code;i<=xkb->max_key_code;i++) {
+ if (XkbKeyHasActions(xkb,i)) {
+ register XkbAction *pAct;
+ register int n;
+
+ pAct= XkbKeyActionsPtr(xkb,i);
+ for (n=XkbKeyNumActions(xkb,i);n>0;n--,pAct++) {
+ if ((pAct->type!=XkbSA_NoAction)&&
+ XkbUpdateActionVirtualMods(xkb,pAct,changed)) {
+ if (lowChange<0)
+ lowChange= i;
+ highChange= i;
+ }
+ }
+ }
+ }
+ if (changes && (lowChange>0)) { /* something changed */
+ if (changes->map.changed&XkbKeyActionsMask) {
+ int last;
+ if (changes->map.first_key_act<lowChange)
+ lowChange= changes->map.first_key_act;
+ last= changes->map.first_key_act+changes->map.num_key_acts-1;
+ if (last>highChange)
+ highChange= last;
+ }
+ changes->map.changed|= XkbKeyActionsMask;
+ changes->map.first_key_act= lowChange;
+ changes->map.num_key_acts= (highChange-lowChange)+1;
+ }
+ }
+ return checkState;
+}
diff --git a/src/xkb/XKBNames.c b/src/xkb/XKBNames.c
new file mode 100644
index 00000000..22439d29
--- /dev/null
+++ b/src/xkb/XKBNames.c
@@ -0,0 +1,953 @@
+/* $Xorg: XKBNames.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+
+static Status
+#if NeedFunctionPrototypes
+_XkbReadAtoms( XkbReadBufferPtr buf,
+ Atom * atoms,
+ int maxAtoms,
+ CARD32 present)
+#else
+_XkbReadAtoms(buf,atoms,maxAtoms,present)
+ XkbReadBufferPtr buf;
+ Atom *atoms;
+ int maxAtoms;
+ CARD32 present;
+#endif
+{
+register int i,bit;
+
+ for (i=0,bit=1;(i<maxAtoms)&&(present);i++,bit<<=1) {
+ if (present&bit) {
+ if (!_XkbReadBufferCopy32(buf,(long *)&atoms[i],1))
+ return BadLength;
+ present&= ~bit;
+ }
+ }
+ return Success;
+}
+
+Status
+#if NeedFunctionPrototypes
+_XkbReadGetNamesReply( Display * dpy,
+ xkbGetNamesReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+#else
+_XkbReadGetNamesReply(dpy,rep,xkb,nread_rtrn)
+ Display * dpy;
+ xkbGetNamesReply * rep;
+ XkbDescPtr xkb;
+ int * nread_rtrn;
+#endif
+{
+ int i,len;
+ XkbReadBufferRec buf;
+ register XkbNamesPtr names;
+
+ if ( xkb->device_spec == XkbUseCoreKbd )
+ xkb->device_spec = rep->deviceID;
+
+ if ((xkb->names==NULL)&&
+ (XkbAllocNames(xkb,rep->which,
+ rep->nRadioGroups,rep->nKeyAliases)!=Success)) {
+ return BadAlloc;
+ }
+ names= xkb->names;
+ if (rep->length==0)
+ return Success;
+
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+
+ if ((rep->which&XkbKeycodesNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->keycodes,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbGeometryNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->geometry,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbSymbolsNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->symbols,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbPhysSymbolsNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->phys_symbols,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbTypesNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->types,1)))
+ goto BAILOUT;
+ if ((rep->which&XkbCompatNameMask)&&
+ (!_XkbReadBufferCopy32(&buf,(long *)&names->compat,1)))
+ goto BAILOUT;
+
+ if ( rep->which & XkbKeyTypeNamesMask ) {
+ XkbClientMapPtr map= xkb->map;
+ XkbKeyTypePtr type;
+
+ len= rep->nTypes*4;
+ if (map!=NULL) {
+ type= map->types;
+ for (i=0;(i<map->num_types)&&(i<rep->nTypes);i++,type++) {
+ if (!_XkbReadBufferCopy32(&buf,(long *)&type->name,1))
+ goto BAILOUT;
+ len-= 4;
+ }
+ }
+ if ((len>0)&&(!_XkbSkipReadBufferData(&buf,len)))
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbKTLevelNamesMask ) {
+ CARD8 *nLevels;
+ XkbClientMapPtr map= xkb->map;
+ XkbKeyTypePtr type;
+
+ nLevels=(CARD8*)_XkbGetReadBufferPtr(&buf,XkbPaddedSize(rep->nTypes));
+ if (nLevels==NULL)
+ goto BAILOUT;
+ if (map!=NULL) {
+ type= map->types;
+ for (i=0;i<(int)rep->nTypes;i++,type++) {
+ if (i>=map->num_types) {
+ if (!_XkbSkipReadBufferData(&buf,nLevels[i]*4))
+ goto BAILOUT;
+ continue;
+ }
+ if ((nLevels[i]>0)&&(nLevels[i]!=type->num_levels)) {
+ goto BAILOUT;
+ }
+ if (type->level_names!=NULL)
+ Xfree(type->level_names);
+ if (nLevels[i]==0) {
+ type->level_names= NULL;
+ continue;
+ }
+ type->level_names= _XkbTypedCalloc(nLevels[i],Atom);
+ if (type->level_names!=NULL) {
+ if (!_XkbReadBufferCopy32(&buf,(long *)type->level_names,
+ nLevels[i]))
+ goto BAILOUT;
+ }
+ else {
+ _XkbSkipReadBufferData(&buf,nLevels[i]*4);
+ }
+ }
+ }
+ else {
+ for (i=0;i<(int)rep->nTypes;i++) {
+ _XkbSkipReadBufferData(&buf,nLevels[i]*4);
+ }
+ }
+ }
+ if (rep->which & XkbIndicatorNamesMask) {
+ if (_XkbReadAtoms(&buf,names->indicators,XkbNumIndicators,
+ rep->indicators)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbVirtualModNamesMask ) {
+ if (_XkbReadAtoms(&buf,names->vmods,XkbNumVirtualMods,
+ (CARD32)rep->virtualMods)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbGroupNamesMask ) {
+ if (_XkbReadAtoms(&buf,names->groups,XkbNumKbdGroups,
+ (CARD32)rep->groupNames)!=Success)
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbKeyNamesMask ) {
+ if (names->keys==NULL) {
+ int nKeys;
+ if (xkb->max_key_code==0) {
+ xkb->min_key_code= rep->minKeyCode;
+ xkb->max_key_code= rep->maxKeyCode;
+ }
+ nKeys= xkb->max_key_code+1;
+ names->keys= _XkbTypedCalloc(nKeys,XkbKeyNameRec);
+ }
+ if (names->keys!=NULL) {
+ if (!_XkbCopyFromReadBuffer(&buf,
+ (char *)&names->keys[rep->firstKey],
+ rep->nKeys*XkbKeyNameLength))
+ goto BAILOUT;
+ }
+ else _XkbSkipReadBufferData(&buf,rep->nKeys*XkbKeyNameLength);
+ }
+ if ( rep->which&XkbKeyAliasesMask && (rep->nKeyAliases>0) ) {
+ if (XkbAllocNames(xkb,XkbKeyAliasesMask,0,rep->nKeyAliases)!=Success)
+ goto BAILOUT;
+ if (!_XkbCopyFromReadBuffer(&buf,(char *)names->key_aliases,
+ rep->nKeyAliases*XkbKeyNameLength*2))
+ goto BAILOUT;
+ }
+ if ( rep->which&XkbRGNamesMask ) {
+ if (rep->nRadioGroups>0) {
+ Atom *rgNames;
+
+ if (names->radio_groups==NULL)
+ names->radio_groups = _XkbTypedCalloc(rep->nRadioGroups,Atom);
+ else if (names->num_rg<rep->nRadioGroups) {
+ names->radio_groups = _XkbTypedRealloc(names->radio_groups,
+ rep->nRadioGroups,
+ Atom);
+ }
+ rgNames= names->radio_groups;
+ if (!rgNames) {
+ goto BAILOUT;
+ }
+ if (!_XkbReadBufferCopy32(&buf,(long *)rgNames,rep->nRadioGroups))
+ goto BAILOUT;
+ names->num_rg= rep->nRadioGroups;
+ }
+ else if (names->num_rg>0) {
+ names->num_rg= 0;
+ Xfree(names->radio_groups);
+ }
+ }
+ len= _XkbFreeReadBuffer(&buf);
+ if (len!=0) return BadLength;
+ else return Success;
+BAILOUT:
+ _XkbFreeReadBuffer(&buf);
+ return BadLength;
+}
+
+Status
+#if NeedFunctionPrototypes
+XkbGetNames(Display *dpy,unsigned which,XkbDescPtr xkb)
+#else
+XkbGetNames(dpy,which,xkb)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetNamesReq *req;
+ xkbGetNamesReply rep;
+ Status status;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (!xkb->names) {
+ xkb->names = _XkbTypedCalloc(1,XkbNamesRec);
+ if (!xkb->names) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ GetReq(kbGetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->which = which;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadImplementation;
+ }
+
+ status = _XkbReadGetNamesReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+/***====================================================================***/
+
+static int
+#if NeedFunctionPrototypes
+_XkbCountBits(int nBitsMax,unsigned long mask)
+#else
+_XkbCountBits(nBitsMax,mask)
+ int nBitsMax;
+ unsigned long mask;
+#endif
+{
+register unsigned long y, nBits;
+
+ y = (mask >> 1) &033333333333;
+ y = mask - y - ((y >>1) & 033333333333);
+ nBits = ((unsigned int) (((y + (y >> 3)) & 030707070707) % 077));
+
+ /* nBitsMax really means max+1 */
+ return (nBits < nBitsMax) ? nBits : (nBitsMax - 1);
+}
+
+static CARD32
+#if NeedFunctionPrototypes
+_XkbCountAtoms(Atom *atoms,int maxAtoms,int *count)
+#else
+_XkbCountAtoms(atoms,maxAtoms,count)
+ Atom *atoms;
+ int maxAtoms;
+ int *count;
+#endif
+{
+register unsigned int i,bit,nAtoms;
+register CARD32 atomsPresent;
+
+ for (i=nAtoms=atomsPresent=0,bit=1;i<maxAtoms;i++,bit<<=1) {
+ if (atoms[i]!=None) {
+ atomsPresent|= bit;
+ nAtoms++;
+ }
+ }
+ if (count)
+ *count= nAtoms;
+ return atomsPresent;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbCopyAtoms(Display *dpy,Atom *atoms,CARD32 mask,int maxAtoms)
+#else
+_XkbCopyAtoms(dpy,atoms,mask,maxAtoms)
+ Display * dpy;
+ Atom * atoms;
+ CARD32 mask;
+ int maxAtoms;
+#endif
+{
+register unsigned int i,bit;
+
+ for (i=0,bit=1;i<maxAtoms;i++,bit<<=1) {
+ if (mask&bit)
+ Data32(dpy,&atoms[i],4);
+ }
+ return;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetNames( Display * dpy,
+ unsigned int which,
+ unsigned int firstType,
+ unsigned int nTypes,
+ XkbDescPtr xkb)
+#else
+XkbSetNames(dpy,which,firstType,nTypes,xkb)
+ Display * dpy;
+ unsigned int which;
+ unsigned int firstType;
+ unsigned int nTypes;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbSetNamesReq *req;
+ int nLvlNames;
+ XkbInfoPtr xkbi;
+ XkbNamesPtr names;
+ unsigned firstLvlType,nLvlTypes;
+ int nVMods,nLEDs,nRG,nKA,nGroups;
+ int nKeys,firstKey,nAtoms;
+ CARD32 leds,vmods,groups;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->names))
+ return False;
+ firstLvlType= firstType;
+ nLvlTypes= nTypes;
+ if (nTypes<1)
+ which&= ~(XkbKTLevelNamesMask|XkbKeyTypeNamesMask);
+ else if (firstType<=XkbLastRequiredType) {
+ int adjust;
+ adjust= XkbLastRequiredType-firstType+1;
+ firstType+= adjust;
+ nTypes-= adjust;
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ }
+ names= xkb->names;
+ if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
+ register int i;
+ XkbKeyTypePtr type;
+ if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
+ (firstType+nTypes>xkb->map->num_types)||
+ (firstLvlType+nLvlTypes>xkb->map->num_types))
+ return False;
+ if (which&XkbKTLevelNamesMask) {
+ type= &xkb->map->types[firstLvlType];
+ for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ nLvlNames+= type->num_levels;
+ }
+ }
+ }
+
+ nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->firstType = firstType;
+ req->nTypes = nTypes;
+ req->firstKey = xkb->min_key_code;
+ req->nKeys = xkb->max_key_code-xkb->min_key_code+1;
+
+ if (which&XkbKeycodesNameMask)
+ nAtoms++;
+ if (which&XkbGeometryNameMask)
+ nAtoms++;
+ if (which&XkbSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbTypesNameMask)
+ nAtoms++;
+ if (which&XkbCompatNameMask)
+ nAtoms++;
+ if (which&XkbKeyTypeNamesMask)
+ nAtoms+= nTypes;
+ if (which&XkbKTLevelNamesMask) {
+ req->firstKTLevel= firstLvlType;
+ req->nKTLevels= nLvlTypes;
+ req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
+ nAtoms+= nLvlNames;
+ }
+ else req->firstKTLevel= req->nKTLevels= 0;
+
+ if (which&XkbIndicatorNamesMask) {
+ req->indicators= leds=
+ _XkbCountAtoms(names->indicators,XkbNumIndicators,&nLEDs);
+ if (nLEDs>0)
+ nAtoms+= nLEDs;
+ else which&= ~XkbIndicatorNamesMask;
+ }
+ else req->indicators= leds= 0;
+
+ if (which&XkbVirtualModNamesMask) {
+ vmods= req->virtualMods= (CARD16)
+ _XkbCountAtoms(names->vmods,XkbNumVirtualMods,&nVMods);
+ if (nVMods>0)
+ nAtoms+= nVMods;
+ else which&= ~XkbVirtualModNamesMask;
+ }
+ else vmods= req->virtualMods= 0;
+
+ if (which&XkbGroupNamesMask) {
+ groups= req->groupNames= (CARD8)
+ _XkbCountAtoms(names->groups,XkbNumKbdGroups,&nGroups);
+ if (nGroups>0)
+ nAtoms+= nGroups;
+ else which&= ~XkbGroupNamesMask;
+ }
+ else groups= req->groupNames= 0;
+
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ firstKey= req->firstKey;
+ nKeys= req->nKeys;
+ nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else which&= ~XkbKeyNamesMask;
+
+ if (which&XkbKeyAliasesMask) {
+ nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
+ if (nKA>0) {
+ req->nKeyAliases= nKA;
+ nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
+ }
+ else {
+ which&= ~XkbKeyAliasesMask;
+ req->nKeyAliases = 0;
+ }
+ }
+ else req->nKeyAliases= 0;
+
+ if (which&XkbRGNamesMask) {
+ nRG= names->num_rg;
+ if (nRG>0)
+ nAtoms+= nRG;
+ else which&= ~XkbRGNamesMask;
+ }
+
+ req->which= which;
+ req->nRadioGroups= nRG;
+ req->length+= (nAtoms*4)/4;
+
+ if (which&XkbKeycodesNameMask)
+ Data32(dpy,(long *)&names->keycodes,4);
+ if (which&XkbGeometryNameMask)
+ Data32(dpy,(long *)&names->geometry,4);
+ if (which&XkbSymbolsNameMask)
+ Data32(dpy,(long *)&names->symbols,4);
+ if (which&XkbPhysSymbolsNameMask)
+ Data32(dpy,(long *)&names->phys_symbols,4);
+ if (which&XkbTypesNameMask)
+ Data32(dpy,(long *)&names->types,4);
+ if (which&XkbCompatNameMask)
+ Data32(dpy,(long *)&names->compat,4);
+ if (which&XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= &xkb->map->types[firstType];
+ for (i=0;i<nTypes;i++,type++) {
+ Data32(dpy,(long *)&type->name,4);
+ }
+ }
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ Data32(dpy,(long *)type->level_names,type->num_levels*4);
+ }
+ }
+ if (which&XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
+ if (which&XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
+ if (which&XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
+ if (which&XkbKeyNamesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKeys*XkbKeyNameLength);
+ for (i=0;i<nKeys;i++,tmp+= XkbKeyNameLength) {
+ tmp[0]= names->keys[firstKey+i].name[0];
+ tmp[1]= names->keys[firstKey+i].name[1];
+ tmp[2]= names->keys[firstKey+i].name[2];
+ tmp[3]= names->keys[firstKey+i].name[3];
+ }
+#else
+ Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
+#endif
+ }
+ if (which&XkbKeyAliasesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKA*XkbKeyNameLength*2);
+ for (i=0;i<nKeys;i++,tmp+= 2*XkbKeyNameLength) {
+ tmp[0]= names->key_aliases[i].real[0];
+ tmp[1]= names->key_aliases[i].real[1];
+ tmp[2]= names->key_aliases[i].real[2];
+ tmp[3]= names->key_aliases[i].real[3];
+ tmp[4]= names->key_aliases[i].alias[0];
+ tmp[5]= names->key_aliases[i].alias[1];
+ tmp[6]= names->key_aliases[i].alias[2];
+ tmp[7]= names->key_aliases[i].alias[3];
+ }
+#else
+ Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
+#endif
+ }
+ if (which&XkbRGNamesMask) {
+ Data32(dpy,(long *)names->radio_groups,nRG*4);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbChangeNames(Display *dpy,XkbDescPtr xkb,XkbNameChangesPtr changes)
+#else
+XkbChangeNames(dpy,xkb,changes)
+ Display * dpy;
+ XkbDescPtr xkb;
+ XkbNameChangesPtr changes;
+#endif
+{
+ register xkbSetNamesReq *req;
+ int nLvlNames;
+ XkbInfoPtr xkbi;
+ XkbNamesPtr names;
+ unsigned which,firstType,nTypes;
+ unsigned firstLvlType,nLvlTypes;
+ int nVMods,nLEDs,nRG,nKA,nGroups;
+ int nKeys,firstKey,nAtoms;
+ CARD32 leds,vmods,groups;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!xkb->names)||(!changes))
+ return False;
+ which= changes->changed;
+ firstType= changes->first_type;
+ nTypes= changes->num_types;
+ firstLvlType= changes->first_lvl;;
+ nLvlTypes= changes->num_lvls;
+ if (which&XkbKeyTypeNamesMask) {
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ else if (firstType<=XkbLastRequiredType) {
+ int adjust;
+ adjust= XkbLastRequiredType-firstType+1;
+ firstType+= adjust;
+ nTypes-= adjust;
+ if (nTypes<1)
+ which&= ~XkbKeyTypeNamesMask;
+ }
+ }
+ else firstType= nTypes= 0;
+
+ if (which&XkbKTLevelNamesMask) {
+ if (nLvlTypes<1)
+ which&= ~XkbKTLevelNamesMask;
+ }
+ else firstLvlType= nLvlTypes= 0;
+
+ names= xkb->names;
+ if (which&(XkbKTLevelNamesMask|XkbKeyTypeNamesMask)) {
+ register int i;
+ XkbKeyTypePtr type;
+ if((xkb->map==NULL)||(xkb->map->types==NULL)||(nTypes==0)||
+ (firstType+nTypes>xkb->map->num_types)||
+ (firstLvlType+nLvlTypes>xkb->map->num_types))
+ return False;
+ if (which&XkbKTLevelNamesMask) {
+ type= &xkb->map->types[firstLvlType];
+ for (i=nLvlNames=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ nLvlNames+= type->num_levels;
+ }
+ }
+ }
+
+ if (changes->num_keys<1)
+ which&= ~XkbKeyNamesMask;
+ if ((which&XkbKeyNamesMask)==0)
+ changes->first_key= changes->num_keys= 0;
+ else if ((changes->first_key<xkb->min_key_code)||
+ (changes->first_key+changes->num_keys>xkb->max_key_code)) {
+ return False;
+ }
+
+ if ((which&XkbVirtualModNamesMask)==0)
+ changes->changed_vmods= 0;
+ else if (changes->changed_vmods==0)
+ which&= ~XkbVirtualModNamesMask;
+
+ if ((which&XkbIndicatorNamesMask)==0)
+ changes->changed_indicators= 0;
+ else if (changes->changed_indicators==0)
+ which&= ~XkbIndicatorNamesMask;
+
+ if ((which&XkbGroupNamesMask)==0)
+ changes->changed_groups= 0;
+ else if (changes->changed_groups==0)
+ which&= ~XkbGroupNamesMask;
+
+ nVMods= nLEDs= nRG= nKA= nAtoms= nGroups= 0;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNames, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNames;
+ req->deviceSpec = xkb->device_spec;
+ req->firstType = firstType;
+ req->nTypes = nTypes;
+ req->firstKey = changes->first_key;
+ req->nKeys = changes->num_keys;
+
+ if (which&XkbKeycodesNameMask)
+ nAtoms++;
+ if (which&XkbGeometryNameMask)
+ nAtoms++;
+ if (which&XkbSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbPhysSymbolsNameMask)
+ nAtoms++;
+ if (which&XkbTypesNameMask)
+ nAtoms++;
+ if (which&XkbCompatNameMask)
+ nAtoms++;
+ if (which&XkbKeyTypeNamesMask)
+ nAtoms+= nTypes;
+ if (which&XkbKTLevelNamesMask) {
+ req->firstKTLevel= firstLvlType;
+ req->nKTLevels= nLvlTypes;
+ req->length+= XkbPaddedSize(nLvlTypes)/4; /* room for group widths */
+ nAtoms+= nLvlNames;
+ }
+ else req->firstKTLevel= req->nKTLevels= 0;
+
+ if (which&XkbIndicatorNamesMask) {
+ leds= req->indicators= (CARD32)changes->changed_indicators;
+ nLEDs= _XkbCountBits(XkbNumIndicators,changes->changed_indicators);
+ if (nLEDs>0)
+ nAtoms+= nLEDs;
+ else which&= ~XkbIndicatorNamesMask;
+ }
+ else req->indicators= 0;
+
+ if (which&XkbVirtualModNamesMask) {
+ vmods= req->virtualMods= changes->changed_vmods;
+ nVMods= _XkbCountBits(XkbNumVirtualMods,
+ (unsigned long)changes->changed_vmods);
+ if (nVMods>0)
+ nAtoms+= nVMods;
+ else which&= ~XkbVirtualModNamesMask;
+ }
+ else req->virtualMods= 0;
+
+ if (which&XkbGroupNamesMask) {
+ groups= req->groupNames= changes->changed_groups;
+ nGroups= _XkbCountBits(XkbNumKbdGroups,
+ (unsigned long)changes->changed_groups);
+ if (nGroups>0)
+ nAtoms+= nGroups;
+ else which&= ~XkbGroupNamesMask;
+ }
+ else req->groupNames= 0;
+
+ if ((which&XkbKeyNamesMask)&&(names->keys!=NULL)) {
+ firstKey= req->firstKey;
+ nKeys= req->nKeys;
+ nAtoms+= nKeys; /* technically not atoms, but 4 bytes wide */
+ }
+ else which&= ~XkbKeyNamesMask;
+
+ if (which&XkbKeyAliasesMask) {
+ nKA= ((names->key_aliases!=NULL)?names->num_key_aliases:0);
+ if (nKA>0)
+ nAtoms+= nKA*2; /* not atoms, but 8 bytes on the wire */
+ else which&= ~XkbKeyAliasesMask;
+ }
+
+ if (which&XkbRGNamesMask) {
+ nRG= names->num_rg;
+ if (nRG>0)
+ nAtoms+= nRG;
+ else which&= ~XkbRGNamesMask;
+ }
+
+ req->which= which;
+ req->nRadioGroups= nRG;
+ req->length+= (nAtoms*4)/4;
+
+ if (which&XkbKeycodesNameMask)
+ Data32(dpy,(long *)&names->keycodes,4);
+ if (which&XkbGeometryNameMask)
+ Data32(dpy,(long *)&names->geometry,4);
+ if (which&XkbSymbolsNameMask)
+ Data32(dpy,(long *)&names->symbols,4);
+ if (which&XkbPhysSymbolsNameMask)
+ Data32(dpy,(long *)&names->phys_symbols,4);
+ if (which&XkbTypesNameMask)
+ Data32(dpy,(long *)&names->types,4);
+ if (which&XkbCompatNameMask)
+ Data32(dpy,(long *)&names->compat,4);
+ if (which&XkbKeyTypeNamesMask) {
+ register int i;
+ register XkbKeyTypePtr type;
+ type= &xkb->map->types[firstType];
+ for (i=0;i<nTypes;i++,type++) {
+ Data32(dpy,(long *)&type->name,4);
+ }
+ }
+ if (which&XkbKTLevelNamesMask) {
+ XkbKeyTypePtr type;
+ int i;
+ char *tmp;
+
+ BufAlloc(char *,tmp,XkbPaddedSize(nLvlTypes));
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ *tmp++ = type->num_levels;
+ }
+ type = &xkb->map->types[firstLvlType];
+ for (i=0;i<nLvlTypes;i++,type++) {
+ if (type->level_names!=NULL)
+ Data32(dpy,(long *)type->level_names,type->num_levels*4);
+ }
+ }
+ if (which&XkbIndicatorNamesMask)
+ _XkbCopyAtoms(dpy,names->indicators,leds,XkbNumIndicators);
+ if (which&XkbVirtualModNamesMask)
+ _XkbCopyAtoms(dpy,names->vmods,vmods,XkbNumVirtualMods);
+ if (which&XkbGroupNamesMask)
+ _XkbCopyAtoms(dpy,names->groups,groups,XkbNumKbdGroups);
+ if (which&XkbKeyNamesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKeys*4);
+ for (i=0;i<nKeys;i++,tmp+= 4) {
+ tmp[0]= names->keys[firstKey+i].name[0];
+ tmp[1]= names->keys[firstKey+i].name[1];
+ tmp[2]= names->keys[firstKey+i].name[2];
+ tmp[3]= names->keys[firstKey+i].name[3];
+ }
+#else
+ Data(dpy,(char *)&names->keys[firstKey],nKeys*XkbKeyNameLength);
+#endif
+ }
+ if (which&XkbKeyAliasesMask) {
+#ifdef WORD64
+ char *tmp;
+ register int i;
+ BufAlloc(char *,tmp,nKA*XkbKeyNameLength*2);
+ for (i=0;i<nKeys;i++,tmp+= 2*XkbKeyNameLength) {
+ tmp[0]= names->key_aliases[i].real[0];
+ tmp[1]= names->key_aliases[i].real[1];
+ tmp[2]= names->key_aliases[i].real[2];
+ tmp[3]= names->key_aliases[i].real[3];
+ tmp[4]= names->key_aliases[i].alias[0];
+ tmp[5]= names->key_aliases[i].alias[1];
+ tmp[6]= names->key_aliases[i].alias[2];
+ tmp[7]= names->key_aliases[i].alias[3];
+ }
+#else
+ Data(dpy,(char *)names->key_aliases,nKA*XkbKeyNameLength*2);
+#endif
+ }
+ if (which&XkbRGNamesMask) {
+ Data32(dpy,(long *)names->radio_groups,nRG*4);
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+void
+#if NeedFunctionPrototypes
+XkbNoteNameChanges( XkbNameChangesPtr old,
+ XkbNamesNotifyEvent * new,
+ unsigned int wanted)
+#else
+XkbNoteNameChanges(old,new,wanted)
+ XkbNameChangesPtr old;
+ XkbNamesNotifyEvent * new;
+ unsigned int wanted;
+#endif
+{
+int first,last,old_last,new_last;
+
+ wanted&= new->changed;
+ if ((old==NULL)||(new==NULL)||(wanted==0))
+ return;
+ if (wanted&XkbKeyTypeNamesMask) {
+ if (old->changed&XkbKeyTypeNamesMask) {
+ new_last= (new->first_type+new->num_types-1);
+ old_last= (old->first_type+old->num_types-1);
+
+ if (new->first_type<old->first_type)
+ first= new->first_type;
+ else first= old->first_type;
+
+ if (old_last>new_last)
+ last= old_last;
+ else last= new_last;
+
+ old->first_type= first;
+ old->num_types= (last-first)+1;
+ }
+ else {
+ old->first_type= new->first_type;
+ old->num_types= new->num_types;
+ }
+ }
+ if (wanted&XkbKTLevelNamesMask) {
+ if (old->changed&XkbKTLevelNamesMask) {
+ new_last= (new->first_lvl+new->num_lvls-1);
+ old_last= (old->first_lvl+old->num_lvls-1);
+
+ if (new->first_lvl<old->first_lvl)
+ first= new->first_lvl;
+ else first= old->first_lvl;
+
+ if (old_last>new_last)
+ last= old_last;
+ else last= new_last;
+
+ old->first_lvl= first;
+ old->num_lvls= (last-first)+1;
+ }
+ else {
+ old->first_lvl= new->first_lvl;
+ old->num_lvls= new->num_lvls;
+ }
+ }
+ if (wanted&XkbIndicatorNamesMask) {
+ if (old->changed&XkbIndicatorNamesMask)
+ old->changed_indicators|= new->changed_indicators;
+ else old->changed_indicators= new->changed_indicators;
+ }
+ if (wanted&XkbKeyNamesMask) {
+ if (old->changed&XkbKeyNamesMask) {
+ new_last= (new->first_key+new->num_keys-1);
+ old_last= (old->first_key+old->num_keys-1);
+
+ first= old->first_key;
+
+ if (new->first_key<old->first_key)
+ first= new->first_key;
+ if (old_last>new_last)
+ new_last= old_last;
+
+ old->first_key= first;
+ old->num_keys= (new_last-first)+1;
+ }
+ else {
+ old->first_key= new->first_key;
+ old->num_keys= new->num_keys;
+ }
+ }
+ if (wanted&XkbVirtualModNamesMask) {
+ if (old->changed&XkbVirtualModNamesMask)
+ old->changed_vmods|= new->changed_vmods;
+ else old->changed_vmods= new->changed_vmods;
+ }
+ if (wanted&XkbGroupNamesMask) {
+ if (old->changed&XkbGroupNamesMask)
+ old->changed_groups|= new->changed_groups;
+ else old->changed_groups= new->changed_groups;
+ }
+ if (wanted&XkbRGNamesMask)
+ old->num_rg= new->num_radio_groups;
+ if (wanted&XkbKeyAliasesMask)
+ old->num_aliases= new->num_aliases;
+ old->changed|= wanted;
+ return;
+}
diff --git a/src/xkb/XKBRdBuf.c b/src/xkb/XKBRdBuf.c
new file mode 100644
index 00000000..11a9ba71
--- /dev/null
+++ b/src/xkb/XKBRdBuf.c
@@ -0,0 +1,322 @@
+/* $Xorg: XKBRdBuf.c,v 1.3 2000/08/17 19:45:02 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBproto.h>
+
+/***====================================================================***/
+
+int
+#if NeedFunctionPrototypes
+_XkbInitReadBuffer(Display *dpy,XkbReadBufferPtr buf,int size)
+#else
+_XkbInitReadBuffer(dpy,buf,size)
+ Display *dpy;
+ XkbReadBufferPtr buf;
+ int size;
+#endif
+{
+ if ((dpy!=NULL) && (buf!=NULL) && (size>0)) {
+ buf->error= 0;
+ buf->size= size;
+ buf->start= buf->data= _XkbAlloc(size);
+ if (buf->start) {
+ _XRead(dpy, buf->start, size);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+#define _XkbReadBufferDataLeft(b) (((b)->size)-((b)->data-(b)->start))
+
+int
+#if NeedFunctionPrototypes
+_XkbSkipReadBufferData(XkbReadBufferPtr from,int size)
+#else
+_XkbSkipReadBufferData(from,size)
+ XkbReadBufferPtr from;
+ int size;
+#endif
+{
+ if (size==0)
+ return 1;
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ from->data+= size;
+ return 1;
+}
+
+int
+#if NeedFunctionPrototypes
+_XkbCopyFromReadBuffer(XkbReadBufferPtr from,char *to,int size)
+#else
+_XkbCopyFromReadBuffer(from,to,size)
+ XkbReadBufferPtr from;
+ char *to;
+ int size;
+#endif
+{
+ if (size==0)
+ return 1;
+ if ((from==NULL)||(from->error)||(to==NULL)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ memcpy(to,from->data,size);
+ from->data+= size;
+ return 1;
+}
+
+#ifdef XKB_FORCE_INT_KEYSYM
+int
+#if NeedFunctionPrototypes
+_XkbReadCopyKeySyms(int *wire,KeySym *to,int num_words)
+#else
+_XkbReadCopyKeySyms(wire,to,num_words)
+ int * wire;
+ KeySym * to;
+ int num_words;
+#endif
+{
+ while (num_words-->0) {
+ *to++= *wire++;
+ }
+ return 1;
+}
+
+int
+#if NeedFunctionPrototypes
+_XkbReadBufferCopyKeySyms(XkbReadBufferPtr from,KeySym *to,int num_words)
+#else
+_XkbReadBufferCopyKeySyms(from,to,num_words)
+ XkbReadBufferPtr from;
+ KeySym * to;
+ int num_words;
+#endif
+{
+ if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
+ return 0;
+ _XkbReadCopyKeySyms((int *)from->data,to,num_words);
+ from->data+= (4*num_words);
+ return True;
+}
+
+int
+#if NeedFunctionPrototypes
+_XkbWriteCopyKeySyms (register KeySym *from,CARD32 *to,int len)
+#else
+_XkbWriteCopyKeySyms (from,to,len)
+ register KeySym * from;
+ CARD32 * to;
+ int len;
+#endif
+{
+
+ while (len-->0) {
+ *to++= (CARD32)*from++;
+ }
+ return True;
+}
+#endif
+
+#ifdef LONG64
+int
+#if NeedFunctionPrototypes
+_XkbReadCopyData32(int *wire,long *to,int num_words)
+#else
+_XkbReadCopyData32(wire,to,num_words)
+ int * wire;
+ long * to;
+ int num_words;
+#endif
+{
+ while (num_words-->0) {
+ *to++= *wire++;
+ }
+ return 1;
+}
+#endif
+#ifdef WORD64
+int
+#if NeedFunctionPrototypes
+_XkbReadCopyData32(int *from,long *lp,int num_words)
+#else
+_XkbReadCopyData32(from,lp,num_words)
+ int * from;
+ long * lp;
+ int num_words;
+#endif
+{
+long *lpack;
+long mask32 = 0x00000000ffffffff;
+long maskw, i, bits;
+
+ lpack = (long *)from;
+ bits = 32;
+
+ for (i=0;i<num_words;i++) {
+ maskw = mask32 << bits;
+ *lp++ = (*lpack & maskw) >> bits;
+ bits = bits ^ 32;
+ if (bits)
+ lpack++;
+ }
+ return 1;
+}
+#endif
+
+#if defined(LONG64) || defined(WORD64)
+int
+#if NeedFunctionPrototypes
+_XkbReadBufferCopy32(XkbReadBufferPtr from,long *to,int num_words)
+#else
+_XkbReadBufferCopy32(from,to,num_words)
+ XkbReadBufferPtr from;
+ long * to;
+ int num_words;
+#endif
+{
+ if ((unsigned)(num_words*4)>_XkbReadBufferDataLeft(from))
+ return 0;
+ _XkbReadCopyData32((int *)from->data,to,num_words);
+ from->data+= (4*num_words);
+ return True;
+}
+#endif
+
+#ifdef LONG64
+int
+#if NeedFunctionPrototypes
+_XkbWriteCopyData32 (register unsigned long *from,CARD32 *to,int len)
+#else
+_XkbWriteCopyData32 (from,to,len)
+ register unsigned long * from;
+ CARD32 * to;
+ int len;
+#endif
+{
+
+ while (len-->0) {
+ *to++= (CARD32)*from++;
+ }
+ return True;
+}
+#endif /* LONG64 */
+
+#ifdef WORD64
+_XkbWriteCopyData32 Not Implemented Yet for sizeof(int)==8
+#endif
+
+char *
+#if NeedFunctionPrototypes
+_XkbPeekAtReadBuffer(XkbReadBufferPtr from,int size)
+#else
+_XkbPeekAtReadBuffer(from,size)
+ XkbReadBufferPtr from;
+ int size;
+#endif
+{
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ return from->data;
+}
+
+char *
+#if NeedFunctionPrototypes
+_XkbGetReadBufferPtr(XkbReadBufferPtr from,int size)
+#else
+_XkbGetReadBufferPtr(from,size)
+ XkbReadBufferPtr from;
+ int size;
+#endif
+{
+char *ptr;
+ if ((from==NULL)||(from->error)||(size<1)||
+ (_XkbReadBufferDataLeft(from)<size))
+ return 0;
+ ptr= from->data;
+ from->data+= size;
+ return ptr;
+}
+
+
+int
+#if NeedFunctionPrototypes
+_XkbFreeReadBuffer(XkbReadBufferPtr buf)
+#else
+_XkbFreeReadBuffer(buf)
+ XkbReadBufferPtr buf;
+#endif
+{
+ if ((buf!=NULL) && (buf->start!=NULL)) {
+ int left;
+ left= (int)_XkbReadBufferDataLeft(buf);
+ if (buf->start!=NULL)
+ Xfree(buf->start);
+ buf->size= 0;
+ buf->start= buf->data= NULL;
+ return left;
+ }
+ return 0;
+}
+
+Bool
+#if NeedFunctionPrototypes
+_XkbGetReadBufferCountedString(XkbReadBufferPtr buf,char **rtrn)
+#else
+_XkbGetReadBufferCountedString(buf,rtrn)
+ XkbReadBufferPtr buf;
+ char ** rtrn;
+#endif
+{
+CARD16 len,*pLen;
+int left;
+char * str;
+
+ if ((buf==NULL)||(buf->error)||((left=(int)_XkbReadBufferDataLeft(buf))<4))
+ return False;
+ pLen= (CARD16 *)buf->data;
+ len= *pLen;
+ if (len>0) {
+ if (XkbPaddedSize(len+2)>left)
+ return False;
+ str= _XkbAlloc(len+1);
+ if (str) {
+ memcpy(str,&buf->data[2],len);
+ str[len]= '\0';
+ }
+ }
+ buf->data+= XkbPaddedSize(len+2);
+ *rtrn= str;
+ return True;
+}
diff --git a/src/xkb/XKBSetGeom.c b/src/xkb/XKBSetGeom.c
new file mode 100644
index 00000000..72d7f3d7
--- /dev/null
+++ b/src/xkb/XKBSetGeom.c
@@ -0,0 +1,561 @@
+/* $Xorg: XKBSetGeom.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+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 DEBUG
+#include <stdio.h>
+#endif
+
+#define NEED_EVENTS
+#define NEED_REPLIES
+#include "Xlibint.h"
+#include "XKBlibint.h"
+#include <X11/extensions/XKBgeom.h>
+#include <X11/extensions/XKBproto.h>
+
+#ifndef MINSHORT
+#define MINSHORT -32768
+#endif
+#ifndef MAXSHORT
+#define MAXSHORT 32767
+#endif
+
+/***====================================================================***/
+
+#define _SizeCountedString(s) ((s)?XkbPaddedSize(2+strlen(s)):4)
+
+static char *
+#if NeedFunctionPrototypes
+_WriteCountedString(char *wire,char *str)
+#else
+_WriteCountedString(wire,str)
+ char * wire;
+ char * str;
+#endif
+{
+CARD16 len,*pLen;
+
+ len= (str?strlen(str):0);
+ pLen= (CARD16 *)wire;
+ *pLen= len;
+ if (len && str)
+ memcpy(&wire[2],str,len);
+ wire+= XkbPaddedSize(len+2);
+ return wire;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomProperties(XkbGeometryPtr geom)
+#else
+_SizeGeomProperties(geom)
+ XkbGeometryPtr geom;
+#endif
+{
+register int i,size;
+XkbPropertyPtr prop;
+
+ for (size=i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ size+= _SizeCountedString(prop->name);
+ size+= _SizeCountedString(prop->value);
+ }
+ return size;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomColors(XkbGeometryPtr geom)
+#else
+_SizeGeomColors(geom)
+ XkbGeometryPtr geom;
+#endif
+{
+register int i,size;
+register XkbColorPtr color;
+
+ for (i=size=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ size+= _SizeCountedString(color->spec);
+ }
+ return size;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomShapes(XkbGeometryPtr geom)
+#else
+_SizeGeomShapes(geom)
+ XkbGeometryPtr geom;
+#endif
+{
+register int i,size;
+register XkbShapePtr shape;
+
+ for (i=size=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int n;
+ register XkbOutlinePtr ol;
+ size+= SIZEOF(xkbShapeWireDesc);
+ for (n=0,ol=shape->outlines;n<shape->num_outlines;n++,ol++) {
+ size+= SIZEOF(xkbOutlineWireDesc);
+ size+= ol->num_points*SIZEOF(xkbPointWireDesc);
+ }
+ }
+ return size;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomDoodads(int num_doodads,XkbDoodadPtr doodad)
+#else
+_SizeGeomDoodads(num_doodads,doodad)
+ int num_doodads;
+ XkbDoodadPtr doodad;
+#endif
+{
+register int i,size;
+
+ for (i=size=0;i<num_doodads;i++,doodad++) {
+ size+= SIZEOF(xkbAnyDoodadWireDesc);
+ if (doodad->any.type==XkbTextDoodad) {
+ size+= _SizeCountedString(doodad->text.text);
+ size+= _SizeCountedString(doodad->text.font);
+ }
+ else if (doodad->any.type==XkbLogoDoodad) {
+ size+= _SizeCountedString(doodad->logo.logo_name);
+ }
+ }
+ return size;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomSections(XkbGeometryPtr geom)
+#else
+_SizeGeomSections(geom)
+ XkbGeometryPtr geom;
+#endif
+{
+register int i,size;
+XkbSectionPtr section;
+
+ for (i=size=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ size+= SIZEOF(xkbSectionWireDesc);
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ for (r=0,row=section->rows;r<section->num_rows;row++,r++) {
+ size+= SIZEOF(xkbRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbKeyWireDesc);
+ }
+ }
+ if (section->doodads)
+ size+= _SizeGeomDoodads(section->num_doodads,section->doodads);
+ if (section->overlays) {
+ int o;
+ XkbOverlayPtr ol;
+ for (o=0,ol=section->overlays;o<section->num_overlays;o++,ol++) {
+ int r;
+ XkbOverlayRowPtr row;
+ size+= SIZEOF(xkbOverlayWireDesc);
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ size+= SIZEOF(xkbOverlayRowWireDesc);
+ size+= row->num_keys*SIZEOF(xkbOverlayKeyWireDesc);
+ }
+ }
+ }
+ }
+ return size;
+}
+
+static int
+#if NeedFunctionPrototypes
+_SizeGeomKeyAliases(XkbGeometryPtr geom)
+#else
+_SizeGeomKeyAliases(geom)
+ XkbGeometryPtr geom;
+#endif
+{
+ return geom->num_key_aliases*(2*XkbKeyNameLength);
+}
+
+/***====================================================================***/
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomProperties(char *wire,XkbGeometryPtr geom)
+#else
+_WriteGeomProperties(wire,geom)
+ char * wire;
+ XkbGeometryPtr geom;
+#endif
+{
+register int i;
+register XkbPropertyPtr prop;
+
+ for (i=0,prop=geom->properties;i<geom->num_properties;i++,prop++) {
+ wire= _WriteCountedString(wire,prop->name);
+ wire= _WriteCountedString(wire,prop->value);
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomColors(char *wire,XkbGeometryPtr geom)
+#else
+_WriteGeomColors(wire,geom)
+ char * wire;
+ XkbGeometryPtr geom;
+#endif
+{
+register int i;
+register XkbColorPtr color;
+
+ for (i=0,color=geom->colors;i<geom->num_colors;i++,color++) {
+ wire= _WriteCountedString(wire,color->spec);
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomShapes(char *wire,XkbGeometryPtr geom)
+#else
+_WriteGeomShapes(wire,geom)
+ char * wire;
+ XkbGeometryPtr geom;
+#endif
+{
+int i;
+XkbShapePtr shape;
+xkbShapeWireDesc * shapeWire;
+
+ for (i=0,shape=geom->shapes;i<geom->num_shapes;i++,shape++) {
+ register int o;
+ XkbOutlinePtr ol;
+ xkbOutlineWireDesc * olWire;
+ shapeWire= (xkbShapeWireDesc *)wire;
+ shapeWire->name= shape->name;
+ shapeWire->nOutlines= shape->num_outlines;
+ if (shape->primary!=NULL)
+ shapeWire->primaryNdx= XkbOutlineIndex(shape,shape->primary);
+ else shapeWire->primaryNdx= XkbNoShape;
+ if (shape->approx!=NULL)
+ shapeWire->approxNdx= XkbOutlineIndex(shape,shape->approx);
+ else shapeWire->approxNdx= XkbNoShape;
+ wire= (char *)&shapeWire[1];
+ for (o=0,ol=shape->outlines;o<shape->num_outlines;o++,ol++) {
+ register int p;
+ XkbPointPtr pt;
+ xkbPointWireDesc * ptWire;
+ olWire= (xkbOutlineWireDesc *)wire;
+ olWire->nPoints= ol->num_points;
+ olWire->cornerRadius= ol->corner_radius;
+ wire= (char *)&olWire[1];
+ ptWire= (xkbPointWireDesc *)wire;
+ for (p=0,pt=ol->points;p<ol->num_points;p++,pt++) {
+ ptWire[p].x= pt->x;
+ ptWire[p].y= pt->y;
+ }
+ wire= (char *)&ptWire[ol->num_points];
+ }
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomDoodads(char *wire,int num_doodads,XkbDoodadPtr doodad)
+#else
+_WriteGeomDoodads(wire,num_doodads,doodad)
+ char * wire;
+ int num_doodads;
+ XkbDoodadPtr doodad;
+#endif
+{
+register int i;
+xkbDoodadWireDesc * doodadWire;
+
+ for (i=0;i<num_doodads;i++,doodad++) {
+ doodadWire= (xkbDoodadWireDesc *)wire;
+ wire= (char *)&doodadWire[1];
+ bzero(doodadWire,SIZEOF(xkbDoodadWireDesc));
+ doodadWire->any.name= doodad->any.name;
+ doodadWire->any.type= doodad->any.type;
+ doodadWire->any.priority= doodad->any.priority;
+ doodadWire->any.top= doodad->any.top;
+ doodadWire->any.left= doodad->any.left;
+ doodadWire->any.angle= doodad->any.angle;
+ switch (doodad->any.type) {
+ case XkbOutlineDoodad:
+ case XkbSolidDoodad:
+ doodadWire->shape.colorNdx= doodad->shape.color_ndx;
+ doodadWire->shape.shapeNdx= doodad->shape.shape_ndx;
+ break;
+ case XkbTextDoodad:
+ doodadWire->text.width= doodad->text.width;
+ doodadWire->text.height= doodad->text.height;
+ doodadWire->text.colorNdx= doodad->text.color_ndx;
+ wire= _WriteCountedString(wire,doodad->text.text);
+ wire= _WriteCountedString(wire,doodad->text.font);
+ break;
+ case XkbIndicatorDoodad:
+ doodadWire->indicator.shapeNdx= doodad->indicator.shape_ndx;
+ doodadWire->indicator.onColorNdx=doodad->indicator.on_color_ndx;
+ doodadWire->indicator.offColorNdx=
+ doodad->indicator.off_color_ndx;
+ break;
+ case XkbLogoDoodad:
+ doodadWire->logo.colorNdx= doodad->logo.color_ndx;
+ doodadWire->logo.shapeNdx= doodad->logo.shape_ndx;
+ wire= _WriteCountedString(wire,doodad->logo.logo_name);
+ break;
+ default:
+ break;
+ }
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomOverlay(char *wire,XkbOverlayPtr ol)
+#else
+_WriteGeomOverlay(wire,ol)
+ char * wire;
+ XkbOverlayPtr ol;
+#endif
+{
+register int r;
+XkbOverlayRowPtr row;
+xkbOverlayWireDesc * olWire;
+
+ olWire= (xkbOverlayWireDesc *)wire;
+ olWire->name= ol->name;
+ olWire->nRows= ol->num_rows;
+ wire= (char *)&olWire[1];
+ for (r=0,row=ol->rows;r<ol->num_rows;r++,row++) {
+ unsigned int k;
+ XkbOverlayKeyPtr key;
+ xkbOverlayRowWireDesc * rowWire;
+ rowWire= (xkbOverlayRowWireDesc *)wire;
+ rowWire->rowUnder= row->row_under;
+ rowWire->nKeys= row->num_keys;
+ wire= (char *)&rowWire[1];
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ xkbOverlayKeyWireDesc * keyWire;
+ keyWire= (xkbOverlayKeyWireDesc *)wire;
+ memcpy(keyWire->over,key->over.name,XkbKeyNameLength);
+ memcpy(keyWire->under,key->under.name,XkbKeyNameLength);
+ wire= (char *)&keyWire[1];
+ }
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomSections(char *wire,XkbGeometryPtr geom)
+#else
+_WriteGeomSections(wire,geom)
+ char * wire;
+ XkbGeometryPtr geom;
+#endif
+{
+register int i;
+XkbSectionPtr section;
+xkbSectionWireDesc * sectionWire;
+
+ for (i=0,section=geom->sections;i<geom->num_sections;i++,section++) {
+ sectionWire= (xkbSectionWireDesc *)wire;
+ sectionWire->name= section->name;
+ sectionWire->top= section->top;
+ sectionWire->left= section->left;
+ sectionWire->width= section->width;
+ sectionWire->height= section->height;
+ sectionWire->angle= section->angle;
+ sectionWire->priority= section->priority;
+ sectionWire->nRows= section->num_rows;
+ sectionWire->nDoodads= section->num_doodads;
+ sectionWire->nOverlays= section->num_overlays;
+ sectionWire->pad= 0;
+ wire= (char *)&sectionWire[1];
+ if (section->rows) {
+ int r;
+ XkbRowPtr row;
+ xkbRowWireDesc * rowWire;
+ for (r=0,row=section->rows;r<section->num_rows;r++,row++) {
+ rowWire= (xkbRowWireDesc *)wire;
+ rowWire->top= row->top;
+ rowWire->left= row->left;
+ rowWire->nKeys= row->num_keys;
+ rowWire->vertical= row->vertical;
+ rowWire->pad= 0;
+ wire= (char *)&rowWire[1];
+ if (row->keys) {
+ int k;
+ XkbKeyPtr key;
+ xkbKeyWireDesc * keyWire;
+ keyWire= (xkbKeyWireDesc *)wire;
+ for (k=0,key=row->keys;k<row->num_keys;k++,key++) {
+ memcpy(keyWire[k].name,key->name.name,XkbKeyNameLength);
+ keyWire[k].gap= key->gap;
+ keyWire[k].shapeNdx= key->shape_ndx;
+ keyWire[k].colorNdx= key->color_ndx;
+ }
+ wire= (char *)&keyWire[row->num_keys];
+ }
+ }
+ }
+ if (section->doodads) {
+ wire= _WriteGeomDoodads(wire,
+ section->num_doodads,section->doodads);
+ }
+ if (section->overlays) {
+ register int o;
+ for (o=0;o<section->num_overlays;o++) {
+ wire= _WriteGeomOverlay(wire,&section->overlays[o]);
+ }
+ }
+ }
+ return wire;
+}
+
+static char *
+#if NeedFunctionPrototypes
+_WriteGeomKeyAliases(char *wire,XkbGeometryPtr geom)
+#else
+_WriteGeomKeyAliases(wire,geom)
+ char * wire;
+ XkbGeometryPtr geom;
+#endif
+{
+register int sz;
+
+ sz= geom->num_key_aliases*(XkbKeyNameLength*2);
+ if (sz>0) {
+ memcpy(wire,(char *)geom->key_aliases,sz);
+ wire+= sz;
+ }
+ return wire;
+}
+
+/***====================================================================***/
+
+static Status
+#if NeedFunctionPrototypes
+_SendSetGeometry(Display *dpy,XkbGeometryPtr geom,xkbSetGeometryReq *req)
+#else
+_SendSetGeometry(dpy,geom,req)
+ Display * dpy;
+ XkbGeometryPtr geom;
+ xkbSetGeometryReq * req;
+#endif
+{
+xkbSetGeometryReq tmp;
+int sz;
+char * wire,*tbuf;
+
+ sz= 0;
+ sz+= _SizeCountedString(geom->label_font);
+ sz+= _SizeGeomProperties(geom);
+ sz+= _SizeGeomColors(geom);
+ sz+= _SizeGeomShapes(geom);
+ sz+= _SizeGeomSections(geom);
+ sz+= _SizeGeomDoodads(geom->num_doodads,geom->doodads);
+ sz+= _SizeGeomKeyAliases(geom);
+ req->length+= (sz/4);
+ tmp= *req;
+ if (sz<BUFSIZE) {
+ BufAlloc(char *,wire,sz);
+ tbuf= NULL;
+ }
+ else {
+ tbuf= _XAllocTemp(dpy,sz);
+ if (!tbuf)
+ return BadAlloc;
+ wire= tbuf;
+ }
+ wire= _WriteCountedString(wire,geom->label_font);
+ if (geom->num_properties>0)
+ wire= _WriteGeomProperties(wire,geom);
+ if (geom->num_colors>0)
+ wire= _WriteGeomColors(wire,geom);
+ if (geom->num_shapes>0)
+ wire= _WriteGeomShapes(wire,geom);
+ if (geom->num_sections>0)
+ wire= _WriteGeomSections(wire,geom);
+ if (geom->num_doodads>0)
+ wire= _WriteGeomDoodads(wire,geom->num_doodads,geom->doodads);
+ if (geom->num_key_aliases>0)
+ wire= _WriteGeomKeyAliases(wire,geom);
+ if (tbuf!=NULL) {
+ Data(dpy,tbuf,sz);
+ _XFreeTemp(dpy,tbuf,sz);
+ }
+ return Success;
+}
+
+/***====================================================================***/
+
+Status
+#if NeedFunctionPrototypes
+XkbSetGeometry(Display *dpy,unsigned deviceSpec,XkbGeometryPtr geom)
+#else
+XkbSetGeometry(dpy,deviceSpec,geom)
+ Display * dpy;
+ unsigned deviceSpec;
+ XkbGeometryPtr geom;
+#endif
+{
+xkbSetGeometryReq *req;
+Status ret;
+
+ if ( (!geom) || (dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+
+ GetReq(kbSetGeometry, req);
+ req->reqType = dpy->xkb_info->codes->major_opcode;
+ req->xkbReqType = X_kbSetGeometry;
+ req->deviceSpec = deviceSpec;
+ req->nShapes= geom->num_shapes;
+ req->nSections= geom->num_sections;
+ req->name= geom->name;
+ req->widthMM= geom->width_mm;
+ req->heightMM= geom->height_mm;
+ req->nProperties= geom->num_properties;
+ req->nColors= geom->num_colors;
+ req->nDoodads= geom->num_doodads;
+ req->nKeyAliases= geom->num_key_aliases;
+ req->baseColorNdx= (geom->base_color-geom->colors);
+ req->labelColorNdx= (geom->label_color-geom->colors);
+
+ ret = _SendSetGeometry(dpy,geom,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return ret;
+}
+
diff --git a/src/xkb/XKBSetMap.c b/src/xkb/XKBSetMap.c
new file mode 100644
index 00000000..f7b99bde
--- /dev/null
+++ b/src/xkb/XKBSetMap.c
@@ -0,0 +1,716 @@
+/* $Xorg: XKBSetMap.c,v 1.4 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeKeyTypes(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeKeyTypes(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+ XkbKeyTypePtr map;
+ int i,len;
+
+ if (((req->present&XkbKeyTypesMask)==0)||(req->nTypes==0)) {
+ req->present&= ~XkbKeyTypesMask;
+ req->firstType= req->nTypes= 0;
+ return 0;
+ }
+ len= 0;
+ map= &xkb->map->types[req->firstType];
+ for (i=0;i<req->nTypes;i++,map++){
+ len+= SIZEOF(xkbKeyTypeWireDesc);
+ len+= map->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (map->preserve)
+ len+= map->map_count*SIZEOF(xkbModsWireDesc);
+ }
+ return len;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteKeyTypes(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteKeyTypes(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+ char * buf;
+ XkbKeyTypePtr type;
+ int i,n,sz;
+ xkbKeyTypeWireDesc *desc;
+
+ if ((req->present&XkbKeyTypesMask)==0)
+ return;
+ type= &xkb->map->types[req->firstType];
+ for (i=0;i<req->nTypes;i++,type++) {
+ sz= SIZEOF(xkbKeyTypeWireDesc);
+ sz+= type->map_count*SIZEOF(xkbKTSetMapEntryWireDesc);
+ if (type->preserve)
+ sz+= type->map_count*SIZEOF(xkbModsWireDesc);
+ BufAlloc(xkbKeyTypeWireDesc *,desc,sz);
+ desc->mask = type->mods.mask;
+ desc->realMods = type->mods.real_mods;
+ desc->virtualMods = type->mods.vmods;
+ desc->numLevels = type->num_levels;
+ desc->nMapEntries = type->map_count;
+ desc->preserve = (type->preserve!=NULL);
+ buf= (char *)&desc[1];
+ if (desc->nMapEntries>0) {
+ xkbKTSetMapEntryWireDesc *wire;
+ wire= (xkbKTSetMapEntryWireDesc *)buf;
+ for (n=0;n<type->map_count;n++,wire++) {
+ wire->level= type->map[n].level;
+ wire->realMods= type->map[n].mods.real_mods;
+ wire->virtualMods= type->map[n].mods.vmods;
+ }
+ buf= (char *)wire;
+ if (type->preserve) {
+ xkbModsWireDesc *pwire;
+ pwire= (xkbModsWireDesc *)buf;
+ for (n=0;n<type->map_count;n++,pwire++) {
+ pwire->realMods= type->preserve[n].real_mods;
+ pwire->virtualMods= type->preserve[n].vmods;
+ }
+ }
+ }
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeKeySyms(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeKeySyms(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+ int i,len;
+ unsigned nSyms;
+
+ if (((req->present&XkbKeySymsMask)==0)||(req->nKeySyms==0)) {
+ req->present&= ~XkbKeySymsMask;
+ req->firstKeySym= req->nKeySyms= 0;
+ req->totalSyms= 0;
+ return 0;
+ }
+ len= (int)(req->nKeySyms*sizeof(XkbSymMapRec));
+ for (i=nSyms=0;i<req->nKeySyms;i++) {
+ nSyms+= XkbKeyNumSyms(xkb,i+req->firstKeySym);
+ }
+ len+= nSyms*sizeof(CARD32);
+ req->totalSyms= nSyms;
+ return len;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteKeySyms(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteKeySyms(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register KeySym * pSym;
+CARD32 * outSym;
+XkbSymMapPtr symMap;
+xkbSymMapWireDesc *desc;
+register int i;
+
+ if ((req->present&XkbKeySymsMask)==0)
+ return;
+ symMap = &xkb->map->key_sym_map[req->firstKeySym];
+ for (i=0;i<req->nKeySyms;i++,symMap++) {
+ BufAlloc(xkbSymMapWireDesc *,desc,
+ SIZEOF(xkbSymMapWireDesc)+
+ (XkbKeyNumSyms(xkb,i+req->firstKeySym)*sizeof(CARD32)));
+ desc->ktIndex[0] = symMap->kt_index[0];
+ desc->ktIndex[1] = symMap->kt_index[1];
+ desc->ktIndex[2] = symMap->kt_index[2];
+ desc->ktIndex[3] = symMap->kt_index[3];
+ desc->groupInfo = symMap->group_info;
+ desc->width = symMap->width;
+ desc->nSyms = XkbKeyNumSyms(xkb,i+req->firstKeySym);
+ outSym = (CARD32 *)&desc[1];
+ if (desc->nSyms>0) {
+ pSym = XkbKeySymsPtr(xkb,i+req->firstKeySym);
+ _XkbWriteCopyKeySyms(pSym,outSym,desc->nSyms);
+ }
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeKeyActions(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeKeyActions(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+ int i,len,nActs;
+
+ if (((req->present&XkbKeyActionsMask)==0)||(req->nKeyActs==0)) {
+ req->present&= ~XkbKeyActionsMask;
+ req->firstKeyAct= req->nKeyActs= 0;
+ req->totalActs= 0;
+ return 0;
+ }
+ for (nActs=i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]!=0)
+ nActs+= XkbKeyNumActions(xkb,i+req->firstKeyAct);
+ }
+ len= XkbPaddedSize(req->nKeyActs)+(nActs*SIZEOF(xkbActionWireDesc));
+ req->totalActs= nActs;
+ return len;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteKeyActions(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteKeyActions(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+ register int i;
+ int n;
+ CARD8 *numDesc;
+ XkbAction *actDesc;
+
+ if ((req->present&XkbKeyActionsMask)==0)
+ return;
+ n = XkbPaddedSize(req->nKeyActs);
+ n+= (req->totalActs*SIZEOF(xkbActionWireDesc));
+
+ BufAlloc(CARD8 *,numDesc,n);
+ for (i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]==0)
+ numDesc[i] = 0;
+ else numDesc[i] = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
+ }
+ actDesc = (XkbAction *)&numDesc[XkbPaddedSize(req->nKeyActs)];
+ for (i=0;i<req->nKeyActs;i++) {
+ if (xkb->server->key_acts[i+req->firstKeyAct]!=0) {
+ n = XkbKeyNumActions(xkb,(i+req->firstKeyAct));
+ memcpy(actDesc,XkbKeyActionsPtr(xkb,(i+req->firstKeyAct)),
+ n*SIZEOF(xkbActionWireDesc));
+ actDesc+= n;
+ }
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeKeyBehaviors(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeKeyBehaviors(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbKeyBehaviorsMask)==0)||(req->nKeyBehaviors<1)) {
+ req->present&= ~XkbKeyBehaviorsMask;
+ req->firstKeyBehavior= req->nKeyBehaviors= 0;
+ req->totalKeyBehaviors= 0;
+ return 0;
+ }
+ first= req->firstKeyBehavior;
+ last= first+req->nKeyBehaviors-1;
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->behaviors[i].type!=XkbKB_Default)
+ nFound++;
+ }
+ req->totalKeyBehaviors= nFound;
+ return (nFound*SIZEOF(xkbBehaviorWireDesc));
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteKeyBehaviors(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteKeyBehaviors(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last;
+xkbBehaviorWireDesc * wire;
+char * buf;
+
+ if ((req->present&XkbKeyBehaviorsMask)==0)
+ return;
+ first= req->firstKeyBehavior;
+ last= first+req->nKeyBehaviors-1;
+
+ i= req->totalKeyBehaviors*SIZEOF(xkbBehaviorWireDesc);
+ BufAlloc(char *,buf,i);
+ wire= (xkbBehaviorWireDesc *)buf;
+ for (i=first;i<=last;i++) {
+ if (xkb->server->behaviors[i].type!=XkbKB_Default) {
+ wire->key= i;
+ wire->type= xkb->server->behaviors[i].type;
+ wire->data= xkb->server->behaviors[i].data;
+ buf+= SIZEOF(xkbBehaviorWireDesc);
+ wire= (xkbBehaviorWireDesc *)buf;
+ }
+ }
+ return;
+}
+
+static unsigned
+#if NeedFunctionPrototypes
+_XkbSizeVirtualMods(xkbSetMapReq *req)
+#else
+_XkbSizeVirtualMods(req)
+ xkbSetMapReq * req;
+#endif
+{
+register int i,bit,nMods;
+
+ if (((req->present&XkbVirtualModsMask)==0)||(req->virtualMods==0)) {
+ req->present&= ~XkbVirtualModsMask;
+ req->virtualMods= 0;
+ return 0;
+ }
+ for (i=nMods=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit)
+ nMods++;
+ }
+ return XkbPaddedSize(nMods);
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteVirtualMods( Display * dpy,
+ XkbDescPtr xkb,
+ xkbSetMapReq * req,
+ unsigned size)
+#else
+_XkbWriteVirtualMods(dpy,xkb,req,size)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+ unsigned size;
+#endif
+{
+ register int i,bit;
+ CARD8 *vmods;
+
+ /* This was req->present&XkbVirtualModsMask==0, and '==' beats '&' */
+ if (((req->present & XkbVirtualModsMask) == 0) || (size < 1))
+ return;
+ BufAlloc(CARD8 *,vmods,size);
+ for (i=0,bit=1;i<XkbNumVirtualMods;i++,bit<<=1) {
+ if (req->virtualMods&bit)
+ *vmods++= xkb->server->vmods[i];
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeKeyExplicit(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeKeyExplicit(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbExplicitComponentsMask)==0)||(req->nKeyExplicit==0)) {
+ req->present&= ~XkbExplicitComponentsMask;
+ req->firstKeyExplicit= req->nKeyExplicit= 0;
+ req->totalKeyExplicit= 0;
+ return 0;
+ }
+ first= req->firstKeyExplicit;
+ last= first+req->nKeyExplicit-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->explicit[i]!=0)
+ nFound++;
+ }
+ req->totalKeyExplicit= nFound;
+ return XkbPaddedSize((nFound*2));
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteKeyExplicit(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteKeyExplicit(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last;
+CARD8 * wire;
+
+ if ((req->present&XkbExplicitComponentsMask)==0)
+ return;
+ first= req->firstKeyExplicit;
+ last= first+req->nKeyExplicit;
+ i= XkbPaddedSize((req->totalKeyExplicit*2));
+ BufAlloc(CARD8 *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->server->explicit[i]!=0) {
+ wire[0]= i;
+ wire[1]= xkb->server->explicit[i];
+ wire+= 2;
+ }
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeModifierMap(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeModifierMap(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbModifierMapMask)==0)||(req->nModMapKeys==0)) {
+ req->present&= ~XkbModifierMapMask;
+ req->firstModMapKey= req->nModMapKeys= 0;
+ req->totalModMapKeys= 0;
+ return 0;
+ }
+ first= req->firstModMapKey;
+ last= first+req->nModMapKeys-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->map->modmap[i]!=0)
+ nFound++;
+ }
+ req->totalModMapKeys= nFound;
+ return XkbPaddedSize((nFound*2));
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteModifierMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteModifierMap(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last;
+CARD8 * wire;
+
+ if ((req->present&XkbModifierMapMask)==0)
+ return;
+ first= req->firstModMapKey;
+ last= first+req->nModMapKeys-1;
+ if (req->totalModMapKeys>0) {
+ i= XkbPaddedSize((req->totalModMapKeys*2));
+ BufAlloc(CARD8 *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->map->modmap[i]!=0) {
+ wire[0]= i;
+ wire[1]= xkb->map->modmap[i];
+ wire+= 2;
+ }
+ }
+ }
+ return;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XkbSizeVirtualModMap(XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbSizeVirtualModMap(xkb,req)
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last,nFound;
+
+ if (((req->present&XkbVirtualModMapMask)==0)||(req->nVModMapKeys==0)) {
+ req->present&= ~XkbVirtualModMapMask;
+ req->firstVModMapKey= req->nVModMapKeys= 0;
+ req->totalVModMapKeys= 0;
+ return 0;
+ }
+ first= req->firstVModMapKey;
+ last= first+req->nVModMapKeys-1;
+
+ for (i=first,nFound=0;i<=last;i++) {
+ if (xkb->server->vmodmap[i]!=0)
+ nFound++;
+ }
+ req->totalVModMapKeys= nFound;
+ return nFound*SIZEOF(xkbVModMapWireDesc);
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbWriteVirtualModMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+_XkbWriteVirtualModMap(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+register int i,first,last;
+xkbVModMapWireDesc * wire;
+
+ if ((req->present&XkbVirtualModMapMask)==0)
+ return;
+ first= req->firstVModMapKey;
+ last= first+req->nVModMapKeys-1;
+ if (req->totalVModMapKeys>0) {
+ i= req->totalVModMapKeys*SIZEOF(xkbVModMapWireDesc);
+ BufAlloc(xkbVModMapWireDesc *,wire,i);
+ for (i=first;i<=last;i++) {
+ if (xkb->server->vmodmap[i]!=0) {
+ wire->key= i;
+ wire->vmods= xkb->server->vmodmap[i];
+ wire++;
+ }
+ }
+ }
+ return;
+}
+
+static void
+#if NeedFunctionPrototypes
+SendSetMap(Display *dpy,XkbDescPtr xkb,xkbSetMapReq *req)
+#else
+SendSetMap(dpy,xkb,req)
+ Display * dpy;
+ XkbDescPtr xkb;
+ xkbSetMapReq * req;
+#endif
+{
+xkbSetMapReq tmp;
+unsigned szMods;
+
+ req->length+= _XkbSizeKeyTypes(xkb,req)/4;
+ req->length+= _XkbSizeKeySyms(xkb,req)/4;
+ req->length+= _XkbSizeKeyActions(xkb,req)/4;
+ req->length+= _XkbSizeKeyBehaviors(xkb,req)/4;
+ szMods= _XkbSizeVirtualMods(req);
+ req->length+= szMods/4;
+ req->length+= _XkbSizeKeyExplicit(xkb,req)/4;
+ req->length+= _XkbSizeModifierMap(xkb,req)/4;
+ req->length+= _XkbSizeVirtualModMap(xkb,req)/4;
+
+ tmp= *req;
+ if ( tmp.nTypes>0 )
+ _XkbWriteKeyTypes(dpy,xkb,&tmp);
+ if ( tmp.nKeySyms>0 )
+ _XkbWriteKeySyms(dpy,xkb,&tmp);
+ if ( tmp.nKeyActs )
+ _XkbWriteKeyActions(dpy,xkb,&tmp);
+ if ( tmp.totalKeyBehaviors>0 )
+ _XkbWriteKeyBehaviors(dpy,xkb,&tmp);
+ if ( tmp.virtualMods )
+ _XkbWriteVirtualMods(dpy,xkb,&tmp,szMods);
+ if ( tmp.totalKeyExplicit>0)
+ _XkbWriteKeyExplicit(dpy,xkb,&tmp);
+ if ( tmp.totalModMapKeys>0)
+ _XkbWriteModifierMap(dpy,xkb,&tmp);
+ if ( tmp.totalVModMapKeys>0)
+ _XkbWriteVirtualModMap(dpy,xkb,&tmp);
+ return;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetMap(Display *dpy,unsigned which,XkbDescPtr xkb)
+#else
+XkbSetMap(dpy,which,xkb)
+ Display * dpy;
+ unsigned which;
+ XkbDescPtr xkb;
+#endif
+{
+register xkbSetMapReq * req;
+XkbInfoPtr xkbi;
+XkbServerMapPtr srv;
+XkbClientMapPtr map;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
+ (!xkb))
+ return False;
+ map= xkb->map;
+ srv= xkb->server;
+
+ if (((which&XkbKeyTypesMask)&&((!map)||(!map->types)))||
+ ((which&XkbKeySymsMask)&&((!map)||(!map->syms)||(!map->key_sym_map)))||
+ ((which&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
+ ((which&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
+ ((which&XkbVirtualModsMask)&&(!srv))||
+ ((which&XkbExplicitComponentsMask)&&((!srv)||(!srv->explicit)))||
+ ((which&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
+ ((which&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
+ return False;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->present = which;
+ req->flags = XkbSetMapAllFlags;
+ req->minKeyCode= xkb->min_key_code;
+ req->maxKeyCode= xkb->max_key_code;
+ req->firstType = 0;
+ if (which&XkbKeyTypesMask) req->nTypes = map->num_types;
+ else req->nTypes = 0;
+ if (which&XkbKeySymsMask) {
+ req->firstKeySym = xkb->min_key_code;
+ req->nKeySyms = XkbNumKeys(xkb);
+ }
+ if (which&XkbKeyActionsMask) {
+ req->firstKeyAct = xkb->min_key_code;
+ req->nKeyActs = XkbNumKeys(xkb);
+ }
+ if (which&XkbKeyBehaviorsMask) {
+ req->firstKeyBehavior = xkb->min_key_code;
+ req->nKeyBehaviors = XkbNumKeys(xkb);
+ }
+ if (which&XkbVirtualModsMask)
+ req->virtualMods= ~0;
+ if (which&XkbExplicitComponentsMask) {
+ req->firstKeyExplicit= xkb->min_key_code;
+ req->nKeyExplicit = XkbNumKeys(xkb);
+ }
+ if (which&XkbModifierMapMask) {
+ req->firstModMapKey= xkb->min_key_code;
+ req->nModMapKeys = XkbNumKeys(xkb);
+ }
+ if (which&XkbVirtualModMapMask) {
+ req->firstVModMapKey= xkb->min_key_code;
+ req->nVModMapKeys = XkbNumKeys(xkb);
+ }
+ SendSetMap(dpy,xkb,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbChangeMap(Display *dpy,XkbDescPtr xkb,XkbMapChangesPtr changes)
+#else
+XkbChangeMap(dpy,xkb,changes)
+ Display * dpy;
+ XkbDescPtr xkb;
+ XkbMapChangesPtr changes;
+#endif
+{
+register xkbSetMapReq * req;
+XkbInfoPtr xkbi;
+XkbServerMapPtr srv;
+XkbClientMapPtr map;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL))||
+ (!xkb)||(!changes))
+ return False;
+ srv= xkb->server;
+ map= xkb->map;
+
+ if (((changes->changed&XkbKeyTypesMask)&&((!map)||(!map->types)))||
+ ((changes->changed&XkbKeySymsMask)&&((!map)||(!map->syms)||
+ (!map->key_sym_map)))||
+ ((changes->changed&XkbKeyActionsMask)&&((!srv)||(!srv->key_acts)))||
+ ((changes->changed&XkbKeyBehaviorsMask)&&((!srv)||(!srv->behaviors)))||
+ ((changes->changed&XkbVirtualModsMask)&&(!srv))||
+ ((changes->changed&XkbExplicitComponentsMask)&&
+ ((!srv)||(!srv->explicit)))||
+ ((changes->changed&XkbModifierMapMask)&&((!map)||(!map->modmap)))||
+ ((changes->changed&XkbVirtualModMapMask)&&((!srv)||(!srv->vmodmap))))
+ return False;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetMap;
+ req->deviceSpec = xkb->device_spec;
+ req->present = changes->changed;
+ req->flags = XkbSetMapRecomputeActions;
+ req->minKeyCode= xkb->min_key_code;
+ req->maxKeyCode= xkb->max_key_code;
+ req->firstType = changes->first_type;
+ req->nTypes = changes->num_types;
+ req->firstKeySym = changes->first_key_sym;
+ req->nKeySyms = changes->num_key_syms;
+ req->firstKeyAct = changes->first_key_act;
+ req->nKeyActs = changes->num_key_acts;
+ req->firstKeyBehavior = changes->first_key_behavior;
+ req->nKeyBehaviors = changes->num_key_behaviors;
+ req->virtualMods = changes->vmods;
+ req->firstKeyExplicit = changes->first_key_explicit;
+ req->nKeyExplicit = changes->num_key_explicit;
+ req->firstModMapKey = changes->first_modmap_key;
+ req->nModMapKeys = changes->num_modmap_keys;
+ req->firstVModMapKey = changes->first_vmodmap_key;
+ req->nVModMapKeys = changes->num_vmodmap_keys;
+ SendSetMap(dpy,xkb,req);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
diff --git a/src/xkb/XKBUse.c b/src/xkb/XKBUse.c
new file mode 100644
index 00000000..1b564cc6
--- /dev/null
+++ b/src/xkb/XKBUse.c
@@ -0,0 +1,837 @@
+/* $Xorg: XKBUse.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#include <stdio.h>
+#include <ctype.h>
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+static Bool _XkbIgnoreExtension = False;
+
+void
+#if NeedFunctionPrototypes
+XkbNoteMapChanges(XkbMapChangesPtr old,XkbMapNotifyEvent *new,unsigned wanted)
+#else
+XkbNoteMapChanges(old,new,wanted)
+ XkbMapChangesPtr old;
+ XkbMapNotifyEvent * new;
+ unsigned int wanted;
+#endif
+{
+ int first,oldLast,newLast;
+ wanted&= new->changed;
+
+ if (wanted&XkbKeyTypesMask) {
+ if (old->changed&XkbKeyTypesMask) {
+ first = old->first_type;
+ oldLast = old->first_type+old->num_types-1;
+ newLast = new->first_type+new->num_types-1;
+
+ if (new->first_type<first)
+ first = new->first_type;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_type = first;
+ old->num_types = newLast-first+1;
+ }
+ else {
+ old->first_type= new->first_type;
+ old->num_types = new->num_types;
+ }
+ }
+ if (wanted&XkbKeySymsMask) {
+ if (old->changed&XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym+old->num_key_syms-1;
+ newLast = new->first_key_sym+new->num_key_syms-1;
+
+ if (new->first_key_sym<first)
+ first = new->first_key_sym;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast-first+1;
+ }
+ else {
+ old->first_key_sym = new->first_key_sym;
+ old->num_key_syms = new->num_key_syms;
+ }
+ }
+ if (wanted&XkbKeyActionsMask) {
+ if (old->changed&XkbKeyActionsMask) {
+ first = old->first_key_act;
+ oldLast = old->first_key_act+old->num_key_acts-1;
+ newLast = new->first_key_act+new->num_key_acts-1;
+
+ if (new->first_key_act<first)
+ first = new->first_key_act;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_act = first;
+ old->num_key_acts = newLast-first+1;
+ }
+ else {
+ old->first_key_act = new->first_key_act;
+ old->num_key_acts = new->num_key_acts;
+ }
+ }
+ if (wanted&XkbKeyBehaviorsMask) {
+ if (old->changed&XkbKeyBehaviorsMask) {
+ first = old->first_key_behavior;
+ oldLast = old->first_key_behavior+old->num_key_behaviors-1;
+ newLast = new->first_key_behavior+new->num_key_behaviors-1;
+
+ if (new->first_key_behavior<first)
+ first = new->first_key_behavior;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_behavior = first;
+ old->num_key_behaviors = newLast-first+1;
+ }
+ else {
+ old->first_key_behavior = new->first_key_behavior;
+ old->num_key_behaviors = new->num_key_behaviors;
+ }
+ }
+ if (wanted&XkbVirtualModsMask) {
+ old->vmods|= new->vmods;
+ }
+ if (wanted&XkbExplicitComponentsMask) {
+ if (old->changed&XkbExplicitComponentsMask) {
+ first = old->first_key_explicit;
+ oldLast = old->first_key_explicit+old->num_key_explicit-1;
+ newLast = new->first_key_explicit+new->num_key_explicit-1;
+
+ if (new->first_key_explicit<first)
+ first = new->first_key_explicit;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_explicit = first;
+ old->num_key_explicit = newLast-first+1;
+ }
+ else {
+ old->first_key_explicit = new->first_key_explicit;
+ old->num_key_explicit = new->num_key_explicit;
+ }
+ }
+ if (wanted&XkbModifierMapMask) {
+ if (old->changed&XkbModifierMapMask) {
+ first = old->first_modmap_key;
+ oldLast = old->first_modmap_key+old->num_modmap_keys-1;
+ newLast = new->first_modmap_key+new->num_modmap_keys-1;
+
+ if (new->first_modmap_key<first)
+ first = new->first_modmap_key;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_modmap_key = first;
+ old->num_modmap_keys = newLast-first+1;
+ }
+ else {
+ old->first_modmap_key = new->first_modmap_key;
+ old->num_modmap_keys = new->num_modmap_keys;
+ }
+ }
+ if (wanted&XkbVirtualModMapMask) {
+ if (old->changed&XkbVirtualModMapMask) {
+ first = old->first_vmodmap_key;
+ oldLast = old->first_vmodmap_key+old->num_vmodmap_keys-1;
+ newLast = new->first_vmodmap_key+new->num_vmodmap_keys-1;
+
+ if (new->first_vmodmap_key<first)
+ first = new->first_vmodmap_key;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_vmodmap_key = first;
+ old->num_vmodmap_keys = newLast-first+1;
+ }
+ else {
+ old->first_vmodmap_key = new->first_vmodmap_key;
+ old->num_vmodmap_keys = new->num_vmodmap_keys;
+ }
+ }
+ old->changed|= wanted;
+ return;
+}
+
+void
+#if NeedFunctionPrototypes
+_XkbNoteCoreMapChanges( XkbMapChangesPtr old,
+ XMappingEvent * new,
+ unsigned int wanted)
+#else
+_XkbNoteCoreMapChanges(old,new,wanted)
+ XkbMapChangesPtr old;
+ XMappingEvent * new;
+ unsigned int wanted;
+#endif
+{
+ int first,oldLast,newLast;
+
+ if ((new->request==MappingKeyboard)&&(wanted&XkbKeySymsMask)) {
+ if (old->changed&XkbKeySymsMask) {
+ first = old->first_key_sym;
+ oldLast = old->first_key_sym+old->num_key_syms-1;
+ newLast = new->first_keycode+new->count-1;
+
+ if (new->first_keycode<first)
+ first = new->first_keycode;
+ if (oldLast>newLast)
+ newLast= oldLast;
+ old->first_key_sym = first;
+ old->num_key_syms = newLast-first+1;
+ }
+ else {
+ old->changed|= XkbKeySymsMask;
+ old->first_key_sym = new->first_keycode;
+ old->num_key_syms = new->count;
+ }
+ }
+ return;
+}
+
+static Bool
+#if NeedFunctionPrototypes
+wire_to_event(Display *dpy,XEvent *re,xEvent *event)
+#else
+wire_to_event(dpy,re,event)
+ Display *dpy;
+ XEvent *re;
+ xEvent *event;
+#endif
+{
+ xkbEvent *xkbevent= (xkbEvent *)event;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ xkbi = dpy->xkb_info;
+ if (((event->u.u.type&0x7f)-xkbi->codes->first_event)!=XkbEventCode)
+ return False;
+
+ switch (xkbevent->u.any.xkbType) {
+ case XkbStateNotify:
+ {
+ xkbStateNotify *sn = (xkbStateNotify *)event;
+ if ( xkbi->selected_events&XkbStateNotifyMask ) {
+ XkbStateNotifyEvent *sev=(XkbStateNotifyEvent *)re;
+ sev->type = XkbEventCode+xkbi->codes->first_event;
+ sev->xkb_type = XkbStateNotify;
+ sev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ sev->send_event = ((event->u.u.type & 0x80) != 0);
+ sev->display = dpy;
+ sev->time = sn->time;
+ sev->device = sn->deviceID;
+ sev->keycode = sn->keycode;
+ sev->event_type = sn->eventType;
+ sev->req_major = sn->requestMajor;
+ sev->req_minor = sn->requestMinor;
+ sev->changed = sn->changed;
+ sev->group = sn->group;
+ sev->base_group = sn->baseGroup;
+ sev->latched_group = sn->latchedGroup;
+ sev->locked_group = sn->lockedGroup;
+ sev->mods = sn->mods;
+ sev->base_mods = sn->baseMods;
+ sev->latched_mods = sn->latchedMods;
+ sev->locked_mods = sn->lockedMods;
+ sev->compat_state = sn->compatState;
+ sev->grab_mods = sn->grabMods;
+ sev->compat_grab_mods = sn->compatGrabMods;
+ sev->lookup_mods = sn->lookupMods;
+ sev->compat_lookup_mods = sn->compatLookupMods;
+ sev->ptr_buttons = sn->ptrBtnState;
+ return True;
+ }
+ }
+ break;
+ case XkbMapNotify:
+ {
+ xkbMapNotify *mn = (xkbMapNotify *)event;
+ if ((xkbi->selected_events&XkbMapNotifyMask)&&
+ (xkbi->selected_map_details&mn->changed)) {
+ XkbMapNotifyEvent *mev;
+ mev =(XkbMapNotifyEvent *)re;
+ mev->type = XkbEventCode+xkbi->codes->first_event;
+ mev->xkb_type = XkbMapNotify;
+ mev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ mev->send_event = ((event->u.u.type&0x80)!=0);
+ mev->display = dpy;
+ mev->time = mn->time;
+ mev->device = mn->deviceID;
+ mev->changed = mn->changed;
+ mev->min_key_code = mn->minKeyCode;
+ mev->max_key_code = mn->maxKeyCode;
+ mev->first_type = mn->firstType;
+ mev->num_types = mn->nTypes;
+ mev->first_key_sym = mn->firstKeySym;
+ mev->num_key_syms = mn->nKeySyms;
+ mev->first_key_act = mn->firstKeyAct;
+ mev->num_key_acts = mn->nKeyActs;
+ mev->first_key_behavior = mn->firstKeyBehavior;
+ mev->num_key_behaviors = mn->nKeyBehaviors;
+ mev->vmods = mn->virtualMods;
+ mev->first_key_explicit = mn->firstKeyExplicit;
+ mev->num_key_explicit = mn->nKeyExplicit;
+ mev->first_modmap_key = mn->firstModMapKey;
+ mev->num_modmap_keys = mn->nModMapKeys;
+ mev->first_vmodmap_key = mn->firstVModMapKey;
+ mev->num_vmodmap_keys = mn->nVModMapKeys;
+ XkbNoteMapChanges(&xkbi->changes,mev,XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags|= XkbMapPending;
+ return True;
+ }
+ else if (mn->nKeySyms>0) {
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ev->send_event = ((event->u.u.type&0x80)!=0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = mn->firstKeySym;
+ ev->request = MappingKeyboard;
+ ev->count = mn->nKeySyms;
+ _XkbNoteCoreMapChanges(&xkbi->changes,ev,XKB_XLIB_MAP_MASK);
+ if (xkbi->changes.changed)
+ xkbi->flags|= XkbMapPending;
+ return True;
+ }
+ }
+ break;
+ case XkbControlsNotify:
+ {
+ if (xkbi->selected_events&XkbControlsNotifyMask) {
+ xkbControlsNotify *cn =(xkbControlsNotify *)event;
+ XkbControlsNotifyEvent *cev;
+ cev =(XkbControlsNotifyEvent *)re;
+ cev->type = XkbEventCode+xkbi->codes->first_event;
+ cev->xkb_type = XkbControlsNotify;
+ cev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ cev->send_event = ((event->u.u.type&0x80)!=0);
+ cev->display = dpy;
+ cev->time = cn->time;
+ cev->device = cn->deviceID;
+ cev->changed_ctrls = cn->changedControls;
+ cev->enabled_ctrls = cn->enabledControls;
+ cev->enabled_ctrl_changes = cn->enabledControlChanges;
+ cev->keycode = cn->keycode;
+ cev->num_groups = cn->numGroups;
+ cev->event_type = cn->eventType;
+ cev->req_major = cn->requestMajor;
+ cev->req_minor = cn->requestMinor;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorMapNotify:
+ {
+ if (xkbi->selected_events&XkbIndicatorMapNotifyMask) {
+ xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
+ XkbIndicatorNotifyEvent *iev;
+ iev =(XkbIndicatorNotifyEvent *)re;
+ iev->type = XkbEventCode+xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorMapNotify;
+ iev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ iev->send_event = ((event->u.u.type&0x80)!=0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state= in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbIndicatorStateNotify:
+ {
+ if (xkbi->selected_events&XkbIndicatorStateNotifyMask) {
+ xkbIndicatorNotify *in =(xkbIndicatorNotify *)event;
+ XkbIndicatorNotifyEvent *iev;
+ iev =(XkbIndicatorNotifyEvent *)re;
+ iev->type = XkbEventCode+xkbi->codes->first_event;
+ iev->xkb_type = XkbIndicatorStateNotify;
+ iev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ iev->send_event = ((event->u.u.type&0x80)!=0);
+ iev->display = dpy;
+ iev->time = in->time;
+ iev->device = in->deviceID;
+ iev->changed = in->changed;
+ iev->state= in->state;
+ return True;
+ }
+ }
+ break;
+ case XkbBellNotify:
+ {
+ if (xkbi->selected_events&XkbBellNotifyMask) {
+ xkbBellNotify *bn =(xkbBellNotify *)event;
+ XkbBellNotifyEvent *bev;
+ bev =(XkbBellNotifyEvent *)re;
+ bev->type = XkbEventCode+xkbi->codes->first_event;
+ bev->xkb_type = XkbBellNotify;
+ bev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ bev->send_event = ((event->u.u.type&0x80)!=0);
+ bev->display = dpy;
+ bev->time = bn->time;
+ bev->device = bn->deviceID;
+ bev->percent = bn->percent;
+ bev->pitch = bn->pitch;
+ bev->duration = bn->duration;
+ bev->bell_class = bn->bellClass;
+ bev->bell_id = bn->bellID;
+ bev->name = bn->name;
+ bev->window = bn->window;
+ bev->event_only = bn->eventOnly;
+ return True;
+ }
+ }
+ break;
+ case XkbAccessXNotify:
+ {
+ if (xkbi->selected_events&XkbAccessXNotifyMask) {
+ xkbAccessXNotify *axn =(xkbAccessXNotify *)event;
+ XkbAccessXNotifyEvent *axev;
+ axev =(XkbAccessXNotifyEvent *)re;
+ axev->type = XkbEventCode+xkbi->codes->first_event;
+ axev->xkb_type = XkbAccessXNotify;
+ axev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ axev->send_event = ((event->u.u.type&0x80)!=0);
+ axev->display = dpy;
+ axev->time = axn->time;
+ axev->device = axn->deviceID;
+ axev->detail = axn->detail;
+ axev->keycode = axn->keycode;
+ axev->sk_delay = axn->slowKeysDelay;
+ axev->debounce_delay = axn->debounceDelay;
+ return True;
+ }
+ }
+ break;
+ case XkbNamesNotify:
+ {
+ if (xkbi->selected_events&XkbNamesNotifyMask) {
+ xkbNamesNotify *nn =(xkbNamesNotify *)event;
+ XkbNamesNotifyEvent *nev;
+ nev =(XkbNamesNotifyEvent *)re;
+ nev->type = XkbEventCode+xkbi->codes->first_event;
+ nev->xkb_type = XkbNamesNotify;
+ nev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ nev->send_event = ((event->u.u.type&0x80)!=0);
+ nev->display = dpy;
+ nev->time = nn->time;
+ nev->device = nn->deviceID;
+ nev->changed = nn->changed;
+ nev->first_type = nn->firstType;
+ nev->num_types = nn->nTypes;
+ nev->first_lvl = nn->firstLevelName;
+ nev->num_lvls = nn->nLevelNames;
+ nev->num_aliases = nn->nAliases;
+ nev->num_radio_groups = nn->nRadioGroups;
+ nev->changed_vmods = nn->changedVirtualMods;
+ nev->changed_groups = nn->changedGroupNames;
+ nev->changed_indicators = nn->changedIndicators;
+ nev->first_key = nn->firstKey;
+ nev->num_keys = nn->nKeys;
+ return True;
+ }
+ }
+ break;
+ case XkbCompatMapNotify:
+ {
+ if (xkbi->selected_events&XkbCompatMapNotifyMask) {
+ xkbCompatMapNotify *cmn =(xkbCompatMapNotify *)event;
+ XkbCompatMapNotifyEvent *cmev;
+ cmev =(XkbCompatMapNotifyEvent *)re;
+ cmev->type = XkbEventCode+xkbi->codes->first_event;
+ cmev->xkb_type = XkbCompatMapNotify;
+ cmev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ cmev->send_event = ((event->u.u.type&0x80)!=0);
+ cmev->display = dpy;
+ cmev->time = cmn->time;
+ cmev->device = cmn->deviceID;
+ cmev->changed_groups = cmn->changedGroups;
+ cmev->first_si = cmn->firstSI;
+ cmev->num_si = cmn->nSI;
+ cmev->num_total_si = cmn->nTotalSI;
+ return True;
+ }
+ }
+ break;
+ case XkbActionMessage:
+ {
+ if (xkbi->selected_events&XkbActionMessageMask) {
+ xkbActionMessage *am= (xkbActionMessage *)event;
+ XkbActionMessageEvent *amev;
+ amev= (XkbActionMessageEvent *)re;
+ amev->type = XkbEventCode+xkbi->codes->first_event;
+ amev->xkb_type = XkbActionMessage;
+ amev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ amev->send_event = ((event->u.u.type&0x80)!=0);
+ amev->display = dpy;
+ amev->time = am->time;
+ amev->device = am->deviceID;
+ amev->keycode = am->keycode;
+ amev->press = am->press;
+ amev->key_event_follows = am->keyEventFollows;
+ amev->group = am->group;
+ amev->mods = am->mods;
+ memcpy(amev->message,am->message,XkbActionMessageLength);
+ amev->message[XkbActionMessageLength]= '\0';
+ return True;
+ }
+ }
+ break;
+ case XkbExtensionDeviceNotify:
+ {
+ if (xkbi->selected_events&XkbExtensionDeviceNotifyMask) {
+ xkbExtensionDeviceNotify *ed=
+ (xkbExtensionDeviceNotify *)event;
+ XkbExtensionDeviceNotifyEvent *edev;
+ edev= (XkbExtensionDeviceNotifyEvent *)re;
+ edev->type= XkbEventCode+xkbi->codes->first_event;
+ edev->xkb_type= XkbExtensionDeviceNotify;
+ edev->serial= _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ edev->send_event= ((event->u.u.type&0x80)!=0);
+ edev->display= dpy;
+ edev->time= ed->time;
+ edev->device= ed->deviceID;
+ edev->led_class= ed->ledClass;
+ edev->led_id= ed->ledID;
+ edev->reason= ed->reason;
+ edev->supported= ed->supported;
+ edev->leds_defined= ed->ledsDefined;
+ edev->led_state= ed->ledState;
+ edev->first_btn= ed->firstBtn;
+ edev->num_btns= ed->nBtns;
+ edev->unsupported= ed->unsupported;
+ return True;
+ }
+ }
+ break;
+ case XkbNewKeyboardNotify:
+ {
+ xkbNewKeyboardNotify *nkn = (xkbNewKeyboardNotify *)event;
+ if ((xkbi->selected_events&XkbNewKeyboardNotifyMask)&&
+ (xkbi->selected_nkn_details&nkn->changed)) {
+ XkbNewKeyboardNotifyEvent *nkev;
+ nkev =(XkbNewKeyboardNotifyEvent *)re;
+ nkev->type = XkbEventCode+xkbi->codes->first_event;
+ nkev->xkb_type = XkbNewKeyboardNotify;
+ nkev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ nkev->send_event = ((event->u.u.type&0x80)!=0);
+ nkev->display = dpy;
+ nkev->time = nkn->time;
+ nkev->device = nkn->deviceID;
+ nkev->old_device = nkn->oldDeviceID;
+ nkev->min_key_code = nkn->minKeyCode;
+ nkev->max_key_code = nkn->maxKeyCode;
+ nkev->old_min_key_code = nkn->oldMinKeyCode;
+ nkev->old_max_key_code = nkn->oldMaxKeyCode;
+ nkev->req_major = nkn->requestMajor;
+ nkev->req_minor = nkn->requestMinor;
+ nkev->changed = nkn->changed;
+ if ((xkbi->desc)&&(nkev->send_event==0)&&
+ ((xkbi->desc->device_spec==nkev->old_device)||
+ (nkev->device!=nkev->old_device))) {
+ xkbi->flags= XkbMapPending|XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ else if(nkn->changed&(XkbNKN_KeycodesMask|XkbNKN_DeviceIDMask)){
+ register XMappingEvent *ev = (XMappingEvent *)re;
+ ev->type = MappingNotify;
+ ev->serial = _XSetLastRequestRead(dpy,
+ (xGenericReply *)event);
+ ev->send_event = ((event->u.u.type&0x80)!=0);
+ ev->display = dpy;
+ ev->window = 0;
+ ev->first_keycode = dpy->min_keycode;
+ ev->request = MappingKeyboard;
+ ev->count = (dpy->max_keycode-dpy->min_keycode)+1;
+ if ((xkbi->desc)&&(ev->send_event==0)&&
+ ((xkbi->desc->device_spec==nkn->oldDeviceID)||
+ (nkn->deviceID!=nkn->oldDeviceID))) {
+ xkbi->flags|= XkbMapPending|XkbXlibNewKeyboard;
+ }
+ return True;
+ }
+ }
+ break;
+ default:
+#ifdef DEBUG
+ fprintf(stderr,"Got unknown XKEYBOARD event (%d, base=%d)\n",
+ re->type,
+ xkbi->codes->first_event);
+#endif
+ break;
+ }
+ return False;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbIgnoreExtension(Bool ignore)
+#else
+XkbIgnoreExtension(ignore)
+ Bool ignore;
+#endif
+{
+ if (getenv("XKB_FORCE")!=NULL) {
+#ifdef DEBUG
+ fprintf(stderr,"Forcing use of XKEYBOARD (overriding an IgnoreExtensions)\n");
+#endif
+ return False;
+ }
+#ifdef DEBUG
+ else if (getenv("XKB_DEBUG")!=NULL) {
+ fprintf(stderr,"Explicitly %signoring XKEYBOARD\n",ignore?"":"not ");
+ }
+#endif
+ _XkbIgnoreExtension = ignore;
+ return True;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XkbFreeInfo(Display *dpy)
+#else
+_XkbFreeInfo(dpy)
+ Display *dpy;
+#endif
+{
+ XkbInfoPtr xkbi = dpy->xkb_info;
+ if (xkbi) {
+ if (xkbi->desc)
+ XkbFreeKeyboard(xkbi->desc,XkbAllComponentsMask,True);
+ Xfree(xkbi);
+ }
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbUseExtension(Display *dpy,int *major_rtrn,int *minor_rtrn)
+#else
+XkbUseExtension(dpy,major_rtrn,minor_rtrn)
+ Display * dpy;
+ int * major_rtrn;
+ int * minor_rtrn;
+#endif
+{
+ xkbUseExtensionReply rep;
+ register xkbUseExtensionReq *req;
+ XExtCodes *codes;
+ int ev_base,forceIgnore;
+ XkbInfoPtr xkbi;
+ char * str;
+ static int debugMsg;
+ static int been_here= 0;
+
+ if ( dpy->xkb_info ) {
+ if (major_rtrn) *major_rtrn= dpy->xkb_info->srv_major;
+ if (minor_rtrn) *minor_rtrn= dpy->xkb_info->srv_minor;
+ return True;
+ }
+ if (!been_here) {
+ debugMsg= (getenv("XKB_DEBUG")!=NULL);
+ been_here= 1;
+ }
+
+ if (major_rtrn) *major_rtrn= 0;
+ if (minor_rtrn) *minor_rtrn= 0;
+
+ forceIgnore= (dpy->flags&XlibDisplayNoXkb)||dpy->keysyms;
+ forceIgnore= forceIgnore&(major_rtrn==NULL)&&(minor_rtrn==NULL);
+ if ( forceIgnore || _XkbIgnoreExtension || getenv("XKB_DISABLE")) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD extension disabled or missing\n");
+ return False;
+ }
+
+ xkbi = _XkbTypedCalloc(1, XkbInfoRec);
+ if ( !xkbi )
+ return False;
+
+ if ( (codes=XInitExtension(dpy,XkbName))==NULL ) {
+ LockDisplay(dpy);
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ Xfree(xkbi);
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD extension not present\n");
+ return False;
+ }
+ xkbi->codes = codes;
+ LockDisplay(dpy);
+
+ GetReq(kbUseExtension, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbUseExtension;
+ req->wantedMajor = XkbMajorVersion;
+ req->wantedMinor = XkbMinorVersion;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse) || !rep.supported ) {
+ Bool fail;
+ fail= True;
+ if (debugMsg)
+ fprintf(stderr,
+ "XKEYBOARD version mismatch (want %d.%02d, got %d.%02d)\n",
+ XkbMajorVersion,XkbMinorVersion,
+ rep.serverMajor, rep.serverMinor);
+
+ /* pre-release 0.65 is very close to 1.00 */
+ if ((rep.serverMajor==0)&&(rep.serverMinor==65)) {
+ if (debugMsg)
+ fprintf(stderr,"Trying to fall back to version 0.65...");
+ GetReq(kbUseExtension, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbUseExtension;
+ req->wantedMajor = 0;
+ req->wantedMinor = 65;
+ if ( _XReply(dpy, (xReply *)&rep, 0, xFalse) && rep.supported ) {
+ if (debugMsg)
+ fprintf(stderr,"succeeded\n");
+ fail= False;
+ }
+ else if (debugMsg) fprintf(stderr,"failed\n");
+ }
+ if (fail) {
+ dpy->flags |= XlibDisplayNoXkb;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ Xfree(xkbi);
+ if (major_rtrn) *major_rtrn= rep.serverMajor;
+ if (minor_rtrn) *minor_rtrn= rep.serverMinor;
+ return False;
+ }
+ }
+#ifdef DEBUG
+ else if ( forceIgnore ) {
+ fprintf(stderr,"Internal Error! XkbUseExtension succeeded with forceIgnore set\n");
+ }
+#endif
+ UnlockDisplay(dpy);
+ xkbi->srv_major= rep.serverMajor;
+ xkbi->srv_minor= rep.serverMinor;
+ if (major_rtrn) *major_rtrn= rep.serverMajor;
+ if (minor_rtrn) *minor_rtrn= rep.serverMinor;
+ if (debugMsg)
+ fprintf(stderr,"XKEYBOARD (version %d.%02d/%d.%02d) OK!\n",
+ XkbMajorVersion,XkbMinorVersion,
+ rep.serverMajor,rep.serverMinor);
+ dpy->xkb_info = xkbi;
+ dpy->free_funcs->xkb = _XkbFreeInfo;
+ ev_base = codes->first_event;
+ xkbi->xlib_ctrls|=
+ (XkbLC_BeepOnComposeFail|XkbLC_ComposeLED|XkbLC_ControlFallback);
+ if ((str=getenv("_XKB_OPTIONS_ENABLE"))!=NULL) {
+ if ((str=getenv("_XKB_LATIN1_LOOKUP"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ForceLatin1Lookup;
+ else xkbi->xlib_ctrls|= XkbLC_ForceLatin1Lookup;
+ }
+ if ((str=getenv("_XKB_CONSUME_LOOKUP_MODS"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ConsumeLookupMods;
+ else xkbi->xlib_ctrls|= XkbLC_ConsumeLookupMods;
+ }
+ if ((str=getenv("_XKB_CONSUME_SHIFT_AND_LOCK"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_AlwaysConsumeShiftAndLock;
+ else xkbi->xlib_ctrls|= XkbLC_AlwaysConsumeShiftAndLock;
+ }
+ if ((str=getenv("_XKB_IGNORE_NEW_KEYBOARDS"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_IgnoreNewKeyboards;
+ else xkbi->xlib_ctrls|= XkbLC_IgnoreNewKeyboards;
+ }
+ if ((str=getenv("_XKB_CONTROL_FALLBACK"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ControlFallback;
+ else xkbi->xlib_ctrls|= XkbLC_ControlFallback;
+ }
+ if ((str=getenv("_XKB_COMP_LED"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_ComposeLED;
+ else {
+ xkbi->xlib_ctrls|= XkbLC_ComposeLED;
+ if (strlen(str)>0)
+ xkbi->composeLED= XInternAtom(dpy,str,False);
+ }
+ }
+ if ((str=getenv("_XKB_COMP_FAIL_BEEP"))!=NULL) {
+ if ((strcmp(str,"off")==0)||(strcmp(str,"0")==0))
+ xkbi->xlib_ctrls&= ~XkbLC_BeepOnComposeFail;
+ else xkbi->xlib_ctrls|= XkbLC_BeepOnComposeFail;
+ }
+ }
+ if ((xkbi->composeLED==None)&&((xkbi->xlib_ctrls&XkbLC_ComposeLED)!=0))
+ xkbi->composeLED= XInternAtom(dpy,"Compose",False);
+#ifdef DEBUG
+ if (debugMsg) {
+ register unsigned c= xkbi->xlib_ctrls;
+ fprintf(stderr,"XKEYBOARD compose: beep on failure is %s, LED is %s\n",
+ ((c&XkbLC_BeepOnComposeFail)?"on":"off"),
+ ((c&XkbLC_ComposeLED)?"on":"off"));
+ fprintf(stderr,"XKEYBOARD XLookupString: %slatin-1, %s lookup modifiers\n",
+ ((c&XkbLC_ForceLatin1Lookup)?"allow non-":"force "),
+ ((c&XkbLC_ConsumeLookupMods)?"consume":"re-use"));
+ fprintf(stderr,
+ "XKEYBOARD XLookupString: %sconsume shift and lock, %scontrol fallback\n",
+ ((c&XkbLC_AlwaysConsumeShiftAndLock)?"always ":"don't "),
+ ((c&XkbLC_ControlFallback)?"":"no "));
+
+ }
+#endif
+ XESetWireToEvent(dpy,ev_base+XkbEventCode,wire_to_event);
+ SyncHandle();
+ return True;
+}
+
diff --git a/src/xkb/XKBleds.c b/src/xkb/XKBleds.c
new file mode 100644
index 00000000..a4636157
--- /dev/null
+++ b/src/xkb/XKBleds.c
@@ -0,0 +1,408 @@
+/* $Xorg: XKBleds.c,v 1.3 2000/08/17 19:45:03 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#define NEED_REPLIES
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include <X11/extensions/XKBproto.h>
+#include "XKBlibint.h"
+
+Status
+#if NeedFunctionPrototypes
+XkbGetIndicatorState(Display *dpy,unsigned deviceSpec,unsigned *pStateRtrn)
+#else
+XkbGetIndicatorState(dpy,deviceSpec,pStateRtrn)
+ Display * dpy;
+ unsigned int deviceSpec;
+ unsigned int * pStateRtrn;
+#endif
+{
+ register xkbGetIndicatorStateReq *req;
+ xkbGetIndicatorStateReply rep;
+ XkbInfoPtr xkbi;
+ Bool ok;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetIndicatorState, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetIndicatorState;
+ req->deviceSpec = deviceSpec;
+ ok=_XReply(dpy, (xReply *)&rep, 0, xFalse);
+ if (ok && (pStateRtrn!=NULL))
+ *pStateRtrn= rep.state;
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return (ok?Success:BadImplementation);
+}
+
+Status
+#if NeedFunctionPrototypes
+_XkbReadGetIndicatorMapReply( Display * dpy,
+ xkbGetIndicatorMapReply * rep,
+ XkbDescPtr xkb,
+ int * nread_rtrn)
+#else
+_XkbReadGetIndicatorMapReply(dpy,rep,xkb,nread_rtrn)
+ Display * dpy;
+ xkbGetIndicatorMapReply * rep;
+ XkbDescPtr xkb;
+ int * nread_rtrn;
+#endif
+{
+XkbIndicatorPtr leds;
+XkbReadBufferRec buf;
+
+ if ((!xkb->indicators)&&(XkbAllocIndicatorMaps(xkb)!=Success))
+ return BadAlloc;
+ leds= xkb->indicators;
+
+ leds->phys_indicators = rep->realIndicators;
+ if (rep->length>0) {
+ register int left;
+ if (!_XkbInitReadBuffer(dpy,&buf,(int)rep->length*4))
+ return BadAlloc;
+ if (nread_rtrn)
+ *nread_rtrn= (int)rep->length*4;
+ if (rep->which) {
+ register int i,bit;
+ left= (int)rep->which;
+ for (i=0,bit=1;(i<XkbNumIndicators)&&(left);i++,bit<<=1) {
+ if (left&bit) {
+ xkbIndicatorMapWireDesc *wire;
+ wire= (xkbIndicatorMapWireDesc *)
+ _XkbGetReadBufferPtr(&buf,
+ SIZEOF(xkbIndicatorMapWireDesc));
+ if (wire==NULL) {
+ _XkbFreeReadBuffer(&buf);
+ return BadAlloc;
+ }
+ leds->maps[i].flags= wire->flags;
+ leds->maps[i].which_groups= wire->whichGroups;
+ leds->maps[i].groups= wire->groups;
+ leds->maps[i].which_mods= wire->whichMods;
+ leds->maps[i].mods.mask= wire->mods;
+ leds->maps[i].mods.real_mods= wire->realMods;
+ leds->maps[i].mods.vmods= wire->virtualMods;
+ leds->maps[i].ctrls= wire->ctrls;
+ left&= ~bit;
+ }
+ }
+ }
+ left= _XkbFreeReadBuffer(&buf);
+ }
+ return Success;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+#else
+XkbGetIndicatorMap(dpy,which,xkb)
+ Display * dpy;
+ unsigned long which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbGetIndicatorMapReq * req;
+ xkbGetIndicatorMapReply rep;
+ XkbInfoPtr xkbi;
+ Status status;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return BadAccess;
+ if ((!which)||(!xkb))
+ return BadValue;
+
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ if (!xkb->indicators) {
+ xkb->indicators = _XkbTypedCalloc(1,XkbIndicatorRec);
+ if (!xkb->indicators) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadAlloc;
+ }
+ }
+ GetReq(kbGetIndicatorMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetIndicatorMap;
+ req->deviceSpec = xkb->device_spec;
+ req->which = (CARD32)which;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return BadValue;
+ }
+ status= _XkbReadGetIndicatorMapReply(dpy,&rep,xkb,NULL);
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return status;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetIndicatorMap(Display *dpy,unsigned long which,XkbDescPtr xkb)
+#else
+XkbSetIndicatorMap(dpy,which,xkb)
+ Display * dpy;
+ unsigned long which;
+ XkbDescPtr xkb;
+#endif
+{
+ register xkbSetIndicatorMapReq *req;
+ register int i,bit;
+ int nMaps;
+ xkbIndicatorMapWireDesc *wire;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ if ((!xkb)||(!which)||(!xkb->indicators))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetIndicatorMap, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetIndicatorMap;
+ req->deviceSpec = xkb->device_spec;
+ req->which = (CARD32)which;
+ for (i=nMaps=0,bit=1;i<32;i++,bit<<=1) {
+ if (which&bit)
+ nMaps++;
+ }
+ req->length+= (nMaps*sizeof(XkbIndicatorMapRec))/4;
+ BufAlloc(xkbIndicatorMapWireDesc *,wire,
+ (nMaps*SIZEOF(xkbIndicatorMapWireDesc)));
+ for (i=0,bit=1;i<32;i++,bit<<=1) {
+ if (which&bit) {
+ wire->flags= xkb->indicators->maps[i].flags;
+ wire->whichGroups= xkb->indicators->maps[i].which_groups;
+ wire->groups= xkb->indicators->maps[i].groups;
+ wire->whichMods= xkb->indicators->maps[i].which_mods;
+ wire->mods= xkb->indicators->maps[i].mods.real_mods;
+ wire->virtualMods= xkb->indicators->maps[i].mods.vmods;
+ wire->ctrls= xkb->indicators->maps[i].ctrls;
+ wire++;
+ }
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetNamedDeviceIndicator( Display * dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ int * pNdxRtrn,
+ Bool * pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool * pRealRtrn)
+#else
+XkbGetNamedDeviceIndicator(dpy,device,class,id,name,pNdxRtrn,pStateRtrn,
+ pMapRtrn,pRealRtrn)
+ Display * dpy;
+ unsigned device;
+ unsigned class;
+ unsigned id;
+ Atom name;
+ int * pNdxRtrn;
+ Bool * pStateRtrn;
+ XkbIndicatorMapPtr pMapRtrn;
+ Bool * pRealRtrn;
+#endif
+{
+ register xkbGetNamedIndicatorReq *req;
+ xkbGetNamedIndicatorReply rep;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbGetNamedIndicator, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbGetNamedIndicator;
+ req->deviceSpec = device;
+ req->ledClass = class;
+ req->ledID = id;
+ req->indicator = (CARD32)name;
+ if (!_XReply(dpy, (xReply *)&rep, 0, xFalse)) {
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return False;
+ }
+ if ((!rep.found)||(!rep.supported))
+ return False;
+ if (pNdxRtrn!=NULL)
+ *pNdxRtrn= rep.ndx;
+ if (pStateRtrn!=NULL)
+ *pStateRtrn= rep.on;
+ if (pMapRtrn!=NULL) {
+ pMapRtrn->flags= rep.flags;
+ pMapRtrn->which_groups= rep.whichGroups;
+ pMapRtrn->groups= rep.groups;
+ pMapRtrn->which_mods= rep.whichMods;
+ pMapRtrn->mods.mask= rep.mods;
+ pMapRtrn->mods.real_mods= rep.realMods;
+ pMapRtrn->mods.vmods= rep.virtualMods;
+ pMapRtrn->ctrls= rep.ctrls;
+ }
+ if (pRealRtrn!=NULL)
+ *pRealRtrn= rep.realIndicator;
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbGetNamedIndicator( Display * dpy,
+ Atom name,
+ int * pNdxRtrn,
+ Bool * pStateRtrn,
+ XkbIndicatorMapPtr pMapRtrn,
+ Bool * pRealRtrn)
+#else
+XkbGetNamedIndicator(dpy,name,pNdxRtrn,pStateRtrn,pMapRtrn,pRealRtrn)
+ Display * dpy;
+ Atom name;
+ int * pNdxRtrn;
+ Bool * pStateRtrn;
+ XkbIndicatorMapPtr pMapRtrn;
+ Bool * pRealRtrn;
+#endif
+{
+ return XkbGetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ name,pNdxRtrn,pStateRtrn,
+ pMapRtrn,pRealRtrn);
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetNamedDeviceIndicator( Display * dpy,
+ unsigned device,
+ unsigned class,
+ unsigned id,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
+#else
+XkbSetNamedDeviceIndicator(dpy,device,class,id,name,changeState,
+ state,createNewMap,pMap)
+ Display * dpy;
+ unsigned device;
+ unsigned class;
+ unsigned id;
+ Atom name;
+ Bool changeState;
+ Bool state;
+ Bool createNewMap;
+ XkbIndicatorMapPtr pMap;
+#endif
+{
+ register xkbSetNamedIndicatorReq *req;
+ XkbInfoPtr xkbi;
+
+ if ((dpy->flags & XlibDisplayNoXkb) || (name==None) ||
+ (!dpy->xkb_info && !XkbUseExtension(dpy,NULL,NULL)) ||
+ (pMap==NULL))
+ return False;
+ LockDisplay(dpy);
+ xkbi = dpy->xkb_info;
+ GetReq(kbSetNamedIndicator, req);
+ req->reqType = xkbi->codes->major_opcode;
+ req->xkbReqType = X_kbSetNamedIndicator;
+ req->deviceSpec = device;
+ req->ledClass = class;
+ req->ledID = id;
+ req->indicator= (CARD32)name;
+ req->setState= changeState;
+ if (req->setState)
+ req->on= state;
+ else req->on= False;
+ if (pMap!=NULL) {
+ req->setMap= True;
+ req->createMap= createNewMap;
+ req->flags= pMap->flags;
+ req->whichGroups= pMap->which_groups;
+ req->groups= pMap->groups;
+ req->whichMods= pMap->which_mods;
+ req->realMods= pMap->mods.real_mods;
+ req->virtualMods= pMap->mods.vmods;
+ req->ctrls= pMap->ctrls;
+ }
+ else {
+ req->setMap= False;
+ req->createMap= False;
+ req->flags= 0;
+ req->whichGroups= 0;
+ req->groups= 0;
+ req->whichMods= 0;
+ req->realMods= 0;
+ req->virtualMods= 0;
+ req->ctrls= 0;
+ }
+ UnlockDisplay(dpy);
+ SyncHandle();
+ return True;
+}
+
+Bool
+#if NeedFunctionPrototypes
+XkbSetNamedIndicator( Display * dpy,
+ Atom name,
+ Bool changeState,
+ Bool state,
+ Bool createNewMap,
+ XkbIndicatorMapPtr pMap)
+#else
+XkbSetNamedIndicator(dpy,name,changeState,state,createNewMap,pMap)
+ Display * dpy;
+ Atom name;
+ Bool changeState;
+ Bool state;
+ Bool createNewMap;
+ XkbIndicatorMapPtr pMap;
+#endif
+{
+ return XkbSetNamedDeviceIndicator(dpy,XkbUseCoreKbd,
+ XkbDfltXIClass,XkbDfltXIId,
+ name,changeState,state,
+ createNewMap,pMap);
+}
diff --git a/src/xkb/XKBlibint.h b/src/xkb/XKBlibint.h
new file mode 100644
index 00000000..5247cb7c
--- /dev/null
+++ b/src/xkb/XKBlibint.h
@@ -0,0 +1,406 @@
+/* $Xorg: XKBlibint.h,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+/************************************************************
+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.
+
+********************************************************/
+
+#ifndef _XKBLIBINT_H_
+#define _XKBLIBINT_H_
+
+#include <X11/Xutil.h>
+#include <X11/XKBlib.h>
+
+#define XkbMapPending (1<<0)
+#define XkbXlibNewKeyboard (1<<1)
+
+typedef int (*XkbKSToMBFunc)(
+#if NeedFunctionPrototypes
+ XPointer /* priv */,
+ KeySym /* sym */,
+ char * /* buf */,
+ int /* len */,
+ int * /* extra_rtrn */
+#endif
+);
+
+typedef KeySym (*XkbMBToKSFunc)(
+#if NeedFunctionPrototypes
+ XPointer /* priv */,
+ char * /* buf */,
+ int /* len */,
+ Status * /* status */
+#endif
+);
+
+typedef KeySym (*XkbToUpperFunc)(
+#if NeedFunctionPrototypes
+ KeySym /* sym */
+#endif
+);
+
+typedef struct _XkbConverters {
+ XkbKSToMBFunc KSToMB;
+ XPointer KSToMBPriv;
+ XkbMBToKSFunc MBToKS;
+ XPointer MBToKSPriv;
+ XkbToUpperFunc KSToUpper;
+} XkbConverters;
+
+extern XkbInternAtomFunc _XkbInternAtomFunc;
+extern XkbGetAtomNameFunc _XkbGetAtomNameFunc;
+
+typedef struct _XkbInfoRec {
+ unsigned flags;
+ unsigned xlib_ctrls;
+ XExtCodes *codes;
+ int srv_major;
+ int srv_minor;
+ unsigned selected_events;
+ unsigned short selected_nkn_details;
+ unsigned short selected_map_details;
+ XkbDescRec *desc;
+ XkbMapChangesRec changes;
+ Atom composeLED;
+ XkbConverters cvt;
+ XkbConverters latin1cvt;
+} XkbInfoRec, *XkbInfoPtr;
+
+
+#define _XkbUnavailable(d) \
+ (((d)->flags&XlibDisplayNoXkb) ||\
+ ((!(d)->xkb_info || (!(d)->xkb_info->desc)) && !_XkbLoadDpy(d)))
+
+#define _XkbCheckPendingRefresh(d,xi) {\
+ if ((xi)->flags&XkbXlibNewKeyboard)\
+ _XkbReloadDpy((d));\
+ else if ((xi)->flags&XkbMapPending) {\
+ if (XkbGetMapChanges((d),(xi)->desc, &(xi)->changes)==Success) {\
+ LockDisplay((d));\
+ (xi)->changes.changed= 0;\
+ UnlockDisplay((d));\
+ }\
+ }\
+}
+
+#define _XkbNeedModmap(i) ((!(i)->desc->map)||(!(i)->desc->map->modmap))
+
+ /*
+ * mask of the events that the "invisible" XKB support in Xlib needs
+ */
+#define XKB_XLIB_MAP_MASK (XkbAllClientInfoMask)
+
+ /*
+ * Handy helper macros
+ */
+#define XKB_INSURE_SIZE(f,t,nNum,oNum) {\
+ if ((f)==NULL) \
+ (f)=(t *)Xmalloc(sizeof(t)*(nNum));\
+ else if ((nNum)<(oNum))\
+ (f)=(t *)Xrealloc((f),sizeof(t)*(nNum));\
+ }
+
+typedef struct _XkbReadBuffer {
+ int error;
+ int size;
+ char *start;
+ char *data;
+} XkbReadBufferRec,*XkbReadBufferPtr;
+
+#define _XkbAlloc(s) Xmalloc((s))
+#define _XkbCalloc(n,s) Xcalloc((n),(s))
+#define _XkbRealloc(o,s) Xrealloc((o),(s))
+#define _XkbTypedAlloc(t) ((t *)Xmalloc(sizeof(t)))
+#define _XkbTypedCalloc(n,t) ((t *)Xcalloc((n),sizeof(t)))
+#define _XkbTypedRealloc(o,n,t) \
+ ((o)?(t *)Xrealloc((o),(n)*sizeof(t)):_XkbTypedCalloc(n,t))
+#define _XkbClearElems(a,f,l,t) bzero(&(a)[f],((l)-(f)+1)*sizeof(t))
+#define _XkbFree(p) Xfree(p)
+
+_XFUNCPROTOBEGIN
+
+extern void _XkbReloadDpy(
+#if NeedFunctionPrototypes
+ Display * /* dpy */
+#endif
+);
+
+extern KeySym _XKeycodeToKeysym(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ KeyCode /* keycode */,
+ int /* index */
+#endif
+);
+
+extern KeyCode _XKeysymToKeycode(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ KeySym /* keysym */
+#endif
+);
+
+extern KeySym _XLookupKeysym(
+#if NeedFunctionPrototypes
+ XKeyEvent* /* key_event */,
+ int /* index */
+#endif
+);
+
+extern int _XRefreshKeyboardMapping(
+#if NeedFunctionPrototypes
+ XMappingEvent* /* event_map */
+#endif
+);
+
+extern unsigned _XKeysymToModifiers(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ KeySym /* ks */
+#endif
+);
+
+extern int _XTranslateKey(
+#if NeedFunctionPrototypes
+ register Display * /* dpy */,
+ KeyCode /* keycode */,
+ register unsigned int /* modifiers */,
+ unsigned int * /* modifiers_return */,
+ KeySym * /* keysym_return */
+#endif
+);
+
+extern int _XTranslateKeySym(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ register KeySym /* symbol */,
+ unsigned int /* modifiers */,
+ char * /* buffer */,
+ int /* nbytes */
+#endif
+);
+
+extern int _XLookupString(
+#if NeedFunctionPrototypes
+ register XKeyEvent * /* event */,
+ char * /* buffer */,
+ int /* nbytes */,
+ KeySym * /* keysym */,
+ XComposeStatus * /* status */
+#endif
+);
+
+extern void _XkbNoteCoreMapChanges(
+#if NeedFunctionPrototypes
+ XkbMapChangesRec * /* old */,
+ XMappingEvent * /* new */,
+ unsigned int /* wanted */
+#endif
+);
+
+extern int _XkbInitReadBuffer(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ XkbReadBufferPtr /* buf */,
+ int /* size */
+#endif
+);
+
+extern int _XkbSkipReadBufferData(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+ int /* size */
+#endif
+);
+
+extern int _XkbCopyFromReadBuffer(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+ char * /* to */,
+ int /* size */
+#endif
+);
+
+
+#if defined(WORD64) || defined(LONG64)
+extern int _XkbReadCopyData32(
+#if NeedFunctionPrototypes
+ int * /* from */,
+ long * /* to */,
+ int /* num_words */
+#endif
+);
+
+extern int _XkbWriteCopyData32(
+#if NeedFunctionPrototypes
+ unsigned long * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
+#endif
+);
+
+extern int _XkbReadBufferCopy32(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+ long * /* to */,
+ int /* size */
+#endif
+);
+#else
+#define _XkbReadCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
+#define _XkbWriteCopyData32(f,t,s) memcpy((char *)(t),(char *)(f),(s)*4)
+#define _XkbReadBufferCopy32(f,t,s) _XkbCopyFromReadBuffer(f,(char *)t,(s)*4)
+#endif
+
+#ifndef NO_DEC_BINARY_COMPATIBILITY
+#define XKB_FORCE_INT_KEYSYM 1
+#endif
+
+#ifdef XKB_FORCE_INT_KEYSYM
+extern int _XkbReadCopyKeySyms(
+#if NeedFunctionPrototypes
+ int * /* from */,
+ KeySym * /* to */,
+ int /* num_words */
+#endif
+);
+
+extern int _XkbWriteCopyKeySyms(
+#if NeedFunctionPrototypes
+ KeySym * /* from */,
+ CARD32 * /* to */,
+ int /* num_words */
+#endif
+);
+
+extern int _XkbReadBufferCopyKeySyms(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+#ifndef NO_DEC_BUG_FIX
+ KeySym * /* to */,
+#else
+ long * /* to */,
+#endif
+ int /* size */
+#endif
+);
+#else
+#define _XkbReadCopyKeySyms(f,t,n) _XkbReadCopyData32(f,t,n)
+#define _XkbWriteCopyKeySyms(f,t,n) _XkbWriteCopyData32(f,t,n)
+#define _XkbReadBufferCopyKeySyms(f,t,s) _XkbReadBufferCopy32(f,t,s)
+#endif
+
+extern char *_XkbPeekAtReadBuffer(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+ int /* size */
+#endif
+);
+
+extern char *_XkbGetReadBufferPtr(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* from */,
+ int /* size */
+#endif
+);
+#define _XkbGetTypedRdBufPtr(b,n,t) ((t *)_XkbGetReadBufferPtr(b,(n)*SIZEOF(t)))
+
+extern int _XkbFreeReadBuffer(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* buf */
+#endif
+);
+
+extern Bool
+_XkbGetReadBufferCountedString(
+#if NeedFunctionPrototypes
+ XkbReadBufferPtr /* buf */,
+ char ** /* rtrn */
+#endif
+);
+
+extern char *_XkbGetCharset(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern int _XkbGetConverters(
+#if NeedFunctionPrototypes
+ char * /* encoding_name */,
+ XkbConverters * /* cvt_rtrn */
+#endif
+);
+
+#ifdef NEED_MAP_READERS
+
+extern Status _XkbReadGetMapReply(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ xkbGetMapReply * /* rep */,
+ XkbDescRec * /* xkb */,
+ int * /* nread_rtrn */
+#endif
+);
+
+extern Status _XkbReadGetCompatMapReply(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ xkbGetCompatMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+#endif
+);
+
+extern Status _XkbReadGetIndicatorMapReply(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ xkbGetIndicatorMapReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+#endif
+);
+
+extern Status _XkbReadGetNamesReply(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ xkbGetNamesReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+#endif
+);
+
+extern Status _XkbReadGetGeometryReply(
+#if NeedFunctionPrototypes
+ Display * /* dpy */,
+ xkbGetGeometryReply * /* rep */,
+ XkbDescPtr /* xkb */,
+ int * /* nread_rtrn */
+#endif
+);
+
+#endif
+
+_XFUNCPROTOEND
+
+#endif /* _XKBLIBINT_H_ */
diff --git a/src/xlibi18n/ICWrap.c b/src/xlibi18n/ICWrap.c
new file mode 100644
index 00000000..be511f4a
--- /dev/null
+++ b/src/xlibi18n/ICWrap.c
@@ -0,0 +1,475 @@
+/*
+ * $Xorg: ICWrap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $
+ */
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the FUJITSU LIMITED
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 names of OMRON, NTT Software, NTT, and
+ * Open Software Foundation not be used in advertising or publicity
+ * pertaining to distribution of the software without specific,
+ * written prior permission. OMRON, NTT Software, NTT, and Open Software
+ * Foundation make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, NTT, AND OPEN SOFTWARE FOUNDATION
+ * DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL OMRON, NTT SOFTWARE, NTT, OR OPEN SOFTWARE FOUNDATION 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tatsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Coproration
+ * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co.
+ *
+ * M. Collins OSF
+ * Takashi Fujiwara FUJITSU LIMITED
+ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+static int
+_XIMNestedListToNestedList(nlist, list)
+ XIMArg *nlist; /* This is the new list */
+ XIMArg *list; /* The original list */
+{
+ register XIMArg *ptr = list;
+
+ while (ptr->name) {
+ if (!strcmp(ptr->name, XNVaNestedList)) {
+ nlist += _XIMNestedListToNestedList(nlist, (XIMArg *)ptr->value);
+ } else {
+ nlist->name = ptr->name;
+ nlist->value = ptr->value;
+ ptr++;
+ nlist++;
+ }
+ }
+ return ptr - list;
+}
+
+static void
+_XIMCountNestedList(args, total_count)
+ XIMArg *args;
+ int *total_count;
+{
+ for (; args->name; args++) {
+ if (!strcmp(args->name, XNVaNestedList))
+ _XIMCountNestedList((XIMArg *)args->value, total_count);
+ else
+ ++(*total_count);
+ }
+}
+
+#if NeedVarargsPrototypes
+static void
+_XIMCountVaList(va_list var, int *total_count)
+#else
+static void
+_XIMCountVaList(var, total_count)
+ va_list var;
+ int *total_count;
+#endif
+{
+ char *attr;
+
+ *total_count = 0;
+
+ for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
+ if (!strcmp(attr, XNVaNestedList)) {
+ _XIMCountNestedList(va_arg(var, XIMArg*), total_count);
+ } else {
+ va_arg(var, XIMArg*);
+ ++(*total_count);
+ }
+ }
+}
+
+#if NeedVarargsPrototypes
+static void
+_XIMVaToNestedList(va_list var, int max_count, XIMArg **args_return)
+#else
+static void
+_XIMVaToNestedList(var, max_count, args_return)
+ va_list var;
+ int max_count;
+ XIMArg **args_return;
+#endif
+{
+ XIMArg *args;
+ char *attr;
+
+ if (max_count <= 0) {
+ *args_return = (XIMArg *)NULL;
+ return;
+ }
+
+ args = (XIMArg *)Xmalloc((unsigned)(max_count + 1) * sizeof(XIMArg));
+ *args_return = args;
+ if (!args) return;
+
+ for (attr = va_arg(var, char*); attr; attr = va_arg(var, char*)) {
+ if (!strcmp(attr, XNVaNestedList)) {
+ args += _XIMNestedListToNestedList(args, va_arg(var, XIMArg*));
+ } else {
+ args->name = attr;
+ args->value = va_arg(var, XPointer);
+ args++;
+ }
+ }
+ args->name = (char*)NULL;
+}
+
+/*ARGSUSED*/
+#if NeedVarargsPrototypes
+XVaNestedList
+XVaCreateNestedList(int dummy, ...)
+#else
+XVaNestedList
+XVaCreateNestedList(dummy, va_alist)
+ int dummy;
+ va_dcl
+#endif
+{
+ va_list var;
+ XIMArg *args = NULL;
+ int total_count;
+
+ Va_start(var, dummy);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ Va_start(var, dummy);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ return (XVaNestedList)args;
+}
+
+#if NeedVarargsPrototypes
+char *
+XSetIMValues(XIM im, ...)
+#else /* NeedVarargsPrototypes */
+char *
+XSetIMValues(im, va_alist)
+ XIM im;
+ va_dcl
+#endif /* NeedVarargsPrototypes */
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ /*
+ * so count the stuff dangling here
+ */
+ Va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ Va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*im->methods->set_values) (im, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+#if NeedVarargsPrototypes
+char *
+XGetIMValues(XIM im, ...)
+#else /* NeedVarargsPrototypes */
+char *
+XGetIMValues(im, va_alist)
+ XIM im;
+ va_dcl
+#endif /* NeedVarargsPrototypes */
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ /*
+ * so count the stuff dangling here
+ */
+ Va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ Va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*im->methods->get_values) (im, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+/*
+ * Create an input context within the input method,
+ * and return a pointer to the input context.
+ */
+
+#if NeedVarargsPrototypes
+XIC
+XCreateIC(XIM im, ...)
+#else
+XIC
+XCreateIC(im, va_alist)
+ XIM im; /* specified the attached input method */
+ va_dcl /* specified variable length argment list */
+#endif
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ XIC ic;
+
+ /*
+ * so count the stuff dangling here
+ */
+ Va_start(var, im);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ Va_start(var, im);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ic = (XIC) (*im->methods->create_ic) (im, args);
+ if (args) Xfree((char *)args);
+ if (ic) {
+ ic->core.next = im->core.ic_chain;
+ im->core.ic_chain = ic;
+ }
+ return ic;
+}
+
+/*
+ * Free the input context.
+ */
+void
+XDestroyIC(ic)
+ XIC ic;
+{
+ XIM im = ic->core.im;
+ XIC *prev;
+
+ (*ic->methods->destroy) (ic);
+ if (im) {
+ for (prev = &im->core.ic_chain; *prev; prev = &(*prev)->core.next) {
+ if (*prev == ic) {
+ *prev = ic->core.next;
+ break;
+ }
+ }
+ }
+ Xfree ((char *) ic);
+}
+
+#if NeedVarargsPrototypes
+char *
+XGetICValues(XIC ic, ...)
+#else
+char *
+XGetICValues(ic, va_alist)
+ XIC ic;
+ va_dcl
+#endif
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ if (!ic->core.im)
+ return (char *) NULL;
+
+ /*
+ * so count the stuff dangling here
+ */
+ Va_start(var, ic);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ Va_start(var, ic);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*ic->methods->get_values) (ic, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+#if NeedVarargsPrototypes
+char *
+XSetICValues(XIC ic, ...)
+#else
+char *
+XSetICValues(ic, va_alist)
+ XIC ic;
+ va_dcl
+#endif
+{
+ va_list var;
+ int total_count;
+ XIMArg *args;
+ char *ret;
+
+ if (!ic->core.im)
+ return (char *) NULL;
+
+ /*
+ * so count the stuff dangling here
+ */
+ Va_start(var, ic);
+ _XIMCountVaList(var, &total_count);
+ va_end(var);
+
+ /*
+ * now package it up so we can send it along
+ */
+ Va_start(var, ic);
+ _XIMVaToNestedList(var, total_count, &args);
+ va_end(var);
+
+ ret = (*ic->methods->set_values) (ic, args);
+ if (args) Xfree((char *)args);
+ return ret;
+}
+
+/*
+ * Require the input manager to focus the focus window attached to the ic
+ * argument.
+ */
+void
+XSetICFocus(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ (*ic->methods->set_focus) (ic);
+}
+
+/*
+ * Require the input manager to unfocus the focus window attached to the ic
+ * argument.
+ */
+void
+XUnsetICFocus(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ (*ic->methods->unset_focus) (ic);
+}
+
+/*
+ * Return the XIM associated with the input context.
+ */
+XIM
+XIMOfIC(ic)
+ XIC ic;
+{
+ return ic->core.im;
+}
+
+char *XmbResetIC(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ return (*ic->methods->mb_reset)(ic);
+ return (char *)NULL;
+}
+
+wchar_t *XwcResetIC(ic)
+ XIC ic;
+{
+ if (ic->core.im)
+ return (*ic->methods->wc_reset)(ic);
+ return (wchar_t *)NULL;
+}
+
+int
+XmbLookupString(ic, ev, buffer, nbytes, keysym, status)
+ XIC ic;
+ register XKeyEvent *ev;
+ char *buffer;
+ int nbytes;
+ KeySym *keysym;
+ Status *status;
+{
+ if (ic->core.im)
+ return (*ic->methods->mb_lookup_string) (ic, ev, buffer, nbytes,
+ keysym, status);
+ return XLookupNone;
+}
+
+int
+XwcLookupString(ic, ev, buffer, nchars, keysym, status)
+ XIC ic;
+ register XKeyEvent *ev;
+ wchar_t *buffer;
+ int nchars;
+ KeySym *keysym;
+ Status *status;
+{
+ if (ic->core.im)
+ return (*ic->methods->wc_lookup_string) (ic, ev, buffer, nchars,
+ keysym, status);
+ return XLookupNone;
+}
diff --git a/src/xlibi18n/IMWrap.c b/src/xlibi18n/IMWrap.c
new file mode 100644
index 00000000..fc8e6426
--- /dev/null
+++ b/src/xlibi18n/IMWrap.c
@@ -0,0 +1,218 @@
+/*
+ * $Xorg: IMWrap.c,v 1.4 2001/02/09 02:03:33 xorgcvs Exp $
+ */
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993, 1994 by the Sony Corporation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 names of Open Software Foundation and
+ * Sony Corporation not be used in advertising or publicity pertaining to
+ * distribution of the software without specific, written prior permission.
+ * Open Software Foundation and Sony Corporation make no
+ * representations about the suitability of this software for any purpose.
+ * It is provided "as is" without express or implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION AND SONY CORPORATION DISCLAIM ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL OPEN
+ * SOFTWARE FOUNDATIONN OR SONY CORPORATION 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.
+ *
+ * M. Collins OSF
+ * Makoto Wakamatsu Sony Corporation
+ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+/*
+ * Compile the resource name. (resource_name ---> xrm_name)
+ */
+void
+_XIMCompileResourceList(res, num_res)
+ register XIMResourceList res;
+ unsigned int num_res;
+{
+ register unsigned int count;
+
+ for (count = 0; count < num_res; res++, count++) {
+ res->xrm_name = XrmStringToQuark(res->resource_name);
+ }
+}
+
+void
+_XCopyToArg(src, dst, size)
+ XPointer src;
+ XPointer *dst;
+ register unsigned int size;
+{
+ if (!*dst) {
+ union {
+ long longval;
+#ifdef LONG64
+ int intval;
+#endif
+ short shortval;
+ char charval;
+ char* charptr;
+ XPointer ptr;
+ } u;
+ if (size <= sizeof(XPointer)) {
+ memcpy((char *)&u, (char *)src, (int)size);
+ if (size == sizeof(long)) *dst = (XPointer)u.longval;
+#ifdef LONG64
+ else if (size == sizeof(int)) *dst = (XPointer)u.intval;
+#endif
+ else if (size == sizeof(short)) *dst = (XPointer)(long)u.shortval;
+ else if (size == sizeof(char)) *dst = (XPointer)(long)u.charval;
+ else if (size == sizeof(char*)) *dst = (XPointer)u.charptr;
+ else if (size == sizeof(XPointer)) *dst = (XPointer)u.ptr;
+ else memcpy( (char*)dst, (char*)src, (int)size );
+ } else {
+ memcpy( (char*)dst, (char*)src, (int)size );
+ }
+ } else {
+ memcpy( (char*)*dst, (char*)src, (int)size );
+ }
+}
+
+/*
+ * Connects to an input method matching current locale specification, creates
+ * a XIM object and return a pointer the newly created XIM back to the caller.
+ */
+
+XIM
+XOpenIM( display, rdb, res_name, res_class )
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+{
+ XLCd lcd = _XOpenLC( (char *)NULL );
+
+ if( !lcd )
+ return( (XIM)NULL );
+ return (*lcd->methods->open_im) (lcd, display, rdb, res_name, res_class);
+}
+
+/*
+ * Close the connection to the input manager, and free the XIM structure
+ */
+Status
+XCloseIM(im)
+ XIM im;
+{
+ Status s;
+ XIC ic;
+ XLCd lcd = im->core.lcd;
+
+ s = (im->methods->close) (im);
+ for (ic = im->core.ic_chain; ic; ic = ic->core.next)
+ ic->core.im = (XIM)NULL;
+ Xfree ((char *) im);
+ _XCloseLC (lcd);
+ return (s);
+}
+
+/*
+ * Return the Display associated with the input method.
+ */
+Display *
+XDisplayOfIM(im)
+ XIM im;
+{
+ return im->core.display;
+}
+
+/*
+ * Return the Locale associated with the input method.
+ */
+char *
+XLocaleOfIM(im)
+ XIM im;
+{
+ return im->core.lcd->core->name;
+}
+
+/*
+ * Register to a input method instantiation callback to prepare the
+ * on-demand input method instantiation.
+ */
+Bool
+XRegisterIMInstantiateCallback( display, rdb, res_name, res_class, callback,
+ client_data)
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+ XIMProc callback;
+ XPointer *client_data;
+{
+ XLCd lcd = _XOpenLC( (char *)NULL );
+
+ if( !lcd )
+ return( False );
+ return( (*lcd->methods->register_callback)( lcd, display, rdb, res_name,
+ res_class, callback,
+ client_data ) );
+}
+
+/*
+ * Unregister to a input method instantiation callback.
+ */
+Bool
+XUnregisterIMInstantiateCallback( display, rdb, res_name, res_class, callback,
+ client_data )
+ Display *display;
+ XrmDatabase rdb;
+ char *res_name;
+ char *res_class;
+ XIMProc callback;
+ XPointer *client_data;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if( !lcd )
+ return( False );
+ if( lcd->methods->unregister_callback == NULL )
+ return( False );
+ return( (*lcd->methods->unregister_callback)( lcd, display, rdb, res_name,
+ res_class, callback,
+ client_data ) );
+}
+
diff --git a/src/xlibi18n/XDefaultIMIF.c b/src/xlibi18n/XDefaultIMIF.c
new file mode 100644
index 00000000..e31c207b
--- /dev/null
+++ b/src/xlibi18n/XDefaultIMIF.c
@@ -0,0 +1,501 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: The above copyright notice and this
+permission notice shall be included in all copies or substantial
+portions of the Software.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without prior
+written authorization from The Open Group and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+
+#include <stdio.h>
+#define NEED_EVENTS
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcGeneric.h"
+
+#ifndef MAXINT
+#define MAXINT (~((unsigned int)1 << (8 * sizeof(int)) - 1))
+#endif /* !MAXINT */
+
+typedef struct _StaticXIM *StaticXIM;
+
+typedef struct _XIMStaticXIMRec {
+ /* for CT => MB,WC converter */
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+} XIMStaticXIMRec;
+
+typedef enum {
+ CREATE_IC = 1,
+ SET_ICVAL = 2,
+ GET_ICVAL = 3
+} XICOp_t;
+
+typedef struct _StaticXIM {
+ XIMMethods methods;
+ XIMCoreRec core;
+ XIMStaticXIMRec *private;
+} StaticXIMRec;
+
+static Status _CloseIM(
+#if NeedFunctionPrototypes
+ XIM
+#endif
+);
+
+static char *_SetIMValues(
+#if NeedFunctionPrototypes
+ XIM, XIMArg *
+#endif
+);
+
+static char *_GetIMValues(
+#if NeedFunctionPrototypes
+ XIM, XIMArg*
+#endif
+);
+
+static XIC _CreateIC(
+#if NeedFunctionPrototypes
+ XIM, XIMArg*
+#endif
+);
+
+static _Xconst XIMMethodsRec local_im_methods = {
+ _CloseIM, /* close */
+ _SetIMValues, /* set_values */
+ _GetIMValues, /* get_values */
+ _CreateIC, /* create_ic */
+ NULL, /* ctstombs */
+ NULL /* ctstowcs */
+};
+
+static void _DestroyIC(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+);
+static void _SetFocus(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+);
+static void _UnsetFocus(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+);
+static char* _SetICValues(
+#if NeedFunctionPrototypes
+ XIC, XIMArg *
+#endif
+);
+static char* _GetICValues(
+#if NeedFunctionPrototypes
+ XIC, XIMArg *
+#endif
+);
+static char *_MbReset(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+);
+static wchar_t *_WcReset(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+);
+static int _MbLookupString(
+#if NeedFunctionPrototypes
+ XIC, XKeyEvent *, char *, int, KeySym *, Status *
+#endif
+);
+static int _WcLookupString(
+#if NeedFunctionPrototypes
+ XIC, XKeyEvent *, wchar_t *, int, KeySym *, Status *
+#endif
+);
+
+static _Xconst XICMethodsRec local_ic_methods = {
+ _DestroyIC, /* destroy */
+ _SetFocus, /* set_focus */
+ _UnsetFocus, /* unset_focus */
+ _SetICValues, /* set_values */
+ _GetICValues, /* get_values */
+ _MbReset, /* mb_reset */
+ _WcReset, /* wc_reset */
+ _MbLookupString, /* mb_lookup_string */
+ _WcLookupString, /* wc_lookup_string */
+};
+
+XIM
+_XDefaultOpenIM(lcd, dpy, rdb, res_name, res_class)
+XLCd lcd;
+Display *dpy;
+XrmDatabase rdb;
+char *res_name, *res_class;
+{
+ FILE *fp;
+ char *name;
+ StaticXIM im;
+ XIMStaticXIMRec *local_impart;
+ XlcConv ctom_conv, ctow_conv;
+ int i;
+ char *mod;
+ char buf[BUFSIZ];
+
+ if (!(ctom_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNMultiByte))) {
+ return((XIM)NULL);
+ }
+
+ if (!(ctow_conv = _XlcOpenConverter(lcd,
+ XlcNCompoundText, lcd, XlcNWideChar))) {
+ return((XIM)NULL);
+ }
+
+ if ((im = (StaticXIM)Xmalloc(sizeof(StaticXIMRec))) == (StaticXIM)NULL) {
+ return((XIM)NULL);
+ }
+ if ((local_impart = (XIMStaticXIMRec*)Xmalloc(sizeof(XIMStaticXIMRec)))
+ == (XIMStaticXIMRec *)NULL) {
+ Xfree(im);
+ return((XIM)NULL);
+ }
+ memset(im, 0, sizeof(StaticXIMRec));
+ memset(local_impart, 0, sizeof(XIMStaticXIMRec));
+
+ buf[0] = '\0';
+ i = 0;
+ if ((lcd->core->modifiers) && (*lcd->core->modifiers)) {
+#define MODIFIER "@im="
+ mod = strstr(lcd->core->modifiers, MODIFIER);
+ if (mod) {
+ mod += strlen(MODIFIER);
+ while (*mod && *mod != '@' && i < BUFSIZ - 1) {
+ buf[i++] = *mod++;
+ }
+ buf[i] = '\0';
+ }
+ }
+#undef MODIFIER
+ if ((im->core.im_name = Xmalloc(i+1)) == NULL)
+ goto Error2;
+ strcpy(im->core.im_name, buf);
+
+ im->private = local_impart;
+ im->methods = (XIMMethods)&local_im_methods;
+ im->core.lcd = lcd;
+ im->core.ic_chain = (XIC)NULL;
+ im->core.display = dpy;
+ im->core.rdb = rdb;
+ im->core.res_name = NULL;
+ im->core.res_class = NULL;
+
+ local_impart->ctom_conv = ctom_conv;
+ local_impart->ctow_conv = ctow_conv;
+
+ if ((res_name != NULL) && (*res_name != '\0')){
+ im->core.res_name = (char *)Xmalloc(strlen(res_name)+1);
+ strcpy(im->core.res_name,res_name);
+ }
+ if ((res_class != NULL) && (*res_class != '\0')){
+ im->core.res_class = (char *)Xmalloc(strlen(res_class)+1);
+ strcpy(im->core.res_class,res_class);
+ }
+
+ return (XIM)im;
+Error1 :
+ if(im->core.im_name)
+ Xfree(im->core.im_name);
+Error2 :
+ Xfree(im->private);
+ Xfree(im->core.im_name);
+ Xfree(im);
+ _XlcCloseConverter(ctom_conv);
+ _XlcCloseConverter(ctow_conv);
+ return(NULL);
+}
+
+static Status
+_CloseIM(xim)
+XIM xim;
+{
+ StaticXIM im = (StaticXIM)xim;
+ _XlcCloseConverter(im->private->ctom_conv);
+ _XlcCloseConverter(im->private->ctow_conv);
+ XFree(im->private);
+ XFree(im->core.im_name);
+ if (im->core.res_name) XFree(im->core.res_name);
+ if (im->core.res_class) XFree(im->core.res_class);
+ return 1; /*bugID 4163122*/
+}
+
+static char *
+_SetIMValues(xim, arg)
+XIM xim;
+XIMArg *arg;
+{
+ return(arg->name); /* evil */
+}
+
+static char *
+_GetIMValues(xim, values)
+XIM xim;
+XIMArg *values;
+{
+ XIMArg *p;
+ XIMStyles **value;
+ XIMStyles *styles;
+ int i;
+ XIMStyles *p_style;
+
+ for (p = values; p->name != NULL; p++) {
+ if (strcmp(p->name, XNQueryInputStyle) == 0) {
+ styles = (XIMStyles *)Xmalloc(sizeof(XIMStyles));
+ *(XIMStyles **)p->value = styles;
+ styles->count_styles = 1;
+ styles->supported_styles =
+ (XIMStyle*)Xmalloc(styles->count_styles * sizeof(XIMStyle));
+ styles->supported_styles[0] = (XIMPreeditNone | XIMStatusNone);
+ } else {
+ break;
+ }
+ }
+ return (p->name);
+}
+
+static char*
+_SetICValueData(ic, values, mode)
+XIC ic;
+XIMArg *values;
+XICOp_t mode;
+{
+ XIMArg *p;
+ int i;
+ char *return_name = NULL;
+
+ for (p = values; p != NULL && p->name != NULL; p++) {
+ if(strcmp(p->name, XNInputStyle) == 0) {
+ if (mode == CREATE_IC)
+ ic->core.input_style = (XIMStyle)p->value;
+ } else if (strcmp(p->name, XNClientWindow) == 0) {
+ ic->core.client_window = (Window)p->value ;
+ } else if (strcmp(p->name, XNFocusWindow) == 0) {
+ ic->core.focus_window = (Window)p->value ;
+ } else if (strcmp(p->name, XNPreeditAttributes) == 0
+ || strcmp(p->name, XNStatusAttributes) == 0) {
+ return_name = _SetICValueData(ic, (XIMArg*)p->value, mode);
+ if (return_name) break;
+ } else {
+ return_name = p->name;
+ break;
+ }
+ }
+ return(return_name);
+}
+
+static char*
+_GetICValueData(ic, values, mode)
+XIC ic;
+XIMArg *values;
+XICOp_t mode;
+{
+ XIMArg *p;
+ char *return_name = NULL;
+
+ for (p = values; p->name != NULL; p++) {
+ if(strcmp(p->name, XNInputStyle) == 0) {
+ *((XIMStyle *)(p->value)) = ic->core.input_style;
+ } else if (strcmp(p->name, XNClientWindow) == 0) {
+ *((Window *)(p->value)) = ic->core.client_window;
+ } else if (strcmp(p->name, XNFocusWindow) == 0) {
+ *((Window *)(p->value)) = ic->core.focus_window;
+ } else if (strcmp(p->name, XNFilterEvents) == 0) {
+ *((unsigned long *)(p->value))= ic->core.filter_events;
+ } else if (strcmp(p->name, XNPreeditAttributes) == 0
+ || strcmp(p->name, XNStatusAttributes) == 0) {
+ return_name = _GetICValueData(ic, (XIMArg*)p->value, mode);
+ if (return_name) break;
+ } else {
+ return_name = p->name;
+ break;
+ }
+ }
+ return(return_name);
+}
+
+static XIC
+_CreateIC(im, arg)
+XIM im;
+XIMArg *arg;
+{
+ XIC ic;
+
+ if ((ic = (XIC)Xmalloc(sizeof(XICRec))) == (XIC)NULL) {
+ return ((XIC)NULL);
+ }
+ memset(ic, 0, sizeof(XICRec));
+
+ ic->methods = (XICMethods)&local_ic_methods;
+ ic->core.im = im;
+ ic->core.filter_events = KeyPressMask;
+
+ if (_SetICValueData(ic, arg, CREATE_IC) != NULL)
+ goto err_return;
+ if (!(ic->core.input_style))
+ goto err_return;
+
+ return (XIC)ic;
+err_return:
+ XFree(ic);
+ return ((XIC)NULL);
+}
+
+static void
+_DestroyIC(ic)
+XIC ic;
+{
+/*BugId4255571. This Xfree() should be removed because XDestroyIC() still need ic after invoking _DestroyIC() and there is a XFree(ic) at the end of XDestroyIC() already.
+ if(ic)
+ XFree(ic); */
+}
+
+static void
+_SetFocus(ic)
+XIC ic;
+{
+}
+
+static void
+_UnsetFocus(ic)
+XIC ic;
+{
+}
+
+static char*
+_SetICValues(ic, args)
+XIC ic;
+XIMArg *args;
+{
+ char *ret = NULL;
+ if (!ic) {
+ return (args->name);
+ }
+ ret = _SetICValueData(ic, args, SET_ICVAL);
+ return(ret);
+}
+
+static char*
+_GetICValues(ic, args)
+XIC ic;
+XIMArg *args;
+{
+ char *ret = NULL;
+ if (!ic) {
+ return (args->name);
+ }
+ ret = _GetICValueData(ic, args, GET_ICVAL);
+ return(ret);
+}
+
+static char *
+_MbReset(xic)
+XIC xic;
+{
+ return(NULL);
+}
+
+static wchar_t *
+_WcReset(xic)
+XIC xic;
+{
+ return(NULL);
+}
+
+static int
+_MbLookupString(xic, ev, buffer, bytes, keysym, status)
+XIC xic;
+XKeyEvent *ev;
+char * buffer;
+int bytes;
+KeySym *keysym;
+Status *status;
+{
+ XComposeStatus NotSupportedYet ;
+ int length;
+
+ length = XLookupString(ev, buffer, bytes, keysym, &NotSupportedYet);
+
+ if (keysym && *keysym == NoSymbol){
+ *status = XLookupNone;
+ } else if (length > 0) {
+ *status = XLookupBoth;
+ } else {
+ *status = XLookupKeySym;
+ }
+ return(length);
+}
+
+static int
+_WcLookupString(xic, ev, buffer, wlen, keysym, status)
+XIC xic;
+XKeyEvent *ev;
+wchar_t * buffer;
+int wlen;
+KeySym *keysym;
+Status *status;
+{
+ XComposeStatus NotSupportedYet ;
+ int length;
+ /* In single-byte, mb_len = wc_len */
+ char *mb_buf = (char *)Xmalloc(wlen);
+
+ length = XLookupString(ev, mb_buf, wlen, keysym, &NotSupportedYet);
+
+ if (keysym && *keysym == NoSymbol){
+ *status = XLookupNone;
+ } else if (length > 0) {
+ *status = XLookupBoth;
+ } else {
+ *status = XLookupKeySym;
+ }
+ mbstowcs(buffer, mb_buf, length);
+ XFree(mb_buf);
+ return(length);
+}
diff --git a/src/xlibi18n/XDefaultOMIF.c b/src/xlibi18n/XDefaultOMIF.c
new file mode 100644
index 00000000..1bb09dac
--- /dev/null
+++ b/src/xlibi18n/XDefaultOMIF.c
@@ -0,0 +1,1372 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: The above copyright notice and this
+permission notice shall be included in all copies or substantial
+portions of the Software.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without prior
+written authorization from The Open Group and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include "XlcPublic.h"
+#include <X11/Xos.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+#define MAXFONTS 100
+
+#define XOM_GENERIC(om) (&((XOMGeneric) om)->gen)
+#define XOC_GENERIC(font_set) (&((XOCGeneric) font_set)->gen)
+
+#define DefineLocalBuf char local_buf[BUFSIZ]
+#define AllocLocalBuf(length) (length > BUFSIZ ? (char *)Xmalloc(length) : local_buf)
+#define FreeLocalBuf(ptr) if (ptr != local_buf) Xfree(ptr)
+
+typedef struct _FontDataRec {
+ char *name;
+} FontDataRec, *FontData;
+
+typedef struct _OMDataRec {
+ int font_data_count;
+ FontData font_data;
+} OMDataRec, *OMData;
+
+typedef struct _XOMGenericPart {
+ OMData data;
+} XOMGenericPart;
+
+typedef struct _XOMGenericRec {
+ XOMMethods methods;
+ XOMCoreRec core;
+ XOMGenericPart gen;
+} XOMGenericRec, *XOMGeneric;
+
+typedef struct _FontSetRec {
+ int id;
+ int font_data_count;
+ FontData font_data;
+ char *font_name;
+ XFontStruct *info;
+ XFontStruct *font;
+} FontSetRec, *FontSet;
+
+typedef struct _XOCGenericPart {
+ XlcConv wcs_to_cs;
+ FontSet font_set;
+} XOCGenericPart;
+
+typedef struct _XOCGenericRec {
+ XOCMethods methods;
+ XOCCoreRec core;
+ XOCGenericPart gen;
+} XOCGenericRec, *XOCGeneric;
+
+static Bool
+init_fontset(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen;
+ FontSet font_set;
+ OMData data;
+
+ data = XOM_GENERIC(oc->core.om)->data;
+
+ font_set = (FontSet) Xmalloc(sizeof(FontSetRec));
+ if (font_set == NULL)
+ return False;
+ bzero((char *) font_set, sizeof(FontSetRec));
+
+ gen = XOC_GENERIC(oc);
+ gen->font_set = font_set;
+
+ font_set->font_data_count = data->font_data_count;
+ font_set->font_data = data->font_data;
+
+ return True;
+}
+
+static char *
+get_prop_name(dpy, fs)
+ Display *dpy;
+ XFontStruct *fs;
+{
+ unsigned long fp;
+
+ if (XGetFontProperty(fs, XA_FONT, &fp))
+ return XGetAtomName(dpy, fp);
+
+ return (char *) NULL;
+}
+
+static FontData
+check_charset(font_set, font_name)
+ FontSet font_set;
+ char *font_name;
+{
+ FontData font_data;
+ char *last;
+ int count;
+ ssize_t length, name_len;
+
+ name_len = strlen(font_name);
+ last = font_name + name_len;
+
+ count = font_set->font_data_count;
+ font_data = font_set->font_data;
+
+ for ( ; count-- > 0; font_data++) {
+ length = strlen(font_data->name);
+
+ if (length > name_len)
+ return(NULL);
+
+ if (_XlcCompareISOLatin1(last - length, font_data->name) == 0)
+ return font_data;
+ }
+ return (FontData) NULL;
+}
+
+static int
+check_fontname(oc, name)
+XOC oc;
+char *name;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontData data;
+ FontSet font_set;
+ XFontStruct *fs_list;
+ char **fn_list, *fname, *prop_fname = NULL;
+ int list_num, i;
+ int list2_num;
+ char **fn2_list = NULL;
+ int found_num = 0;
+
+ fn_list = XListFonts(dpy, name, MAXFONTS, &list_num);
+ if (fn_list == NULL)
+ return found_num;
+
+ for (i = 0; i < list_num; i++) {
+ fname = fn_list[i];
+
+ font_set = gen->font_set;
+
+ if ((data = check_charset(font_set, fname)) == NULL) {
+ if ((fn2_list = XListFontsWithInfo(dpy, name, MAXFONTS,
+ &list2_num, &fs_list))
+ && (prop_fname = get_prop_name(dpy, fs_list))
+ && (data = check_charset(font_set, prop_fname)))
+ fname = prop_fname;
+ }
+ if (data) {
+ font_set->font_name = (char *) Xmalloc(strlen(fname) + 1);
+ if (font_set->font_name) {
+ strcpy(font_set->font_name, fname);
+ found_num++;
+ }
+ }
+ if (fn2_list) {
+ XFreeFontInfo(fn2_list, fs_list, list2_num);
+ fn2_list = NULL;
+ if (prop_fname) {
+ Xfree(prop_fname);
+ prop_fname = NULL;
+ }
+ }
+ if (found_num == 1)
+ break;
+ }
+ XFreeFontNames(fn_list);
+ return found_num;
+}
+
+static Bool
+load_font(oc)
+ XOC oc;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+
+ if (font_set->font_name == NULL)
+ return False;
+
+ if (font_set->font == NULL) {
+ font_set->font = XLoadQueryFont(dpy, font_set->font_name);
+ if (font_set->font == NULL)
+ return False;
+ }
+ return True;
+}
+
+static Bool
+load_font_info(oc)
+ XOC oc;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set = gen->font_set;
+ char **fn_list;
+ int fn_num;
+
+ if (font_set->font_name == NULL)
+ return False;
+
+ if (font_set->info == NULL) {
+ fn_list = XListFontsWithInfo(dpy, font_set->font_name, 1, &fn_num,
+ &font_set->info);
+ if (font_set->info == NULL)
+ return False;
+ if (fn_num > 0)
+ font_set->info->fid = XLoadFont(dpy, font_set->font_name);
+
+ if (fn_list) XFreeFontNames(fn_list);
+ }
+ return True;
+}
+
+static void
+set_fontset_extents(oc)
+ XOC oc;
+{
+ XRectangle *ink = &oc->core.font_set_extents.max_ink_extent;
+ XRectangle *logical = &oc->core.font_set_extents.max_logical_extent;
+ XFontStruct **font_list, *font;
+ XCharStruct overall;
+ int logical_ascent, logical_descent;
+
+ font_list = oc->core.font_info.font_struct_list;
+ font = *font_list++;
+ overall = font->max_bounds;
+ overall.lbearing = font->min_bounds.lbearing;
+ logical_ascent = font->ascent;
+ logical_descent = font->descent;
+
+ ink->x = overall.lbearing;
+ ink->y = -(overall.ascent);
+ ink->width = overall.rbearing - overall.lbearing;
+ ink->height = overall.ascent + overall.descent;
+
+ logical->x = 0;
+ logical->y = -(logical_ascent);
+ logical->width = overall.width;
+ logical->height = logical_ascent + logical_descent;
+}
+
+static Bool
+init_core_part(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ XFontStruct **font_struct_list;
+ char **font_name_list, *font_name_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ count = length = 0;
+
+ if (font_set->font_name != NULL) {
+ length += strlen(font_set->font_name) + 1;
+ count++;
+ }
+ if (count == 0)
+ return False;
+
+ font_struct_list = (XFontStruct **) Xmalloc(sizeof(XFontStruct *));
+ if (font_struct_list == NULL)
+ return False;
+
+ font_name_list = (char **) Xmalloc(sizeof(char *));
+ if (font_name_list == NULL)
+ goto err;
+
+ font_name_buf = (char *) Xmalloc(length);
+ if (font_name_buf == NULL)
+ goto err;
+
+ oc->core.font_info.num_font = 1;
+ oc->core.font_info.font_name_list = font_name_list;
+ oc->core.font_info.font_struct_list = font_struct_list;
+
+ font_set = gen->font_set;
+
+ if (font_set->font_name != NULL) {
+ font_set->id = 1;
+ if (font_set->font)
+ *font_struct_list++ = font_set->font;
+ else
+ *font_struct_list++ = font_set->info;
+ strcpy(font_name_buf, font_set->font_name);
+ Xfree(font_set->font_name);
+ *font_name_list++ = font_set->font_name = font_name_buf;
+ font_name_buf += strlen(font_name_buf) + 1;
+ }
+
+ set_fontset_extents(oc);
+
+ return True;
+
+err:
+ if (font_name_list)
+ Xfree(font_name_list);
+ Xfree(font_struct_list);
+
+ return False;
+}
+
+static char *
+get_font_name(oc, pattern)
+ XOC oc;
+ char *pattern;
+{
+ char **list, *name, *prop_name;
+ int count;
+ XFontStruct *fs;
+ Display *dpy = oc->core.om->core.display;
+
+ list = XListFonts(dpy, pattern, 1, &count);
+ if (list != NULL) {
+ name = (char *) Xmalloc(strlen(*list) + 1);
+ if (name)
+ strcpy(name, *list);
+
+ XFreeFontNames(list);
+ } else {
+ fs = XLoadQueryFont(dpy, pattern);
+ if (fs == NULL) return NULL;
+
+ prop_name = get_prop_name(dpy, fs);
+ if (prop_name == NULL) return NULL;
+
+ name = (char*) Xmalloc(strlen(prop_name) + 1);
+ if (name)
+ strcpy(name, prop_name);
+
+ XFreeFont(dpy, fs);
+ }
+ return name;
+}
+
+static int
+parse_fontname(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ FontData font_data;
+ char *pattern, *last, buf[BUFSIZ];
+ int font_data_count, found_num = 0;
+ ssize_t length;
+ int count, num_fields;
+ char *base_name, *font_name, **name_list, **cur_name_list;
+ char *charset_p;
+ Bool append_charset;
+ /*
+ append_charset flag should be set to True when the XLFD fontname
+ doesn't contain a chaset part.
+ */
+
+ name_list = _XParseBaseFontNameList(oc->core.base_name_list, &count);
+ if (name_list == NULL)
+ return -1;
+ cur_name_list = name_list;
+
+ while (count-- > 0) {
+ pattern = *cur_name_list++;
+ if (pattern == NULL || *pattern == '\0')
+ continue;
+
+ append_charset = False;
+
+ if (strchr(pattern, '*') == NULL &&
+ (font_name = get_font_name(oc, pattern))) {
+
+ font_set = gen->font_set;
+
+ font_data = check_charset(font_set, font_name);
+ if (font_data == NULL) {
+ Display *dpy = oc->core.om->core.display;
+ char **fn_list = NULL, *prop_fname = NULL;
+ int list_num;
+ XFontStruct *fs_list;
+ if ((fn_list = XListFontsWithInfo(dpy, font_name,
+ MAXFONTS,
+ &list_num, &fs_list))
+ && (prop_fname = get_prop_name(dpy, fs_list))
+ && (font_data = check_charset(font_set, prop_fname))) {
+ if (fn_list) {
+ XFreeFontInfo(fn_list, fs_list, list_num);
+ fn_list = NULL;
+ }
+ font_name = prop_fname;
+ }
+ }
+ if (font_data == NULL)
+ continue;
+
+ font_set->font_name = (char *) Xmalloc(strlen(font_name) + 1);
+ if (font_set->font_name == NULL) {
+ Xfree(font_name);
+ goto err;
+ }
+ strcpy(font_set->font_name, font_name);
+ Xfree(font_name);
+ found_num++;
+ goto found;
+ }
+/*
+1266793
+Limit the length of the string copy to prevent stack corruption.
+ strcpy(buf, pattern);
+*/
+ strncpy(buf, pattern, BUFSIZ);
+ buf[BUFSIZ-1] = '\0';
+ length = strlen(buf);
+ last = buf + length - 1;
+
+ for (num_fields = 0, base_name = buf; *base_name != '\0'; base_name++)
+ if (*base_name == '-') num_fields++;
+ if (strchr(pattern, '*') == NULL) {
+ if (num_fields == 12) {
+ append_charset = True;
+ *++last = '-';
+ last++;
+ } else
+ continue;
+ } else {
+ if (num_fields == 13 || num_fields == 14) {
+ /*
+ * There are 14 fields in an XLFD name -- make certain the
+ * charset (& encoding) is placed in the correct field.
+ */
+ append_charset = True;
+ last = strrchr (buf, '-');
+ if (num_fields == 14) {
+ *last = '\0';
+ last = strrchr (buf, '-');
+ }
+ last++;
+ } else if (*last == '*') {
+ append_charset = True;
+ if (length > 3 && *(last-3) == '-' && *(last-2) == '*'
+ && *(last-1) == '-') {
+ last -= 2;
+ }
+ *++last = '-';
+ last++;
+ } else {
+ last = strrchr (buf, '-');
+ charset_p = last;
+ charset_p = strrchr (buf, '-');
+ while (*(--charset_p) != '-');
+ charset_p++;
+ }
+ }
+
+ font_set = gen->font_set;
+
+ font_data = font_set->font_data;
+ font_data_count = font_set->font_data_count;
+ for ( ; font_data_count-- > 0; font_data++) {
+ if (append_charset)
+ {
+/*
+1266793
+Limit the length of the string copy to prevent stack corruption.
+ strcpy(last, font_data->name);
+*/
+ strncpy(last, font_data->name, BUFSIZ - length);
+ buf[BUFSIZ-1] = '\0';
+ }
+ else {
+ if (_XlcCompareISOLatin1(charset_p,
+ font_data->name)) {
+ continue;
+ }
+ }
+ if ((font_set->font_name = get_font_name(oc, buf)))
+ break;
+ }
+ if (font_set->font_name != NULL) {
+ found_num++;
+ goto found;
+ }
+ }
+ found:
+ base_name = (char *) Xmalloc(strlen(oc->core.base_name_list) + 1);
+ if (base_name == NULL)
+ goto err;
+
+ strcpy(base_name, oc->core.base_name_list);
+ oc->core.base_name_list = base_name;
+
+ XFreeStringList(name_list);
+
+ return found_num;
+err:
+ XFreeStringList(name_list);
+
+ return -1;
+}
+
+static Bool
+set_missing_list(oc)
+ XOC oc;
+{
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ FontSet font_set;
+ char **charset_list, *charset_buf;
+ int count, length;
+
+ font_set = gen->font_set;
+ count = length = 0;
+
+ if (!font_set->info && !font_set->font) {
+ length += strlen(font_set->font_data->name) + 1;
+ count++;
+ }
+
+ if (count == 0)
+ return True;
+
+ charset_list = (char **) Xmalloc(sizeof(char *));
+ if (charset_list == NULL)
+ return False;
+
+ charset_buf = (char *) Xmalloc(length);
+ if (charset_buf == NULL) {
+ Xfree(charset_list);
+ return False;
+ }
+
+ oc->core.missing_list.charset_list = charset_list;
+
+ font_set = gen->font_set;
+
+ if (!font_set->info && !font_set->font) {
+ strcpy(charset_buf, font_set->font_data->name);
+ *charset_list++ = charset_buf;
+ charset_buf += strlen(charset_buf) + 1;
+ }
+ return True;
+}
+
+static Bool
+create_fontset(oc)
+ XOC oc;
+{
+ XOMGenericPart *gen = XOM_GENERIC(oc->core.om);
+ int found_num;
+
+ if (init_fontset(oc) == False)
+ return False;
+
+ found_num = parse_fontname(oc);
+ if (found_num <= 0) {
+ if (found_num == 0)
+ set_missing_list(oc);
+ return False;
+ }
+
+ if (load_font(oc) == False)
+ return False;
+
+ if (init_core_part(oc) == False)
+ return False;
+
+ if (set_missing_list(oc) == False)
+ return False;
+
+ return True;
+}
+
+static void
+destroy_oc(oc)
+ XOC oc;
+{
+ Display *dpy = oc->core.om->core.display;
+ XOCGenericPart *gen = XOC_GENERIC(oc);
+ XFontStruct **font_list, *font;
+
+ if (gen->font_set)
+ Xfree(gen->font_set);
+
+ if (oc->core.base_name_list)
+ Xfree(oc->core.base_name_list);
+
+ if (oc->core.font_info.font_name_list)
+ XFreeStringList(oc->core.font_info.font_name_list);
+
+ if (font_list = oc->core.font_info.font_struct_list) {
+ if (font = *font_list) {
+ if (font->fid)
+ XFreeFont(dpy, font);
+ else
+ XFreeFontInfo(NULL, font, 1);
+ }
+ Xfree(oc->core.font_info.font_struct_list);
+ }
+
+ if (oc->core.missing_list.charset_list)
+ XFreeStringList(oc->core.missing_list.charset_list);
+
+#ifdef notdef
+ if (oc->core.res_name)
+ Xfree(oc->core.res_name);
+ if (oc->core.res_class)
+ Xfree(oc->core.res_class);
+#endif
+
+ Xfree(oc);
+}
+
+static char *
+set_oc_values(oc, args, num_args)
+ XOC oc;
+ XlcArgList args;
+ int num_args;
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_oc_values(oc, args, num_args)
+ XOC oc;
+ XlcArgList args;
+ int num_args;
+{
+ if (oc->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) oc, oc->core.resources,
+ oc->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static Bool
+wcs_to_mbs(oc, to, from, length)
+ XOC oc;
+ char *to;
+ wchar_t *from;
+ int length;
+{
+ XlcConv conv = XOC_GENERIC(oc)->wcs_to_cs;
+ XLCd lcd;
+ int ret, to_left = length;
+
+ if (conv == NULL) {
+ lcd = oc->core.om->core.lcd;
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return False;
+ XOC_GENERIC(oc)->wcs_to_cs = conv;
+ } else
+ _XlcResetConverter(conv);
+
+ ret = _XlcConvert(conv, (XPointer *) &from, &length, (XPointer *) &to,
+ &to_left, NULL, 0);
+ if (ret != 0 || length > 0)
+ return False;
+
+ return True;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XmbDefaultTextEscapement(XOC oc, _Xconst char *text, int length)
+#else
+_XmbDefaultTextEscapement(oc, text, length)
+ XOC oc;
+ char *text;
+ int length;
+#endif
+{
+ return XTextWidth(*oc->core.font_info.font_struct_list, text, length);
+}
+
+static int
+#if NeedFunctionPrototypes
+_XwcDefaultTextEscapement(XOC oc, _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultTextEscapement(oc, text, length)
+ XOC oc;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextEscapement(oc, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XmbDefaultTextExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XmbDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ int direction, logical_ascent, logical_descent;
+ XCharStruct overall;
+
+ XTextExtents(*oc->core.font_info.font_struct_list, text, length, &direction,
+ &logical_ascent, &logical_descent, &overall);
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(logical_ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = logical_ascent + logical_descent;
+ }
+
+ return overall.width;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XwcDefaultTextExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *overall_ink, XRectangle *overall_logical)
+#else
+_XwcDefaultTextExtents(oc, text, length, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextExtents(oc, buf, length, overall_ink, overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XmbDefaultTextPerCharExtents(XOC oc, _Xconst char *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XmbDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink, overall_logical)
+ XOC oc;
+ char *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+ XCharStruct *def, *cs, overall;
+ Bool first = True;
+
+ if (buf_size < length)
+ return 0;
+
+ bzero((char *) &overall, sizeof(XCharStruct));
+ *num_chars = 0;
+
+ CI_GET_DEFAULT_INFO_1D(font, def)
+
+ while (length-- > 0) {
+ CI_GET_CHAR_INFO_1D(font, *text, def, cs)
+ text++;
+ if (cs == NULL)
+ continue;
+
+ ink_buf->x = overall.width + cs->lbearing;
+ ink_buf->y = -(cs->ascent);
+ ink_buf->width = cs->rbearing - cs->lbearing;
+ ink_buf->height = cs->ascent + cs->descent;
+ ink_buf++;
+
+ logical_buf->x = overall.width;
+ logical_buf->y = -(font->ascent);
+ logical_buf->width = cs->width;
+ logical_buf->height = font->ascent + font->descent;
+ logical_buf++;
+
+ if (first) {
+ overall = *cs;
+ first = False;
+ } else {
+ overall.ascent = max(overall.ascent, cs->ascent);
+ overall.descent = max(overall.descent, cs->descent);
+ overall.lbearing = min(overall.lbearing, overall.width +
+ cs->lbearing);
+ overall.rbearing = max(overall.rbearing, overall.width +
+ cs->rbearing);
+ overall.width += cs->width;
+ }
+ (*num_chars)++;
+ }
+
+ if (overall_ink) {
+ overall_ink->x = overall.lbearing;
+ overall_ink->y = -(overall.ascent);
+ overall_ink->width = overall.rbearing - overall.lbearing;
+ overall_ink->height = overall.ascent + overall.descent;
+ }
+
+ if (overall_logical) {
+ overall_logical->x = 0;
+ overall_logical->y = -(font->ascent);
+ overall_logical->width = overall.width;
+ overall_logical->height = font->ascent + font->descent;
+ }
+
+ return 1;
+}
+
+static Status
+#if NeedFunctionPrototypes
+_XwcDefaultTextPerCharExtents(XOC oc, _Xconst wchar_t *text, int length,
+ XRectangle *ink_buf, XRectangle *logical_buf,
+ int buf_size, int *num_chars,
+ XRectangle *overall_ink,
+ XRectangle *overall_logical)
+#else
+_XwcDefaultTextPerCharExtents(oc, text, length, ink_buf, logical_buf, buf_size,
+ num_chars, overall_ink, overall_logical)
+ XOC oc;
+ wchar_t *text;
+ int length;
+ XRectangle *ink_buf;
+ XRectangle *logical_buf;
+ int buf_size;
+ int *num_chars;
+ XRectangle *overall_ink;
+ XRectangle *overall_logical;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ Status ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultTextPerCharExtents(oc, buf, length, ink_buf, logical_buf,
+ buf_size, num_chars, overall_ink,
+ overall_logical);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static int
+#if NeedFunctionPrototypes
+_XmbDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst char *text, int length)
+#else
+_XmbDefaultDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ XFontStruct *font = *oc->core.font_info.font_struct_list;
+
+ XSetFont(dpy, gc, font->fid);
+ XDrawString(dpy, d, gc, x, y, text, length);
+
+ return XTextWidth(font, text, length);
+}
+
+static int
+#if NeedFunctionPrototypes
+_XwcDefaultDrawString(Display *dpy, Drawable d, XOC oc, GC gc, int x, int y,
+ _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultDrawString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+ int ret;
+
+ if (buf == NULL)
+ return 0;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ ret = _XmbDefaultDrawString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+
+ return ret;
+}
+
+static void
+#if NeedFunctionPrototypes
+_XmbDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst char *text, int length)
+#else
+_XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ char *text;
+ int length;
+#endif
+{
+ XSetFont(dpy, gc, (*oc->core.font_info.font_struct_list)->fid);
+ XDrawImageString(dpy, d, gc, x, y, text, length);
+}
+
+static void
+#if NeedFunctionPrototypes
+_XwcDefaultDrawImageString(Display *dpy, Drawable d, XOC oc, GC gc, int x,
+ int y, _Xconst wchar_t *text, int length)
+#else
+_XwcDefaultDrawImageString(dpy, d, oc, gc, x, y, text, length)
+ Display *dpy;
+ Drawable d;
+ XOC oc;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int length;
+#endif
+{
+ DefineLocalBuf;
+ char *buf = AllocLocalBuf(length);
+
+ if (buf == NULL)
+ return;
+
+ if (wcs_to_mbs(oc, buf, text, length) == False)
+ goto err;
+
+ _XmbDefaultDrawImageString(dpy, d, oc, gc, x, y, buf, length);
+
+err:
+ FreeLocalBuf(buf);
+}
+
+static _Xconst XOCMethodsRec oc_default_methods = {
+ destroy_oc,
+ set_oc_values,
+ get_oc_values,
+ _XmbDefaultTextEscapement,
+ _XmbDefaultTextExtents,
+ _XmbDefaultTextPerCharExtents,
+ _XmbDefaultDrawString,
+ _XmbDefaultDrawImageString,
+ _XwcDefaultTextEscapement,
+ _XwcDefaultTextExtents,
+ _XwcDefaultTextPerCharExtents,
+ _XwcDefaultDrawString,
+ _XwcDefaultDrawImageString
+};
+
+static XlcResource oc_resources[] = {
+ { XNBaseFontName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.base_name_list), XlcCreateMask | XlcGetMask },
+ { XNOMAutomatic, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOCRec, core.om_automatic), XlcGetMask },
+ { XNMissingCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOCRec, core.missing_list), XlcGetMask },
+ { XNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.default_string), XlcGetMask },
+ { XNOrientation, NULLQUARK, sizeof(XOrientation),
+ XOffsetOf(XOCRec, core.orientation), XlcSetMask | XlcGetMask },
+ { XNResourceName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_name), XlcSetMask | XlcGetMask },
+ { XNResourceClass, NULLQUARK, sizeof(char *),
+ XOffsetOf(XOCRec, core.res_class), XlcSetMask | XlcGetMask },
+ { XNFontInfo, NULLQUARK, sizeof(XOMFontInfo),
+ XOffsetOf(XOCRec, core.font_info), XlcGetMask }
+};
+
+static XOC
+create_oc(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ XOC oc;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+
+ oc = (XOC) Xmalloc(sizeof(XOCGenericRec));
+ if (oc == NULL)
+ return (XOC) NULL;
+ bzero((char *) oc, sizeof(XOCGenericRec));
+
+ oc->core.om = om;
+
+ if (oc_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(oc_resources, XlcNumber(oc_resources));
+
+ if (_XlcSetValues((XPointer) oc, oc_resources, XlcNumber(oc_resources),
+ args, num_args, XlcCreateMask | XlcDefaultMask))
+ goto err;
+
+ if (oc->core.base_name_list == NULL)
+ goto err;
+
+ oc->core.resources = oc_resources;
+ oc->core.num_resources = XlcNumber(oc_resources);
+
+ if (create_fontset(oc) == False)
+ goto err;
+
+ oc->methods = (XOCMethods)&oc_default_methods;
+
+ return oc;
+
+err:
+ destroy_oc(oc);
+
+ return (XOC) NULL;
+}
+
+static Status
+close_om(om)
+ XOM om;
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ FontData font_data;
+ int count;
+
+ if (data = gen->data) {
+ if (data->font_data) {
+ for (font_data = data->font_data, count = data->font_data_count;
+ count-- > 0 ; font_data++) {
+ if (font_data->name)
+ Xfree(font_data->name);
+ }
+ Xfree(data->font_data);
+ }
+ Xfree(gen->data);
+ }
+
+ if (om->core.res_name)
+ Xfree(om->core.res_name);
+ if (om->core.res_class)
+ Xfree(om->core.res_class);
+ if (om->core.required_charset.charset_list)
+ XFreeStringList(om->core.required_charset.charset_list);
+ else
+ Xfree((char*)om->core.required_charset.charset_list);
+ if (om->core.orientation_list.orientation)
+ Xfree(om->core.orientation_list.orientation);
+
+ Xfree(om);
+
+ return 1;
+}
+
+static char *
+set_om_values(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcSetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcSetMask);
+}
+
+static char *
+get_om_values(om, args, num_args)
+ XOM om;
+ XlcArgList args;
+ int num_args;
+{
+ if (om->core.resources == NULL)
+ return NULL;
+
+ return _XlcGetValues((XPointer) om, om->core.resources,
+ om->core.num_resources, args, num_args, XlcGetMask);
+}
+
+static _Xconst XOMMethodsRec methods = {
+ close_om,
+ set_om_values,
+ get_om_values,
+ create_oc
+};
+
+static XlcResource om_resources[] = {
+ { XNRequiredCharSet, NULLQUARK, sizeof(XOMCharSetList),
+ XOffsetOf(XOMRec, core.required_charset), XlcGetMask },
+ { XNQueryOrientation, NULLQUARK, sizeof(XOMOrientation),
+ XOffsetOf(XOMRec, core.orientation_list), XlcGetMask },
+ { XNDirectionalDependentDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.directional_dependent), XlcGetMask },
+ { XNContextualDrawing, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XOMRec, core.contextual_drawing), XlcGetMask }
+};
+
+static OMData
+add_data(om)
+ XOM om;
+{
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData new;
+
+ new = (OMData) Xmalloc(sizeof(OMDataRec));
+
+ if (new == NULL)
+ return NULL;
+
+ gen->data = new;
+
+ bzero((char *) new, sizeof(OMDataRec));
+
+ return new;
+}
+
+static _Xconst char *supported_charset_list[] = {
+ "ISO8859-1",
+/* fix for bug4332979 */
+ "adobe-fontspecific",
+/* fix for bug4237353: "JISX0201.1976-0" entry should be removed from
+ supported_charset_list because it is not a supported_charset for C locale
+ "JISX0201.1976-0", */
+ "SUNOLCURSOR-1",
+ "SUNOLGLYPH-1"
+};
+
+static Bool
+init_om(om)
+ XOM om;
+{
+ XLCd lcd = om->core.lcd;
+ XOMGenericPart *gen = XOM_GENERIC(om);
+ OMData data;
+ FontData font_data;
+ char **required_list;
+ XOrientation *orientation;
+ char **value, buf[BUFSIZ], *bufptr;
+ int count, length = 0;
+
+ value = (char**)supported_charset_list;
+ count = XlcNumber(supported_charset_list);
+
+ data = add_data(om);
+ if (data == NULL)
+ return False;
+
+ font_data = (FontData) Xmalloc(sizeof(FontDataRec) * count);
+ if (font_data == NULL)
+ return False;
+ bzero((char *) font_data, sizeof(FontDataRec) * count);
+ data->font_data = font_data;
+ data->font_data_count = count;
+
+ for ( ; count-- > 0; font_data++) {
+/*
+1266793
+This one is fine. *value points to one of the local strings in
+supported_charset_list[].
+*/
+ strcpy(buf, *value++);
+ font_data->name = (char *) Xmalloc(strlen(buf) + 1);
+ if (font_data->name == NULL)
+ return False;
+ strcpy(font_data->name, buf);
+ }
+
+ length += strlen(data->font_data->name) + 1;
+
+ /* required charset list */
+ required_list = (char **) Xmalloc(sizeof(char *));
+ if (required_list == NULL)
+ return False;
+
+ bufptr = (char *) Xmalloc(length);
+ if (bufptr == NULL) {
+ Xfree(required_list);
+ return False;
+ }
+
+ om->core.required_charset.charset_list = required_list;
+ om->core.required_charset.charset_count = 1; /* always 1 */
+
+ data = gen->data;
+
+ strcpy(bufptr, data->font_data->name);
+ *required_list++ = bufptr;
+ bufptr += strlen(bufptr) + 1;
+
+ /* orientation list */
+ orientation = (XOrientation *) Xmalloc(sizeof(XOrientation));
+ if (orientation == NULL)
+ return False;
+
+ *orientation = XOMOrientation_LTR_TTB;
+ om->core.orientation_list.orientation = orientation;
+ om->core.orientation_list.num_orientation = 1;
+
+ /* directional dependent drawing */
+ om->core.directional_dependent = False;
+
+ /* contexual drawing */
+ om->core.contextual_drawing = False;
+
+ /* context dependent */
+ om->core.context_dependent = False;
+
+ return True;
+}
+
+XOM
+#if NeedFunctionPrototypes
+_XDefaultOpenOM(XLCd lcd, Display *dpy, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+#else
+_XDefaultOpenOM(lcd, dpy, rdb, res_name, res_class)
+XLCd lcd;
+Display *dpy;
+XrmDatabase rdb;
+char *res_name;
+char *res_class;
+#endif
+{
+ XOM om;
+
+ om = (XOM) Xmalloc(sizeof(XOMGenericRec));
+ if (om == NULL)
+ return (XOM) NULL;
+ bzero((char *) om, sizeof(XOMGenericRec));
+
+ om->methods = (XOMMethods)&methods;
+ om->core.lcd = lcd;
+ om->core.display = dpy;
+ om->core.rdb = rdb;
+ if (res_name) {
+ om->core.res_name = (char *)Xmalloc(strlen(res_name) + 1);
+ if (om->core.res_name == NULL)
+ goto err;
+ strcpy(om->core.res_name, res_name);
+ }
+ if (res_class) {
+ om->core.res_class = (char *)Xmalloc(strlen(res_class) + 1);
+ if (om->core.res_class == NULL)
+ goto err;
+ strcpy(om->core.res_class, res_class);
+ }
+
+ if (om_resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(om_resources, XlcNumber(om_resources));
+
+ om->core.resources = om_resources;
+ om->core.num_resources = XlcNumber(om_resources);
+
+ if (init_om(om) == False)
+ goto err;
+
+ return om;
+err:
+ close_om(om);
+
+ return (XOM) NULL;
+}
diff --git a/src/xlibi18n/Xaixlcint.h b/src/xlibi18n/Xaixlcint.h
new file mode 100644
index 00000000..2e4f3f52
--- /dev/null
+++ b/src/xlibi18n/Xaixlcint.h
@@ -0,0 +1,54 @@
+/* $Xorg: Xaixlcint.h,v 1.3 2000/08/17 19:45:04 cpqbld Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+/************************************************************************/
+/* Xaixlcint.h */
+/*----------------------------------------------------------------------*/
+/* This file contains Xlcint.h extension for AIX. */
+/************************************************************************/
+#ifndef _Xaixlcint_h
+#define _Xaixlcint_h
+
+#include "Xlcint.h"
+#include <sys/lc_core.h>
+
+#define _LC_LDX 11
+#define _LC_LDX_R6 (_LC_LDX+1)
+#define _LC_VERSION_R5 5
+#define _LC_VERSION_R6 6
+
+typedef struct _LC_core_ldx_t {
+ _LC_object_t lc_object_header;
+ XLCd (*default_loader)();
+ Bool sticky;
+} _XlcCoreObjRec, *_XlcCoreObj;
+
+#if _LC_VERSION < 0x40000000
+#define __type_id type_id
+#define __magic magic
+#define __version version
+#endif
+
+#endif /*_Xaixlcint_h*/
diff --git a/src/xlibi18n/XimImSw.h b/src/xlibi18n/XimImSw.h
new file mode 100644
index 00000000..eac27843
--- /dev/null
+++ b/src/xlibi18n/XimImSw.h
@@ -0,0 +1,53 @@
+/* $Xorg: XimImSw.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMIMSW_H
+#define _XIMIMSW_H
+
+typedef struct {
+ Bool (*checkprocessing)(
+#if NeedNestedPrototypes
+ Xim im
+#endif
+ );
+ Bool (*im_open)(
+#if NeedNestedPrototypes
+ Xim im
+#endif
+ );
+ void (*im_free)(
+#if NeedNestedPrototypes
+ Xim im
+#endif
+ );
+} XimImsportSW;
+
+extern XimImsportSW _XimImSportRec[];
+
+#endif /* _XIMIMSW_H */
diff --git a/src/xlibi18n/XimProto.h b/src/xlibi18n/XimProto.h
new file mode 100644
index 00000000..fe6e5f69
--- /dev/null
+++ b/src/xlibi18n/XimProto.h
@@ -0,0 +1,227 @@
+/* $Xorg: XimProto.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+FUJITSU LIMITED makes no representations about the suitability of
+this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+EVENT SHALL FUJITSU LIMITED 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMPROTO_H
+#define _XIMPROTO_H
+
+/*
+ * Default Preconnection selection target
+ */
+#define XIM_SERVERS "XIM_SERVERS"
+#define XIM_LOCALES "LOCALES"
+#define XIM_TRANSPORT "TRANSPORT"
+
+/*
+ * categories in XIM_SERVERS
+ */
+#define XIM_SERVER_CATEGORY "@server="
+#define XIM_LOCAL_CATEGORY "@locale="
+#define XIM_TRANSPORT_CATEGORY "@transport="
+
+/*
+ * Xim implementation revision
+ */
+#define PROTOCOLMAJORVERSION 1
+#define PROTOCOLMINORVERSION 0
+
+/*
+ * Major Protocol number
+ */
+#define XIM_CONNECT 1
+#define XIM_CONNECT_REPLY 2
+#define XIM_DISCONNECT 3
+#define XIM_DISCONNECT_REPLY 4
+
+#define XIM_AUTH_REQUIRED 10
+#define XIM_AUTH_REPLY 11
+#define XIM_AUTH_NEXT 12
+#define XIM_AUTH_SETUP 13
+#define XIM_AUTH_NG 14
+
+#define XIM_ERROR 20
+
+#define XIM_OPEN 30
+#define XIM_OPEN_REPLY 31
+#define XIM_CLOSE 32
+#define XIM_CLOSE_REPLY 33
+#define XIM_REGISTER_TRIGGERKEYS 34
+#define XIM_TRIGGER_NOTIFY 35
+#define XIM_TRIGGER_NOTIFY_REPLY 36
+#define XIM_SET_EVENT_MASK 37
+#define XIM_ENCODING_NEGOTIATION 38
+#define XIM_ENCODING_NEGOTIATION_REPLY 39
+#define XIM_QUERY_EXTENSION 40
+#define XIM_QUERY_EXTENSION_REPLY 41
+#define XIM_SET_IM_VALUES 42
+#define XIM_SET_IM_VALUES_REPLY 43
+#define XIM_GET_IM_VALUES 44
+#define XIM_GET_IM_VALUES_REPLY 45
+
+#define XIM_CREATE_IC 50
+#define XIM_CREATE_IC_REPLY 51
+#define XIM_DESTROY_IC 52
+#define XIM_DESTROY_IC_REPLY 53
+#define XIM_SET_IC_VALUES 54
+#define XIM_SET_IC_VALUES_REPLY 55
+#define XIM_GET_IC_VALUES 56
+#define XIM_GET_IC_VALUES_REPLY 57
+#define XIM_SET_IC_FOCUS 58
+#define XIM_UNSET_IC_FOCUS 59
+#define XIM_FORWARD_EVENT 60
+#define XIM_SYNC 61
+#define XIM_SYNC_REPLY 62
+#define XIM_COMMIT 63
+#define XIM_RESET_IC 64
+#define XIM_RESET_IC_REPLY 65
+
+#define XIM_GEOMETRY 70
+#define XIM_STR_CONVERSION 71
+#define XIM_STR_CONVERSION_REPLY 72
+#define XIM_PREEDIT_START 73
+#define XIM_PREEDIT_START_REPLY 74
+#define XIM_PREEDIT_DRAW 75
+#define XIM_PREEDIT_CARET 76
+#define XIM_PREEDIT_CARET_REPLY 77
+#define XIM_PREEDIT_DONE 78
+#define XIM_STATUS_START 79
+#define XIM_STATUS_DRAW 80
+#define XIM_STATUS_DONE 81
+#define XIM_PREEDITSTATE 82
+
+/*
+ * values for the flag of XIM_ERROR
+ */
+#define XIM_IMID_VALID 0x0001
+#define XIM_ICID_VALID 0x0002
+
+/*
+ * XIM Error Code
+ */
+#define XIM_BadAlloc 1
+#define XIM_BadStyle 2
+#define XIM_BadClientWindow 3
+#define XIM_BadFocusWindow 4
+#define XIM_BadArea 5
+#define XIM_BadSpotLocation 6
+#define XIM_BadColormap 7
+#define XIM_BadAtom 8
+#define XIM_BadPixel 9
+#define XIM_BadPixmap 10
+#define XIM_BadName 11
+#define XIM_BadCursor 12
+#define XIM_BadProtocol 13
+#define XIM_BadForeground 14
+#define XIM_BadBackground 15
+#define XIM_LocaleNotSupported 16
+#define XIM_BadSomething 999
+
+/*
+ * byte order
+ */
+#define BIGENDIAN (CARD8)0x42 /* MSB first */
+#define LITTLEENDIAN (CARD8)0x6c /* LSB first */
+
+/*
+ * values for the type of XIMATTR & XICATTR
+ */
+#define XimType_SeparatorOfNestedList 0
+#define XimType_CARD8 1
+#define XimType_CARD16 2
+#define XimType_CARD32 3
+#define XimType_STRING8 4
+#define XimType_Window 5
+#define XimType_XIMStyles 10
+#define XimType_XRectangle 11
+#define XimType_XPoint 12
+#define XimType_XFontSet 13
+#define XimType_XIMOptions 14
+#define XimType_XIMHotKeyTriggers 15
+#define XimType_XIMHotKeyState 16
+#define XimType_XIMStringConversion 17
+#define XimType_NEST 0x7fff
+
+/*
+ * values for the category of XIM_ENCODING_NEGITIATON_REPLY
+ */
+#define XIM_Encoding_NameCategory 0
+#define XIM_Encoding_DetailCategory 1
+
+/*
+ * value for the index of XIM_ENCODING_NEGITIATON_REPLY
+ */
+#define XIM_Default_Encoding_IDX -1
+
+/*
+ * value for the flag of XIM_FORWARD_EVENT, XIM_COMMIT
+ */
+#define XimSYNCHRONUS 0x0001
+#define XimLookupChars 0x0002
+#define XimLookupKeySym 0x0004
+#define XimLookupBoth 0x0006
+
+/*
+ * request packet header size
+ */
+#define XIM_HEADER_SIZE \
+ sizeof(CARD8) /* sizeof mejor-opcode */ \
+ + sizeof(CARD8) /* sizeof minor-opcode */ \
+ + sizeof(INT16) /* sizeof length */
+
+/*
+ * Client Message data size
+ */
+#define XIM_CM_DATA_SIZE 20
+
+/*
+ * XIM data structure
+ */
+typedef CARD16 BITMASK16;
+typedef CARD32 BITMASK32;
+typedef CARD32 EVENTMASK;
+
+typedef CARD16 XIMID; /* Input Method ID */
+typedef CARD16 XICID; /* Input Context ID */
+
+/*
+ * Padding macro
+ */
+#define XIM_PAD(length) ((4 - ((length) % 4)) % 4)
+
+#define XIM_SET_PAD(ptr, length) \
+ { \
+ register int Counter = XIM_PAD((int)length); \
+ if (Counter) { \
+ register char *Ptr = (char *)(ptr) + (length); \
+ length += Counter; \
+ for (; Counter; --Counter, ++Ptr) \
+ *Ptr = '\0'; \
+ } \
+ }
+
+#endif /* _XIMPROTO_H */
diff --git a/src/xlibi18n/XimThai.h b/src/xlibi18n/XimThai.h
new file mode 100644
index 00000000..b883a6ef
--- /dev/null
+++ b/src/xlibi18n/XimThai.h
@@ -0,0 +1,201 @@
+/* $Xorg: XimThai.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/***********************************************************
+
+Copyright 1993, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall not be
+used in advertising or otherwise to promote the sale, use or other dealings
+in this Software without prior written authorization from The Open Group.
+
+
+Copyright 1993 by Digital Equipment Corporation, Maynard, Massachusetts.
+
+ All Rights Reserved
+
+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 Digital not be
+used in advertising or publicity pertaining to distribution of the
+software without specific, written prior permission.
+
+DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+DIGITAL 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.
+
+******************************************************************/
+
+/*
+**++
+** FACILITY:
+**
+** Xlib
+**
+** ABSTRACT:
+**
+** Definition file for Thai specific functions.
+**
+** MODIFICATION HISTORY:
+**
+**/
+
+#ifndef _XIMTHAI_H_
+#define _XIMTHAI_H_
+
+#include <X11/Xlib.h>
+
+/* Classification of characters in TACTIS according to WTT */
+
+#define CTRL 0 /* control chars */
+#define NON 1 /* non composibles */
+#define CONS 2 /* consonants */
+#define LV 3 /* leading vowels */
+#define FV1 4 /* following vowels */
+#define FV2 5
+#define FV3 6
+#define BV1 7 /* below vowels */
+#define BV2 8
+#define BD 9 /* below diacritics */
+#define TONE 10 /* tonemarks */
+#define AD1 11 /* above diacritics */
+#define AD2 12
+#define AD3 13
+#define AV1 14 /* above vowels */
+#define AV2 15
+#define AV3 16
+
+
+/* extended classification */
+
+#define DEAD 17 /* group of non-spacing characters */
+
+
+/* display levels in display cell */
+
+#define NONDISP 0 /* non displayable */
+#define TOP 1
+#define ABOVE 2
+#define BASE 3
+#define BELOW 4
+
+
+/* Input Sequence Check modes */
+
+#define WTT_ISC1 1 /* WTT default ISC mode */
+#define WTT_ISC2 2 /* WTT strict ISC mode */
+#define THAICAT_ISC 3 /* THAICAT ISC mode */
+#define NOISC 255 /* No ISC */
+
+
+/* Function prototypes (thaisub.c) */
+
+Private
+int THAI_chtype ( /* returns classification of a char */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+int THAI_chlevel ( /* returns the display level */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+Bool THAI_isdead ( /* return True if char is non-spacing */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+Bool THAI_iscons ( /* return True if char is consonant */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+Bool THAI_isvowel ( /* return True if char is vowel */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+Bool THAI_istone ( /* return True if char is tonemark */
+#if NeedFunctionPrototypes
+ unsigned char ch
+#endif
+);
+
+Private
+Bool THAI_iscomposible (
+#if NeedFunctionPrototypes
+ unsigned char follow_ch,
+ unsigned char lead_ch
+#endif
+);
+
+Private
+Bool THAI_isaccepted (
+#if NeedFunctionPrototypes
+ unsigned char follow_ch,
+ unsigned char lead_ch,
+ unsigned char isc_mode
+#endif
+);
+
+Private
+void THAI_apply_write_rules (
+#if NeedFunctionPrototypes
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char insert_ch,
+ int *num_insert_ch
+#endif
+);
+
+Private
+int THAI_find_chtype (
+#if NeedFunctionPrototypes
+ unsigned char *instr,
+ int chtype
+#endif
+);
+
+Private
+int THAI_apply_scm (
+#if NeedFunctionPrototypes
+ unsigned char *instr,
+ unsigned char *outstr,
+ unsigned char spec_ch,
+ int num_sp,
+ unsigned char insert_ch
+#endif
+);
+
+#endif /* _XIMTHAI_H_ */
diff --git a/src/xlibi18n/XimTrInt.h b/src/xlibi18n/XimTrInt.h
new file mode 100644
index 00000000..b10898b3
--- /dev/null
+++ b/src/xlibi18n/XimTrInt.h
@@ -0,0 +1,73 @@
+/* $Xorg: XimTrInt.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+not be used in advertising or publicity pertaining to distribution
+of the software without specific, written prior permission.
+Sun Microsystems, Inc. makes no representations about the suitability of
+this software for any purpose. It is provided "as is" without
+express or implied warranty.
+
+Sun Microsystems Inc. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS
+SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
+IN NO EVENT SHALL Sun Microsystems, Inc. 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMTRINT_H
+#define _XIMTRINT_H
+
+#if NeedFunctionPrototypes
+#include "Ximint.h"
+#endif
+
+typedef struct {
+ char *transportname;
+ Bool (*config)(
+#if NeedFunctionPrototypes
+ Xim,
+ char *
+#endif
+ );
+} TransportSW;
+
+extern TransportSW _XimTransportRec[];
+
+/*
+ * Global symbols
+ */
+
+extern Bool _XimXConf(
+#if NeedFunctionPrototypes
+ Xim im,
+ char *address
+#endif
+);
+
+#if defined(TCPCONN) || defined(UNIXCONN) || defined(DNETCONN) || defined(STREAMSCONN)
+
+extern Bool _XimTransConf(
+#if NeedFunctionPrototypes
+ Xim im,
+ char *address
+#endif
+);
+
+#endif
+
+#endif /* _XIMTRINT_H */
diff --git a/src/xlibi18n/XimTrX.h b/src/xlibi18n/XimTrX.h
new file mode 100644
index 00000000..489a0e3c
--- /dev/null
+++ b/src/xlibi18n/XimTrX.h
@@ -0,0 +1,67 @@
+/* $Xorg: XimTrX.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMTRX_H
+#define _XIMTRX_H
+
+typedef struct _XIntrCallbackRec *XIntrCallbackPtr;
+
+typedef struct _XIntrCallbackRec {
+ Bool (*func)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+);
+ XPointer call_data;
+ XIntrCallbackPtr next;
+} XIntrCallbackRec ;
+
+typedef struct _XSpecRec {
+ XIntrCallbackPtr intr_cb;
+ Atom imconnectid;
+ Atom improtocolid;
+ Atom immoredataid;
+ Window lib_connect_wid;
+ Window ims_connect_wid;
+ XPointer ev;
+ CARD32 major_code;
+ CARD32 minor_code;
+ CARD32 BoundarySize;
+} XSpecRec;
+
+#define _XIM_PROTOCOL "_XIM_PROTOCOL"
+#define _XIM_XCONNECT "_XIM_XCONNECT"
+#define _XIM_MOREDATA "_XIM_MOREDATA"
+
+#define MAJOR_TRANSPORT_VERSION 0
+#define MINOR_TRANSPORT_VERSION 0
+
+#endif /* _XIMTRX_H */
diff --git a/src/xlibi18n/XimTrans.h b/src/xlibi18n/XimTrans.h
new file mode 100644
index 00000000..6914190e
--- /dev/null
+++ b/src/xlibi18n/XimTrans.h
@@ -0,0 +1,127 @@
+/* $Xorg: XimTrans.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 Sun Microsystems, Inc.
+and FUJITSU LIMITED not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior permission.
+Sun Microsystems, Inc. and FUJITSU LIMITED makes no representations about
+the suitability of this software for any purpose.
+It is provided "as is" without express or implied warranty.
+
+Sun Microsystems Inc. AND FUJITSU LIMITED DISCLAIMS ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc. AND FUJITSU LIMITED
+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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+
+******************************************************************/
+
+#ifndef _XIMTRANS_H
+#define _XIMTRANS_H
+
+typedef struct _TransIntrCallbackRec *TransIntrCallbackPtr;
+
+typedef struct _TransIntrCallbackRec {
+ Bool (*func)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ );
+ XPointer call_data;
+ TransIntrCallbackPtr next;
+} TransIntrCallbackRec ;
+
+typedef struct {
+ TransIntrCallbackPtr intr_cb;
+ struct _XtransConnInfo *trans_conn; /* transport connection object */
+ int fd;
+ char *address;
+ Window window;
+ Bool is_putback;
+} TransSpecRec;
+
+
+/*
+ * Prototypes
+ */
+
+extern Bool _XimTransIntrCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ Bool (*callback)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+ XPointer call_data
+#endif
+);
+
+extern void _XimFreeTransIntrCallback(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimTransIntrCallbackCheck(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data
+#endif
+);
+
+extern Bool _XimTransFilterWaitEvent(
+#if NeedFunctionPrototypes
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer arg
+#endif
+);
+
+extern void _XimTransInternalConnection(
+#if NeedFunctionPrototypes
+ Display *d,
+ int fd,
+ XPointer arg
+#endif
+);
+
+extern Bool _XimTransWrite(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data
+#endif
+);
+
+extern Bool _XimTransRead(
+#if NeedFunctionPrototypes
+ Xim im,
+ XPointer recv_buf,
+ int buf_len,
+ int *ret_len
+#endif
+);
+
+extern void _XimTransFlush(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+#endif /* _XIMTRANS__H */
diff --git a/src/xlibi18n/Ximint.h b/src/xlibi18n/Ximint.h
new file mode 100644
index 00000000..17ca94a0
--- /dev/null
+++ b/src/xlibi18n/Ximint.h
@@ -0,0 +1,1144 @@
+/* $Xorg: Ximint.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Sony Corporation not be used in advertising or publicity pertaining to
+distribution of the software without specific, written prior
+permission. FUJITSU LIMITED and Sony Corporation makes no
+representations about the suitability of this software for any
+purpose. It is provided "as is" without express or implied warranty.
+
+FUJITSU LIMITED AND SONY CORPORATION DISCLAIM ALL WARRANTIES WITH
+REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL FUJITSU LIMITED AND
+SONY CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Motifier: Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+
+******************************************************************/
+
+#ifndef _XIMINT_H
+#define _XIMINT_H
+
+#include <stdio.h>
+#include <X11/Xutil.h>
+
+#define Public /**/
+#define Private static
+
+typedef struct _Xim *Xim;
+typedef struct _Xic *Xic;
+
+/*
+ * Input Method data
+ */
+#include "XimintP.h"
+#include "XimintL.h"
+
+/*
+ * XIM dependent data
+ */
+typedef union _XIMPrivateRec {
+ XimLocalPrivateRec local;
+ XimProtoPrivateRec proto;
+} XIMPrivateRec;
+
+/*
+ * IM struct
+ */
+typedef struct _Xim {
+ XIMMethods methods;
+ XIMCoreRec core;
+ XIMPrivateRec private;
+} XimRec;
+
+/*
+ * IC deprndent data
+ */
+typedef union _XICPrivateRec {
+ XicLocalPrivateRec local;
+ XicProtoPrivateRec proto;
+} XICPrivateRec;
+
+/*
+ * IC struct
+ */
+typedef struct _Xic {
+ XICMethods methods;
+ XICCoreRec core;
+ XICPrivateRec private;
+} XicRec;
+
+typedef struct _XimDefIMValues {
+ XIMValuesList *im_values_list;
+ XIMValuesList *ic_values_list;
+ XIMStyles *styles;
+ XIMCallback destroy_callback;
+ char *res_name;
+ char *res_class;
+ Bool visible_position;
+} XimDefIMValues;
+
+typedef struct _XimDefICValues {
+ XIMStyle input_style;
+ Window client_window;
+ Window focus_window;
+ unsigned long filter_events;
+ XIMCallback geometry_callback;
+ char *res_name;
+ char *res_class;
+ XIMCallback destroy_callback;
+ XIMCallback preedit_state_notify_callback;
+ XIMCallback string_conversion_callback;
+ XIMStringConversionText string_conversion;
+ XIMResetState reset_state;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyState hotkey_state;
+ ICPreeditAttributes preedit_attr;
+ ICStatusAttributes status_attr;
+} XimDefICValues;
+
+#define XIM_MODE_IM_GET (1 << 0)
+#define XIM_MODE_IM_SET (1 << 1)
+#define XIM_MODE_IM_DEFAULT (1 << 2)
+
+#define XIM_MODE_PRE_GET (1 << 0)
+#define XIM_MODE_PRE_SET (1 << 1)
+#define XIM_MODE_PRE_CREATE (1 << 2)
+#define XIM_MODE_PRE_ONCE (1 << 3)
+#define XIM_MODE_PRE_DEFAULT (1 << 4)
+
+#define XIM_MODE_STS_GET (1 << 5)
+#define XIM_MODE_STS_SET (1 << 6)
+#define XIM_MODE_STS_CREATE (1 << 7)
+#define XIM_MODE_STS_ONCE (1 << 8)
+#define XIM_MODE_STS_DEFAULT (1 << 9)
+
+#define XIM_MODE_IC_GET (XIM_MODE_PRE_GET | XIM_MODE_STS_GET)
+#define XIM_MODE_IC_SET (XIM_MODE_PRE_SET | XIM_MODE_STS_SET)
+#define XIM_MODE_IC_CREATE (XIM_MODE_PRE_CREATE | XIM_MODE_STS_CREATE)
+#define XIM_MODE_IC_ONCE (XIM_MODE_PRE_ONCE | XIM_MODE_STS_ONCE)
+#define XIM_MODE_IC_DEFAULT (XIM_MODE_PRE_DEFAULT | XIM_MODE_STS_DEFAULT)
+
+#define XIM_MODE_PRE_MASK (XIM_MODE_PRE_GET | XIM_MODE_PRE_SET | \
+ XIM_MODE_PRE_CREATE | XIM_MODE_PRE_ONCE | \
+ XIM_MODE_PRE_DEFAULT)
+#define XIM_MODE_STS_MASK (XIM_MODE_STS_GET | XIM_MODE_STS_SET | \
+ XIM_MODE_STS_CREATE | XIM_MODE_STS_ONCE | \
+ XIM_MODE_STS_DEFAULT)
+
+#define XIM_SETIMDEFAULTS (1L << 0)
+#define XIM_SETIMVALUES (1L << 1)
+#define XIM_GETIMVALUES (1L << 2)
+
+#define XIM_SETICDEFAULTS (1L << 0)
+#define XIM_CREATEIC (1L << 1)
+#define XIM_SETICVALUES (1L << 2)
+#define XIM_GETICVALUES (1L << 3)
+#define XIM_PREEDIT_ATTR (1L << 4)
+#define XIM_STATUS_ATTR (1L << 5)
+
+#define XIM_CHECK_VALID 0
+#define XIM_CHECK_INVALID 1
+#define XIM_CHECK_ERROR 2
+
+#define FILTERD True
+#define NOTFILTERD False
+
+#define XIMMODIFIER "@im="
+
+#define XIM_TRUE True
+#define XIM_FALSE False
+#define XIM_OVERFLOW (-1)
+
+/*
+ * Global symbols
+ */
+
+extern Bool _XimSetIMResourceList(
+#if NeedFunctionPrototypes
+ XIMResourceList *res_list,
+ unsigned int *list_num
+#endif
+);
+
+extern Bool _XimSetICResourceList(
+#if NeedFunctionPrototypes
+ XIMResourceList *res_list,
+ unsigned int *list_num
+#endif
+);
+
+extern Bool _XimSetInnerIMResourceList(
+#if NeedFunctionPrototypes
+ XIMResourceList *res_list,
+ unsigned int *list_num
+#endif
+);
+
+extern Bool _XimSetInnerICResourceList(
+#if NeedFunctionPrototypes
+ XIMResourceList *res_list,
+ unsigned int *list_num
+#endif
+);
+
+extern Bool cw_XimCheckCreateICValues(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern XIMResourceList _XimGetResourceListRec(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned int list_num,
+ char *name
+#endif
+);
+
+extern void _XimSetIMMode(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern void _XimSetICMode(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMStyle style
+#endif
+);
+
+extern int _XimCheckIMMode(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned long mode
+#endif
+);
+
+extern int _XimCheckICMode(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned long mode
+#endif
+);
+
+extern Bool _XimSetLocalIMDefaults(
+#if NeedFunctionPrototypes
+ Xim im,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern Bool _XimSetICDefaults(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XPointer top,
+ unsigned long mode,
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern Bool _XimEncodeLocalIMAttr(
+#if NeedFunctionPrototypes
+ XIMResourceList res,
+ XPointer top,
+ XPointer val
+#endif
+);
+
+extern Bool _XimEncodeLocalICAttr(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XIMResourceList res,
+ XPointer top,
+ XIMArg *arg,
+ unsigned long mode
+#endif
+);
+
+extern Bool _XimCheckLocalInputStyle(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XPointer top,
+ XIMArg *values,
+ XIMStyles *styles,
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern Bool _XimDecodeLocalIMAttr(
+#if NeedFunctionPrototypes
+ XIMResourceList res,
+ XPointer top,
+ XPointer val
+#endif
+);
+
+extern Bool _XimDecodeLocalICAttr(
+#if NeedFunctionPrototypes
+ XIMResourceList res,
+ XPointer top,
+ XPointer val,
+ unsigned long mode
+#endif
+);
+
+extern void _XimGetCurrentIMValues(
+#if NeedFunctionPrototypes
+ Xim im,
+ XimDefIMValues *im_values
+#endif
+);
+
+extern void _XimSetCurrentIMValues(
+#if NeedFunctionPrototypes
+ Xim im,
+ XimDefIMValues *im_values
+#endif
+);
+
+extern void _XimGetCurrentICValues(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XimDefICValues *ic_values
+#endif
+);
+
+extern void _XimSetCurrentICValues(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XimDefICValues *ic_values
+#endif
+);
+
+extern void _XimInitialResourceInfo(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern void _XimParseStringFile(
+#if NeedFunctionPrototypes
+ FILE *fp,
+ DefTree **ptop
+#endif
+);
+
+extern Bool _XimCheckIfLocalProcessing(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimCheckIfThaiProcessing(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimLocalOpenIM(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimThaiOpenIM(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimProtoOpenIM(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimLocalIMFree(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimThaiIMFree(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimProtoIMFree(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern char * _XimSetIMValueData(
+#if NeedFunctionPrototypes
+ Xim im,
+ XPointer top,
+ XIMArg *arg,
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern char * _XimGetIMValueData(
+#if NeedFunctionPrototypes
+ Xim im,
+ XPointer top,
+ XIMArg *arg,
+ XIMResourceList res_list,
+ unsigned int list_num
+#endif
+);
+
+extern char * _XimSetICValueData(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *arg,
+ unsigned long mode,
+ Bool flag
+#endif
+);
+
+extern char * _XimGetICValueData(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XPointer top,
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XIMArg *arg,
+ unsigned long mode
+#endif
+);
+
+extern char * _XimLocalSetIMValues(
+#if NeedFunctionPrototypes
+ XIM im,
+ XIMArg *arg
+#endif
+);
+
+extern char * _XimLocalGetIMValues(
+#if NeedFunctionPrototypes
+ XIM im,
+ XIMArg *arg
+#endif
+);
+
+extern XIC _XimLocalCreateIC(
+#if NeedFunctionPrototypes
+ XIM im,
+ XIMArg *arg
+#endif
+);
+
+extern Bool _XimDispatchInit(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimGetAttributeID(
+#if NeedFunctionPrototypes
+ Xim im,
+ CARD16 *buf
+#endif
+);
+
+extern Bool _XimExtension(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimDestroyIMStructureList(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern char * _XimMakeIMAttrIDList(
+#if NeedFunctionPrototypes
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *buf,
+ INT16 *len,
+ unsigned long mode
+#endif
+);
+
+extern char * _XimMakeICAttrIDList(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ CARD16 *idList,
+ INT16 *num,
+ unsigned long mode
+#endif
+);
+
+extern char * _XimDecodeIMATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *buf,
+ INT16 buf_len,
+ XIMArg *arg,
+ BITMASK32 mode
+#endif
+);
+
+extern char * _XimDecodeICATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ CARD16 *buf,
+ INT16 buf_len,
+ XIMArg *arg,
+ BITMASK32 mode
+#endif
+);
+
+extern Bool _XimRegProtoIntrCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ CARD16 major_code,
+ CARD16 minor_code,
+ Bool (*proc)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimErrorCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimRegisterTriggerKeysCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimSetEventMaskCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimForwardEventCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimCommitCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern Bool _XimSyncCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern void _XimFreeProtoIntrCallback(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern XIC _XimProtoCreateIC(
+#if NeedFunctionPrototypes
+ XIM im,
+ XIMArg *arg
+#endif
+);
+
+extern void _XimRegisterServerFilter(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimUnregisterServerFilter(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimTriggerNotify(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic,
+ int mode,
+ CARD32 idx
+#endif
+);
+
+extern Bool _XimProcSyncReply(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic
+#endif
+);
+
+extern void _XimSendSetFocus(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic
+#endif
+);
+
+extern Bool _XimForwardEvent(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XEvent *ev,
+ Bool sync
+#endif
+);
+
+extern void _XimFreeRemakeArg(
+#if NeedFunctionPrototypes
+ XIMArg *arg
+#endif
+);
+
+extern void _XimServerDestroy(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern char * _XimEncodeIMATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+#endif
+);
+
+extern char * _XimEncodeICATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ XIMArg *arg,
+ XIMArg **arg_ret,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ BITMASK32 *flag,
+ unsigned long mode
+#endif
+);
+
+#ifdef EXT_MOVE
+extern Bool _XimExtenMove(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic,
+ CARD32 flag,
+ CARD16 *buf,
+ INT16 length
+#endif
+);
+#endif
+
+extern int _Ximctstombs(
+#if NeedFunctionPrototypes
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+#endif
+);
+
+extern int _Ximctstowcs(
+#if NeedFunctionPrototypes
+ XIM im,
+ char *from,
+ int from_len,
+ wchar_t *to,
+ int to_len,
+ Status *state
+#endif
+);
+
+extern int _XimLcctstombs(
+#if NeedFunctionPrototypes
+ XIM im,
+ char *from,
+ int from_len,
+ char *to,
+ int to_len,
+ Status *state
+#endif
+);
+
+extern int _XimLcctstowcs(
+#if NeedFunctionPrototypes
+ XIM im,
+ char *from,
+ int from_len,
+ wchar_t *to,
+ int to_len,
+ Status *state
+#endif
+);
+
+extern void _XimSetHeader(
+#if NeedFunctionPrototypes
+ XPointer buf,
+ CARD8 major_opcode,
+ CARD8 minor_opcode,
+ INT16 *len
+#endif
+);
+
+extern Bool _XimSync(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic
+#endif
+);
+
+extern int _XimProtoMbLookupString(
+#if NeedFunctionPrototypes
+ XIC xic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state
+#endif
+);
+
+extern int _XimProtoWcLookupString(
+#if NeedFunctionPrototypes
+ XIC xic,
+ XKeyEvent *ev,
+ wchar_t *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *state
+#endif
+);
+
+extern void _XimRegisterFilter(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern void _XimUnregisterFilter(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern void _XimReregisterFilter(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern Status _XimProtoEventToWire(
+#if NeedFunctionPrototypes
+ XEvent *re,
+ xEvent *event,
+ Bool sw
+#endif
+);
+
+extern Bool _XimProtoWireToEvent(
+#if NeedFunctionPrototypes
+ XEvent *re,
+ xEvent *event,
+ Bool sw
+#endif
+);
+
+#ifdef EXT_FORWARD
+extern Bool _XimExtForwardKeyEvent(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XKeyEvent *ev,
+ Bool sync
+#endif
+);
+#endif
+
+extern int _XimLookupMBText(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XKeyEvent *event,
+ char *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status
+#endif
+);
+
+extern int _XimLookupWCText(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XKeyEvent *event,
+ wchar_t *buffer,
+ int nbytes,
+ KeySym *keysym,
+ XComposeStatus *status
+#endif
+);
+
+extern EVENTMASK _XimGetWindowEventmask(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern Xic _XimICOfXICID(
+#if NeedFunctionPrototypes
+ Xim im,
+ XICID icid
+#endif
+);
+
+extern void _XimResetIMInstantiateCallback(
+#if NeedFunctionPrototypes
+ Xim xim
+#endif
+);
+
+extern Bool _XimRegisterIMInstantiateCallback(
+#if NeedFunctionPrototypes
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIMProc callback,
+ XPointer *client_data
+#endif
+);
+
+extern Bool _XimUnRegisterIMInstantiateCallback(
+#if NeedFunctionPrototypes
+ XLCd lcd,
+ Display *display,
+ XrmDatabase rdb,
+ char *res_name,
+ char *res_class,
+ XIMProc callback,
+ XPointer *client_data
+#endif
+);
+
+extern void _XimFreeCommitInfo(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern Bool _XimConnect(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimShutdown(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimWrite(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data
+#endif
+);
+
+extern Bool _XimRead(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 *len,
+ XPointer data,
+ int data_len,
+ Bool (*predicate)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+ XPointer arg
+#endif
+);
+
+extern Bool _XimIntrCallback(
+#if NeedFunctionPrototypes
+ Xim im,
+ Bool (*callback)(
+#if NeedNestedPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+ ),
+ XPointer call_data
+#endif
+);
+
+extern void _XimFlush(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimFilterWaitEvent(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimProcError(
+#if NeedFunctionPrototypes
+ Xim im,
+ Xic ic,
+ XPointer data
+#endif
+);
+
+#ifdef EXT_MOVE
+extern CARD32 _XimExtenArgCheck(
+#if NeedFunctionProtoTypes
+ XIMArg *arg
+#endif
+);
+#endif
+
+extern Bool _XimCbDispatch(
+#if NeedFunctionPrototypes
+ Xim im,
+ INT16 len,
+ XPointer data,
+ XPointer call_data
+#endif
+);
+
+extern void _XimGetResourceName(
+#if NeedFunctionPrototypes
+ Xim im,
+ char *res_name,
+ char *res_class
+#endif
+);
+
+extern Bool _XimLocalFilter(
+#if NeedFunctionPrototypes
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data
+#endif
+);
+
+extern XIMResourceList _XimGetResourceListRecByQuark(
+#if NeedFunctionPrototypes
+ XIMResourceList res_list,
+ unsigned int list_num,
+ XrmQuark quark
+#endif
+);
+
+extern Bool _XimReconnectModeCreateIC(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern char *_XimLocalSetICValues(
+#if NeedFunctionPrototypes
+ XIC ic,
+ XIMArg *values
+#endif
+);
+
+extern char * _XimLocalGetICValues(
+#if NeedFunctionPrototypes
+ XIC ic,
+ XIMArg *values
+#endif
+);
+
+extern int _XimLocalMbLookupString(
+#if NeedFunctionPrototypes
+ XIC ic,
+ XKeyEvent *ev,
+ char *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status
+#endif
+);
+
+extern int _XimLocalWcLookupString(
+#if NeedFunctionPrototypes
+ XIC ic,
+ XKeyEvent *ev,
+ wchar_t *buffer,
+ int bytes,
+ KeySym *keysym,
+ Status *status
+#endif
+);
+
+extern Bool _XimThaiFilter(
+#if NeedFunctionPrototypes
+ Display *d,
+ Window w,
+ XEvent *ev,
+ XPointer client_data
+#endif
+);
+
+extern XIC _XimThaiCreateIC(
+#if NeedFunctionPrototypes
+ XIM im,
+ XIMArg *values
+#endif
+);
+
+extern Status _XimThaiCloseIM(
+#if NeedFunctionPrototypes
+ XIM xim
+#endif
+);
+
+#ifdef XIM_CONNECTABLE
+extern void _XimSetProtoResource(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimConnectServer(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern Bool _XimDelayModeSetAttr(
+#if NeedFunctionPrototypes
+ Xim im
+#endif
+);
+
+extern void _XimServerReconectableDestroy(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern Bool _XimReCreateIC(
+#if NeedFunctionPrototypes
+ Xic ic
+#endif
+);
+
+extern Bool _XimEncodeSavedIMATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xim im,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+#endif
+);
+
+extern Bool _XimEncodeSavedICATTRIBUTE(
+#if NeedFunctionPrototypes
+ Xic ic,
+ XIMResourceList res_list,
+ unsigned int res_num,
+ int *idx,
+ char *buf,
+ int size,
+ int *ret_len,
+ XPointer top,
+ unsigned long mode
+#endif
+);
+#endif
+
+#endif /* _XIMINT_H */
diff --git a/src/xlibi18n/XimintL.h b/src/xlibi18n/XimintL.h
new file mode 100644
index 00000000..720a78bd
--- /dev/null
+++ b/src/xlibi18n/XimintL.h
@@ -0,0 +1,78 @@
+/* $Xorg: XimintL.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993 by Digital Equipment Corporation
+
+Permission to use, copy, modify, distribute, and sell this software
+and its documentation for any purpose is hereby granted without fee,
+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 FUJITSU LIMITED and
+Digital Equipment Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. FUJITSU LIMITED and Digital Equipment Corporation
+makes no representations about the suitability of this software for
+any purpose. It is provided "as is" without express or implied
+warranty.
+
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION DISCLAIM ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+FUJITSU LIMITED AND DIGITAL EQUIPMENT CORPORATION 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.
+
+ Author: Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Modifier: Franky Ling Digital Equipment Corporation
+ frankyling@hgrd01.enet.dec.com
+
+******************************************************************/
+
+#ifndef _XIMINTL_H
+#define _XIMINTL_H
+
+#define COMPOSE_FILE "Compose"
+
+/*
+ * Data Structure for Local Processing
+ */
+typedef struct _DefTree {
+ struct _DefTree *next; /* another Key definition */
+ struct _DefTree *succession; /* successive Key Sequence */
+ /* Key definitions */
+ unsigned modifier_mask;
+ unsigned modifier;
+ KeySym keysym; /* leaf only */
+ char *mb;
+ wchar_t *wc; /* make from mb */
+ KeySym ks;
+} DefTree;
+
+typedef struct _XimLocalPrivateRec {
+ XIC current_ic;
+ DefTree *top;
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+} XimLocalPrivateRec;
+
+typedef struct _XicThaiPart {
+ int comp_state;
+ KeySym keysym;
+ int input_mode;
+} XicThaiPart;
+
+typedef struct _XicLocalPrivateRec {
+ long value_mask;
+ DefTree *context;
+ DefTree *composed;
+ XicThaiPart thai;
+
+ XIMResourceList ic_resources;
+ unsigned int ic_num_resources;
+} XicLocalPrivateRec;
+#endif /* _XIMINTL_H */
diff --git a/src/xlibi18n/XimintP.h b/src/xlibi18n/XimintP.h
new file mode 100644
index 00000000..28e09e04
--- /dev/null
+++ b/src/xlibi18n/XimintP.h
@@ -0,0 +1,301 @@
+/* $Xorg: XimintP.h,v 1.3 2000/08/17 19:45:05 cpqbld Exp $ */
+/******************************************************************
+
+ Copyright 1991, 1992 by Sun Microsystems, Inc.
+ Copyright 1992, 1993, 1994 by FUJITSU LIMITED
+ Copyright 1993, 1994 by Sony Corporation
+
+Permission to use, copy, modify, distribute, and sell this software and
+its documentation for any purpose is hereby granted without fee, 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 Sun Microsystems, Inc., FUJITSU
+LIMITED and Sony Corporation not be used in advertising or publicity
+pertaining to distribution of the software without specific, written
+prior permission. Sun Microsystems, Inc., FUJITSU LIMITED and Sony
+Corporation makes no representations about the suitability of this
+software for any purpose. It is provided "as is" without express or
+implied warranty.
+
+Sun Microsystems Inc. ,FUJITSU LIMITED AND SONY CORPORATION DISCLAIMS ALL
+WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL Sun Microsystems, Inc.,
+FUJITSU LIMITED, SONY CORPORATIN 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.
+
+ Author: Hideki Hiura (hhiura@Sun.COM) Sun Microsystems, Inc.
+ Takashi Fujiwara FUJITSU LIMITED
+ fujiwara@a80.tech.yk.fujitsu.co.jp
+ Makoto Wakamatsu Sony Corporation
+ makoto@sm.sony.co.jp
+ Hiroyuki Miyamoto Digital Equipment Corporation
+ miyamoto@jrd.dec.com
+
+******************************************************************/
+
+#ifndef _XIMINTP_H
+#define _XIMINTP_H
+
+#include "XimProto.h"
+#include "XlcPublic.h"
+
+/*
+ * for protocol layer callback function
+ */
+typedef Bool (*XimProtoIntrProc)(
+#if NeedFunctionPrototypes
+ Xim, INT16, XPointer, XPointer
+#endif
+);
+typedef struct _XimProtoIntrRec {
+ XimProtoIntrProc func;
+ CARD16 major_code;
+ CARD16 minor_code;
+ XPointer call_data;
+ struct _XimProtoIntrRec *next;
+} XimProtoIntrRec;
+
+/*
+ * for transport layer methods
+ */
+typedef Bool (*XimTransConnectProc)(
+#if NeedFunctionPrototypes
+ Xim
+#endif
+);
+typedef Bool (*XimTransShutdownProc)(
+#if NeedFunctionPrototypes
+ Xim
+#endif
+);
+typedef Bool (*XimTransWriteProc)(
+#if NeedFunctionPrototypes
+ Xim, INT16, XPointer
+#endif
+);
+typedef Bool (*XimTransReadProc)(
+#if NeedFunctionPrototypes
+ Xim, XPointer, int, int *
+#endif
+);
+typedef void (*XimTransFlushProc)(
+#if NeedFunctionPrototypes
+ Xim
+#endif
+);
+typedef Bool (*XimTransRegDispatcher)(
+#if NeedNestedPrototypes
+ Xim, Bool (*)(Xim, INT16, XPointer, XPointer), XPointer
+#endif
+);
+typedef Bool (*XimTransCallDispatcher)(
+#if NeedFunctionPrototypes
+ Xim, INT16, XPointer
+#endif
+);
+
+/*
+ * private part of IM
+ */
+typedef struct _XimProtoPrivateRec {
+ Window im_window;
+ XIMID imid;
+ CARD16 unused;
+ XIMStyles *default_styles;
+ CARD32 *im_onkeylist;
+ CARD32 *im_offkeylist;
+ BITMASK32 flag;
+
+ BITMASK32 registed_filter_event;
+ EVENTMASK forward_event_mask;
+ EVENTMASK synchronous_event_mask;
+
+ XimProtoIntrRec *intrproto;
+ XIMResourceList im_inner_resources;
+ unsigned int im_num_inner_resources;
+ XIMResourceList ic_inner_resources;
+ unsigned int ic_num_inner_resources;
+ char *hold_data;
+ int hold_data_len;
+ char *locale_name;
+ CARD16 protocol_major_version;
+ CARD16 protocol_minor_version;
+ XrmQuark *saved_imvalues;
+ int num_saved_imvalues;
+
+ XlcConv ctom_conv;
+ XlcConv ctow_conv;
+
+ /*
+ * transport specific
+ */
+ XimTransConnectProc connect;
+ XimTransShutdownProc shutdown;
+ XimTransWriteProc write;
+ XimTransReadProc read;
+ XimTransFlushProc flush;
+ XimTransRegDispatcher register_dispatcher;
+ XimTransCallDispatcher call_dispatcher;
+ XPointer spec;
+} XimProtoPrivateRec;
+
+/*
+ * bit mask for the flag of XIMPrivateRec
+ */
+#define SERVER_CONNECTED (1L)
+#define DYNAMIC_EVENT_FLOW (1L << 1)
+#define USE_AUTHORIZATION_FUNC (1L << 2)
+#ifdef XIM_CONNECTABLE
+#define DELAYBINDABLE (1L << 3)
+#define RECONNECTABLE (1L << 4)
+#endif /* XIM_CONNECTABLE */
+
+/*
+ * macro for the flag of XIMPrivateRec
+ */
+#define IS_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag & SERVER_CONNECTED)
+#define MARK_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag |= SERVER_CONNECTED)
+#define UNMARK_SERVER_CONNECTED(im) \
+ ((((Xim)im))->private.proto.flag &= ~SERVER_CONNECTED)
+
+#define IS_DYNAMIC_EVENT_FLOW(im) \
+ (((Xim)im)->private.proto.flag & DYNAMIC_EVENT_FLOW)
+#define MARK_DYNAMIC_EVENT_FLOW(im) \
+ (((Xim)im)->private.proto.flag |= DYNAMIC_EVENT_FLOW)
+
+#define IS_USE_AUTHORIZATION_FUNC(im) \
+ (((Xim)im)->private.proto.flag & USE_AUTHORIZATION_FUNC)
+#define MARK_USE_AUTHORIZATION_FUNC(im) \
+ (((Xim)im)->private.proto.flag |= USE_AUTHORIZATION_FUNC)
+
+#ifdef XIM_CONNECTABLE
+#define IS_DELAYBINDABLE(im) \
+ (((Xim)im)->private.proto.flag & DELAYBINDABLE)
+#define MARK_DELAYBINDABLE(im) \
+ (((Xim)im)->private.proto.flag |= DELAYBINDABLE)
+
+#define IS_RECONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag & RECONNECTABLE)
+#define MARK_RECONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag |= RECONNECTABLE)
+
+#define IS_CONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag & (DELAYBINDABLE|RECONNECTABLE))
+#define UNMAKE_CONNECTABLE(im) \
+ (((Xim)im)->private.proto.flag &= ~(DELAYBINDABLE|RECONNECTABLE))
+#endif /* XIM_CONNECTABLE */
+
+/*
+ * bit mask for the register_filter_event of XIMPrivateRec/XICPrivateRec
+ */
+#define KEYPRESS_MASK (1L)
+#define KEYRELEASE_MASK (1L << 1)
+#define DESTROYNOTIFY_MASK (1L << 2)
+
+typedef struct _XimCommitInfoRec {
+ struct _XimCommitInfoRec *next;
+ char *string;
+ int string_len;
+ KeySym *keysym;
+ int keysym_len;
+} XimCommitInfoRec, *XimCommitInfo;
+
+typedef struct _XimPendingCallback {
+ int major_opcode;
+ Xim im;
+ Xic ic;
+ char *proto;
+ int proto_len;
+ struct _XimPendingCallback *next;
+} XimPendingCallbackRec, *XimPendingCallback;
+
+
+/*
+ * private part of IC
+ */
+typedef struct _XicProtoPrivateRec {
+ XICID icid; /* ICID */
+ CARD16 dmy;
+ BITMASK32 flag; /* Input Mode */
+
+ BITMASK32 registed_filter_event; /* registed filter mask */
+ EVENTMASK forward_event_mask; /* forward event mask */
+ EVENTMASK synchronous_event_mask;/* sync event mask */
+ EVENTMASK filter_event_mask; /* negrect event mask */
+ EVENTMASK intercept_event_mask; /* deselect event mask */
+ EVENTMASK select_event_mask; /* select event mask */
+
+ char *preedit_font; /* Base font name list */
+ int preedit_font_length; /* length of base font name */
+ char *status_font; /* Base font name list */
+ int status_font_length; /* length of base font name */
+
+ XimCommitInfo commit_info;
+ XIMResourceList ic_resources;
+ unsigned int ic_num_resources;
+ XIMResourceList ic_inner_resources;
+ unsigned int ic_num_inner_resources;
+ XrmQuark *saved_icvalues;
+ int num_saved_icvalues;
+ XimPendingCallback pend_cb_que;
+ Bool waitCallback;
+} XicProtoPrivateRec ;
+
+/*
+ * bit mask for the flag of XICPrivateRec
+ */
+#define IC_CONNECTED (1L)
+#define FABLICATED (1L << 1)
+#define NEED_SYNC_REPLY (1L << 2)
+
+/*
+ * macro for the flag of XICPrivateRec
+ */
+#define IS_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag & IC_CONNECTED)
+#define MARK_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag |= IC_CONNECTED)
+#define UNMARK_IC_CONNECTED(ic) \
+ (((Xic)ic)->private.proto.flag &= ~IC_CONNECTED)
+
+#define IS_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag & FABLICATED)
+#define MARK_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag |= FABLICATED)
+#define UNMARK_FABLICATED(ic) \
+ (((Xic)ic)->private.proto.flag &= ~FABLICATED)
+
+#define IS_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag & NEED_SYNC_REPLY)
+#define MARK_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag |= NEED_SYNC_REPLY)
+#define UNMARK_NEED_SYNC_REPLY(ic) \
+ (((Xic)ic)->private.proto.flag &= ~NEED_SYNC_REPLY)
+
+/*
+ * macro for the filter_event_mask of XICPrivateRec
+ */
+#define IS_NEGLECT_EVENT(ic, mask) \
+ (((Xic)ic)->private.proto.filter_event_mask & (mask))
+
+/*
+ * macro for the forward_event_mask of XICPrivateRec
+ */
+#define IS_FORWARD_EVENT(ic, mask) \
+ (((Xic)ic)->private.proto.forward_event_mask & (mask))
+
+/*
+ * macro for the synchronous_event_mask of XICPrivateRec
+ */
+#define IS_SYNCHRONOUS_EVENT(ic, mask) \
+ ((((Xic)ic)->private.proto.synchronous_event_mask & (mask)) ? True: False)
+
+#define XIM_MAXIMNAMELEN 64
+#define XIM_MAXLCNAMELEN 64
+
+#endif /* _XIMINTP_H */
diff --git a/src/xlibi18n/XlcDL.c b/src/xlibi18n/XlcDL.c
new file mode 100644
index 00000000..210bd731
--- /dev/null
+++ b/src/xlibi18n/XlcDL.c
@@ -0,0 +1,650 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: The above copyright notice and this
+permission notice shall be included in all copies or substantial
+portions of the Software.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without prior
+written authorization from The Open Group and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+
+#include <stdio.h>
+#if defined(hpux)
+#include <dl.h>
+#else
+#include <dlfcn.h>
+#endif
+#include <ctype.h>
+
+#include "Xlibint.h"
+#include "XlcPublic.h"
+#include "XlcPubI.h"
+
+#ifdef _LP64
+#if defined(__sparcv9)
+#define _MACH64_NAME "sparcv9"
+#define _MACH64_NAME_LEN (sizeof (_MACH64_NAME) - 1)
+#else /* !defined(__sparcv9) */
+#error "Unknown architecture"
+#endif /* defined(__sparcv9) */
+#endif /* _LP64 */
+
+#define XI18N_DLREL 2
+
+#define iscomment(ch) ((ch) == '\0' || (ch) == '#')
+
+typedef enum {
+ XLC_OBJECT,
+ XIM_OBJECT,
+ XOM_OBJECT
+} XI18NDLType;
+
+typedef struct {
+ XI18NDLType type;
+ int locale_name_len;
+ char *locale_name;
+ char *dl_name;
+ char *open;
+ char *im_register;
+ char *im_unregister;
+ int dl_release;
+#if defined(hpux)
+ shl_t dl_module;
+#else
+ void *dl_module;
+#endif
+} XI18NObjectsListRec, *XI18NObjectsList;
+
+#define OBJECT_INIT_LEN 8
+#define OBJECT_INC_LEN 4
+static int lc_len = 0;
+static XI18NObjectsListRec *xi18n_objects_list = NULL;
+static int lc_count = 0;
+
+static int
+parse_line(line, argv, argsize)
+char *line;
+char **argv;
+int argsize;
+{
+ int argc = 0;
+ char *p = line;
+
+ while (argc < argsize) {
+ while (isspace(*p)) {
+ ++p;
+ }
+ if (iscomment(*p)){
+ break;
+ }
+ argv[argc++] = p;
+ while (!isspace(*p)) {
+ ++p;
+ }
+ if (iscomment(*p)) {
+ break;
+ }
+ *p++ = '\0';
+ }
+ return argc;
+}
+
+static void
+resolve_object(path, lc_name)
+char *path;
+char *lc_name;
+{
+ char filename[BUFSIZ];
+ FILE *fp;
+ char buf[BUFSIZ];
+
+ if (lc_len == 0) { /* True only for the 1st time */
+ lc_len = OBJECT_INIT_LEN;
+ xi18n_objects_list = (XI18NObjectsList)
+ Xmalloc(sizeof(XI18NObjectsListRec) * lc_len);
+ if (!xi18n_objects_list) return;
+ }
+/*
+1266793
+Limit the length of path to prevent stack buffer corruption.
+ sprintf(filename, "%s/%s", path, "XI18N_OBJS");
+*/
+ sprintf(filename, "%.*s/%s", BUFSIZ - 12, path, "XI18N_OBJS");
+ fp = fopen(filename, "r");
+ if (fp == (FILE *)NULL){
+ return;
+ }
+
+ while (fgets(buf, BUFSIZ, fp) != NULL){
+ char *p = buf;
+ int n;
+ char *args[6];
+ while (isspace(*p)){
+ ++p;
+ }
+ if (iscomment(*p)){
+ continue;
+ }
+
+ if (lc_count == lc_len) {
+ lc_len += OBJECT_INC_LEN;
+ xi18n_objects_list = (XI18NObjectsList)
+ Xrealloc(xi18n_objects_list,
+ sizeof(XI18NObjectsListRec) * lc_len);
+ if (!xi18n_objects_list) return;
+ }
+ n = parse_line(p, args, 6);
+
+ if (n == 3 || n == 5) {
+ if (!strcmp(args[0], "XLC")){
+ xi18n_objects_list[lc_count].type = XLC_OBJECT;
+ } else if (!strcmp(args[0], "XOM")){
+ xi18n_objects_list[lc_count].type = XOM_OBJECT;
+ } else if (!strcmp(args[0], "XIM")){
+ xi18n_objects_list[lc_count].type = XIM_OBJECT;
+ }
+ xi18n_objects_list[lc_count].dl_name = strdup(args[1]);
+ xi18n_objects_list[lc_count].open = strdup(args[2]);
+ xi18n_objects_list[lc_count].dl_release = XI18N_DLREL;
+ xi18n_objects_list[lc_count].locale_name = strdup(lc_name);
+ xi18n_objects_list[lc_count].dl_module = (void*)NULL;
+ if (n == 5) {
+ xi18n_objects_list[lc_count].im_register = strdup(args[3]);
+ xi18n_objects_list[lc_count].im_unregister = strdup(args[4]);
+ } else {
+ xi18n_objects_list[lc_count].im_register = NULL;
+ xi18n_objects_list[lc_count].im_unregister = NULL;
+ }
+ lc_count++;
+ }
+ }
+ fclose(fp);
+}
+
+static char*
+__lc_path(dl_name, lc_dir)
+const char *dl_name;
+const char *lc_dir;
+{
+ char *path;
+ size_t len;
+
+#ifdef _LP64
+ len = (lc_dir ? strlen(lc_dir) : 0 ) +
+ (dl_name ? strlen(dl_name) : 0) + _MACH64_NAME_LEN + 10;
+ path = Xmalloc(len + 1);
+
+ if (strchr(dl_name, '/') != NULL) {
+ char *tmp = strdup(dl_name);
+ char *dl_dir, *dl_file;
+ char *slash_p;
+ slash_p = strchr(tmp, '/');
+ *slash_p = '\0';
+ dl_dir = tmp;
+ dl_file = ++slash_p;
+
+ slash_p = strrchr(lc_dir, '/');
+ *slash_p = '\0';
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, dl_dir); strcat(path, "/");
+ strcat(path, _MACH64_NAME); strcat(path, "/");
+ strcat(path, dl_file); strcat(path, ".so.2");
+
+ *slash_p = '/';
+ Xfree(tmp);
+ } else {
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, _MACH64_NAME); strcat(path, "/");
+ strcat(path, dl_name); strcat(path, ".so.2");
+ }
+#else
+ len = (lc_dir ? strlen(lc_dir) : 0 ) +
+ (dl_name ? strlen(dl_name) : 0) + 10;
+ path = Xmalloc(len + 1);
+
+ if (strchr(dl_name, '/') != NULL) {
+ char *slash_p;
+ slash_p = strrchr(lc_dir, '/');
+ *slash_p = '\0';
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, dl_name); strcat(path, ".so.2");
+ *slash_p = '/';
+ } else {
+ strcpy(path, lc_dir); strcat(path, "/");
+ strcat(path, dl_name); strcat(path, ".so.2");
+ }
+#endif
+ return path;
+}
+
+XLCd
+_XlcDynamicLoad(lc_name)
+ char *lc_name;
+{
+ XLCd lcd = (XLCd)NULL;
+ XLCd (*lc_loader)() = (XLCd(*)())NULL;
+ char *path;
+ int count;
+ XI18NObjectsList objects_list;
+ char lc_dir[BUFSIZE];
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ if (lc_name == NULL) return (XLCd)NULL;
+
+ if (_XlcLocaleDirName(lc_dir, lc_name) == (char*)NULL) return (XLCd)NULL;
+
+ resolve_object(lc_dir, lc_name);
+
+ objects_list = xi18n_objects_list;
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XLC_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!objects_list->dl_module) {
+ path = __lc_path(objects_list->dl_name, lc_dir);
+#if defined(hpux)
+ objects_list->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ objects_list->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+ if (!objects_list->dl_module) continue;
+ }
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(objects_list->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, objects_list->open)) {
+ lc_loader = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ lc_loader = (XLCd(*)())dlsym(objects_list->dl_module,
+ objects_list->open);
+#endif
+ if (!lc_loader) continue;
+ lcd = (*lc_loader)(lc_name);
+ if (lcd != (XLCd)NULL) {
+ break;
+ }
+#if defined(hpux)
+ shl_unload(objects_list->dl_module);
+#else
+ dlclose(objects_list->dl_module);
+#endif
+ objects_list->dl_module = NULL;
+ }
+ return (XLCd)lcd;
+}
+
+static XIM
+#if NeedFunctionPrototypes
+_XDynamicOpenIM(XLCd lcd, Display *display, XrmDatabase rdb,
+ char *res_name, char *res_class)
+#else
+_XDynamicOpenIM(lcd, display, rdb, res_name, res_class)
+XLCd lcd;
+Display *display;
+XrmDatabase rdb;
+char *res_name, *res_class;
+#endif
+{
+ XIM im = (XIM)NULL;
+ char *path;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ XIM (*im_openIM)() = (XIM(*)())NULL;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, lc_name) == NULL) return (XIM)0;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!objects_list->dl_module) {
+ path = __lc_path(objects_list->dl_name, lc_dir);
+#if defined(hpux)
+ objects_list->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ objects_list->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+ if (!objects_list->dl_module) continue;
+ }
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(objects_list->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, objects_list->open)) {
+ im_openIM = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ im_openIM = (XIM(*)())dlsym(objects_list->dl_module,
+ objects_list->open);
+ if (!im_openIM) continue;
+#endif
+ im = (*im_openIM)(lcd, display, rdb, res_name, res_class);
+ if (im != (XIM)NULL) {
+ break;
+ }
+ im_openIM = 0;
+#if defined(hpux)
+ shl_unload(objects_list->dl_module);
+#else
+ dlclose(objects_list->dl_module);
+#endif
+ objects_list->dl_module = NULL;
+ }
+ return (XIM)im;
+}
+
+static Bool
+_XDynamicRegisterIMInstantiateCallback(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data)
+XLCd lcd;
+Display *display;
+XrmDatabase rdb;
+char *res_name, *res_class;
+XIMProc callback;
+XPointer *client_data;
+{
+ char *path;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ Bool (*im_registerIM)() = (Bool(*)())NULL;
+ Bool ret_flag = False;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, lc_name) == NULL) return False;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!objects_list->dl_module) {
+ path = __lc_path(objects_list->dl_name, lc_dir);
+#if defined(hpux)
+ objects_list->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ objects_list->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+ if (!objects_list->dl_module) continue;
+ }
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(objects_list->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, objects_list->open)) {
+ im_registerIM = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ im_registerIM = (Bool(*)())dlsym(objects_list->dl_module,
+ objects_list->im_register);
+ if (!im_registerIM) continue;
+#endif
+ ret_flag = (*im_registerIM)(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data);
+ if (ret_flag) break;
+
+ im_registerIM = 0;
+#if defined(hpux)
+ shl_unload(objects_list->dl_module);
+#else
+ dlclose(objects_list->dl_module);
+#endif
+ objects_list->dl_module = NULL;
+ }
+ return (Bool)ret_flag;
+}
+
+static Bool
+_XDynamicUnRegisterIMInstantiateCallback(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data)
+XLCd lcd;
+Display *display;
+XrmDatabase rdb;
+char *res_name, *res_class;
+XIMProc callback;
+XPointer *client_data;
+{
+ char *path;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ Bool (*im_unregisterIM)() = (Bool(*)())NULL;
+ Bool ret_flag = False;
+ int count;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+ if (_XlcLocaleDirName(lc_dir, lc_name) == NULL) return False;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XIM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!objects_list->dl_module) {
+ path = __lc_path(objects_list->dl_name, lc_dir);
+#if defined(hpux)
+ objects_list->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ objects_list->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+ if (!objects_list->dl_module) continue;
+ }
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(objects_list->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, objects_list->open)) {
+ im_unregisterIM = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ im_unregisterIM = (Bool(*)())dlsym(objects_list->dl_module,
+ objects_list->im_unregister);
+
+ if (!im_unregisterIM) continue;
+#endif
+ ret_flag = (*im_unregisterIM)(lcd, display, rdb,
+ res_name, res_class,
+ callback, client_data);
+ if (ret_flag) break;
+
+ im_unregisterIM = 0;
+#if defined(hpux)
+ shl_unload(objects_list->dl_module);
+#else
+ dlclose(objects_list->dl_module);
+#endif
+ objects_list->dl_module = NULL;
+ }
+ return (Bool)ret_flag;
+}
+
+Bool
+_XInitDynamicIM(lcd)
+XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+ lcd->methods->open_im = _XDynamicOpenIM;
+ lcd->methods->register_callback = _XDynamicRegisterIMInstantiateCallback;
+ lcd->methods->unregister_callback = _XDynamicUnRegisterIMInstantiateCallback;
+ return True;
+}
+
+static XOM
+#if NeedFunctionPrototypes
+_XDynamicOpenOM(XLCd lcd, Display *display, XrmDatabase rdb,
+ _Xconst char *res_name, _Xconst char *res_class)
+#else
+_XDynamicOpenOM(lcd, display, rdb, res_name, res_class)
+XLCd lcd;
+Display *display;
+XrmDatabase rdb;
+char *res_name;
+char *res_class;
+#endif
+{
+ XOM om = (XOM)NULL;
+ int count;
+ char *path;
+ char lc_dir[BUFSIZE];
+ char *lc_name;
+ XOM (*om_openOM)() = (XOM(*)())NULL;
+ XI18NObjectsList objects_list = xi18n_objects_list;
+#if defined(hpux)
+ int getsyms_cnt, i;
+ struct shl_symbol *symbols;
+#endif
+
+ lc_name = lcd->core->name;
+
+ if (_XlcLocaleDirName(lc_dir, lc_name) == NULL) return (XOM)0;
+
+ count = lc_count;
+ for (; count-- > 0; objects_list++) {
+ if (objects_list->type != XOM_OBJECT ||
+ strcmp(objects_list->locale_name, lc_name)) continue;
+ if (!objects_list->dl_module) {
+ path = __lc_path(objects_list->dl_name, lc_dir);
+#if defined(hpux)
+ objects_list->dl_module = shl_load(path, BIND_DEFERRED, 0L);
+#else
+ objects_list->dl_module = dlopen(path, RTLD_LAZY);
+#endif
+ Xfree(path);
+ if (!objects_list->dl_module) continue;
+ }
+#if defined(hpux)
+ getsyms_cnt = shl_getsymbols(objects_list->dl_module, TYPE_PROCEDURE,
+ EXPORT_SYMBOLS, malloc, &symbols);
+
+ for(i=0; i<getsyms_cnt; i++) {
+ if(!strcmp(symbols[i].name, objects_list->open)) {
+ om_openOM = symbols[i].value;
+ break;
+ }
+ }
+
+ if(getsyms_cnt > 0) {
+ free(symbols);
+ }
+#else
+ om_openOM = (XOM(*)())dlsym(objects_list->dl_module,
+ objects_list->open);
+ if (!om_openOM) continue;
+#endif
+ om = (*om_openOM)(lcd, display, rdb, res_name, res_class);
+ if (om != (XOM)NULL) {
+ break;
+ }
+ om_openOM = 0;
+#if defined(hpux)
+ shl_unload(objects_list->dl_module);
+#else
+ dlclose(objects_list->dl_module);
+#endif
+ objects_list->dl_module = NULL;
+ }
+ return (XOM)om;
+}
+
+Bool
+_XInitDynamicOM(lcd)
+ XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+
+ lcd->methods->open_om = _XDynamicOpenOM;
+
+ return True;
+}
diff --git a/src/xlibi18n/XlcGeneric.h b/src/xlibi18n/XlcGeneric.h
new file mode 100644
index 00000000..96f49fe8
--- /dev/null
+++ b/src/xlibi18n/XlcGeneric.h
@@ -0,0 +1,146 @@
+/* $Xorg: XlcGeneric.h,v 1.3 2000/08/17 19:45:06 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+
+#ifndef _XLCGENERIC_H_
+#define _XLCGENERIC_H_
+
+#include "XlcPubI.h"
+
+typedef struct _ByteInfo {
+ unsigned char start,end;
+} ByteInfoRec, *ByteInfo;
+
+typedef struct _ByteInfoList {
+ int M; /* 1 <= M <= length */
+ int byteinfo_num;
+ ByteInfo byteinfo;
+} ByteInfoListRec, *ByteInfoList;
+
+/* conversion_type values */
+#define LOCALCONV 1
+#define FILECONV 2
+#define FUNCTIONCONV 4
+
+typedef struct _Conversion {
+ unsigned long conversion_type;
+ int conv_num;
+ FontScope convlist;
+ char *cnv_file;
+ XlcConv cnvfunc;
+} ConversionRec, *Conversion;
+
+typedef struct _ExtdSegment {
+ char *name;
+ XlcSide side;
+ FontScope area;
+ int area_num;
+ XlcCharSet charset;
+} ExtdSegmentRec, *ExtdSegment;
+
+typedef struct _SegConvRec {
+ int length;
+ char *source_encoding;
+ XlcCharSet source;
+ char *destination_encoding;
+ XlcCharSet dest;
+ FontScopeRec range;
+ int conv_num;
+ FontScope conv;
+} SegConvRec, *SegConv;
+
+typedef struct _ParseInfoRec *ParseInfo;
+
+typedef struct _CodeSetRec {
+ XlcCharSet *charset_list;
+ int num_charsets;
+ int cs_num;
+ XlcSide side;
+ int length;
+ ByteInfoList byteM;
+ Conversion mbconv;
+ Conversion ctconv;
+ ExtdSegment ctextseg;
+ ParseInfo parse_info;
+ unsigned long wc_encoding;
+} CodeSetRec, *CodeSet;
+
+typedef enum {
+ E_GL, /* GL encoding */
+ E_GR, /* GR encoding */
+ E_SS, /* single shift */
+ E_LSL, /* locking shift left */
+ E_LSR, /* locking shift right */
+ E_LAST
+} EncodingType;
+
+typedef struct _ParseInfoRec {
+ EncodingType type;
+ char *encoding;
+ CodeSet codeset;
+} ParseInfoRec;
+
+/*
+ * XLCd private data
+ */
+
+#define XLC_GENERIC(lcd, x) (((XLCdGeneric) lcd->core)->gen.x)
+#define XLC_GENERIC_PART(lcd) (&(((XLCdGeneric) lcd->core)->gen))
+
+typedef struct _XLCdGenericPart {
+ int codeset_num;
+ CodeSet *codeset_list;
+ unsigned char *mb_parse_table;
+ int mb_parse_list_num;
+ ParseInfo *mb_parse_list;
+ unsigned long wc_encode_mask;
+ unsigned long wc_shift_bits;
+ CodeSet initial_state_GL;
+ CodeSet initial_state_GR;
+ int segment_conv_num; /* UDC */
+ SegConv segment_conv; /* UDC */
+#ifndef X_NOT_STDC_ENV
+ Bool use_stdc_env;
+ Bool force_convert_to_mb;
+#endif
+} XLCdGenericPart;
+
+typedef struct _XLCdGenericRec {
+ XLCdCoreRec core;
+ XLCdPublicPart pub;
+ XLCdGenericPart gen;
+} XLCdGenericRec, *XLCdGeneric;
+
+extern XLCdMethods _XlcGenericMethods;
+
+#endif /* _XLCGENERIC_H_ */
diff --git a/src/xlibi18n/XlcPubI.h b/src/xlibi18n/XlcPubI.h
new file mode 100644
index 00000000..0234f0f4
--- /dev/null
+++ b/src/xlibi18n/XlcPubI.h
@@ -0,0 +1,252 @@
+/* $Xorg: XlcPubI.h,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#ifndef _XLCPUBLICI_H_
+#define _XLCPUBLICI_H_
+
+#include "XlcPublic.h"
+
+#define XLC_PUBLIC(lcd, x) (((XLCdPublic) lcd->core)->pub.x)
+#define XLC_PUBLIC_PART(lcd) (&(((XLCdPublic) lcd->core)->pub))
+#define XLC_PUBLIC_METHODS(lcd) (&(((XLCdPublicMethods) lcd->methods)->pub))
+
+/*
+ * XLCd public methods
+ */
+
+typedef struct _XLCdPublicMethodsRec *XLCdPublicMethods;
+
+typedef XLCd (*XlcPubCreateProc)(
+#if NeedFunctionPrototypes
+ char* /* name */,
+ XLCdMethods /* methods */
+#endif
+);
+
+typedef Bool (*XlcPubInitializeProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+typedef void (*XlcPubDestroyProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+typedef char* (*XlcPubGetValuesProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef void (*XlcPubGetResourceProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* category */,
+ char* /* class */,
+ char*** /* value */,
+ int* /* count */
+#endif
+);
+
+typedef struct _XLCdPublicMethodsPart {
+ XLCdPublicMethods superclass;
+ XlcPubCreateProc create;
+ XlcPubInitializeProc initialize;
+ XlcPubDestroyProc destroy;
+ XlcPubGetValuesProc get_values;
+ XlcPubGetResourceProc get_resource;
+} XLCdPublicMethodsPart;
+
+typedef struct _XLCdPublicMethodsRec {
+ XLCdMethodsRec core;
+ XLCdPublicMethodsPart pub;
+} XLCdPublicMethodsRec;
+
+/*
+ * XLCd public data
+ */
+
+typedef struct _XLCdPublicPart {
+ char *siname; /* for _XlcMapOSLocaleName() */
+ char *language; /* language part of locale name */
+ char *territory; /* territory part of locale name */
+ char *codeset; /* codeset part of locale name */
+ char *encoding_name; /* encoding name */
+ int mb_cur_max; /* ANSI C MB_CUR_MAX */
+ Bool is_state_depend; /* state-depend encoding */
+ char *default_string; /* for XDefaultString() */
+ XPointer xlocale_db;
+} XLCdPublicPart;
+
+typedef struct _XLCdPublicRec {
+ XLCdCoreRec core;
+ XLCdPublicPart pub;
+} XLCdPublicRec, *XLCdPublic;
+
+extern XLCdMethods _XlcPublicMethods;
+
+_XFUNCPROTOBEGIN
+
+extern XLCd _XlcCreateLC(
+#if NeedFunctionPrototypes
+ char* /* name */,
+ XLCdMethods /* methods */
+#endif
+);
+
+extern void _XlcDestroyLC(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern Bool _XlcParseCharSet(
+#if NeedFunctionPrototypes
+ XlcCharSet /* charset */
+#endif
+);
+
+extern XlcCharSet _XlcCreateDefaultCharSet(
+#if NeedFunctionPrototypes
+ char* /* name */,
+ char* /* control_sequence */
+#endif
+);
+
+extern XlcCharSet _XlcAddCT(
+#if NeedFunctionPrototypes
+ char* /* name */,
+ char* /* control_sequence */
+#endif
+);
+
+extern XrmMethods _XrmDefaultInitParseInfo(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ XPointer* /* state */
+#endif
+);
+
+extern int _XmbTextPropertyToTextList(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ XTextProperty* /* text_prop */,
+ char*** /* list_ret */,
+ int* /* count_ret */
+#endif
+);
+
+extern int _XwcTextPropertyToTextList(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ XTextProperty* /* text_prop */,
+ wchar_t*** /* list_ret */,
+ int* /* count_ret */
+#endif
+);
+
+extern int _XmbTextListToTextProperty(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ char** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop */
+#endif
+);
+
+extern int _XwcTextListToTextProperty(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* dpy */,
+ wchar_t** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop */
+#endif
+);
+
+extern void _XwcFreeStringList(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ wchar_t** /* list */
+#endif
+);
+
+extern int _XlcResolveLocaleName(
+#if NeedFunctionPrototypes
+ char* /* lc_name */,
+ XLCdPublicPart* /* pub */
+#endif
+);
+
+extern int _XlcResolveI18NPath(
+#if NeedFunctionPrototypes
+ char* /* buf */,
+ int /* buf_len */
+#endif
+);
+
+extern char *_XlcLocaleDirName(
+#if NeedFunctionPrototypes
+ char* /* dir_name */,
+ char* /* lc_name */
+#endif
+);
+
+extern XPointer _XlcCreateLocaleDataBase(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern void _XlcDestroyLocaleDataBase(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern void _XlcGetLocaleDataBase(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* category */,
+ char* /* name */,
+ char*** /* value */,
+ int* /* count */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLCPUBLICI_H_ */
diff --git a/src/xlibi18n/XlcPublic.h b/src/xlibi18n/XlcPublic.h
new file mode 100644
index 00000000..0deb44c1
--- /dev/null
+++ b/src/xlibi18n/XlcPublic.h
@@ -0,0 +1,287 @@
+/* $Xorg: XlcPublic.h,v 1.3 2000/08/17 19:45:06 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+
+#ifndef _XLCPUBLIC_H_
+#define _XLCPUBLIC_H_
+
+#include "Xlcint.h"
+
+#define XlcNCharSize "charSize"
+#define XlcNCodeset "codeset"
+#define XlcNControlSequence "controlSequence"
+#define XlcNDefaultString "defaultString"
+#define XlcNEncodingName "encodingName"
+#define XlcNLanguage "language"
+#define XlcNMbCurMax "mbCurMax"
+#define XlcNName "name"
+#define XlcNSetSize "setSize"
+#define XlcNSide "side"
+#define XlcNStateDependentEncoding "stateDependentEncoding"
+#define XlcNTerritory "territory"
+
+typedef enum {
+ XlcUnknown, XlcC0, XlcGL, XlcC1, XlcGR, XlcGLGR, XlcOther, XlcNONE
+} XlcSide;
+
+typedef struct _FontScope {
+ unsigned long start;
+ unsigned long end;
+ unsigned long shift;
+ unsigned long shift_direction;
+} FontScopeRec, *FontScope;
+
+typedef struct _UDCArea {
+ unsigned long start,end;
+} UDCAreaRec, *UDCArea;
+
+typedef struct _XlcCharSetRec *XlcCharSet;
+
+typedef char* (*XlcGetCSValuesProc)(
+#if NeedFunctionPrototypes
+ XlcCharSet /* charset */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef struct _XlcCharSetRec {
+ char *name; /* character set name */
+ XrmQuark xrm_name;
+ char *encoding_name; /* XLFD encoding name */
+ XrmQuark xrm_encoding_name;
+ XlcSide side; /* GL, GR or others */
+ int char_size; /* number of bytes per character */
+ int set_size; /* graphic character sets */
+ char *ct_sequence; /* control sequence of CT */
+ XlcGetCSValuesProc get_values;
+ /* UDC */
+ Bool string_encoding;
+ UDCArea udc_area;
+ int udc_area_num;
+} XlcCharSetRec;
+
+/*
+ * conversion methods
+ */
+
+typedef struct _XlcConvRec *XlcConv;
+
+typedef XlcConv (*XlcOpenConverterProc)(
+#if NeedFunctionPrototypes
+ XLCd /* from_lcd */,
+ char* /* from_type */,
+ XLCd /* to_lcd */,
+ char* /* to_type */
+#endif
+);
+
+typedef void (*XlcCloseConverterProc)(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */
+#endif
+);
+
+typedef int (*XlcConvertProc)(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */,
+ XPointer* /* from */,
+ int* /* from_left */,
+ XPointer* /* to */,
+ int* /* to_left */,
+ XPointer* /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef void (*XlcResetConverterProc)(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */
+#endif
+);
+
+typedef struct _XlcConvMethodsRec{
+ XlcCloseConverterProc close;
+ XlcConvertProc convert;
+ XlcResetConverterProc reset;
+} XlcConvMethodsRec, *XlcConvMethods;
+
+/*
+ * conversion data
+ */
+
+#define XlcNMultiByte "multiByte"
+#define XlcNWideChar "wideChar"
+#define XlcNCompoundText "compoundText"
+#define XlcNString "string"
+#define XlcNCharSet "charSet"
+#define XlcNCTCharSet "CTcharSet"
+#define XlcNChar "char"
+
+typedef struct _XlcConvRec {
+ XlcConvMethods methods;
+ XPointer state;
+} XlcConvRec;
+
+
+_XFUNCPROTOBEGIN
+
+extern Bool _XInitOM(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern Bool _XInitIM(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern char *_XGetLCValues(
+#if NeedVarargsPrototypes
+ XLCd /* lcd */,
+ ...
+#endif
+);
+
+extern XlcCharSet _XlcGetCharSet(
+#if NeedFunctionPrototypes
+ char* /* name */
+#endif
+);
+
+extern Bool _XlcAddCharSet(
+#if NeedFunctionPrototypes
+ XlcCharSet /* charset */
+#endif
+);
+
+extern char *_XlcGetCSValues(
+#if NeedVarargsPrototypes
+ XlcCharSet /* charset */,
+ ...
+#endif
+);
+
+extern XlcConv _XlcOpenConverter(
+#if NeedFunctionPrototypes
+ XLCd /* from_lcd */,
+ char* /* from_type */,
+ XLCd /* to_lcd */,
+ char* /* to_type */
+#endif
+);
+
+extern void _XlcCloseConverter(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */
+#endif
+);
+
+extern int _XlcConvert(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */,
+ XPointer* /* from */,
+ int* /* from_left */,
+ XPointer* /* to */,
+ int* /* to_left */,
+ XPointer* /* args */,
+ int /* num_args */
+#endif
+);
+
+extern void _XlcResetConverter(
+#if NeedFunctionPrototypes
+ XlcConv /* conv */
+#endif
+);
+
+extern Bool _XlcSetConverter(
+#if NeedFunctionPrototypes
+ XLCd /* from_lcd */,
+ char* /* from_type */,
+ XLCd /* to_lcd */,
+ char* /* to_type */,
+ XlcOpenConverterProc /* open_converter */
+#endif
+);
+
+extern void _XlcGetResource(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* category */,
+ char* /* class */,
+ char*** /* value */,
+ int* /* count */
+#endif
+);
+
+extern char *_XlcFileName(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* category */
+#endif
+);
+
+extern int _Xwcslen(
+#if NeedFunctionPrototypes
+ wchar_t* /* wstr */
+#endif
+);
+
+extern wchar_t *_Xwcscpy(
+#if NeedFunctionPrototypes
+ wchar_t* /* wstr1 */,
+ wchar_t* /* wstr2 */
+#endif
+);
+
+extern int _XlcCompareISOLatin1(
+#if NeedFunctionPrototypes
+ char* /* str1 */,
+ char* /* str2 */
+#endif
+);
+
+extern int _XlcNCompareISOLatin1(
+#if NeedFunctionPrototypes
+ char* /* str1 */,
+ char* /* str2 */,
+ int /* len */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLCPUBLIC_H_ */
diff --git a/src/xlibi18n/XlcSL.c b/src/xlibi18n/XlcSL.c
new file mode 100644
index 00000000..12391b1d
--- /dev/null
+++ b/src/xlibi18n/XlcSL.c
@@ -0,0 +1,79 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: The above copyright notice and this
+permission notice shall be included in all copies or substantial
+portions of the Software.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without prior
+written authorization from The Open Group and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+extern XIM _XDefaultOpenIM(
+#if NeedNestedPrototypes
+ XLCd, Display *, XrmDatabase, char *, char *
+#endif
+ );
+
+Bool
+_XInitDefaultIM(lcd)
+XLCd lcd;
+{
+ if(lcd == (XLCd)NULL)
+ return False;
+
+ lcd->methods->open_im = _XDefaultOpenIM;
+ lcd->methods->register_callback = NULL;
+ lcd->methods->unregister_callback = NULL;
+ return True;
+}
+
+extern XOM _XDefaultOpenOM(
+#if NeedFunctionPrototypes
+ XLCd, Display*, XrmDatabase, _Xconst char*, _Xconst char*
+#endif
+ );
+
+Bool
+_XInitDefaultOM(lcd)
+ XLCd lcd;
+{
+ lcd->methods->open_om = _XDefaultOpenOM;
+ return True;
+}
diff --git a/src/xlibi18n/Xlcint.h b/src/xlibi18n/Xlcint.h
new file mode 100644
index 00000000..60041e7e
--- /dev/null
+++ b/src/xlibi18n/Xlcint.h
@@ -0,0 +1,1003 @@
+/* $Xorg: Xlcint.h,v 1.4 2001/02/09 02:03:38 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Copyright 1990, 1991 by OMRON Corporation, NTT Software Corporation,
+ * and Nippon Telegraph and Telephone Corporation
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the TOSHIBA Corp.
+ * Copyright 1993, 1994 by Sony Corporation
+ * Copyright 1993, 1994 by the FUJITSU LIMITED
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 names of OMRON, NTT Software, NTT, Open
+ * Software Foundation, and Sony Corporation not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. OMRON, NTT Software, NTT, Open Software
+ * Foundation, and Sony Corporation make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, AND SONY
+ * CORPORATION DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT
+ * SHALL OMRON, NTT SOFTWARE, NTT, OPEN SOFTWARE FOUNDATION, OR SONY
+ * CORPORATION 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.
+ *
+ * Authors: Li Yuhong OMRON Corporation
+ * Tatsuya Kato NTT Software Corporation
+ * Hiroshi Kuribayashi OMRON Coproration
+ * Muneiyoshi Suzuki Nippon Telegraph and Telephone Co.
+ *
+ * M. Collins OSF
+ * Katsuhisa Yano TOSHIBA Corp.
+ * Makoto Wakamatsu Sony Corporation
+ * Takashi Fujiwara FUJITSU LIMITED
+ */
+
+
+#ifndef _XLCINT_H_
+#define _XLCINT_H_
+
+#include <X11/Xresource.h>
+#include <X11/Xutil.h>
+#include "Xvarargs.h"
+
+typedef Bool (*XFilterEventProc)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+#endif
+);
+
+typedef struct _XIMFilter {
+ struct _XIMFilter *next;
+ Window window;
+ unsigned long event_mask;
+ int start_type, end_type;
+ XFilterEventProc filter;
+ XPointer client_data;
+} XFilterEventRec, *XFilterEventList;
+
+typedef struct {
+ char *name;
+ XPointer value;
+} XIMArg;
+
+#ifdef offsetof
+#define XOffsetOf(s_type,field) offsetof(s_type,field)
+#else
+#define XOffsetOf(s_type,field) ((unsigned int)&(((s_type*)NULL)->field))
+#endif
+
+#define XIMNumber(arr) ((unsigned int) (sizeof(arr) / sizeof(arr[0])))
+
+/*
+ * define secondary data structs which are part of Input Methods
+ * and Input Context
+ */
+typedef struct {
+ char *resource_name; /* Resource string */
+ XrmQuark xrm_name; /* Resource name quark */
+ int resource_size; /* Size in bytes of data */
+ long resource_offset; /* Offset from base */
+ unsigned short mode; /* Read Write Permission */
+ unsigned short id; /* Input Method Protocol */
+} XIMResource, *XIMResourceList;
+
+/*
+ * data block describing the visual attributes associated with
+ * an input context
+ */
+typedef struct {
+ XRectangle area;
+ XRectangle area_needed;
+ XPoint spot_location;
+ Colormap colormap;
+ Atom std_colormap;
+ unsigned long foreground;
+ unsigned long background;
+ Pixmap background_pixmap;
+ XFontSet fontset;
+ int line_spacing;
+ Cursor cursor;
+ XIMCallback start_callback;
+ XIMCallback done_callback;
+ XIMCallback draw_callback;
+ XIMCallback caret_callback;
+ XIMPreeditState preedit_state;
+ XIMCallback state_notify_callback;
+} ICPreeditAttributes, *ICPreeditAttributesPtr;
+
+typedef struct {
+ XRectangle area;
+ XRectangle area_needed;
+ Colormap colormap;
+ Atom std_colormap;
+ unsigned long foreground;
+ unsigned long background;
+ Pixmap background_pixmap;
+ XFontSet fontset;
+ int line_spacing;
+ Cursor cursor;
+ XIMCallback start_callback;
+ XIMCallback done_callback;
+ XIMCallback draw_callback;
+} ICStatusAttributes, *ICStatusAttributesPtr;
+
+/*
+ * Methods for Xrm parsing
+ */
+
+typedef void (*XmbInitProc)(
+#if NeedFunctionPrototypes
+ XPointer /* state */
+#endif
+);
+
+typedef char (*XmbCharProc)(
+#if NeedFunctionPrototypes
+ XPointer /* state */,
+ char* /* str */,
+ int* /* lenp */
+#endif
+);
+
+typedef void (*XmbFinishProc)(
+#if NeedFunctionPrototypes
+ XPointer /* state */
+#endif
+);
+
+typedef char* (*XlcNameProc)(
+#if NeedFunctionPrototypes
+ XPointer /* state */
+#endif
+);
+
+typedef void (*XrmDestroyProc)(
+#if NeedFunctionPrototypes
+ XPointer /* state */
+#endif
+);
+
+typedef struct {
+ XmbInitProc mbinit;
+ XmbCharProc mbchar;
+ XmbFinishProc mbfinish;
+ XlcNameProc lcname;
+ XrmDestroyProc destroy;
+} XrmMethodsRec, *XrmMethods;
+
+typedef struct _XLCd *XLCd; /* need forward reference */
+
+/*
+ * define an LC, it's methods, and data.
+ */
+
+typedef void (*XCloseLCProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+typedef char* (*XlcMapModifiersProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* user_mods */,
+ char* /* prog_mods */
+#endif
+);
+
+typedef XOM (*XOpenOMProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ _Xconst char* /* res_name */,
+ _Xconst char* /* res_class */
+#endif
+);
+
+typedef XIM (*XOpenIMProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */
+#endif
+);
+
+typedef Bool (*XRegisterIMInstantiateCBProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIMProc /* callback */,
+ XPointer* /* client_data */
+#endif
+);
+
+typedef Bool (*XUnregisterIMInstantiateCBProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XrmDatabase /* rdb */,
+ char* /* res_name */,
+ char* /* res_class */,
+ XIMProc /* callback */,
+ XPointer* /* client_data */
+#endif
+);
+
+typedef XrmMethods (*XrmInitParseInfoProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ XPointer* /* state */
+#endif
+);
+
+typedef int (*XmbTextPropertyToTextListProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XTextProperty* /* text_prop */,
+ char*** /* list_return */,
+ int* /* count_return */
+#endif
+);
+
+typedef int (*XwcTextPropertyToTextListProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ XTextProperty* /* text_prop */,
+ wchar_t*** /* list_return */,
+ int* /* count_return */
+#endif
+);
+
+typedef int (*XmbTextListToTextPropertyProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ char** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+typedef int (*XwcTextListToTextPropertyProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ Display* /* display */,
+ wchar_t** /* list */,
+ int /* count */,
+ XICCEncodingStyle /* style */,
+ XTextProperty* /* text_prop_return */
+#endif
+);
+
+typedef void (*XwcFreeStringListProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ wchar_t** /* list */
+#endif
+);
+
+typedef char* (*XDefaultStringProc)(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+typedef struct {
+ XCloseLCProc close;
+ XlcMapModifiersProc map_modifiers;
+ XOpenOMProc open_om;
+ XOpenIMProc open_im;
+ XrmInitParseInfoProc init_parse_info;
+ XmbTextPropertyToTextListProc mb_text_prop_to_list;
+ XwcTextPropertyToTextListProc wc_text_prop_to_list;
+ XmbTextListToTextPropertyProc mb_text_list_to_prop;
+ XwcTextListToTextPropertyProc wc_text_list_to_prop;
+ XwcFreeStringListProc wc_free_string_list;
+ XDefaultStringProc default_string;
+ XRegisterIMInstantiateCBProc register_callback;
+ XUnregisterIMInstantiateCBProc unregister_callback;
+} XLCdMethodsRec, *XLCdMethods;
+
+
+typedef struct {
+ char* name; /* name of this LC */
+ char* modifiers; /* modifiers of locale */
+} XLCdCoreRec, *XLCdCore;
+
+
+typedef struct _XLCd {
+ XLCdMethods methods; /* methods of this LC */
+ XLCdCore core; /* data of this LC */
+ XPointer opaque; /* LDX specific data */
+} XLCdRec;
+
+typedef int XlcPosition;
+
+#define XlcHead 0
+#define XlcTail -1
+
+typedef struct {
+ char *name;
+ XPointer value;
+} XlcArg, *XlcArgList;
+
+typedef struct _XlcResource {
+ char *name;
+ XrmQuark xrm_name;
+ int size;
+ int offset;
+ unsigned long mask;
+} XlcResource, *XlcResourceList;
+
+#define XlcCreateMask (1L<<0)
+#define XlcDefaultMask (1L<<1)
+#define XlcGetMask (1L<<2)
+#define XlcSetMask (1L<<3)
+#define XlcIgnoreMask (1L<<4)
+
+#define XlcNumber(arr) (sizeof(arr) / sizeof(arr[0]))
+
+typedef Status (*XCloseOMProc)(
+#if NeedFunctionPrototypes
+ XOM /* om */
+#endif
+);
+
+typedef char* (*XSetOMValuesProc)(
+#if NeedFunctionPrototypes
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef char* (*XGetOMValuesProc)(
+#if NeedFunctionPrototypes
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef XOC (*XCreateOCProc)(
+#if NeedFunctionPrototypes
+ XOM /* om */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef struct _XOMMethodsRec {
+ XCloseOMProc close;
+ XSetOMValuesProc set_values;
+ XGetOMValuesProc get_values;
+ XCreateOCProc create_oc;
+} XOMMethodsRec, *XOMMethods;
+
+typedef struct _XOMCoreRec {
+ XLCd lcd; /* lcd */
+ Display *display; /* display */
+ XrmDatabase rdb; /* database */
+ char *res_name; /* resource name */
+ char *res_class; /* resource class */
+ XOC oc_list; /* xoc list */
+ XlcResourceList resources; /* xom resources */
+ int num_resources; /* number of xom resources */
+ XOMCharSetList required_charset; /* required charset list */
+ XOMOrientation orientation_list; /* orientation list */
+ Bool directional_dependent; /* directional-dependent */
+ Bool contextual_drawing; /* contextual drawing */
+ Bool context_dependent; /* context-dependent drawing */
+} XOMCoreRec, *XOMCore;
+
+typedef struct _XOM {
+ XOMMethods methods;
+ XOMCoreRec core;
+} XOMRec;
+
+typedef void (*XDestroyOCProc)(
+#if NeedFunctionPrototypes
+ XOC /* oc */
+#endif
+);
+
+typedef char* (*XSetOCValuesProc)(
+#if NeedFunctionPrototypes
+ XOC /* oc */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+typedef char* (*XGetOCValuesProc)(
+#if NeedFunctionPrototypes
+ XOC /* oc */,
+ XlcArgList /* args */,
+ int /* num_args */
+#endif
+);
+
+/*
+ * X Font Sets are an instantiable object, so we define it, the
+ * object itself, a method list and data
+ */
+
+/*
+ * XFontSet object method list
+ */
+
+typedef int (*XmbTextEscapementProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef int (*XmbTextExtentsProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */,
+ XRectangle* /* overall_ink_extents */,
+ XRectangle* /* overall_logical_extents */
+#endif
+);
+
+typedef Status (*XmbTextPerCharExtentsProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst char* /* text */,
+ int /* text_len */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* max_ink_extents */,
+ XRectangle* /* max_logical_extents */
+#endif
+);
+
+typedef int (*XmbDrawStringProc)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef void (*XmbDrawImageStringProc)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst char* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef int (*XwcTextEscapementProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef int (*XwcTextExtentsProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */,
+ XRectangle* /* overall_ink_extents */,
+ XRectangle* /* overall_logical_extents */
+#endif
+);
+
+typedef Status (*XwcTextPerCharExtentsProc)(
+#if NeedFunctionPrototypes
+ XFontSet /* font_set */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */,
+ XRectangle* /* ink_extents_buffer */,
+ XRectangle* /* logical_extents_buffer */,
+ int /* buffer_size */,
+ int* /* num_chars */,
+ XRectangle* /* max_ink_extents */,
+ XRectangle* /* max_logical_extents */
+#endif
+);
+
+typedef int (*XwcDrawStringProc)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef void (*XwcDrawImageStringProc)(
+#if NeedFunctionPrototypes
+ Display* /* display */,
+ Drawable /* drawable */,
+ XFontSet /* font_set */,
+ GC /* gc */,
+ int /* x */,
+ int /* y */,
+ _Xconst wchar_t* /* text */,
+ int /* text_len */
+#endif
+);
+
+typedef struct {
+ XDestroyOCProc destroy;
+ XSetOCValuesProc set_values;
+ XGetOCValuesProc get_values;
+
+ /* multi-byte text drawing methods */
+
+ XmbTextEscapementProc mb_escapement;
+ XmbTextExtentsProc mb_extents;
+ XmbTextPerCharExtentsProc mb_extents_per_char;
+ XmbDrawStringProc mb_draw_string;
+ XmbDrawImageStringProc mb_draw_image_string;
+
+ /* wide character text drawing methods */
+
+ XwcTextEscapementProc wc_escapement;
+ XwcTextExtentsProc wc_extents;
+ XwcTextPerCharExtentsProc wc_extents_per_char;
+ XwcDrawStringProc wc_draw_string;
+ XwcDrawImageStringProc wc_draw_image_string;
+} XOCMethodsRec, *XOCMethods;
+
+
+/*
+ * XOC independent data
+ */
+
+typedef struct {
+ XOM om; /* XOM */
+ XOC next; /* next XOC */
+ XlcResourceList resources; /* xoc resources */
+ int num_resources; /* number of xoc resources */
+ char *base_name_list; /* base font name list */
+ Bool om_automatic; /* OM Automatic */
+ XOMFontInfo font_info; /* font info */
+ XFontSetExtents font_set_extents; /* font set extents */
+ char *default_string; /* default string */
+ XOMCharSetList missing_list; /* missing charset list */
+ XOrientation orientation; /* orientation */
+ char *res_name; /* resource name */
+ char *res_class; /* resource class */
+} XOCCoreRec, *XOCCore;
+
+typedef struct _XOC {
+ XOCMethods methods;
+ XOCCoreRec core;
+} XOCRec;
+
+
+/* current Ultrix compiler gets horribly confused */
+#if defined(FUNCPROTO) && defined(ultrix)
+#undef NeedFunctionPrototypes
+#endif
+
+
+/*
+ * X Input Managers are an instantiable object, so we define it, the
+ * object itself, a method list and data.
+ */
+
+/*
+ * an Input Manager object method list
+ */
+typedef struct {
+ Status (*close)(
+#if NeedFunctionPrototypes
+ XIM
+#endif
+ );
+ char* (*set_values)(
+#if NeedFunctionPrototypes
+ XIM, XIMArg*
+#endif
+ );
+ char* (*get_values)(
+#if NeedFunctionPrototypes
+ XIM, XIMArg*
+#endif
+ );
+ XIC (*create_ic)(
+#if NeedFunctionPrototypes
+ XIM, XIMArg*
+#endif
+ );
+ int (*ctstombs)(
+#if NeedFunctionPrototypes
+ XIM, char*, int, char*, int, Status *
+#endif
+ );
+ int (*ctstowcs)(
+#if NeedFunctionPrototypes
+ XIM, char*, int, wchar_t*, int, Status *
+#endif
+ );
+} XIMMethodsRec, *XIMMethods;
+
+/*
+ * Input Manager LC independent data
+ */
+typedef struct {
+ XLCd lcd; /* LC of this input method */
+ XIC ic_chain; /* list of ICs for this IM */
+
+ Display * display; /* display */
+ XrmDatabase rdb;
+ char * res_name;
+ char * res_class;
+
+ XIMValuesList *im_values_list;
+ XIMValuesList *ic_values_list;
+ XIMStyles *styles;
+ XIMCallback destroy_callback;
+ char * im_name; /* XIMMODIFIER name */
+ XIMResourceList im_resources; /* compiled IM resource list */
+ unsigned int im_num_resources;
+ XIMResourceList ic_resources; /* compiled IC resource list */
+ unsigned int ic_num_resources;
+ Bool visible_position;
+} XIMCoreRec, *XIMCore;
+
+
+
+/*
+ * An X Input Manager (IM). Implementations may need to extend this data
+ * structure to accomodate additional data, state information etc.
+ */
+typedef struct _XIM {
+ XIMMethods methods; /* method list of this IM */
+ XIMCoreRec core; /* data of this IM */
+} XIMRec;
+
+
+
+/*
+ * X Input Contexts (IC) are an instantiable object, so we define it, the
+ * object itself, a method list and data for this object
+ */
+
+/*
+ * Input Context method list
+ */
+typedef struct {
+ void (*destroy)(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+ );
+ void (*set_focus)(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+ );
+ void (*unset_focus)(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+ );
+ char* (*set_values)(
+#if NeedFunctionPrototypes
+ XIC, XIMArg*
+#endif
+ );
+ char* (*get_values)(
+#if NeedFunctionPrototypes
+ XIC, XIMArg*
+#endif
+ );
+ char* (*mb_reset)(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+ );
+ wchar_t* (*wc_reset)(
+#if NeedFunctionPrototypes
+ XIC
+#endif
+ );
+ int (*mb_lookup_string)(
+#if NeedFunctionPrototypes
+ XIC, XKeyEvent*, char*, int, KeySym*, Status*
+#endif
+ );
+ int (*wc_lookup_string)(
+#if NeedFunctionPrototypes
+ XIC, XKeyEvent*, wchar_t*, int, KeySym*, Status*
+#endif
+ );
+} XICMethodsRec, *XICMethods;
+
+
+/*
+ * Input Context LC independent data
+ */
+typedef struct {
+ XIM im; /* XIM this IC belongs too */
+ XIC next; /* linked list of ICs for IM */
+
+ Window client_window; /* window IM can use for */
+ /* display or subwindows */
+ XIMStyle input_style; /* IM's input style */
+ Window focus_window; /* where key events go */
+ unsigned long filter_events; /* event mask from IM */
+ XIMCallback geometry_callback; /* client callback */
+ char * res_name;
+ char * res_class;
+
+ XIMCallback destroy_callback;
+ XIMCallback string_conversion_callback;
+ XIMStringConversionText string_conversion;
+ XIMResetState reset_state;
+ XIMHotKeyTriggers *hotkey;
+ XIMHotKeyState hotkey_state;
+
+ ICPreeditAttributes preedit_attr; /* visuals of preedit area */
+ ICStatusAttributes status_attr; /* visuals of status area */
+} XICCoreRec, *XICCore;
+
+
+/*
+ * an Input Context. Implementations may need to extend this data
+ * structure to accomodate additional data, state information etc.
+ */
+typedef struct _XIC {
+ XICMethods methods; /* method list of this IC */
+ XICCoreRec core; /* data of this IC */
+} XICRec;
+
+/* current Ultrix compiler gets horribly confused */
+#if !defined(NeedFunctionPrototypes) && defined(FUNCPROTO)
+#define NeedFunctionPrototypes 1
+#endif
+
+typedef XLCd (*XLCdLoadProc)(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+
+_XFUNCPROTOBEGIN
+
+extern XLCd _XOpenLC(
+#if NeedFunctionPrototypes
+ char* /* name */
+#endif
+);
+
+extern void _XCloseLC(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */
+#endif
+);
+
+extern XLCd _XlcCurrentLC(
+#if NeedFunctionPrototypes
+ void
+#endif
+);
+
+extern Bool _XlcValidModSyntax(
+#if NeedFunctionPrototypes
+ char* /* mods */,
+ char** /* valid */
+#endif
+);
+
+extern char *_XlcDefaultMapModifiers(
+#if NeedFunctionPrototypes
+ XLCd /* lcd */,
+ char* /* user_mods */,
+ char* /* prog_mods */
+#endif
+);
+
+extern void _XIMCompileResourceList(
+#if NeedFunctionPrototypes
+ XIMResourceList /* res */,
+ unsigned int /* num_res */
+#endif
+);
+
+extern void _XCopyToArg(
+#if NeedFunctionPrototypes
+ XPointer /* src */,
+ XPointer* /* dst */,
+ unsigned int /* size */
+#endif
+);
+
+extern char ** _XParseBaseFontNameList(
+#if NeedFunctionPrototypes
+ char* /* str */,
+ int* /* num */
+#endif
+);
+
+extern XrmMethods _XrmInitParseInfo(
+#if NeedFunctionPrototypes
+ XPointer* /* statep */
+#endif
+);
+
+extern void _XRegisterFilterByMask(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* window */,
+ unsigned long /* event_mask */,
+ Bool (*)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+#endif
+ ) /* filter */,
+ XPointer /* client_data */
+#endif
+);
+
+extern void _XRegisterFilterByType(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* window */,
+ int /* start_type */,
+ int /* end_type */,
+ Bool (*)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+#endif
+ ) /* filter */,
+ XPointer /* client_data */
+#endif
+);
+
+extern void _XUnregisterFilter(
+#if NeedFunctionPrototypes
+ Display* /* dpy */,
+ Window /* window */,
+ Bool (*)(
+#if NeedNestedPrototypes
+ Display* /* display */,
+ Window /* window */,
+ XEvent* /* event */,
+ XPointer /* client_data */
+#endif
+ ) /* filter */,
+ XPointer /* client_data */
+#endif
+);
+
+extern void _XlcCountVaList(
+#if NeedFunctionPrototypes
+ va_list /* var */,
+ int* /* count_return */
+#endif
+);
+
+extern void _XlcVaToArgList(
+#if NeedFunctionPrototypes
+ va_list /* var */,
+ int /* count */,
+ XlcArgList* /* args_return */
+#endif
+);
+
+extern void _XlcCompileResourceList(
+#if NeedFunctionPrototypes
+ XlcResourceList /* resources */,
+ int /* num_resources */
+#endif
+);
+
+extern char *_XlcGetValues(
+#if NeedFunctionPrototypes
+ XPointer /* base */,
+ XlcResourceList /* resources */,
+ int /* num_resources */,
+ XlcArgList /* args */,
+ int /* num_args */,
+ unsigned long /* mask */
+#endif
+);
+
+extern char *_XlcSetValues(
+#if NeedFunctionPrototypes
+ XPointer /* base */,
+ XlcResourceList /* resources */,
+ int /* num_resources */,
+ XlcArgList /* args */,
+ int /* num_args */,
+ unsigned long /* mask */
+#endif
+);
+
+extern Bool _XlcAddLoader(
+#if NeedFunctionPrototypes
+ XLCdLoadProc /* proc */,
+ XlcPosition /* position */
+#endif
+);
+
+extern void _XlcRemoveLoader(
+#if NeedFunctionPrototypes
+ XLCdLoadProc /* proc */
+#endif
+);
+
+_XFUNCPROTOEND
+
+#endif /* _XLCINT_H_ */
diff --git a/src/xlibi18n/lcCT.c b/src/xlibi18n/lcCT.c
new file mode 100644
index 00000000..5dd2ddcc
--- /dev/null
+++ b/src/xlibi18n/lcCT.c
@@ -0,0 +1,909 @@
+/* $Xorg: lcCT.c,v 1.4 2000/08/17 19:45:16 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xos.h>
+#include <stdio.h>
+
+typedef struct _StateRec {
+ XlcCharSet charset;
+ XlcCharSet GL_charset;
+ XlcCharSet GR_charset;
+ XlcCharSet ext_seg_charset;
+ int ext_seg_left;
+} StateRec, *State;
+
+typedef struct _CTDataRec {
+ char *name;
+ char *encoding; /* Compound Text encoding */
+} CTDataRec, *CTData;
+
+typedef struct _CTInfoRec {
+ XlcCharSet charset;
+ int encoding_len;
+ char *encoding; /* Compound Text encoding */
+ int ext_segment_len;
+ char *ext_segment; /* extended segment */
+ struct _CTInfoRec *next;
+} CTInfoRec, *CTInfo;
+
+static CTDataRec default_ct_data[] =
+{
+ { "ISO8859-1:GL", "\033(B" },
+ { "ISO8859-1:GR", "\033-A" },
+ { "ISO8859-2:GR", "\033-B" },
+ { "ISO8859-3:GR", "\033-C" },
+ { "ISO8859-4:GR", "\033-D" },
+ { "ISO8859-7:GR", "\033-F" },
+ { "ISO8859-6:GR", "\033-G" },
+ { "ISO8859-8:GR", "\033-H" },
+ { "ISO8859-5:GR", "\033-L" },
+ { "ISO8859-9:GR", "\033-M" },
+ { "ISO8859-10:GR", "\033-V" },
+ { "JISX0201.1976-0:GL", "\033(J" },
+ { "JISX0201.1976-0:GR", "\033)I" },
+
+ { "GB2312.1980-0:GL", "\033$(A" },
+ { "GB2312.1980-0:GR", "\033$)A" },
+ { "JISX0208.1983-0:GL", "\033$(B" },
+ { "JISX0208.1983-0:GR", "\033$)B" },
+ { "KSC5601.1987-0:GL", "\033$(C" },
+ { "KSC5601.1987-0:GR", "\033$)C" },
+#ifdef notdef
+ { "JISX0212.1990-0:GL", "\033$(D" },
+ { "JISX0212.1990-0:GR", "\033$)D" },
+ { "CNS11643.1986-1:GL", "\033$(G" },
+ { "CNS11643.1986-1:GR", "\033$)G" },
+ { "CNS11643.1986-2:GL", "\033$(H" },
+ { "CNS11643.1986-2:GR", "\033$)H" },
+#endif
+ { "TIS620.2533-1:GR", "\033-T"},
+ { "ISO10646-1", "\033%B"},
+ /* Non-Standard Character Set Encodings */
+ { "KOI8-R:GR", "\033%/1\200\210koi8-r\002"},
+ { "FCD8859-15:GR", "\033%/1\200\213fcd8859-15\002"},
+} ;
+
+#define XctC0 0x0000
+#define XctHT 0x0009
+#define XctNL 0x000a
+#define XctESC 0x001b
+#define XctGL 0x0020
+#define XctC1 0x0080
+#define XctCSI 0x009b
+#define XctGR 0x00a0
+
+#define XctCntrlFunc 0x0023
+#define XctMB 0x0024
+#define XctOtherCoding 0x0025
+#define XctGL94 0x0028
+#define XctGR94 0x0029
+#define XctGR96 0x002d
+#define XctNonStandard 0x002f
+#define XctIgnoreExt 0x0030
+#define XctNotIgnoreExt 0x0031
+#define XctLeftToRight 0x0031
+#define XctRightToLeft 0x0032
+#define XctDirection 0x005d
+#define XctDirectionEnd 0x005d
+
+#define XctGL94MB 0x2428
+#define XctGR94MB 0x2429
+#define XctExtSeg 0x252f
+#define XctOtherSeg 0x2f00
+
+#define XctESCSeq 0x1b00
+#define XctCSISeq 0x9b00
+
+#define SKIP_I(str) while (*(str) >= 0x20 && *(str) <= 0x2f) (str)++;
+#define SKIP_P(str) while (*(str) >= 0x30 && *(str) <= 0x3f) (str)++;
+
+typedef struct {
+ XlcSide side;
+ int char_size;
+ int set_size;
+ int ext_seg_length;
+ int version;
+ CTInfo ct_info;
+} CTParseRec, *CTParse;
+
+CTDataRec *default_ct_data_list()
+{
+ return(default_ct_data);
+}
+
+size_t default_ct_data_list_num()
+{
+ size_t num = sizeof(default_ct_data) / sizeof(CTDataRec);
+ return(num);
+}
+
+static CTInfo ct_list = NULL;
+
+static CTInfo
+_XlcGetCTInfoFromEncoding(encoding, length)
+ register char *encoding;
+ register int length;
+{
+ register CTInfo ct_info;
+
+ for (ct_info = ct_list; ct_info; ct_info = ct_info->next) {
+ if (length >= ct_info->encoding_len) {
+ if (ct_info->ext_segment) {
+ if (!strncmp(ct_info->encoding, encoding, 4) &&
+ !strncmp(ct_info->ext_segment, encoding + 6,
+ ct_info->ext_segment_len))
+ return ct_info;
+ } else if (!strncmp(ct_info->encoding, encoding,
+ ct_info->encoding_len)) {
+ return ct_info;
+ }
+ }
+ }
+
+ return (CTInfo) NULL;
+}
+
+static unsigned int
+_XlcParseCT(parse, text, length)
+ register CTParse parse;
+ char **text;
+ int *length;
+{
+ unsigned int ret = 0;
+ unsigned char ch;
+ register unsigned char *str = (unsigned char *) *text;
+
+ bzero((char *) parse, sizeof(CTParseRec));
+
+ switch (ch = *str++) {
+ case XctESC:
+ if (*str == XctOtherCoding && *(str + 1) == XctNonStandard
+ && *(str + 2) >= 0x30 && *(str + 2) <= 0x3f && *length >= 6) {
+
+ /* non-standard encodings */
+ parse->side = XlcGLGR;
+ parse->set_size = 0;
+ str += 2;
+ if (*str <= 0x34) {
+ parse->char_size = *str - 0x30;
+ if (parse->char_size == 0) parse->char_size = 1;
+ ret = XctExtSeg;
+ parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length);
+ } else
+ ret = XctOtherSeg;
+ str++;
+ parse->ext_seg_length = (*str - 128) * 128 + *(str + 1) - 128;
+ str += 2;
+
+ goto done;
+ } else if (*str == XctCntrlFunc && *length >= 4 &&
+ *(str + 1) >= 0x20 && *(str + 1) <= 0x2f &&
+ (*(str + 2) == XctIgnoreExt ||
+ *(str + 2) == XctNotIgnoreExt)) {
+
+ /* ignore extension or not */
+ str++;
+ parse->version = *str++ - 0x20;
+ ret = *str++;
+
+ goto done;
+ }
+
+ if (*str == XctMB) { /* multiple-byte sets */
+ parse->char_size = 2;
+ str++;
+ } else
+ parse->char_size = 1;
+
+ switch (*str) {
+ case XctGL94:
+ parse->side = XlcGL;
+ parse->set_size = 94;
+ ret = (parse->char_size == 1) ? XctGL94 : XctGL94MB;
+ break;
+ case XctGR94:
+ parse->side = XlcGR;
+ parse->set_size = 94;
+ ret = (parse->char_size == 1) ? XctGR94 : XctGR94MB;
+ break;
+ case XctGR96:
+ if (parse->char_size == 1) {
+ parse->side = XlcGR;
+ parse->set_size = 96;
+ ret = XctGR96;
+ }
+ break;
+ }
+ if (ret) {
+ str++;
+ if (*str >= 0x24 && *str <= 0x2f) { /* non-standard */
+ ret = 0;
+ str++;
+ }
+ }
+
+ SKIP_I(str)
+
+ if (ret && *str < 0x40) /* non-standard */
+ ret = 0;
+
+ if (*str < 0x30 || *str > 0x7e || (char *) str - *text >= *length)
+ break;
+
+ if (ret == 0)
+ ret = XctESCSeq;
+ else {
+ if (parse->char_size == 2) {
+ if (*str >= 0x70)
+ parse->char_size = 4;
+ else if (*str >= 0x60)
+ parse->char_size = 3;
+ }
+ parse->ct_info = _XlcGetCTInfoFromEncoding(*text, *length);
+ }
+ str++;
+ goto done;
+ case XctCSI:
+ /* direction */
+ if (*str == XctLeftToRight && *(str + 1) == XctDirection) {
+ ret = XctLeftToRight;
+ str += 2;
+ goto done;
+ } else if (*str == XctRightToLeft && *(str + 1) == XctDirection) {
+ ret = XctRightToLeft;
+ str += 2;
+ goto done;
+ } else if (*str == XctDirectionEnd) {
+ ret = XctDirectionEnd;
+ str++;
+ goto done;
+ }
+
+ SKIP_P(str)
+ SKIP_I(str)
+
+ if (*str < 0x40 && *str > 0x7e)
+ break;
+
+ ret = XctCSISeq;
+ str++;
+ goto done;
+ }
+
+ if (ch & 0x80) {
+ if (ch < 0xa0)
+ ret = XctC1;
+ else
+ ret = XctGR;
+ } else {
+ if (ch == XctHT || ch == XctNL)
+ ret = ch;
+ else if (ch < 0x20)
+ ret = XctC0;
+ else
+ ret = XctGL;
+ }
+
+ return ret;
+
+done:
+ *length -= (char *) str - *text;
+ *text = (char *) str;
+
+ return ret;
+}
+
+XlcCharSet
+_XlcAddCT(name, encoding)
+ char *name;
+ char *encoding;
+{
+ CTInfo ct_info;
+ XlcCharSet charset;
+ CTParseRec parse;
+ char *ct_ptr = encoding;
+ int length;
+ unsigned int type;
+
+ length = strlen(encoding);
+
+ switch (type = _XlcParseCT(&parse, &ct_ptr, &length)) {
+ case XctExtSeg:
+ case XctGL94:
+ case XctGL94MB:
+ case XctGR94:
+ case XctGR94MB:
+ case XctGR96:
+ if (parse.ct_info) /* existed */
+ return parse.ct_info->charset;
+ break;
+ default:
+ return (XlcCharSet) NULL;
+ }
+
+ charset = _XlcCreateDefaultCharSet(name, encoding);
+ if (charset == NULL)
+ return (XlcCharSet) NULL;
+ _XlcAddCharSet(charset);
+
+ ct_info = (CTInfo) Xmalloc(sizeof(CTInfoRec));
+ if (ct_info == NULL)
+ return (XlcCharSet) NULL;
+
+ ct_info->charset = charset;
+ ct_info->encoding = charset->ct_sequence;
+ ct_info->encoding_len = strlen(ct_info->encoding);
+ if (type == XctExtSeg) {
+ ct_info->ext_segment = ct_info->encoding + 6;
+ ct_info->ext_segment_len = strlen(ct_info->ext_segment);
+ } else {
+ ct_info->ext_segment = NULL;
+ ct_info->ext_segment_len = 0;
+ }
+ ct_info->next = ct_list;
+ ct_list = ct_info;
+
+ return charset;
+}
+
+static CTInfo
+_XlcGetCTInfoFromCharSet(charset)
+ register XlcCharSet charset;
+{
+ register CTInfo ct_info;
+
+ for (ct_info = ct_list; ct_info; ct_info = ct_info->next)
+ if (ct_info->charset == charset)
+ return ct_info;
+
+ return (CTInfo) NULL;
+}
+
+Bool
+_XlcParseCharSet(charset)
+ XlcCharSet charset;
+{
+ CTParseRec parse;
+ char *ptr, *bufp, buf[BUFSIZ];
+ int length;
+
+ if (charset->ct_sequence == NULL)
+ return False;
+
+ ptr = charset->ct_sequence;
+ length = strlen(ptr);
+
+ (void) _XlcParseCT(&parse, &ptr, &length);
+
+ if (charset->name) {
+ charset->xrm_name = XrmStringToQuark(charset->name);
+
+ if ((length = strlen (charset->name)) < sizeof buf) bufp = buf;
+ else bufp = Xmalloc (length + 1);
+
+ if (bufp == NULL) return False;
+ strcpy(bufp, charset->name);
+ if ((ptr = strchr(bufp, ':')))
+ *ptr = '\0';
+ charset->xrm_encoding_name = XrmStringToQuark(bufp);
+ if (bufp != buf) Xfree (bufp);
+ charset->encoding_name = XrmQuarkToString(charset->xrm_encoding_name);
+ } else {
+ charset->xrm_name = 0;
+ charset->encoding_name = NULL;
+ charset->xrm_encoding_name = 0;
+ }
+
+ charset->side = parse.side;
+ charset->char_size = parse.char_size;
+ charset->set_size = parse.set_size;
+
+ return True;
+}
+
+static void init_converter();
+
+Bool
+_XlcInitCTInfo()
+{
+ register XlcCharSet charset;
+ register CTData ct_data;
+ register int num;
+
+ if (ct_list == NULL) {
+ num = sizeof(default_ct_data) / sizeof(CTDataRec);
+ for (ct_data = default_ct_data; num-- > 0; ct_data++) {
+ charset = _XlcAddCT(ct_data->name, ct_data->encoding);
+ if (charset == NULL)
+ continue;
+ }
+ init_converter();
+ }
+
+ return True;
+}
+
+
+static int
+_XlcCheckCTSequence(state, ctext, ctext_len)
+ State state;
+ char **ctext;
+ int *ctext_len;
+{
+ XlcCharSet charset;
+ CTParseRec parse;
+ CTInfo ct_info;
+ int length;
+
+ _XlcParseCT(&parse, ctext, ctext_len);
+
+ ct_info = parse.ct_info;
+ if (parse.ext_seg_length > 0) { /* XctExtSeg or XctOtherSeg */
+ if (ct_info) {
+ length = ct_info->ext_segment_len;
+ *ctext += length;
+ *ctext_len -= length;
+ state->ext_seg_left = parse.ext_seg_length - length;
+ state->ext_seg_charset = ct_info->charset;
+ } else {
+ state->ext_seg_left = parse.ext_seg_length;
+ state->ext_seg_charset = NULL;
+ }
+ } else if (ct_info) {
+ if ((charset = ct_info->charset)) {
+ if (charset->side == XlcGL)
+ state->GL_charset = charset;
+ else if (charset->side == XlcGR)
+ state->GR_charset = charset;
+ }
+ }
+
+ return 0;
+}
+
+
+static void
+init_state(conv)
+ XlcConv conv;
+{
+ State state = (State) conv->state;
+ static XlcCharSet GL_charset = NULL;
+ static XlcCharSet GR_charset = NULL;
+
+ if (GL_charset == NULL) {
+ GL_charset = _XlcGetCharSet("ISO8859-1:GL");
+ GR_charset = _XlcGetCharSet("ISO8859-1:GR");
+ }
+
+ state->GL_charset = state->charset = GL_charset;
+ state->GR_charset = GR_charset;
+ state->ext_seg_charset = NULL;
+ state->ext_seg_left = 0;
+}
+
+static int
+cttocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ register State state = (State) conv->state;
+ register unsigned char ch;
+ int length;
+ XlcCharSet charset = NULL;
+ char *ctptr, *bufptr;
+ int ctext_len, buf_len;
+
+ ctptr = *((char **) from);
+ bufptr = *((char **) to);
+ ctext_len = *from_left;
+ buf_len = *to_left;
+
+ while (ctext_len > 0 && buf_len > 0) {
+ if (state->ext_seg_left > 0) {
+ length = min(state->ext_seg_left, ctext_len);
+ length = min(length, buf_len);
+
+ ctext_len -= length;
+ state->ext_seg_left -= length;
+
+ if (state->ext_seg_charset) {
+ charset = state->ext_seg_charset;
+ buf_len -= length;
+ if (charset->side == XlcGL) {
+ while (length-- > 0)
+ *bufptr++ = *ctptr++ & 0x7f;
+ } else if (charset->side == XlcGR) {
+ while (length-- > 0)
+ *bufptr++ = *ctptr++ | 0x80;
+ } else {
+ while (length-- > 0)
+ *bufptr++ = *ctptr++;
+ }
+
+ if (state->ext_seg_left < 1)
+ state->ext_seg_charset = NULL;
+ }
+ break;
+ }
+ ch = *((unsigned char *) ctptr);
+ if (ch == 0x1b || ch == 0x9b) {
+ length = _XlcCheckCTSequence(state, &ctptr, &ctext_len);
+ if (length < 0)
+ return -1;
+ if (state->ext_seg_left > 0 && charset)
+ break;
+ } else {
+ if (charset) {
+ if (charset != (ch & 0x80 ? state->GR_charset :
+ state->GL_charset))
+ break;
+ } else
+ charset = ch & 0x80 ? state->GR_charset : state->GL_charset;
+
+ if ((ch < 0x20 && ch != '\0' && ch != '\n' && ch != '\t') ||
+ (ch >= 0x80 && ch < 0xa0))
+ return -1;
+
+ *bufptr++ = *ctptr++;
+ ctext_len--;
+ buf_len--;
+ }
+ }
+
+ if (charset)
+ state->charset = charset;
+ if (num_args > 0)
+ *((XlcCharSet *) args[0]) = state->charset;
+
+ *from_left -= ctptr - *((char **) from);
+ *from = (XPointer) ctptr;
+
+ *to_left -= bufptr - *((char **) to);
+ *to = (XPointer) bufptr;
+
+ return 0;
+}
+
+static int
+cstoct(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ XlcSide side;
+ unsigned char min_ch, max_ch;
+ register unsigned char ch;
+ int length;
+ CTInfo ct_info;
+ XlcCharSet charset;
+ char *csptr, *ctptr;
+ int csstr_len, ct_len;
+
+ if (num_args < 1)
+ return -1;
+
+ csptr = *((char **) from);
+ ctptr = *((char **) to);
+ csstr_len = *from_left;
+ ct_len = *to_left;
+
+ charset = (XlcCharSet) args[0];
+
+ ct_info = _XlcGetCTInfoFromCharSet(charset);
+ if (ct_info == NULL)
+ return -1;
+
+ side = charset->side;
+
+ if (ct_info->ext_segment) {
+ if (charset != state->ext_seg_charset && state->ext_seg_left < 1) {
+ length = ct_info->encoding_len;
+ if (ct_len < length)
+ return -1;
+ strcpy(ctptr, ct_info->encoding);
+ ctptr[4] = ((ct_info->ext_segment_len + csstr_len) / 128) | 0x80;
+ ctptr[5] = ((ct_info->ext_segment_len + csstr_len) % 128) | 0x80;
+ ctptr += length;
+ ct_len -= length;
+ state->ext_seg_left = csstr_len;
+ }
+ length = min(state->ext_seg_left, csstr_len);
+ state->ext_seg_left -= length;
+
+ if (side == XlcGL) {
+ while (length-- > 0)
+ *ctptr++ = *csptr++ & 0x7f;
+ } else if (side == XlcGR) {
+ while (length-- > 0)
+ *ctptr++ = *csptr++ | 0x80;
+ } else {
+ while (length-- > 0)
+ *ctptr++ = *csptr++;
+ }
+ state->ext_seg_charset = (state->ext_seg_left > 0) ? charset : NULL;
+ } else {
+ if ((side == XlcGR && charset != state->GR_charset) ||
+ (side == XlcGL && charset != state->GL_charset)) {
+
+ ct_len -= ct_info->encoding_len;
+ if (ct_len < 0)
+ return -1;
+ strcpy(ctptr, ct_info->encoding);
+ ctptr += ct_info->encoding_len;
+ }
+
+ min_ch = 0x20;
+ max_ch = 0x7f;
+
+ if (charset->set_size == 94) {
+ max_ch--;
+ if (charset->char_size > 1 || side == XlcGR)
+ min_ch++;
+ }
+
+ while (csstr_len > 0 && ct_len > 0) {
+ ch = *((unsigned char *) csptr++) & 0x7f;
+ if (ch < min_ch || ch > max_ch)
+ if (ch != 0x00 && ch != 0x09 && ch != 0x0a && ch != 0x1b)
+ continue; /* XXX */
+ if (side == XlcGL)
+ *ctptr++ = ch & 0x7f;
+ else if (side == XlcGR)
+ *ctptr++ = ch | 0x80;
+ else
+ *ctptr++ = ch;
+ csstr_len--;
+ ct_len--;
+ }
+ if (side == XlcGR)
+ state->GR_charset = charset;
+ else if (side == XlcGL)
+ state->GL_charset = charset;
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ *to_left -= ctptr - *((char **) to);
+ *to = (XPointer) ctptr;
+
+ return 0;
+}
+
+static int
+strtocs(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ register char *src, *dst;
+ unsigned char side;
+ register int length;
+
+ src = (char *) *from;
+ dst = (char *) *to;
+
+ length = min(*from_left, *to_left);
+ side = *((unsigned char *) src) & 0x80;
+
+ while (side == (*((unsigned char *) src) & 0x80) && length-- > 0)
+ *dst++ = *src++;
+
+ *from_left -= src - (char *) *from;
+ *from = (XPointer) src;
+ *to_left -= dst - (char *) *to;
+ *to = (XPointer) dst;
+
+ if (num_args > 0)
+ *((XlcCharSet *)args[0]) = side ? state->GR_charset : state->GL_charset;
+
+ return 0;
+}
+
+static int
+cstostr(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ State state = (State) conv->state;
+ char *csptr, *string_ptr;
+ int csstr_len, str_len;
+ unsigned char ch;
+ int unconv_num = 0;
+
+ if (num_args < 1 || (state->GL_charset != (XlcCharSet) args[0] &&
+ state->GR_charset != (XlcCharSet) args[0]))
+ return -1;
+
+ csptr = *((char **) from);
+ string_ptr = *((char **) to);
+ csstr_len = *from_left;
+ str_len = *to_left;
+
+ while (csstr_len-- > 0 && str_len > 0) {
+ ch = *((unsigned char *) csptr++);
+ if ((ch < 0x20 && ch != 0x00 && ch != 0x09 && ch != 0x0a) ||
+ ch == 0x7f || ((ch & 0x80) && ch < 0xa0)) {
+ unconv_num++;
+ continue;
+ }
+ *((unsigned char *) string_ptr++) = ch;
+ str_len--;
+ }
+
+ *from_left -= csptr - *((char **) from);
+ *from = (XPointer) csptr;
+
+ *to_left -= string_ptr - *((char **) to);
+ *to = (XPointer) string_ptr;
+
+ return unconv_num;
+}
+
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ if (conv->state)
+ Xfree((char *) conv->state);
+
+ Xfree((char *) conv);
+}
+
+static XlcConv
+create_conv(methods)
+ XlcConvMethods methods;
+{
+ register XlcConv conv;
+
+ conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (conv == NULL)
+ return (XlcConv) NULL;
+
+ conv->state = (XPointer) Xmalloc(sizeof(StateRec));
+ if (conv->state == NULL)
+ goto err;
+
+ conv->methods = methods;
+
+ init_state(conv);
+
+ return conv;
+
+err:
+ close_converter(conv);
+
+ return (XlcConv) NULL;
+}
+
+static XlcConvMethodsRec cttocs_methods = {
+ close_converter,
+ cttocs,
+ init_state
+} ;
+
+static XlcConv
+open_cttocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&cttocs_methods);
+}
+
+static XlcConvMethodsRec cstoct_methods = {
+ close_converter,
+ cstoct,
+ init_state
+} ;
+
+static XlcConv
+open_cstoct(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&cstoct_methods);
+}
+
+static XlcConvMethodsRec strtocs_methods = {
+ close_converter,
+ strtocs,
+ init_state
+} ;
+
+static XlcConv
+open_strtocs(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&strtocs_methods);
+}
+
+static XlcConvMethodsRec cstostr_methods = {
+ close_converter,
+ cstostr,
+ init_state
+} ;
+
+static XlcConv
+open_cstostr(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ char *from_type;
+ XLCd to_lcd;
+ char *to_type;
+{
+ return create_conv(&cstostr_methods);
+}
+
+static void
+init_converter()
+{
+ _XlcSetConverter((XLCd) NULL, XlcNCompoundText, (XLCd) NULL, XlcNCharSet,
+ open_cttocs);
+ _XlcSetConverter((XLCd) NULL, XlcNString, (XLCd) NULL, XlcNCharSet,
+ open_strtocs);
+
+ _XlcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNCompoundText,
+ open_cstoct);
+ _XlcSetConverter((XLCd) NULL, XlcNCharSet, (XLCd) NULL, XlcNString,
+ open_cstostr);
+}
diff --git a/src/xlibi18n/lcCharSet.c b/src/xlibi18n/lcCharSet.c
new file mode 100644
index 00000000..e9a376b0
--- /dev/null
+++ b/src/xlibi18n/lcCharSet.c
@@ -0,0 +1,164 @@
+/* $Xorg: lcCharSet.c,v 1.3 2000/08/17 19:45:16 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPublic.h"
+
+#if NeedVarargsPrototypes
+char *
+_XlcGetCSValues(XlcCharSet charset, ...)
+#else
+char *
+_XlcGetCSValues(charset, va_alist)
+ XlcCharSet charset;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+
+ Va_start(var, charset);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, charset);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ if (charset->get_values)
+ ret = (*charset->get_values)(charset, args, num_args);
+ else
+ ret = args->name;
+
+ Xfree(args);
+
+ return ret;
+}
+
+typedef struct _XlcCharSetListRec {
+ XlcCharSet charset;
+ struct _XlcCharSetListRec *next;
+} XlcCharSetListRec, *XlcCharSetList;
+
+static XlcCharSetList charset_list = NULL;
+
+XlcCharSet
+_XlcGetCharSet(name)
+ char *name;
+{
+ XlcCharSetList list;
+ XrmQuark xrm_name;
+
+ xrm_name = XrmStringToQuark(name);
+
+ for (list = charset_list; list; list = list->next) {
+ if (xrm_name == list->charset->xrm_name)
+ return (XlcCharSet) list->charset;
+ }
+
+ return (XlcCharSet) NULL;
+}
+
+Bool
+_XlcAddCharSet(charset)
+ XlcCharSet charset;
+{
+ XlcCharSetList list;
+
+ if (_XlcGetCharSet(charset->name))
+ return False;
+
+ list = (XlcCharSetList) Xmalloc(sizeof(XlcCharSetListRec));
+ if (list == NULL)
+ return False;
+
+ list->charset = charset;
+ list->next = charset_list;
+ charset_list = list;
+
+ return True;
+}
+
+static XlcResource resources[] = {
+ { XlcNName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, name), XlcGetMask },
+ { XlcNEncodingName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, encoding_name), XlcGetMask },
+ { XlcNSide, NULLQUARK, sizeof(XlcSide),
+ XOffsetOf(XlcCharSetRec, side), XlcGetMask },
+ { XlcNCharSize, NULLQUARK, sizeof(int),
+ XOffsetOf(XlcCharSetRec, char_size), XlcGetMask },
+ { XlcNSetSize, NULLQUARK, sizeof(int),
+ XOffsetOf(XlcCharSetRec, set_size), XlcGetMask },
+ { XlcNControlSequence, NULLQUARK, sizeof(char *),
+ XOffsetOf(XlcCharSetRec, ct_sequence), XlcGetMask }
+};
+
+static char *
+get_values(charset, args, num_args)
+ register XlcCharSet charset;
+ register XlcArgList args;
+ register int num_args;
+{
+ if (resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(resources, XlcNumber(resources));
+
+ return _XlcGetValues((XPointer) charset, resources, XlcNumber(resources),
+ args, num_args, XlcGetMask);
+}
+
+XlcCharSet
+_XlcCreateDefaultCharSet(name, ct_sequence)
+ char *name;
+ char *ct_sequence;
+{
+ XlcCharSet charset;
+
+ charset = (XlcCharSet) Xmalloc(sizeof(XlcCharSetRec));
+ if (charset == NULL)
+ return (XlcCharSet) NULL;
+ bzero((char *) charset, sizeof(XlcCharSetRec));
+
+ charset->name = (char *) Xmalloc(strlen(name) + strlen(ct_sequence) + 2);
+ if (charset->name == NULL) {
+ Xfree((char *) charset);
+ return (XlcCharSet) NULL;
+ }
+ strcpy(charset->name, name);
+ charset->ct_sequence = charset->name + strlen(name) + 1;
+ strcpy(charset->ct_sequence, ct_sequence);
+ charset->get_values = get_values;
+
+ _XlcParseCharSet(charset);
+
+ return (XlcCharSet) charset;
+}
diff --git a/src/xlibi18n/lcConv.c b/src/xlibi18n/lcConv.c
new file mode 100644
index 00000000..f03adcc6
--- /dev/null
+++ b/src/xlibi18n/lcConv.c
@@ -0,0 +1,332 @@
+/* $Xorg: lcConv.c,v 1.4 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <stdio.h>
+
+typedef XlcConv (*XlcConverter)();
+
+typedef struct _XlcConverterListRec {
+ XLCd from_lcd;
+ char *from;
+ XrmQuark from_type;
+ XLCd to_lcd;
+ char *to;
+ XrmQuark to_type;
+ XlcConverter converter;
+ struct _XlcConverterListRec *next;
+} XlcConverterListRec, *XlcConverterList;
+
+static XlcConverterList conv_list = NULL;
+
+static void
+close_converter(conv)
+ XlcConv conv;
+{
+ (*conv->methods->close)(conv);
+}
+
+static XlcConv
+get_converter(from_lcd, from_type, to_lcd, to_type)
+ XLCd from_lcd;
+ XrmQuark from_type;
+ XLCd to_lcd;
+ XrmQuark to_type;
+{
+ register XlcConverterList list, prev = NULL;
+
+ for (list = conv_list; list; list = list->next) {
+ if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
+ && list->from_type == from_type && list->to_type == to_type) {
+
+ if (prev && prev != conv_list) { /* XXX */
+ prev->next = list->next;
+ list->next = conv_list;
+ conv_list = list;
+ }
+
+ return (*list->converter)(from_lcd, list->from, to_lcd, list->to);
+ }
+
+ prev = list;
+ }
+
+ return (XlcConv) NULL;
+}
+
+Bool
+_XlcSetConverter(from_lcd, from, to_lcd, to, converter)
+ XLCd from_lcd;
+ char *from;
+ XLCd to_lcd;
+ char *to;
+ XlcOpenConverterProc converter;
+{
+ register XlcConverterList list;
+ register XrmQuark from_type, to_type;
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ for (list = conv_list; list; list = list->next) {
+ if (list->from_lcd == from_lcd && list->to_lcd == to_lcd
+ && list->from_type == from_type && list->to_type == to_type) {
+
+ list->converter = converter;
+ return True;
+ }
+ }
+
+ list = (XlcConverterList) Xmalloc(sizeof(XlcConverterListRec));
+ if (list == NULL)
+ return False;
+
+ list->from_lcd = from_lcd;
+ list->from = from;
+ list->from_type = from_type;
+ list->to_lcd = to_lcd;
+ list->to = to;
+ list->to_type = to_type;
+ list->converter = converter;
+ list->next = conv_list;
+ conv_list = list;
+
+ return True;
+}
+
+typedef struct _ConvRec {
+ XlcConv from_conv;
+ XlcConv to_conv;
+} ConvRec, *Conv;
+
+static int
+indirect_convert(lc_conv, from, from_left, to, to_left, args, num_args)
+ XlcConv lc_conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ Conv conv = (Conv) lc_conv->state;
+ XlcConv from_conv = conv->from_conv;
+ XlcConv to_conv = conv->to_conv;
+ XlcCharSet charset;
+ char buf[BUFSIZ], *cs;
+ XPointer tmp_args[1];
+ int cs_left, ret, length, unconv_num = 0;
+
+ if (from == NULL || *from == NULL) {
+ if (from_conv->methods->reset)
+ (*from_conv->methods->reset)(from_conv);
+
+ if (to_conv->methods->reset)
+ (*to_conv->methods->reset)(to_conv);
+
+ return 0;
+ }
+
+ while (*from_left > 0) {
+ cs = buf;
+ cs_left = BUFSIZ;
+ tmp_args[0] = (XPointer) &charset;
+
+ ret = (*from_conv->methods->convert)(from_conv, from, from_left, &cs,
+ &cs_left, tmp_args, 1);
+ if (ret < 0)
+ break;
+
+ length = cs_left = cs - buf;
+ cs = buf;
+
+ tmp_args[0] = (XPointer) charset;
+
+ ret = (*to_conv->methods->convert)(to_conv, &cs, &cs_left, to, to_left,
+ tmp_args, 1);
+ if (ret < 0) {
+ unconv_num += length / charset->char_size;
+ continue;
+ }
+
+ if (*to_left < 1)
+ break;
+ }
+
+ return unconv_num;
+}
+
+static void
+close_indirect_converter(lc_conv)
+ XlcConv lc_conv;
+{
+ Conv conv = (Conv) lc_conv->state;
+
+ if (conv) {
+ if (conv->from_conv)
+ close_converter(conv->from_conv);
+ if (conv->to_conv)
+ close_converter(conv->to_conv);
+
+ Xfree((char *) conv);
+ }
+
+ Xfree((char *) lc_conv);
+}
+
+static void
+reset_indirect_converter(lc_conv)
+ XlcConv lc_conv;
+{
+ Conv conv = (Conv) lc_conv->state;
+
+ if (conv) {
+ if (conv->from_conv && conv->from_conv->methods->reset)
+ (*conv->from_conv->methods->reset)(conv->from_conv);
+ if (conv->to_conv && conv->to_conv->methods->reset)
+ (*conv->to_conv->methods->reset)(conv->to_conv);
+ }
+}
+
+static XlcConvMethodsRec conv_methods = {
+ close_indirect_converter,
+ indirect_convert,
+ reset_indirect_converter
+} ;
+
+static XlcConv
+open_indirect_converter(from_lcd, from, to_lcd, to)
+ XLCd from_lcd;
+ char *from;
+ XLCd to_lcd;
+ char *to;
+{
+ XlcConv lc_conv, from_conv, to_conv;
+ Conv conv;
+ XrmQuark from_type, to_type;
+ static XrmQuark QChar, QCharSet, QCTCharSet = (XrmQuark) 0;
+
+ if (QCTCharSet == (XrmQuark) 0) {
+ QCTCharSet = XrmStringToQuark(XlcNCTCharSet);
+ QCharSet = XrmStringToQuark(XlcNCharSet);
+ QChar = XrmStringToQuark(XlcNChar);
+ }
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ if (from_type == QCharSet || from_type == QChar || to_type == QCharSet ||
+ to_type == QChar)
+ return (XlcConv) NULL;
+
+ lc_conv = (XlcConv) Xmalloc(sizeof(XlcConvRec));
+ if (lc_conv == NULL)
+ return (XlcConv) NULL;
+
+ lc_conv->methods = &conv_methods;
+
+ lc_conv->state = (XPointer) Xcalloc(1, sizeof(ConvRec));
+ if (lc_conv->state == NULL)
+ goto err;
+
+ conv = (Conv) lc_conv->state;
+
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QCTCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter((XLCd)NULL, from_type, (XLCd)NULL, QCharSet);
+ if (from_conv == NULL)
+ from_conv = get_converter(from_lcd, from_type, from_lcd, QChar);
+ if (from_conv == NULL)
+ goto err;
+ conv->from_conv = from_conv;
+
+ to_conv = get_converter(to_lcd, QCTCharSet, to_lcd, to_type);
+ if (to_conv == NULL)
+ to_conv = get_converter(to_lcd, QCharSet, to_lcd, to_type);
+ if (to_conv == NULL)
+ to_conv = get_converter((XLCd) NULL, QCharSet, (XLCd) NULL, to_type);
+ if (to_conv == NULL)
+ goto err;
+ conv->to_conv = to_conv;
+
+ return lc_conv;
+
+err:
+ close_indirect_converter(lc_conv);
+
+ return (XlcConv) NULL;
+}
+
+XlcConv
+_XlcOpenConverter(from_lcd, from, to_lcd, to)
+ XLCd from_lcd;
+ char *from;
+ XLCd to_lcd;
+ char *to;
+{
+ XlcConv conv;
+ XrmQuark from_type, to_type;
+
+ from_type = XrmStringToQuark(from);
+ to_type = XrmStringToQuark(to);
+
+ if ((conv = get_converter(from_lcd, from_type, to_lcd, to_type)))
+ return conv;
+
+ return open_indirect_converter(from_lcd, from, to_lcd, to);
+}
+
+void
+_XlcCloseConverter(conv)
+ XlcConv conv;
+{
+ close_converter(conv);
+}
+
+int
+_XlcConvert(conv, from, from_left, to, to_left, args, num_args)
+ XlcConv conv;
+ XPointer *from;
+ int *from_left;
+ XPointer *to;
+ int *to_left;
+ XPointer *args;
+ int num_args;
+{
+ return (*conv->methods->convert)(conv, from, from_left, to, to_left, args,
+ num_args);
+}
+
+void
+_XlcResetConverter(conv)
+ XlcConv conv;
+{
+ if (conv->methods->reset)
+ (*conv->methods->reset)(conv);
+}
diff --git a/src/xlibi18n/lcDB.c b/src/xlibi18n/lcDB.c
new file mode 100644
index 00000000..a6d8648b
--- /dev/null
+++ b/src/xlibi18n/lcDB.c
@@ -0,0 +1,1281 @@
+/* $Xorg: lcDB.c,v 1.6 2000/08/17 19:45:17 cpqbld Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+#ifndef NOT_X_ENV
+
+#include <X11/Xlib.h>
+#include <X11/Xresource.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+#else /* NOT_X_ENV */
+
+#define Xmalloc malloc
+#define Xrealloc realloc
+#define Xfree free
+
+#endif /* NOT_X_ENV */
+
+/* specifying NOT_X_ENV allows users to just use
+ the database parsing routine. */
+/* For UDC/VW */
+#ifndef BUFSIZE
+#define BUFSIZE 2048
+#endif
+
+#ifdef COMMENT
+#ifdef BUFSIZE
+#undef BUFSIZE
+#endif
+#define BUFSIZE 6144 /* 2048*3 */
+#endif
+
+#include <stdio.h>
+
+typedef struct _DatabaseRec {
+ char *category;
+ char *name;
+ char **value;
+ int value_num;
+ struct _DatabaseRec *next;
+} DatabaseRec, *Database;
+
+typedef enum {
+ S_NULL, /* outside category */
+ S_CATEGORY, /* inside category */
+ S_NAME, /* has name, expecting values */
+ S_VALUE
+} ParseState;
+
+typedef enum {
+ T_NEWLINE,
+ T_COMMENT,
+ T_SEMICOLON,
+ T_DOUBLE_QUOTE,
+ T_LEFT_BRACE,
+ T_RIGHT_BRACE,
+ T_SPACE,
+ T_TAB,
+ T_BACKSLASH,
+ T_NUMERIC_HEX,
+ T_NUMERIC_DEC,
+ T_NUMERIC_OCT,
+ T_DEFAULT
+} Token;
+
+typedef struct {
+ Token token; /* token id */
+ char *name; /* token sequence */
+ int len; /* length of token sequence */
+ int (*parse_proc)(); /* parsing procedure */
+} TokenTable;
+
+static int f_newline();
+static int f_comment();
+static int f_semicolon();
+static int f_double_quote();
+static int f_left_brace();
+static int f_right_brace();
+static int f_white();
+static int f_backslash();
+static int f_numeric();
+static int f_default();
+
+static TokenTable token_tbl[] = {
+ { T_NEWLINE, "\n", 1, f_newline },
+ { T_COMMENT, "#", 1, f_comment },
+ { T_SEMICOLON, ";", 1, f_semicolon },
+ { T_DOUBLE_QUOTE, "\"", 1, f_double_quote },
+ { T_LEFT_BRACE, "{", 1, f_left_brace },
+ { T_RIGHT_BRACE, "}", 1, f_right_brace },
+ { T_SPACE, " ", 1, f_white },
+ { T_TAB, "\t", 1, f_white },
+ { T_BACKSLASH, "\\", 1, f_backslash },
+ { T_NUMERIC_HEX, "\\x", 2, f_numeric },
+ { T_NUMERIC_DEC, "\\d", 2, f_numeric },
+ { T_NUMERIC_OCT, "\\o", 2, f_numeric },
+ { T_DEFAULT, " ", 1, f_default }, /* any character */
+ 0
+};
+
+#define SYM_NEWLINE '\n'
+#define SYM_COMMENT '#'
+#define SYM_SEMICOLON ';'
+#define SYM_DOUBLE_QUOTE '"'
+#define SYM_LEFT_BRACE '{'
+#define SYM_RIGHT_BRACE '}'
+#define SYM_SPACE ' '
+#define SYM_TAB '\t'
+#define SYM_BACKSLASH '\\'
+
+/************************************************************************/
+
+#define MAX_NAME_NEST 64
+
+typedef struct {
+ ParseState pre_state;
+ char *category;
+ char *name[MAX_NAME_NEST];
+ int nest_depth;
+ char **value;
+ int value_len;
+ int value_num;
+ int bufsize; /* bufMaxSize >= bufsize >= 0 */
+ int bufMaxSize; /* default : BUFSIZE */
+ char *buf;
+} DBParseInfo;
+
+static DBParseInfo parse_info;
+
+static void init_parse_info()
+{
+ static int first = 1;
+ char *ptr;
+ int size;
+ if(first == 1){
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = (char *)Xmalloc(BUFSIZE);
+ parse_info.bufMaxSize = BUFSIZE;
+ first = 0;
+ return ;
+ }
+ ptr = parse_info.buf;
+ size = parse_info.bufMaxSize;
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = ptr;
+ parse_info.bufMaxSize = size;
+}
+
+static void
+clear_parse_info()
+{
+ int i;
+ char *ptr;
+ int size;
+ parse_info.pre_state = S_NULL;
+ if(parse_info.category != NULL){
+ Xfree(parse_info.category);
+ }
+ for(i = 0; i <= parse_info.nest_depth; ++i){
+ if(parse_info.name[i]){
+ Xfree(parse_info.name[i]);
+ }
+ }
+ if(parse_info.value){
+ if(*parse_info.value){
+ Xfree(*parse_info.value);
+ }
+ Xfree((char *)parse_info.value);
+ }
+ ptr = parse_info.buf;
+ size = parse_info.bufMaxSize;
+ bzero(&parse_info, sizeof(DBParseInfo));
+ parse_info.buf = ptr;
+ parse_info.bufMaxSize = size;
+}
+
+static Bool
+realloc_parse_info(len)
+int len;
+{
+ char *p;
+
+
+ parse_info.bufMaxSize = BUFSIZE *
+ ((parse_info.bufsize + len)/BUFSIZE + 1);
+ p = (char *)Xrealloc(parse_info.buf, parse_info.bufMaxSize);
+ if(p == NULL){
+ return(False);
+ }
+ parse_info.buf = p;
+
+ return(True);
+}
+/************************************************************************/
+typedef struct _Line {
+ char *str;
+ int cursize;
+ int maxsize;
+ int seq;
+} Line;
+
+static void
+free_line(line)
+ Line *line;
+{
+ if(line->str != NULL){
+ Xfree(line->str);
+ }
+ bzero(line, sizeof(Line));
+}
+
+static int
+realloc_line(line, size)
+ Line *line;
+ int size;
+{
+ char *str = line->str;
+
+ if(str != NULL){
+ str = (char *)Xrealloc(str, size);
+ }else{
+ str = (char *)Xmalloc(size);
+ }
+ if(str == NULL){
+ /* malloc error */
+ if (line->str != NULL) {
+ Xfree(line->str);
+ }
+ bzero(line, sizeof(Line));
+ return 0;
+ }
+ line->str = str;
+ line->maxsize = size;
+ return 1;
+}
+
+#define iswhite(ch) ((ch) == SYM_SPACE || (ch) == SYM_TAB)
+
+static void
+zap_comment(str, quoted)
+ char *str;
+ int *quoted;
+{
+ char *p = str;
+#ifdef never
+ *quoted = 0;
+ if(*p == SYM_COMMENT){
+ int len = strlen(str);
+ if(p[len - 1] == SYM_NEWLINE){
+ *p++ = SYM_NEWLINE;
+ }
+ *p = '\0';
+ }
+#else
+ while(*p){
+ if(*p == SYM_DOUBLE_QUOTE){
+ if(p == str || p[-1] != SYM_BACKSLASH){
+ /* unescaped double quote changes quoted state. */
+ *quoted = *quoted ? 0 : 1;
+ }
+ }
+ if(*p == SYM_COMMENT && !*quoted){
+ int pos = p - str;
+ if(pos == 0 ||
+ iswhite(p[-1]) && (pos == 1 || p[-2] != SYM_BACKSLASH)){
+ int len = strlen(p);
+ if(len > 0 && p[len - 1] == SYM_NEWLINE){
+ /* newline is the identifier for finding end of value.
+ therefore, it should not be removed. */
+ *p++ = SYM_NEWLINE;
+ }
+ *p = '\0';
+ break;
+ }
+ }
+ ++p;
+ }
+#endif
+}
+
+static int
+read_line(fd, line)
+ FILE *fd;
+ Line *line;
+{
+ char buf[BUFSIZE], *p;
+ int len;
+ int quoted = 0; /* quoted by double quote? */
+ char *str;
+ int cur;
+
+ str = line->str;
+ cur = line->cursize = 0;
+
+ while((p = fgets(buf, BUFSIZE, fd)) != NULL){
+ ++line->seq;
+ zap_comment(p, &quoted); /* remove comment line */
+ len = strlen(p);
+ if(len == 0){
+ if(cur > 0){
+ break;
+ }
+ continue;
+ }
+ if(cur + len + 1 > line->maxsize){
+ /* need to reallocate buffer. */
+ if(! realloc_line(line, line->maxsize + BUFSIZE)){
+ return -1; /* realloc error. */
+ }
+ str = line->str;
+ }
+ strncpy(str + cur, p, len);
+
+ cur += len;
+ str[cur] = '\0';
+ if(!quoted){
+ if(cur > 1 && str[cur - 2] == SYM_BACKSLASH &&
+ str[cur - 1] == SYM_NEWLINE){
+ /* the line is ended backslash followed by newline.
+ need to concatinate the next line. */
+ cur -= 2;
+ str[cur] = '\0';
+ }else{
+ break;
+ }
+ }
+ }
+ if(quoted){
+ /* error. still in quoted state. */
+ return -1;
+ }
+ return line->cursize = cur;
+}
+
+/************************************************************************/
+
+static Token
+get_token(str)
+ char *str;
+{
+ switch(*str){
+ case SYM_NEWLINE: return T_NEWLINE;
+ case SYM_COMMENT: return T_COMMENT;
+ case SYM_SEMICOLON: return T_SEMICOLON;
+ case SYM_DOUBLE_QUOTE: return T_DOUBLE_QUOTE;
+ case SYM_LEFT_BRACE: return T_LEFT_BRACE;
+ case SYM_RIGHT_BRACE: return T_RIGHT_BRACE;
+ case SYM_SPACE: return T_SPACE;
+ case SYM_TAB: return T_TAB;
+ case SYM_BACKSLASH:
+ switch(str[1]){
+ case 'x': return T_NUMERIC_HEX;
+ case 'd': return T_NUMERIC_DEC;
+ case 'o': return T_NUMERIC_OCT;
+ }
+ return T_BACKSLASH;
+ default:
+ return T_DEFAULT;
+ }
+}
+
+static int
+get_word(str, word)
+ char *str;
+ char *word;
+{
+ char *p = str, *w = word;
+ Token token;
+ int token_len;
+
+ while(*p != '\0'){
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ if(token == T_BACKSLASH){
+ p += token_len;
+ if(*p == '\0'){
+ break;
+ }
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ }else if(token != T_COMMENT &&
+ token != T_DEFAULT){
+ break;
+ }
+ strncpy(w, p, token_len);
+ p += token_len; w += token_len;
+ }
+ *w = '\0';
+ return p - str; /* return number of scanned chars */
+}
+
+static int
+get_quoted_word(str, word)
+ char *str;
+ char *word;
+{
+ char *p = str, *w = word;
+ Token token;
+ int token_len;
+
+ if(*p == SYM_DOUBLE_QUOTE){
+ ++p;
+ }
+ while(*p != '\0'){
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ if(token == T_DOUBLE_QUOTE){
+ p += token_len;
+ goto found;
+ }
+ if(token == T_BACKSLASH){
+ p += token_len;
+ if(*p == '\0'){
+ break;
+ }
+ token = get_token(p);
+ token_len = token_tbl[token].len;
+ }
+ strncpy(w, p, token_len);
+ p += token_len; w += token_len;
+ }
+ /* error. cannot detect next double quote */
+ return 0;
+
+ found:;
+ *w = '\0';
+ return p - str;
+}
+
+/************************************************************************/
+
+static int
+append_value_list()
+{
+ char **value_list = parse_info.value;
+ char *value;
+ int value_num = parse_info.value_num;
+ int value_len = parse_info.value_len;
+ char *str = parse_info.buf;
+ int len = parse_info.bufsize;
+ char *p;
+
+ if(len < 1){
+ return 1; /* return with no error */
+ }
+
+ if(value_list == (char **)NULL){
+ value_list = (char **)Xmalloc(sizeof(char *) * 2);
+ *value_list = NULL;
+ }else{
+ char **prev_list = value_list;
+
+ value_list = (char **)
+ Xrealloc(value_list, sizeof(char *) * (value_num + 2));
+ if (value_list == NULL){
+ Xfree(prev_list);
+ }
+ }
+ if(value_list == (char **)NULL){
+ goto err;
+ }
+
+ value = *value_list;
+ if(value == NULL){
+ value = (char *)Xmalloc(value_len + len + 1);
+ }else{
+ char *prev_value = value;
+
+ value = (char *)Xrealloc(value, value_len + len + 1);
+ if (value == NULL){
+ Xfree(prev_value);
+ }
+ }
+ if(value == NULL){
+ goto err;
+ }
+ if(value != *value_list){
+ int delta, i;
+ delta = value - *value_list;
+ *value_list = value;
+ for(i = 1; i < value_num; ++i){
+ value_list[i] += delta;
+ }
+ }
+
+ value_list[value_num] = p = &value[value_len];
+ value_list[value_num + 1] = NULL;
+ strncpy(p, str, len);
+ p[len] = 0;
+
+ parse_info.value = value_list;
+ parse_info.value_num = value_num + 1;
+ parse_info.value_len = value_len + len + 1;
+ parse_info.bufsize = 0;
+ return 1;
+
+ err:
+ if(value_list){
+ Xfree((char **)value_list);
+ }
+ if(value){
+ Xfree(value);
+ }
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+ parse_info.bufsize = 0;
+ return 0;
+}
+
+static int
+construct_name(name, size)
+ char *name;
+ int size;
+{
+ register int i, len = 0;
+ char *p = name;
+
+ for(i = 0; i <= parse_info.nest_depth; ++i){
+ len += strlen(parse_info.name[i]) + 1;
+ }
+ if (len >= size)
+ return 0;
+
+ strcpy(p, parse_info.name[0]);
+ p += strlen(parse_info.name[0]);
+ for(i = 1; i <= parse_info.nest_depth; ++i){
+ *p++ = '.';
+ strcpy(p, parse_info.name[i]);
+ p += strlen(parse_info.name[i]);
+ }
+ return *name != '\0';
+}
+
+static int
+store_to_database(db)
+ Database *db;
+{
+ Database new = (Database)NULL;
+ char name[BUFSIZE];
+
+ if(parse_info.pre_state == S_VALUE){
+ if(! append_value_list()){
+ goto err;
+ }
+ }
+
+ if(parse_info.name[parse_info.nest_depth] == NULL){
+ goto err;
+ }
+
+ new = (Database)Xmalloc(sizeof(DatabaseRec));
+ if(new == (Database)NULL){
+ goto err;
+ }
+ bzero(new, sizeof(DatabaseRec));
+
+ new->category = (char *)Xmalloc(strlen(parse_info.category) + 1);
+ if(new->category == NULL){
+ goto err;
+ }
+ strcpy(new->category, parse_info.category);
+
+ if(! construct_name(name, sizeof(name))){
+ goto err;
+ }
+ new->name = (char *)Xmalloc(strlen(name) + 1);
+ if(new->name == NULL){
+ goto err;
+ }
+ strcpy(new->name, name);
+ new->next = *db;
+ new->value = parse_info.value;
+ new->value_num = parse_info.value_num;
+ *db = new;
+
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ parse_info.name[parse_info.nest_depth] = NULL;
+
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+
+ return 1;
+
+ err:
+ if(new){
+ if(new->category){
+ Xfree(new->category);
+ }
+ if(new->name){
+ Xfree(new->name);
+ }
+ }
+ if(parse_info.value){
+ if(*parse_info.value){
+ Xfree(*parse_info.value);
+ }
+ Xfree((char **)parse_info.value);
+ parse_info.value = (char **)NULL;
+ parse_info.value_num = 0;
+ parse_info.value_len = 0;
+ }
+ return 0;
+}
+
+#define END_MARK "END"
+#define END_MARK_LEN 3 /*strlen(END_MARK)*/
+
+static int
+check_category_end(str)
+ char *str;
+{
+ char *p;
+ int len;
+
+ p = str;
+ if(strncmp(p, END_MARK, END_MARK_LEN)){
+ return 0;
+ }
+ p += END_MARK_LEN;
+
+ while(iswhite(*p)){
+ ++p;
+ }
+ len = strlen(parse_info.category);
+ if(strncmp(p, parse_info.category, len)){
+ return 0;
+ }
+ p += len;
+ return p - str;
+}
+
+/************************************************************************/
+
+static int
+f_newline(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_CATEGORY:
+ break;
+ case S_NAME:
+ return 0; /* no value */
+ case S_VALUE:
+ if(!store_to_database(db))
+ return 0;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_comment(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ /* NOTE: comment is already handled in read_line(),
+ so this function is not necessary. */
+
+ char *p = str;
+
+ while(*p != SYM_NEWLINE && *p != '\0'){
+ ++p; /* zap to the end of line */
+ }
+ return p - str;
+}
+
+static int
+f_white(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ char *p = str;
+
+ while(iswhite(*p)){
+ ++p;
+ }
+ return p - str;
+}
+
+static int
+f_semicolon(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_CATEGORY:
+ case S_NAME:
+ return 0;
+ case S_VALUE:
+ if(! append_value_list())
+ return 0;
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_left_brace(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_CATEGORY:
+ case S_VALUE:
+ return 0;
+ case S_NAME:
+ if(parse_info.name[parse_info.nest_depth] == NULL ||
+ parse_info.nest_depth + 1 > MAX_NAME_NEST)
+ return 0;
+ ++parse_info.nest_depth;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_right_brace(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ if(parse_info.nest_depth < 1)
+ return 0;
+
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_NAME:
+ return 0;
+ case S_VALUE:
+ if(! store_to_database(db))
+ return 0;
+ /* fall into next case */
+ case S_CATEGORY:
+ if(parse_info.name[parse_info.nest_depth] != NULL){
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ parse_info.name[parse_info.nest_depth] = NULL;
+ }
+ --parse_info.nest_depth;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ default:
+ return 0;
+ }
+ return token_tbl[token].len;
+}
+
+static int
+f_double_quote(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ char word[BUFSIZE];
+ char* wordp;
+ int len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ len = 0;
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_CATEGORY:
+ goto err;
+ case S_NAME:
+ case S_VALUE:
+ len = get_quoted_word(str, wordp);
+ if(len < 1)
+ goto err;
+ if( (parse_info.bufsize + (int)strlen(wordp) +1)
+ >= parse_info.bufMaxSize){
+ if(realloc_parse_info(strlen(wordp) +1) == False){
+ goto err;
+ }
+ }
+ strcpy(&parse_info.buf[parse_info.bufsize], wordp);
+ parse_info.bufsize += strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word) Xfree (wordp);
+ return len; /* including length of token */
+
+err:
+ if (wordp != word) Xfree (wordp);
+ return 0;
+}
+
+static int
+f_backslash(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ return f_default(str, token, db);
+}
+
+static int
+f_numeric(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ char word[BUFSIZE], *p;
+ char* wordp;
+ int len;
+ int token_len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ switch(parse_info.pre_state){
+ case S_NULL:
+ case S_CATEGORY:
+ goto err;
+ case S_NAME:
+ case S_VALUE:
+ token_len = token_tbl[token].len;
+ p = str + token_len;
+ len = get_word(p, wordp);
+ if(len < 1)
+ goto err;
+ if( (parse_info.bufsize + token_len + (int)strlen(wordp) +1)
+ >= parse_info.bufMaxSize){
+ if(realloc_parse_info(token_len + strlen(wordp) +1) == False)
+ goto err;
+ }
+ strncpy(&parse_info.buf[parse_info.bufsize], str, token_len);
+ strcpy(&parse_info.buf[parse_info.bufsize + token_len], wordp);
+ parse_info.bufsize += token_len + strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word) Xfree (wordp);
+ return len + token_len;
+
+err:
+ if (wordp != word) Xfree (wordp);
+ return 0;
+}
+
+static int
+f_default(str, token, db)
+ char *str;
+ Token token;
+ Database *db;
+{
+ char word[BUFSIZE], *p;
+ char* wordp;
+ int len;
+
+ if ((len = strlen (str)) < sizeof word)
+ wordp = word;
+ else
+ wordp = Xmalloc (len + 1);
+ if (wordp == NULL)
+ return 0;
+
+ len = get_word(str, wordp);
+ if(len < 1)
+ goto err;
+
+ switch(parse_info.pre_state){
+ case S_NULL:
+ if(parse_info.category != NULL)
+ goto err;
+ p = (char *)Xmalloc(strlen(wordp) + 1);
+ if(p == NULL)
+ goto err;
+ strcpy(p, wordp);
+ parse_info.category = p;
+ parse_info.pre_state = S_CATEGORY;
+ break;
+ case S_CATEGORY:
+ if(parse_info.nest_depth == 0){
+ if(check_category_end(str)){
+ /* end of category is detected.
+ clear context and zap to end of this line */
+ clear_parse_info();
+ len = strlen(str);
+ break;
+ }
+ }
+ p = (char *)Xmalloc(strlen(wordp) + 1);
+ if(p == NULL)
+ goto err;
+ strcpy(p, wordp);
+ if(parse_info.name[parse_info.nest_depth] != NULL){
+ Xfree(parse_info.name[parse_info.nest_depth]);
+ }
+ parse_info.name[parse_info.nest_depth] = p;
+ parse_info.pre_state = S_NAME;
+ break;
+ case S_NAME:
+ case S_VALUE:
+ if( (parse_info.bufsize + (int)strlen(wordp) +1 )
+ >= parse_info.bufMaxSize){
+ if(realloc_parse_info(strlen(wordp) +1) == False)
+ goto err;
+ }
+ strcpy(&parse_info.buf[parse_info.bufsize], wordp);
+ parse_info.bufsize += strlen(wordp);
+ parse_info.pre_state = S_VALUE;
+ break;
+ default:
+ goto err;
+ }
+ if (wordp != word) Xfree (wordp);
+ return len;
+
+err:
+ if (wordp != word) Xfree (wordp);
+ return 0;
+}
+
+/************************************************************************/
+
+#ifdef DEBUG
+static void
+PrintDatabase(db)
+ Database db;
+{
+ Database p = db;
+ int i = 0, j;
+
+ printf("***\n*** BEGIN Database\n***\n");
+ while(p){
+ printf("%3d: ", i++);
+ printf("%s, %s, ", p->category, p->name);
+ printf("\t[%d: ", p->value_num);
+ for(j = 0; j < p->value_num; ++j){
+ printf("%s, ", p->value[j]);
+ }
+ printf("]\n");
+ p = p->next;
+ }
+ printf("***\n*** END Database\n***\n");
+}
+#endif
+
+static void
+DestroyDatabase(db)
+ Database db;
+{
+ Database p = db;
+
+ while(p){
+ if(p->category != NULL){
+ Xfree(p->category);
+ }
+ if(p->name != NULL){
+ Xfree(p->name);
+ }
+ if(p->value != (char **)NULL){
+ if(*p->value != NULL){
+ Xfree(*p->value);
+ }
+ Xfree((char *)p->value);
+ }
+ db = p->next;
+ Xfree((char *)p);
+ p = db;
+ }
+}
+
+static int
+CountDatabase(db)
+ Database db;
+{
+ Database p = db;
+ int cnt = 0;
+
+ while(p){
+ ++cnt;
+ p = p->next;
+ }
+ return cnt;
+}
+
+static Database
+CreateDatabase(dbfile)
+ char *dbfile;
+{
+ Database db = (Database)NULL;
+ FILE *fd;
+ Line line;
+ char *p;
+ Token token;
+ int len;
+ int error = 0;
+
+ fd = _XFopenFile(dbfile, "r");
+ if(fd == (FILE *)NULL){
+ return NULL;
+ }
+
+ bzero(&line, sizeof(Line));
+ init_parse_info();
+
+ do {
+ int rc = read_line(fd, &line);
+ if(rc < 0){
+ error = 1;
+ break;
+ }else if(rc == 0){
+ break;
+ }
+ p = line.str;
+ while(*p){
+ token = get_token(p);
+ len = (*token_tbl[token].parse_proc)(p, token, &db);
+ if(len < 1){
+ error = 1;
+ break;
+ }
+ p += len;
+ }
+ } while (!error);
+
+ if(parse_info.pre_state != S_NULL){
+ clear_parse_info();
+ error = 1;
+ }
+ if(error){
+#ifdef DEBUG
+ fprintf(stderr, "database format error at line %d.\n", line.seq);
+#endif
+ DestroyDatabase(db);
+ db = (Database)NULL;
+ }
+
+ fclose(fd);
+ free_line(&line);
+
+#ifdef DEBUG
+ PrintDatabase(db);
+#endif
+
+ return db;
+}
+
+/************************************************************************/
+
+#ifndef NOT_X_ENV
+
+/* locale framework functions */
+
+typedef struct _XlcDatabaseRec {
+ XrmQuark category_q;
+ XrmQuark name_q;
+ Database db;
+ struct _XlcDatabaseRec *next;
+} XlcDatabaseRec, *XlcDatabase;
+
+typedef struct _XlcDatabaseListRec {
+ XrmQuark name_q;
+ XlcDatabase lc_db;
+ Database database;
+ int ref_count;
+ struct _XlcDatabaseListRec *next;
+} XlcDatabaseListRec, *XlcDatabaseList;
+
+/* database cache list (per file) */
+static XlcDatabaseList _db_list = (XlcDatabaseList)NULL;
+
+/************************************************************************/
+/* _XlcGetResource(lcd, category, class, value, count) */
+/*----------------------------------------------------------------------*/
+/* This function retrieves XLocale database information. */
+/************************************************************************/
+void
+_XlcGetResource(lcd, category, class, value, count)
+ XLCd lcd;
+ char *category;
+ char *class;
+ char ***value;
+ int *count;
+{
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+
+ (*methods->get_resource)(lcd, category, class, value, count);
+ return;
+}
+
+/************************************************************************/
+/* _XlcGetLocaleDataBase(lcd, category, class, value, count) */
+/*----------------------------------------------------------------------*/
+/* This function retrieves XLocale database information. */
+/************************************************************************/
+void
+_XlcGetLocaleDataBase(lcd, category, name, value, count)
+ XLCd lcd;
+ char *category;
+ char *name;
+ char ***value;
+ int *count;
+{
+ XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
+ XrmQuark category_q, name_q;
+
+ category_q = XrmStringToQuark(category);
+ name_q = XrmStringToQuark(name);
+ for(; lc_db->db; ++lc_db){
+ if(category_q == lc_db->category_q && name_q == lc_db->name_q){
+ *value = lc_db->db->value;
+ *count = lc_db->db->value_num;
+ return;
+ }
+ }
+ *value = (char **)NULL;
+ *count = 0;
+}
+
+/************************************************************************/
+/* _XlcDestroyLocaleDataBase(lcd) */
+/*----------------------------------------------------------------------*/
+/* This function destroy the XLocale Database that bound to the */
+/* specified lcd. If the XLocale Database is refered from some */
+/* other lcd, this function just decreases reference count of */
+/* the database. If no locale refers the database, this function */
+/* remove it from the cache list and free work area. */
+/************************************************************************/
+void
+_XlcDestroyLocaleDataBase(lcd)
+ XLCd lcd;
+{
+ XlcDatabase lc_db = (XlcDatabase)XLC_PUBLIC(lcd, xlocale_db);
+ XlcDatabaseList p, prev;
+
+ for(p = _db_list, prev = (XlcDatabaseList)NULL; p;
+ prev = p, p = p->next){
+ if(p->lc_db == lc_db){
+ if((-- p->ref_count) < 1){
+ if(p->lc_db != (XlcDatabase)NULL){
+ Xfree((char *)p->lc_db);
+ }
+ DestroyDatabase(p->database);
+ if(prev == (XlcDatabaseList)NULL){
+ _db_list = p->next;
+ }else{
+ prev->next = p->next;
+ }
+ Xfree((char*)p);
+ }
+ break;
+ }
+ }
+ XLC_PUBLIC(lcd, xlocale_db) = (XPointer)NULL;
+}
+
+/************************************************************************/
+/* _XlcCreateLocaleDataBase(lcd) */
+/*----------------------------------------------------------------------*/
+/* This function create an XLocale database which correspond to */
+/* the specified XLCd. */
+/************************************************************************/
+XPointer
+_XlcCreateLocaleDataBase(lcd)
+ XLCd lcd;
+{
+ XlcDatabaseList list, new;
+ Database p, database = (Database)NULL;
+ XlcDatabase lc_db = (XlcDatabase)NULL;
+ XrmQuark name_q;
+ char *name;
+ int i, n;
+
+ name = _XlcFileName(lcd, "locale");
+ if(name == NULL){
+ return (XPointer)NULL;
+ }
+
+ name_q = XrmStringToQuark(name);
+ for(list = _db_list; list; list = list->next){
+ if(name_q == list->name_q){
+ list->ref_count++;
+ Xfree (name);
+ return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)list->lc_db;
+ }
+ }
+
+ database = CreateDatabase(name);
+ if(database == (Database)NULL){
+ Xfree (name);
+ return (XPointer)NULL;
+ }
+ n = CountDatabase(database);
+ lc_db = (XlcDatabase)Xmalloc(sizeof(XlcDatabaseRec) * (n + 1));
+ if(lc_db == (XlcDatabase)NULL){
+ goto err;
+ }
+ bzero(lc_db, sizeof(XlcDatabaseRec) * (n + 1));
+ for(p = database, i = 0; p && i < n; p = p->next, ++i){
+ lc_db[i].category_q = XrmStringToQuark(p->category);
+ lc_db[i].name_q = XrmStringToQuark(p->name);
+ lc_db[i].db = p;
+ }
+
+ new = (XlcDatabaseList)Xmalloc(sizeof(XlcDatabaseListRec));
+ if(new == (XlcDatabaseList)NULL){
+ goto err;
+ }
+ new->name_q = name_q;
+ new->lc_db = lc_db;
+ new->database = database;
+ new->ref_count = 1;
+ new->next = _db_list;
+ _db_list = new;
+
+ Xfree (name);
+ return XLC_PUBLIC(lcd, xlocale_db) = (XPointer)lc_db;
+
+ err:
+ DestroyDatabase(database);
+ if(lc_db != (XlcDatabase)NULL){
+ Xfree((char *)lc_db);
+ }
+ Xfree (name);
+ return (XPointer)NULL;
+}
+
+#endif /* NOT_X_ENV */
diff --git a/src/xlibi18n/lcDynamic.c b/src/xlibi18n/lcDynamic.c
new file mode 100644
index 00000000..64484382
--- /dev/null
+++ b/src/xlibi18n/lcDynamic.c
@@ -0,0 +1,74 @@
+/* $Xorg: lcDynamic.c,v 1.4 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+Copyright 1996, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+*/
+/*
+ * Copyright 1995 by FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Takanori Tateno FUJITSU LIMITED
+ *
+ */
+#ifdef USE_DYNAMIC_LOADER
+#include <stdio.h>
+#include <string.h>
+#include "Xlibint.h"
+
+#ifndef XLOCALEDIR
+#define XLOCALEDIR "/usr/lib/X11/locale"
+#endif
+
+#define LCLIBNAME "xi18n.so"
+
+extern void *dlopen();
+extern void *dlsym();
+extern int dlclose();
+extern char *dlerror();
+
+#define LAZY 1
+#define NOW 2
+#define GLOBAL 0x100
+
+XLCd
+_XlcDynamicLoader(name)
+ char *name;
+{
+ char libpath[1024];
+ XLCdMethods _XlcGenericMethods;
+ XLCd lcd;
+ void *nlshandler;
+
+ sprintf(libpath,"%s/%s/%s",
+ XLOCALEDIR,name,LCLIBNAME);
+ nlshandler = dlopen(libpath,LAZY);
+ _XlcGenericMethods = (XLCdMethods)dlsym(nlshandler,
+ "genericMethods");
+ lcd = _XlcCreateLC(name,_XlcGenericMethods);
+
+
+ return lcd;
+}
+#endif /* USE_DYNAMIC_LOADER */
diff --git a/src/xlibi18n/lcFile.c b/src/xlibi18n/lcFile.c
new file mode 100644
index 00000000..164674fc
--- /dev/null
+++ b/src/xlibi18n/lcFile.c
@@ -0,0 +1,417 @@
+/* $Xorg: lcFile.c,v 1.5 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ *
+ * Copyright IBM Corporation 1993
+ *
+ * All Rights Reserved
+ *
+ * License 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 IBM not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * IBM DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS, AND
+ * NONINFRINGEMENT OF THIRD PARTY RIGHTS, IN NO EVENT SHALL
+ * IBM 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.
+ *
+*/
+#include <stdio.h>
+#include <ctype.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xos.h>
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+/************************************************************************/
+
+#define iscomment(ch) ((ch) == '#' || (ch) == '\0')
+#if defined(WIN32) || defined(__EMX__) /* || defined(OS2) */
+#define isreadable(f) (_XAccessFile(f))
+#else
+#define isreadable(f) ((access((f), R_OK) != -1) ? 1 : 0)
+#endif
+
+#define XLC_BUFSIZE 256
+
+#ifndef X_NOT_POSIX
+#ifdef _POSIX_SOURCE
+#include <limits.h>
+#else
+#define _POSIX_SOURCE
+#include <limits.h>
+#undef _POSIX_SOURCE
+#endif
+#endif
+#ifndef PATH_MAX
+#ifdef WIN32
+#define PATH_MAX 512
+#else
+#include <sys/param.h>
+#endif
+#ifndef PATH_MAX
+#ifdef MAXPATHLEN
+#define PATH_MAX MAXPATHLEN
+#else
+#define PATH_MAX 1024
+#endif
+#endif
+#endif
+
+#define NUM_LOCALEDIR 64
+
+static int
+parse_line(line, argv, argsize)
+ char *line;
+ char **argv;
+ int argsize;
+{
+ int argc = 0;
+ char *p = line;
+
+ while(argc < argsize){
+ while(isspace(*p)){
+ ++p;
+ }
+ if(*p == '\0'){
+ break;
+ }
+ argv[argc++] = p;
+ while(*p != ':' && *p != '\n' && *p != '\0'){
+ ++p;
+ }
+ if(*p == '\0'){
+ break;
+ }
+ *p++ = '\0';
+ }
+
+ return argc;
+}
+
+/* parse the colon separated list in path into argv */
+int
+_XlcParsePath(path, argv, argsize)
+ char *path;
+ char **argv;
+ int argsize;
+{
+ char *p = path;
+ int i, n;
+
+#if 0
+ while((p = strchr(p, ':')) != NULL){
+ *p = ' '; /* place space on delimter */
+ }
+#endif
+ n = parse_line(path, argv, argsize);
+ if(n == 0){
+ return 0;
+ }
+ for(i = 0; i < n; ++i){
+ int len;
+ p = argv[i];
+ len = strlen(p);
+ if(p[len - 1] == '/'){
+ /* eliminate slash */
+ p[len - 1] = '\0';
+ }
+ }
+ return n;
+}
+
+#ifndef XLOCALEDIR
+#define XLOCALEDIR "/usr/lib/X11/locale"
+#endif
+
+static void
+xlocaledir(buf, buf_len)
+ char *buf;
+ int buf_len;
+{
+ char *dir, *p = buf;
+ int len = 0;
+
+ dir = getenv("XLOCALEDIR");
+ if(dir != NULL){
+ len = strlen(dir);
+ strncpy(p, dir, buf_len);
+ if (len < buf_len) {
+ p[len++] = ':';
+ p += len;
+ }
+ }
+ if (len < buf_len)
+ strncpy(p, XLOCALEDIR, buf_len-len);
+ buf[buf_len-1] = '\0';
+}
+
+enum { LtoR, RtoL };
+
+static char *
+resolve_name(lc_name, file_name, direction)
+ char *lc_name;
+ char *file_name;
+ int direction; /* mapping direction */
+{
+ FILE *fp;
+ char buf[XLC_BUFSIZE], *name = NULL;
+
+ fp = _XFopenFile (file_name, "r");
+ if(fp == (FILE *)NULL){
+ return NULL;
+ }
+
+ while(fgets(buf, XLC_BUFSIZE, fp) != NULL){
+ char *p = buf;
+ int n;
+ char *args[2], *from, *to;
+ while(isspace(*p)){
+ ++p;
+ }
+ if(iscomment(*p)){
+ continue;
+ }
+ n = parse_line(p, args, 2); /* get first 2 fields */
+ if(n != 2){
+ continue;
+ }
+ if(direction == LtoR){
+ from = args[0], to = args[1]; /* left to right */
+ }else{
+ from = args[1], to = args[0]; /* right to left */
+ }
+ if(! strcmp(from, lc_name)){
+ name = Xmalloc(strlen(to) + 1);
+ if(name != NULL){
+ strcpy(name, to);
+ }
+ break;
+ }
+ }
+ if(fp != (FILE *)NULL){
+ fclose(fp);
+ }
+ return name;
+}
+
+/*
+#define isupper(ch) ('A' <= (ch) && (ch) <= 'Z')
+#define tolower(ch) ((ch) - 'A' + 'a')
+*/
+static char *
+lowercase(dst, src)
+ char *dst;
+ char *src;
+{
+ char *s, *t;
+
+ for(s = src, t = dst; *s; ++s, ++t){
+ *t = isupper(*s) ? tolower(*s) : *s;
+ }
+ *t = '\0';
+ return dst;
+}
+
+/************************************************************************/
+char *
+_XlcFileName(lcd, category)
+ XLCd lcd;
+ char *category;
+{
+ char *siname;
+ char cat[XLC_BUFSIZE], dir[XLC_BUFSIZE];
+ int i, n;
+ char *args[NUM_LOCALEDIR];
+ char *file_name = NULL;
+
+ if(lcd == (XLCd)NULL){
+ return NULL;
+ }
+
+ siname = XLC_PUBLIC(lcd, siname);
+
+ lowercase(cat, category);
+ xlocaledir(dir,XLC_BUFSIZE);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
+ for(i = 0; i < n; ++i){
+ char buf[PATH_MAX], *name;
+
+ name = NULL;
+ if ((5 + (args[i] ? strlen (args[i]) : 0) +
+ (cat ? strlen (cat) : 0)) < PATH_MAX) {
+ sprintf(buf, "%s/%s.dir", args[i], cat);
+ name = resolve_name(siname, buf, RtoL);
+ }
+ if(name == NULL){
+ continue;
+ }
+ if(*name == '/'){
+ /* supposed to be absolute path name */
+ file_name = name;
+ }else{
+ file_name = Xmalloc(2 + (args[i] ? strlen (args[i]) : 0) +
+ (name ? strlen (name) : 0));
+ if (file_name != NULL)
+ sprintf(file_name, "%s/%s", args[i], name);
+ Xfree(name);
+ }
+ if(isreadable(file_name)){
+ break;
+ }
+ Xfree(file_name);
+ file_name = NULL;
+ /* Then, try with next dir */
+ }
+ return file_name;
+}
+
+/************************************************************************/
+#ifndef LOCALE_ALIAS
+#define LOCALE_ALIAS "locale.alias"
+#endif
+
+int
+_XlcResolveLocaleName(lc_name, pub)
+ char* lc_name;
+ XLCdPublicPart* pub;
+{
+ char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char *dst;
+ int i, n, sinamelen;
+ char *args[NUM_LOCALEDIR];
+ static char locale_alias[] = LOCALE_ALIAS;
+
+ xlocaledir (dir, PATH_MAX);
+ n = _XlcParsePath(dir, args, NUM_LOCALEDIR);
+ for(i = 0; i < n; ++i){
+ if ((2 + (args[i] ? strlen (args[i]) : 0) +
+ strlen (locale_alias)) < PATH_MAX) {
+ sprintf (buf, "%s/%s", args[i], locale_alias);
+ name = resolve_name (lc_name, buf, LtoR);
+ }
+ if(name != NULL){
+ break;
+ }
+ }
+
+ if (name == NULL) {
+ /* vendor locale name == Xlocale name, no expansion of alias */
+ pub->siname = Xmalloc (strlen (lc_name) + 1);
+ strcpy (pub->siname, lc_name);
+ } else {
+ pub->siname = name;
+ }
+
+ sinamelen = strlen (pub->siname);
+ if (sinamelen == 1 && pub->siname[0] == 'C') {
+ pub->language = pub->siname;
+ pub->territory = pub->codeset = NULL;
+ return 1;
+ }
+
+ /*
+ * pub->siname is in the format <lang>_<terr>.<codeset>, typical would
+ * be "en_US.ISO8859-1", "en_US.utf8", "ru_RU.KOI-8", or ja_JP.SJIS,
+ * although it could be ja.SJIS too.
+ */
+ pub->siname = Xrealloc (pub->siname, 2 * (sinamelen + 1));
+
+ /* language */
+ dst = &pub->siname[sinamelen + 1];
+ strcpy (dst, pub->siname);
+ pub->language = dst;
+
+ /* territory */
+ dst = strchr (dst, '_');
+ if (dst) {
+ *dst = '\0';
+ pub->territory = ++dst;
+ } else
+ dst = &pub->siname[sinamelen + 1];
+
+ /* codeset */
+ dst = strchr (dst, '.');
+ if (dst) {
+ *dst = '\0';
+ pub->codeset = ++dst;
+ }
+
+ return (pub->siname[0] != '\0') ? 1 : 0;
+}
+
+/************************************************************************/
+int
+_XlcResolveI18NPath(buf, buf_len)
+ char *buf;
+ int buf_len;
+{
+ if(buf != NULL){
+ xlocaledir(buf, buf_len);
+ }
+ return 1;
+}
+
+char *
+_XlcLocaleDirName(dir_name, lc_name)
+ char *dir_name;
+ char *lc_name;
+{
+ char dir[PATH_MAX], buf[PATH_MAX], *name = NULL;
+ char *dst;
+ int i, n, sinamelen;
+ char *args[NUM_LOCALEDIR];
+ static char locale_alias[] = LOCALE_ALIAS;
+ char *target_name = (char*)0;
+ char *target_dir = (char*)0;
+
+ xlocaledir (dir, PATH_MAX);
+ n = _XlcParsePath(dir, args, 256);
+ for (i = 0; i < n; ++i){
+ if ((2 + (args[i] ? strlen(args[i]) : 0) +
+ strlen(locale_alias)) < PATH_MAX) {
+ sprintf (buf, "%s/%s", args[i], locale_alias);
+ name = resolve_name(lc_name, buf, LtoR);
+ }
+ if (name != NULL){
+ /* look at locale.dir */
+ const char *cat = "locale";
+
+ target_dir = args[i];
+ if (!target_dir) {
+ /* something wrong */
+ continue;
+ }
+ if ((5 + (target_dir ? strlen (target_dir) : 0) +
+ (cat ? strlen(cat) : 0)) < PATH_MAX) {
+ sprintf(buf, "%s/%s.dir", target_dir, cat);
+ target_name = resolve_name(name, buf, RtoL);
+ }
+ if (target_name != NULL) {
+ char *p = 0;
+ if (p = strstr(target_name, "/XLC_LOCALE")) {
+ *p = '\0';
+ break;
+ }
+ }
+ }
+ }
+ if (target_name == NULL) {
+ /* vendor locale name == Xlocale name, no expansion of alias */
+ target_dir = args[0];
+ target_name = lc_name;
+ }
+ strcpy(dir_name, target_dir);
+ strcat(dir_name, "/");
+ strcat(dir_name, target_name);
+ return dir_name;
+}
diff --git a/src/xlibi18n/lcGeneric.c b/src/xlibi18n/lcGeneric.c
new file mode 100644
index 00000000..48261139
--- /dev/null
+++ b/src/xlibi18n/lcGeneric.c
@@ -0,0 +1,1185 @@
+/* $Xorg: lcGeneric.c,v 1.7 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ */
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcGeneric.h"
+
+static XLCd create();
+static Bool initialize();
+static void destroy();
+
+static XLCdPublicMethodsRec genericMethods = {
+ { NULL }, /* use default methods */
+ {
+ NULL,
+ create,
+ initialize,
+ destroy,
+ NULL
+ }
+};
+
+XLCdMethods _XlcGenericMethods = (XLCdMethods) &genericMethods;
+
+static XLCd
+create(name, methods)
+ char *name;
+ XLCdMethods methods;
+{
+ XLCd lcd;
+ XLCdPublicMethods new;
+
+ lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ if (lcd == NULL)
+ return (XLCd) NULL;
+ bzero((char *) lcd, sizeof(XLCdRec));
+
+ lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdGenericRec));
+ if (lcd->core == NULL)
+ goto err;
+ bzero((char *) lcd->core, sizeof(XLCdGenericRec));
+
+ new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ if (new == NULL)
+ goto err;
+ *new = *((XLCdPublicMethods) methods);
+ lcd->methods = (XLCdMethods) new;
+
+ return lcd;
+
+err:
+ Xfree(lcd);
+ return (XLCd) NULL;
+}
+
+static Bool
+string_to_encoding(str, encoding)
+ char *str;
+ char *encoding;
+{
+ char *next;
+ long value;
+ int base;
+
+ while (*str) {
+ if (*str == '\\') {
+ switch (*(str + 1)) {
+ case 'x':
+ case 'X':
+ base = 16;
+ break;
+ default:
+ base = 8;
+ break;
+ }
+ value = strtol(str + 2, &next, base);
+ if (str + 2 != next) {
+ *((unsigned char *) encoding++) = (unsigned char) value;
+ str = next;
+ continue;
+ }
+ }
+ *encoding++ = *str++;
+ }
+
+ *encoding = '\0';
+
+ return True;
+}
+
+static Bool
+string_to_ulong(str, value)
+char *str;
+unsigned long *value;
+{
+ char *tmp1 = str;
+ int base;
+
+ if(*tmp1++ != '\\'){
+ tmp1--;
+ base = 10;
+ }else{
+ switch(*tmp1++){
+ case 'x':
+ base = 16;
+ break;
+ case 'o':
+ base = 8;
+ break;
+ case 'd':
+ base = 10;
+ break;
+ default:
+ return(False);
+ }
+ }
+ *value = (unsigned) strtol(tmp1, NULL, base);
+ return(True);
+}
+
+
+static Bool
+add_charset(codeset, charset)
+ CodeSet codeset;
+ XlcCharSet charset;
+{
+ XlcCharSet *new_list;
+ int num;
+
+ if ((num = codeset->num_charsets))
+ new_list = (XlcCharSet *) Xrealloc(codeset->charset_list,
+ (num + 1) * sizeof(XlcCharSet));
+ else
+ new_list = (XlcCharSet *) Xmalloc(sizeof(XlcCharSet));
+
+ if (new_list == NULL)
+ return False;
+
+ new_list[num] = charset;
+ codeset->charset_list = new_list;
+ codeset->num_charsets = num + 1;
+
+ return True;
+}
+
+static CodeSet
+add_codeset(gen)
+ XLCdGenericPart *gen;
+{
+ CodeSet new, *new_list;
+ int num;
+
+ new = (CodeSet) Xmalloc(sizeof(CodeSetRec));
+ if (new == NULL)
+ return NULL;
+ bzero((char *) new, sizeof(CodeSetRec));
+
+ if ((num = gen->codeset_num))
+ new_list = (CodeSet *) Xrealloc(gen->codeset_list,
+ (num + 1) * sizeof(CodeSet));
+ else
+ new_list = (CodeSet *) Xmalloc(sizeof(CodeSet));
+
+ if (new_list == NULL)
+ goto err;
+
+ new_list[num] = new;
+ gen->codeset_list = new_list;
+ gen->codeset_num = num + 1;
+
+ return new;
+
+err:
+ Xfree(new);
+
+ return NULL;
+}
+
+static Bool
+add_parse_list(gen, type, encoding, codeset)
+ XLCdGenericPart *gen;
+ EncodingType type;
+ char *encoding;
+ CodeSet codeset;
+{
+ ParseInfo new, *new_list;
+ char *str;
+ unsigned char ch;
+ int num;
+
+ str = (char *) Xmalloc(strlen(encoding) + 1);
+ if (str == NULL)
+ return False;
+ strcpy(str, encoding);
+
+ new = (ParseInfo) Xmalloc(sizeof(ParseInfoRec));
+ if (new == NULL)
+ goto err;
+ bzero((char *) new, sizeof(ParseInfoRec));
+
+ if (gen->mb_parse_table == NULL) {
+ gen->mb_parse_table = (unsigned char *) Xmalloc(256); /* 2^8 */
+ if (gen->mb_parse_table == NULL)
+ goto err;
+ bzero((char *) gen->mb_parse_table, 256);
+ }
+
+ if ((num = gen->mb_parse_list_num))
+ new_list = (ParseInfo *) Xrealloc(gen->mb_parse_list,
+ (num + 2) * sizeof(ParseInfo));
+ else {
+ new_list = (ParseInfo *) Xmalloc(2 * sizeof(ParseInfo));
+ }
+
+ if (new_list == NULL)
+ goto err;
+
+ new_list[num] = new;
+ new_list[num + 1] = NULL;
+ gen->mb_parse_list = new_list;
+ gen->mb_parse_list_num = num + 1;
+
+ ch = (unsigned char) *str;
+ if (gen->mb_parse_table[ch] == 0)
+ gen->mb_parse_table[ch] = num + 1;
+
+ new->type = type;
+ new->encoding = str;
+ new->codeset = codeset;
+
+ if (codeset->parse_info == NULL)
+ codeset->parse_info = new;
+
+ return True;
+
+err:
+ Xfree(str);
+ if (new)
+ Xfree(new);
+
+ return False;
+}
+
+static void
+free_charset(lcd)
+ XLCd lcd;
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ ParseInfo *parse_info;
+ int num;
+
+ if (gen->mb_parse_table)
+ Xfree(gen->mb_parse_table);
+ if ((num = gen->mb_parse_list_num)) {
+ for (parse_info = gen->mb_parse_list; num-- > 0; parse_info++) {
+ if ((*parse_info)->encoding)
+ Xfree((*parse_info)->encoding);
+ Xfree(*parse_info);
+ }
+ Xfree(gen->mb_parse_list);
+ }
+
+ if ((num = gen->codeset_num))
+ Xfree(gen->codeset_list);
+}
+/* For VW/UDC */
+
+#define FORWARD (unsigned long)'+'
+#define BACKWARD (unsigned long)'-'
+
+static char *getscope(str,scp)
+char *str;
+FontScope scp;
+{
+ char* next;
+ unsigned long start=0,end=0,dest=0,shift=0,direction=0;
+ sscanf(str,"[\\x%lx,\\x%lx]->\\x%lx", &start, &end,&dest);
+ if( dest ){
+ if(dest >= start ){
+ shift = dest - start;
+ direction = FORWARD ;
+ } else {
+ shift = start - dest;
+ direction = BACKWARD;
+ }
+ }
+ scp->start = start ;
+ scp->end = end ;
+ scp->shift = shift ;
+ scp->shift_direction
+ = direction ;
+ /* .......... */
+ while(*str){
+ if(*str == ',' && *(str+1) == '['){
+ break;
+ }
+ str++;
+ }
+ next = str+1 ;
+ return(next);
+}
+
+static int count_scopemap(str)
+char *str;
+{
+ char *ptr;
+ int num=0;
+ for(ptr=str;*ptr;ptr++){
+ if(*ptr == ']'){
+ num ++;
+ }
+ }
+ return(num);
+}
+
+FontScope _XlcParse_scopemaps(str,size)
+char *str;
+int *size;
+{
+ int num=0,i;
+ FontScope scope,sc_ptr;
+ char *str_sc;
+ num = count_scopemap(str);
+ scope = (FontScope )Xmalloc(num * sizeof(FontScopeRec));
+ if(scope == NULL) {
+ return (NULL);
+ }
+ for (i=0,str_sc=str,sc_ptr=scope;
+ i < num; i++,sc_ptr++){
+ str_sc = getscope(str_sc,sc_ptr);
+ }
+ *size = num;
+ return (scope);
+}
+
+void _XlcDbg_printValue(str,value,num)
+char *str;
+char **value;
+int num;
+{
+/*
+ int i;
+ for(i=0;i<num;i++){
+ fprintf(stderr,"%s value[%d] = %s\n",str,i,value[i]);
+ }
+*/
+}
+
+static void dmpscope(name,sc,num)
+char* name;
+FontScope sc;
+int num;
+{
+/*
+ int i;
+ fprintf(stderr,"dmpscope %s\n",name);
+ for(i=0;i<num;i++){
+ fprintf(stderr,"%x %x %x %x \n",
+ sc[i].start,
+ sc[i].end,
+ sc[i].shift,
+ sc[i].shift_direction);
+ }
+ fprintf(stderr,"dmpscope end\n");
+*/
+}
+
+static XlcCharSet srch_charset_define(name,new)
+char *name;
+int *new;
+{
+ XlcCharSet charset = NULL;
+ *new = 0;
+ charset = _XlcGetCharSet(name);
+ if (charset == NULL &&
+ (charset = _XlcCreateDefaultCharSet(name, ""))) {
+ _XlcAddCharSet(charset);
+ *new = 1;
+ }
+ return(charset);
+}
+
+static void read_charset_define(lcd,gen)
+XLCd lcd;
+XLCdGenericPart *gen;
+{
+ int i=0;
+ char csd[16],cset_name[256];
+ char name[BUFSIZ];
+ XlcCharSet charsetd;
+ char **value;
+ int num,new;
+ XlcSide side = XlcUnknown;
+ char *tmp;
+
+ for(i=0;;i++){ /* loop start */
+ charsetd = 0;
+ sprintf(csd, "csd%d", i);
+
+ /* charset_name */
+ sprintf(name, "%s.%s", csd , "charset_name");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ _XlcDbg_printValue(name,value,num);
+ if (num > 0) {
+ /* hackers will get truncated -- C'est la vie */
+ strncpy(cset_name,value[0], sizeof cset_name - 1);
+ cset_name[(sizeof cset_name) - 1] = '\0';
+ sprintf(name, "%s.%s", csd , "side");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ if( !_XlcNCompareISOLatin1(value[0], "none", 4) ){
+ side = XlcNONE ;
+ strcat(cset_name,":none");
+ } else
+ if( !_XlcNCompareISOLatin1(value[0], "GL", 2) ){
+ side = XlcGL ;
+ strcat(cset_name,":GL");
+ } else {
+ side = XlcGR ;
+ strcat(cset_name,":GR");
+ }
+ if (charsetd == NULL &&
+ (charsetd = srch_charset_define(cset_name,&new)) == NULL)
+ return ;
+ }
+ } else {
+ if(i == 0){
+ continue ;
+ } else {
+ break ;
+ }
+ }
+ if(new){
+ tmp = (char *)Xmalloc(strlen(cset_name)+1);
+ if(tmp == NULL){
+ return ;
+ }
+ strcpy(tmp,cset_name);
+ charsetd->name = tmp;
+ }
+ /* side */
+ charsetd->side = side ;
+ /* length */
+ sprintf(name, "%s.%s", csd , "length");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ charsetd->char_size = atoi(value[0]);
+ }
+ /* gc_number */
+ sprintf(name, "%s.%s", csd , "gc_number");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ charsetd->set_size = atoi(value[0]);
+ }
+ /* string_encoding */
+ sprintf(name, "%s.%s", csd , "string_encoding");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ if(!strcmp("False",value[0])){
+ charsetd->string_encoding = False;
+ } else {
+ charsetd->string_encoding = True;
+ }
+ }
+ /* sequence */
+ sprintf(name, "%s.%s", csd , "sequence");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+/*
+ if(charsetd->ct_sequence){
+ Xfree(charsetd->ct_sequence);
+ }
+*/
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if(tmp == NULL){
+ return;
+ }
+ charsetd->ct_sequence = tmp;
+ string_to_encoding(value[0],tmp);
+ }
+ /* encoding_name */
+ sprintf(name, "%s.%s", csd , "encoding_name");
+ _XlcGetResource(lcd, "XLC_CHARSET_DEFINE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+/*
+ if(charsetd->encoding_name){
+ Xfree(charsetd->encoding_name);
+ }
+*/
+ tmp = (char *)Xmalloc(strlen(value[0]+1));
+ strcpy(tmp,value[0]);
+ charsetd->encoding_name = tmp;
+ charsetd->xrm_encoding_name =
+ XrmStringToQuark(tmp);
+ }
+ }
+
+}
+
+SegConv
+add_conversion(gen)
+XLCdGenericPart *gen;
+{
+ SegConv new_list;
+ int num;
+
+ if ((num = gen->segment_conv_num)){
+ new_list = (SegConv) Xrealloc(gen->segment_conv,
+ (num + 1) * sizeof(SegConvRec));
+ } else {
+ new_list = (SegConv) Xmalloc(sizeof(SegConvRec));
+ }
+
+ if (new_list == NULL)
+ return False;
+
+ gen->segment_conv = new_list;
+ gen->segment_conv_num = num + 1;
+
+ return (&new_list[num]);
+
+}
+static void read_segmentconversion(lcd,gen)
+XLCd lcd;
+XLCdGenericPart *gen;
+{
+ int i=0;
+ char conv[16];
+ char name[BUFSIZ];
+ char **value;
+ int num,new;
+ SegConv conversion;
+ for(i=0 ; ; i++){ /* loop start */
+ conversion = 0;
+ sprintf(conv, "conv%d", i);
+
+ /* length */
+ sprintf(name, "%s.%s", conv , "length");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ if (conversion == NULL &&
+ (conversion = add_conversion(gen)) == NULL) {
+ return ;
+ }
+ _XlcDbg_printValue(name,value,num);
+ } else {
+ if(i == 0){
+ continue;
+ } else {
+ break ;
+ }
+ }
+ conversion->length = atoi(value[0]);
+
+ /* source_encoding */
+ sprintf(name, "%s.%s", conv , "source_encoding");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+ _XlcDbg_printValue(name,value,num);
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if(tmp == NULL){
+ return;
+ }
+ strcpy(tmp,value[0]);
+ conversion->source_encoding = tmp;
+ conversion->source = srch_charset_define(tmp,&new);
+ if(new){
+ tmp = (char *)Xmalloc(strlen(conversion->source_encoding)+1);
+ if(tmp == NULL){
+ return ;
+ }
+ strcpy(tmp,conversion->source_encoding);
+ conversion->source->name = tmp;
+ }
+ }
+ /* destination_encoding */
+ sprintf(name, "%s.%s", conv , "destination_encoding");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+ _XlcDbg_printValue(name,value,num);
+ tmp = (char *)Xmalloc(strlen(value[0])+1);
+ if(tmp == NULL){
+ return;
+ }
+ strcpy(tmp,value[0]);
+ conversion->destination_encoding = tmp;
+ conversion->dest = srch_charset_define(tmp,&new);
+ if(new){
+ tmp = (char *)Xmalloc(
+ strlen(conversion->destination_encoding)+1);
+ if(tmp == NULL){
+ return ;
+ }
+ strcpy(tmp,conversion->destination_encoding);
+ conversion->dest->name = tmp;
+ }
+ }
+ /* range */
+ sprintf(name, "%s.%s", conv , "range");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ sscanf(value[0],"\\x%lx,\\x%lx",
+ &(conversion->range.start),
+ &(conversion->range.end));
+ }
+ /* conversion */
+ sprintf(name, "%s.%s", conv , "conversion");
+ _XlcGetResource(lcd, "XLC_SEGMENTCONVERSION", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ conversion->conv =
+ _XlcParse_scopemaps(value[0],&conversion->conv_num);
+ }
+ } /* loop end */
+}
+
+static ExtdSegment create_ctextseg(value,num)
+char **value;
+int num;
+{
+ ExtdSegment ret;
+ char* ptr;
+ char* cset_name = NULL;
+ int i,new;
+ FontScope scope;
+ ret = (ExtdSegment)Xmalloc(sizeof(ExtdSegmentRec));
+ if(ret == NULL){
+ return NULL;
+ }
+ if(strchr(value[0],':')){
+ ret->name = (char *)Xmalloc(strlen(value[0])+1);
+ if(ret->name == NULL){
+ Xfree (ret);
+ return NULL;
+ }
+ strcpy(ret->name,value[0]);
+ ptr = strchr(ret->name,':');
+ *ptr = '\0';
+ ptr++;
+ cset_name = (char*) Xmalloc (strlen (ret->name) + 6);
+ if (cset_name == NULL) {
+ Xfree (ret->name);
+ Xfree (ret);
+ return NULL;
+ }
+ if( !_XlcNCompareISOLatin1(ptr, "none", 4) ){
+ ret->side = XlcNONE ;
+ sprintf(cset_name,"%s:%s",ret->name,"none");
+ } else
+ if( !_XlcNCompareISOLatin1(ptr, "GL", 2) ){
+ ret->side = XlcGL ;
+ sprintf(cset_name,"%s:%s",ret->name,"GL");
+ } else {
+ ret->side = XlcGR ;
+ sprintf(cset_name,"%s:%s",ret->name,"GR");
+ }
+ } else {
+ ret->name = (char *)Xmalloc(strlen(value[0])+1);
+ if(ret->name == NULL){
+ Xfree (ret);
+ return NULL;
+ }
+ strcpy(ret->name,value[0]);
+ }
+ ret->area = (FontScope)Xmalloc((num - 1)*sizeof(FontScopeRec));
+ if(ret->area == NULL){
+ Xfree (ret->name);
+ Xfree (ret);
+ return NULL;
+ }
+ ret->area_num = num - 1;
+ scope = ret->area ;
+ for(i=1;i<num;i++){
+ sscanf(value[i],"\\x%lx,\\x%lx",
+ &scope[i-1].start,&scope[i-1].end);
+ }
+ ret->charset = srch_charset_define(cset_name,&new);
+ if (new)
+ ret->charset->name = cset_name;
+ else
+ Xfree (cset_name);
+
+ return ret;
+}
+/* For VW/UDC end */
+
+static Bool
+load_generic(lcd)
+ XLCd lcd;
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ char **value;
+ int num;
+ unsigned long l;
+ int i;
+ int M,ii;
+
+ gen->codeset_num = 0;
+
+ /***** wc_encoding_mask *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "wc_encoding_mask", &value, &num);
+ if (num > 0) {
+ if (string_to_ulong(value[0], &l) == False)
+ goto err;
+ gen->wc_encode_mask = l;
+ }
+ /***** wc_shift_bits *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "wc_shift_bits", &value, &num);
+ if (num > 0)
+ gen->wc_shift_bits = atoi(value[0]);
+ if (gen->wc_shift_bits < 1)
+ gen->wc_shift_bits = 8;
+#ifndef X_NOT_STDC_ENV
+ /***** use_stdc_env *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "use_stdc_env", &value, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))
+ gen->use_stdc_env = True;
+ else
+ gen->use_stdc_env = False;
+ /***** force_convert_to_mb *****/
+ _XlcGetResource(lcd, "XLC_XLOCALE", "force_convert_to_mb", &value, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(value[0], "True"))
+ gen->force_convert_to_mb = True;
+ else
+ gen->force_convert_to_mb = False;
+#endif
+
+ for (i = 0; ; i++) {
+ CodeSetRec *codeset = NULL;
+ char cs[16];
+ char name[BUFSIZ];
+
+ sprintf(cs, "cs%d", i);
+
+ /***** codeset.side *****/
+ sprintf(name, "%s.%s", cs , "side");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ char *tmp;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+
+ /* 3.4.1 side */
+ if( !_XlcNCompareISOLatin1(value[0], "none", 4) ){
+ codeset->side = XlcNONE ;
+ } else
+ if( !_XlcNCompareISOLatin1(value[0], "GL", 2) ){
+ codeset->side = XlcGL ;
+ } else {
+ codeset->side = XlcGR ;
+ }
+
+ tmp = strrchr(value[0], ':');
+ if (tmp != NULL && !_XlcCompareISOLatin1(tmp + 1, "Default")) {
+ if (codeset->side == XlcGR)
+ gen->initial_state_GR = codeset;
+ else
+ gen->initial_state_GL = codeset;
+ }
+ }
+
+ /***** codeset.length *****/
+ sprintf(name, "%s.%s", cs , "length");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ codeset->length = atoi(value[0]);
+ if (codeset->length < 1)
+ codeset->length = 1;
+ }
+
+ /***** codeset.mb_encoding *****/
+ sprintf(name, "%s.%s", cs, "mb_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ static struct {
+ char *str;
+ int type;
+ } shifts[] = {
+ {"<SS>", E_SS},
+ {"<LSL>", E_LSL},
+ {"<LSR>", E_LSR},
+ 0
+ };
+ int j;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ for ( ; num-- > 0; value++) {
+ char encoding[256];
+ char *tmp = *value;
+ int type = E_SS; /* for BC */
+ for (j = 0; shifts[j].str; j++) {
+ if (!_XlcNCompareISOLatin1(tmp, shifts[j].str,
+ strlen(shifts[j].str))) {
+ type = shifts[j].type;
+ tmp += strlen(shifts[j].str);
+ break;
+ }
+ }
+ if (strlen (tmp) > sizeof encoding ||
+ string_to_encoding(tmp, encoding) == False)
+ goto err;
+ add_parse_list(gen, type, encoding, codeset);
+ }
+ }
+
+ /***** codeset.wc_encoding *****/
+ sprintf(name, "%s.%s", cs, "wc_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ if (string_to_ulong(value[0], &l) == False)
+ goto err;
+ codeset->wc_encoding = l;
+ }
+
+ /***** codeset.ct_encoding *****/
+ sprintf(name, "%s.%s", cs, "ct_encoding");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ XlcCharSet charset;
+ char *encoding;
+
+ if (codeset == NULL && (codeset = add_codeset(gen)) == NULL)
+ goto err;
+ for ( ; num-- > 0; value++) {
+ if (strlen (*value) > sizeof name)
+ goto err;
+ string_to_encoding(*value, name);
+ charset = NULL;
+ if ((encoding = strchr(name, ':')) &&
+ (encoding = strchr(encoding + 1, ':'))) {
+ *encoding++ = '\0';
+ charset = _XlcAddCT(name, encoding);
+ }
+ if (charset == NULL) {
+ charset = _XlcGetCharSet(name);
+ if (charset == NULL &&
+ (charset = _XlcCreateDefaultCharSet(name, ""))) {
+ charset->side = codeset->side;
+ charset->char_size = codeset->length;
+ _XlcAddCharSet(charset);
+ }
+ }
+ if (charset) {
+ if (add_charset(codeset, charset) == False)
+ goto err;
+ }
+ }
+ }
+
+ if (codeset == NULL)
+ break;
+ codeset->cs_num = i;
+ /* For VW/UDC */
+ /***** 3.4.2 byteM (1 <= M <= length)*****/
+ for(M=1; M-1 < codeset->length; M++){
+ long start,end;
+ ByteInfo tmpb;
+
+ sprintf(name,"%s.%s%d",cs,"byte",M);
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+
+ if( M == 1){
+ if(num < 1) {
+ codeset->byteM = NULL ;
+ break ;
+ }
+ codeset->byteM =
+ (ByteInfoListRec *)Xmalloc(
+ (codeset->length)*sizeof(ByteInfoListRec));
+ if(codeset->byteM == NULL){
+ goto err;
+ }
+ }
+
+ if(num > 0){
+ _XlcDbg_printValue(name,value,num);
+ (codeset->byteM)[M-1].M = M;
+ (codeset->byteM)[M-1].byteinfo_num = num;
+ (codeset->byteM)[M-1].byteinfo =
+ (ByteInfo)Xmalloc( num * sizeof(ByteInfoRec));
+ for(ii = 0 ; ii < num ; ii++){
+ tmpb = (codeset->byteM)[M-1].byteinfo ;
+ /* default 0x00 - 0xff */
+ sscanf(value[ii],"\\x%lx,\\x%lx",&start,&end);
+ tmpb[ii].start = (unsigned char)start;
+ tmpb[ii].end = (unsigned char)end;
+ }
+ }
+ /* .... */
+ }
+
+
+ /***** codeset.mb_conversion *****/
+ sprintf(name, "%s.%s", cs, "mb_conversion");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->mbconv = Xmalloc(sizeof(ConversionRec));
+ codeset->mbconv->convlist =
+ _XlcParse_scopemaps(value[0],&(codeset->mbconv->conv_num));
+ dmpscope("mb_conv",codeset->mbconv->convlist,
+ codeset->mbconv->conv_num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_conversion *****/
+ sprintf(name, "%s.%s", cs, "ct_conversion");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->ctconv = Xmalloc(sizeof(ConversionRec));
+ codeset->ctconv->convlist =
+ _XlcParse_scopemaps(value[0],&(codeset->ctconv->conv_num));
+ dmpscope("ctconv",codeset->ctconv->convlist,
+ codeset->ctconv->conv_num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_conversion_file *****/
+ sprintf(name, "%s.%s", cs, "ct_conversion_file");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /***** codeset.ct_extended_segment *****/
+ sprintf(name, "%s.%s", cs, "ct_extended_segment");
+ _XlcGetResource(lcd, "XLC_XLOCALE", name, &value, &num);
+ if (num > 0) {
+ _XlcDbg_printValue(name,value,num);
+ codeset->ctextseg = create_ctextseg(value,num);
+ /* [\x%x,\x%x]->\x%x,... */
+ }
+ /* For VW/UDC end */
+
+ }
+
+ read_charset_define(lcd,gen); /* For VW/UDC */
+ read_segmentconversion(lcd,gen); /* For VW/UDC */
+
+ return True;
+
+err:
+ free_charset(lcd);
+
+ return False;
+}
+
+#ifdef USE_DYNAMIC_LC
+/* override the open_om and open_im methods which were set by
+ super_class's initialize method() */
+
+static Bool
+initialize_core(lcd)
+ XLCd lcd;
+{
+ _XInitDynamicOM(lcd);
+
+ _XInitDynamicIM(lcd);
+
+ return True;
+}
+#endif
+
+static Bool
+initialize(lcd)
+ XLCd lcd;
+{
+ XLCdPublicMethods superclass = (XLCdPublicMethods) _XlcPublicMethods;
+
+ XLC_PUBLIC_METHODS(lcd)->superclass = superclass;
+
+ if (superclass->pub.initialize) {
+ if ((*superclass->pub.initialize)(lcd) == False)
+ return False;
+ }
+
+#ifdef USE_DYNAMIC_LC
+ if (initialize_core(lcd) == False)
+ return False;
+#endif
+
+ if(load_generic(lcd) == False)
+ return False;
+
+ return True;
+}
+/* VW/UDC start 95.01.08 */
+static void
+freeByteM(codeset)
+ CodeSet codeset;
+{
+ int i;
+ ByteInfoList blst;
+ if(codeset->byteM == NULL) {
+ return ;
+ }
+ blst = codeset->byteM;
+ for(i=0;i<codeset->length;i++){
+ if(blst[i].byteinfo){
+ Xfree(blst[i].byteinfo);
+ blst[i].byteinfo = NULL;
+ }
+ }
+ Xfree(codeset->byteM);
+ codeset->byteM = NULL;
+}
+static void
+freeConversion(codeset)
+ CodeSet codeset;
+{
+ Conversion mbconv,ctconv;
+ if( codeset->mbconv ) {
+ mbconv = codeset->mbconv;
+ /* ... */
+ if(mbconv->convlist){
+ Xfree(mbconv->convlist);
+ mbconv->convlist = NULL;
+ }
+ Xfree(mbconv);
+ codeset->mbconv = NULL;
+ }
+ if( codeset->ctconv ) {
+ ctconv = codeset->ctconv;
+ /* ... */
+ if(ctconv->convlist){
+ Xfree(ctconv->convlist);
+ ctconv->convlist = NULL;
+ }
+ Xfree(ctconv);
+ codeset->ctconv = NULL;
+ }
+}
+static void
+freeExtdSegment(codeset)
+ CodeSet codeset;
+{
+ ExtdSegment ctextseg;
+ if(codeset->ctextseg == NULL) {
+ return ;
+ }
+ ctextseg = codeset->ctextseg;
+ if(ctextseg->name){
+ Xfree(ctextseg->name);
+ ctextseg->name = NULL;
+ }
+ if(ctextseg->area){
+ Xfree(ctextseg->area);
+ ctextseg->area = NULL;
+ }
+ Xfree(codeset->ctextseg);
+ codeset->ctextseg = NULL;
+}
+static void
+freeParseInfo(codeset)
+ CodeSet codeset;
+{
+ ParseInfo parse_info;
+ if(codeset->parse_info == NULL) {
+ return ;
+ }
+ parse_info = codeset->parse_info;
+ if(parse_info->encoding){
+ Xfree(parse_info->encoding);
+ parse_info->encoding = NULL;
+ }
+ Xfree(codeset->parse_info);
+ codeset->parse_info = NULL;
+}
+static void
+destroy_CodeSetList(gen)
+ XLCdGenericPart *gen ;
+{
+ CodeSet *codeset = gen->codeset_list;
+ int i;
+ if(gen->codeset_num == 0) {
+ return;
+ }
+ for(i=0;i<gen->codeset_num;i++){
+ freeByteM(codeset[i]);
+ freeConversion(codeset[i]);
+ freeExtdSegment(codeset[i]);
+ freeParseInfo(codeset[i]);
+ if(codeset[i]->charset_list){
+ Xfree(codeset[i]->charset_list);
+ codeset[i]->charset_list = NULL;
+ }
+ Xfree(codeset[i]); codeset[i]=NULL;
+ }
+ Xfree(codeset); gen->codeset_list = NULL;
+}
+/* */
+static void
+destroy_SegConv(gen)
+ XLCdGenericPart *gen ;
+{
+ SegConv seg = gen->segment_conv;
+ int i;
+ if(gen->segment_conv_num == 0) {
+ return;
+ }
+ for(i=0;i<gen->segment_conv_num;i++){
+ if(seg[i].source_encoding){
+ Xfree(seg[i].source_encoding);
+ seg[i].source_encoding = NULL;
+ }
+ if(seg[i].destination_encoding){
+ Xfree(seg[i].destination_encoding);
+ seg[i].destination_encoding = NULL;
+ }
+ if(seg[i].conv){
+ Xfree(seg[i].conv); seg[i].conv = NULL;
+ }
+ }
+ Xfree(seg); gen->segment_conv = NULL;
+}
+
+static void
+destroy_gen(lcd)
+ XLCd lcd;
+{
+ XLCdGenericPart *gen = XLC_GENERIC_PART(lcd);
+ destroy_SegConv(gen);
+ destroy_CodeSetList(gen);
+ if(gen->mb_parse_table){
+ Xfree(gen->mb_parse_table);
+ gen->mb_parse_table = NULL;
+ }
+ if(gen->mb_parse_list){
+ Xfree(gen->mb_parse_list);
+ gen->mb_parse_list = NULL;
+ }
+}
+/* VW/UDC end 95.01.08 */
+static void
+destroy(lcd)
+ XLCd lcd;
+{
+ XLCdPublicMethods superclass = XLC_PUBLIC_METHODS(lcd)->superclass;
+
+ destroy_gen(lcd); /* ADD 1996.01.08 */
+ if (superclass && superclass->pub.destroy)
+ (*superclass->pub.destroy)(lcd);
+}
diff --git a/src/xlibi18n/lcInit.c b/src/xlibi18n/lcInit.c
new file mode 100644
index 00000000..e4d3a7a4
--- /dev/null
+++ b/src/xlibi18n/lcInit.c
@@ -0,0 +1,229 @@
+/*
+Copyright 1985, 1986, 1987, 1991, 1998 The Open Group
+
+Portions Copyright 2000 Sun Microsystems, Inc. All Rights Reserved.
+
+Permission is hereby granted, free of charge, to any person obtaining a
+copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions: The above copyright notice and this
+permission notice shall be included in all copies or substantial
+portions of the Software.
+
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP OR SUN MICROSYSTEMS, INC. BE LIABLE
+FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH
+THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE EVEN IF
+ADVISED IN ADVANCE OF THE POSSIBILITY OF SUCH DAMAGES.
+
+
+Except as contained in this notice, the names of The Open Group and/or
+Sun Microsystems, Inc. shall not be used in advertising or otherwise to
+promote the sale, use or other dealings in this Software without prior
+written authorization from The Open Group and/or Sun Microsystems,
+Inc., as applicable.
+
+
+X Window System is a trademark of The Open Group
+
+OSF/1, OSF/Motif and Motif are registered trademarks, and OSF, the OSF
+logo, LBX, X Window System, and Xinerama are trademarks of the Open
+Group. All other trademarks and registered trademarks mentioned herein
+are the property of their respective owners. No right, title or
+interest in or to any trademark, service mark, logo or trade name of
+Sun Microsystems, Inc. or its licensors is granted.
+
+*/
+/* $Xorg: lcInit.c,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+/*
+ * (c) Copyright 1995 FUJITSU LIMITED
+ * This is source code modified by FUJITSU LIMITED under the Joint
+ * Development Agreement for the CDE/Motif PST.
+ *
+ * Modifier: Masayoshi Shimamura FUJITSU LIMITED
+ *
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+#ifdef USE_DYNAMIC_LC
+#undef USE_DEFAULT_LOADER
+#else
+#define USE_GENERIC_LOADER
+#define USE_DEFAULT_LOADER
+#ifdef X_LOCALE
+# define USE_EUC_LOADER
+# define USE_SJIS_LOADER
+# define USE_JIS_LOADER
+# define USE_UTF_LOADER
+#endif
+#endif
+
+#ifdef USE_DEFAULT_LOADER
+extern XLCd _XlcDefaultLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_DYNAMIC_LC
+extern XLCd _XlcDynamicLoad(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef DYNAMIC_LOAD
+#ifdef AIXV3
+extern XLCd _XaixOsDynamicLoad(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif /* AIXV3 */
+#endif
+
+#ifdef USE_GENERIC_LOADER
+extern XLCd _XlcGenericLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_UTF_LOADER
+extern XLCd _XlcUtfLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_EUC_LOADER
+extern XLCd _XlcEucLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_SJIS_LOADER
+extern XLCd _XlcSjisLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_JIS_LOADER
+extern XLCd _XlcJisLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+#ifdef USE_DYNAMIC_LOADER
+extern XLCd _XlcDynamicLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+#endif
+
+/*
+ * The _XlcInitLoader function initializes the locale object loader list
+ * with vendor specific manner.
+ */
+
+void
+#if NeedFunctionPrototypes
+_XlcInitLoader(char *name)
+#else
+_XlcInitLoader(name)
+ char *name;
+#endif
+{
+
+#ifdef USE_DYNAMIC_LC
+ _XlcAddLoader(_XlcDynamicLoad, XlcHead);
+
+#ifdef USE_DEFAULT_LOADER
+ if (strcmp(name, "C") == 0 || strcmp(name, "POSIX") == 0)
+ _XlcAddLoader(_XlcDefaultLoader, XlcHead);
+ else
+ _XlcAddLoader(_XlcDefaultLoader, XlcTail);
+#endif
+
+#else /* USE_DYNAMIC_LC */
+
+#ifdef USE_GENERIC_LOADER
+ _XlcAddLoader(_XlcGenericLoader, XlcHead);
+#endif
+
+#ifdef USE_DEFAULT_LOADER
+ _XlcAddLoader(_XlcDefaultLoader, XlcHead);
+#endif
+
+#ifdef USE_EUC_LOADER
+ _XlcAddLoader(_XlcEucLoader, XlcHead);
+#endif
+
+#ifdef USE_SJIS_LOADER
+ _XlcAddLoader(_XlcSjisLoader, XlcHead);
+#endif
+
+#ifdef USE_JIS_LOADER
+ _XlcAddLoader(_XlcJisLoader, XlcHead);
+#endif
+
+#ifdef USE_UTF_LOADER
+ _XlcAddLoader(_XlcUtfLoader, XlcHead);
+#endif
+
+#endif /* USE_DYNAMIC_LC */
+
+#ifdef DYNAMIC_LOAD
+#ifdef AIXV3
+ _XlcAddLoader(_XaixOsDynamicLoad, XlcHead);
+#endif /* AIXV3 */
+#endif /* DYNAMIC_LOAD */
+
+#ifdef USE_DYNAMIC_LOADER
+ _XlcAddLoader(_XlcDynamicLoader, XlcHead);
+#endif
+}
diff --git a/src/xlibi18n/lcPrTxt.c b/src/xlibi18n/lcPrTxt.c
new file mode 100644
index 00000000..c06a628f
--- /dev/null
+++ b/src/xlibi18n/lcPrTxt.c
@@ -0,0 +1,252 @@
+/* $Xorg: lcPrTxt.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+
+static XPointer *
+alloc_list(is_wide_char, count, nitems)
+ Bool is_wide_char;
+ int count;
+ int nitems;
+{
+ if (is_wide_char) {
+ wchar_t **wstr_list;
+
+ wstr_list = (wchar_t **) Xmalloc(count * sizeof(wchar_t *));
+ if (wstr_list == NULL)
+ return (XPointer *) NULL;
+
+ *wstr_list = (wchar_t *) Xmalloc(nitems * sizeof(wchar_t));
+ if (*wstr_list == NULL) {
+ Xfree(wstr_list);
+ return (XPointer *) NULL;
+ }
+
+ return (XPointer *) wstr_list;
+ } else {
+ char **str_list;
+
+ str_list = (char **) Xmalloc(count * sizeof(char *));
+ if (str_list == NULL)
+ return (XPointer *) NULL;
+
+ *str_list = (char *) Xmalloc(nitems);
+ if (*str_list == NULL) {
+ Xfree(str_list);
+ return (XPointer *) NULL;
+ }
+
+ return (XPointer *) str_list;
+ }
+}
+
+static void
+copy_list(is_wide_char, text, list, count)
+ Bool is_wide_char;
+ XPointer text;
+ XPointer *list;
+ int count;
+{
+ int length;
+
+ if (is_wide_char) {
+ wchar_t *wc_text, *wstr, **wstr_list;
+
+ wc_text = (wchar_t *) text;
+ wstr_list = (wchar_t **) list;
+
+ for (wstr = *wstr_list; count > 0; count--, wstr_list++) {
+ _Xwcscpy(wstr, wc_text);
+ *wstr_list = wstr;
+ length = _Xwcslen(wstr) + 1;
+ wstr += length;
+ wc_text += length;
+ }
+ } else {
+ char *mb_text, *str, **str_list;
+
+ mb_text = (char *) text;
+ str_list = (char **) list;
+
+ for (str = *str_list; count > 0; count--, str_list++) {
+ strcpy(str, mb_text);
+ *str_list = str;
+ length = strlen(str) + 1;
+ str += length;
+ mb_text += length;
+ }
+ }
+}
+
+static int
+_XTextPropertyToTextList(lcd, dpy, text_prop, to_type, list_ret, count_ret)
+ XLCd lcd;
+ Display *dpy;
+ XTextProperty *text_prop;
+ char *to_type;
+ XPointer **list_ret;
+ int *count_ret;
+{
+ XlcConv conv;
+ char *from_type;
+ XPointer from, to, buf;
+ char *str_ptr, *last_ptr;
+ Atom encoding;
+ int from_left, to_left, buf_len, ret;
+ int unconv_num, nitems = text_prop->nitems;
+ Bool is_wide_char = False;
+
+ if (strcmp(XlcNWideChar, to_type) == 0)
+ is_wide_char = True;
+
+ if (nitems <= 0) {
+ *list_ret = NULL;
+ *count_ret = 0;
+ return Success;
+ }
+
+ if (text_prop->format != 8)
+ return XConverterNotFound;
+
+ encoding = text_prop->encoding;
+ if (encoding == XA_STRING)
+ from_type = XlcNString;
+ else if (encoding == XInternAtom(dpy, "COMPOUND_TEXT", False))
+ from_type = XlcNCompoundText;
+ else if (encoding == XInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False))
+ from_type = XlcNMultiByte;
+ else
+ return XConverterNotFound;
+
+ if (is_wide_char) {
+ buf_len = text_prop->nitems + 1;
+ buf = (XPointer) Xmalloc(buf_len * sizeof(wchar_t));
+ } else {
+ buf_len = text_prop->nitems * XLC_PUBLIC(lcd, mb_cur_max) + 1;
+ buf = (XPointer) Xmalloc(buf_len);
+ }
+ if (buf == NULL)
+ return XNoMemory;
+ to = buf;
+ to_left = buf_len;
+
+ conv = _XlcOpenConverter(lcd, from_type, lcd, to_type);
+ if (conv == NULL) {
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+
+ last_ptr = str_ptr = (char *) text_prop->value;
+ unconv_num = *count_ret = 0;
+
+ while (1) {
+ if (nitems == 0 || *str_ptr == 0) {
+ from = (XPointer) last_ptr;
+ from_left = str_ptr - last_ptr;
+ last_ptr = str_ptr;
+
+ ret = _XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0);
+
+ if (ret < 0)
+ continue;
+
+ unconv_num += ret;
+ (*count_ret)++;
+
+ if (nitems == 0)
+ break;
+ last_ptr = ++str_ptr;
+ if (is_wide_char) {
+ *((wchar_t *)to) = (wchar_t) 0;
+ to += sizeof(wchar_t);
+ to_left -= sizeof(wchar_t);
+ } else {
+ *((char *)to) = '\0';
+ to++;
+ to_left--;
+ }
+ _XlcResetConverter(conv);
+ } else
+ str_ptr++;
+
+ nitems--;
+ }
+
+ _XlcCloseConverter(conv);
+
+ if (is_wide_char)
+ *((wchar_t *) to) = (wchar_t) 0;
+ else
+ *((char *) to) = '\0';
+ to_left--;
+
+ *list_ret = alloc_list(is_wide_char, *count_ret, buf_len - to_left);
+ if (*list_ret)
+ copy_list(is_wide_char, buf, *list_ret, *count_ret);
+
+ Xfree(buf);
+
+ return unconv_num;
+}
+
+int
+_XmbTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
+ XLCd lcd;
+ Display *dpy;
+ XTextProperty *text_prop;
+ char ***list_ret;
+ int *count_ret;
+{
+ return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNMultiByte,
+ (XPointer **) list_ret, count_ret);
+}
+
+int
+_XwcTextPropertyToTextList(lcd, dpy, text_prop, list_ret, count_ret)
+ XLCd lcd;
+ Display *dpy;
+ XTextProperty *text_prop;
+ wchar_t ***list_ret;
+ int *count_ret;
+{
+ return _XTextPropertyToTextList(lcd, dpy, text_prop, XlcNWideChar,
+ (XPointer **) list_ret, count_ret);
+}
+
+void
+_XwcFreeStringList(lcd, list)
+ XLCd lcd;
+ wchar_t **list;
+{
+ if (list) {
+ if (*list)
+ Xfree(*list);
+ Xfree(list);
+ }
+}
diff --git a/src/xlibi18n/lcPubWrap.c b/src/xlibi18n/lcPubWrap.c
new file mode 100644
index 00000000..f9eeb244
--- /dev/null
+++ b/src/xlibi18n/lcPubWrap.c
@@ -0,0 +1,104 @@
+/* $Xorg: lcPubWrap.c,v 1.3 2000/08/17 19:45:18 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+#if NeedVarargsPrototypes
+char *
+_XGetLCValues(XLCd lcd, ...)
+#else
+char *
+_XGetLCValues(lcd, va_alist)
+ XLCd lcd;
+ va_dcl
+#endif
+{
+ va_list var;
+ XlcArgList args;
+ char *ret;
+ int num_args;
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+
+ Va_start(var, lcd);
+ _XlcCountVaList(var, &num_args);
+ va_end(var);
+
+ Va_start(var, lcd);
+ _XlcVaToArgList(var, num_args, &args);
+ va_end(var);
+
+ if (args == (XlcArgList) NULL)
+ return (char *) NULL;
+
+ ret = (*methods->get_values)(lcd, args, num_args);
+
+ Xfree(args);
+
+ return ret;
+}
+
+void
+_XlcDestroyLC(lcd)
+ XLCd lcd;
+{
+ XLCdPublicMethods methods = (XLCdPublicMethods) lcd->methods;
+
+ (*methods->pub.destroy)(lcd);
+}
+
+XLCd
+_XlcCreateLC(name, methods)
+ char *name;
+ XLCdMethods methods;
+{
+ XLCdPublicMethods pub_methods = (XLCdPublicMethods) methods;
+ XLCd lcd;
+
+ lcd = (*pub_methods->pub.create)(name, methods);
+ if (lcd == NULL)
+ return (XLCd) NULL;
+
+ if (lcd->core->name == NULL) {
+ lcd->core->name = (char*) Xmalloc(strlen(name) + 1);
+ if (lcd->core->name == NULL)
+ goto err;
+ strcpy(lcd->core->name, name);
+ }
+
+ if (lcd->methods == NULL)
+ lcd->methods = methods;
+
+ if ((*pub_methods->pub.initialize)(lcd) == False)
+ goto err;
+
+ return lcd;
+
+err:
+ _XlcDestroyLC(lcd);
+
+ return (XLCd) NULL;
+}
diff --git a/src/xlibi18n/lcPublic.c b/src/xlibi18n/lcPublic.c
new file mode 100644
index 00000000..c72669ef
--- /dev/null
+++ b/src/xlibi18n/lcPublic.c
@@ -0,0 +1,308 @@
+/* $Xorg: lcPublic.c,v 1.4 2000/12/12 12:44:05 coskrey Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include <stdio.h>
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+static char *default_string();
+
+static XLCd create();
+static Bool initialize();
+static void destroy();
+static char *get_values();
+
+static XLCdPublicMethodsRec publicMethods = {
+ {
+ destroy,
+ _XlcDefaultMapModifiers,
+ NULL,
+ NULL,
+ _XrmDefaultInitParseInfo,
+ _XmbTextPropertyToTextList,
+ _XwcTextPropertyToTextList,
+ _XmbTextListToTextProperty,
+ _XwcTextListToTextProperty,
+ _XwcFreeStringList,
+ default_string,
+ NULL,
+ NULL
+ },
+ {
+ NULL,
+ create,
+ initialize,
+ destroy,
+ get_values,
+ _XlcGetLocaleDataBase
+ }
+};
+
+XLCdMethods _XlcPublicMethods = (XLCdMethods) &publicMethods;
+
+static char *
+default_string(lcd)
+ XLCd lcd;
+{
+ return XLC_PUBLIC(lcd, default_string);
+}
+
+static XLCd
+create(name, methods)
+ char *name;
+ XLCdMethods methods;
+{
+ XLCd lcd;
+ XLCdPublicMethods new;
+
+ lcd = (XLCd) Xmalloc(sizeof(XLCdRec));
+ if (lcd == NULL)
+ return (XLCd) NULL;
+ bzero((char *) lcd, sizeof(XLCdRec));
+
+ lcd->core = (XLCdCore) Xmalloc(sizeof(XLCdPublicRec));
+ if (lcd->core == NULL)
+ goto err;
+ bzero((char *) lcd->core, sizeof(XLCdPublicRec));
+
+ new = (XLCdPublicMethods) Xmalloc(sizeof(XLCdPublicMethodsRec));
+ if (new == NULL)
+ goto err;
+ *new = *((XLCdPublicMethods) methods);
+ lcd->methods = (XLCdMethods) new;
+
+ return lcd;
+
+err:
+ Xfree(lcd);
+ return (XLCd) NULL;
+}
+
+static Bool
+load_public(lcd)
+ XLCd lcd;
+{
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+ char **values, *str;
+ int num;
+
+ if(_XlcCreateLocaleDataBase(lcd) == NULL)
+ return False;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "mb_cur_max", &values, &num);
+ if (num > 0) {
+ pub->mb_cur_max = atoi(values[0]);
+ if (pub->mb_cur_max < 1)
+ pub->mb_cur_max = 1;
+ } else
+ pub->mb_cur_max = 1;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "state_depend_encoding", &values, &num);
+ if (num > 0 && !_XlcCompareISOLatin1(values[0], "True"))
+ pub->is_state_depend = True;
+ else
+ pub->is_state_depend = False;
+
+ _XlcGetResource(lcd, "XLC_XLOCALE", "encoding_name", &values, &num);
+ str = (num > 0) ? values[0] : "STRING";
+ pub->encoding_name = (char*) Xmalloc(strlen(str) + 1);
+ if (pub->encoding_name == NULL)
+ return False;
+ strcpy(pub->encoding_name, str);
+
+ return True;
+}
+
+static Bool
+initialize_core(lcd)
+ XLCd lcd;
+{
+ XLCdMethods methods = lcd->methods;
+ XLCdMethods core = &publicMethods.core;
+
+ if (methods->close == NULL)
+ methods->close = core->close;
+
+ if (methods->map_modifiers == NULL)
+ methods->map_modifiers = core->map_modifiers;
+
+ if (methods->open_om == NULL)
+#ifdef USE_DYNAMIC_LC
+ _XInitDefaultOM(lcd);
+#else
+ _XInitOM(lcd);
+#endif
+
+ if (methods->open_im == NULL)
+#ifdef USE_DYNAMIC_LC
+ _XInitDefaultIM(lcd);
+#else
+ _XInitIM(lcd);
+#endif
+
+ if (methods->init_parse_info == NULL)
+ methods->init_parse_info = core->init_parse_info;
+
+ if (methods->mb_text_prop_to_list == NULL)
+ methods->mb_text_prop_to_list = core->mb_text_prop_to_list;
+
+ if (methods->wc_text_prop_to_list == NULL)
+ methods->wc_text_prop_to_list = core->wc_text_prop_to_list;
+
+ if (methods->mb_text_list_to_prop == NULL)
+ methods->mb_text_list_to_prop = core->mb_text_list_to_prop;
+
+ if (methods->wc_text_list_to_prop == NULL)
+ methods->wc_text_list_to_prop = core->wc_text_list_to_prop;
+
+ if (methods->wc_free_string_list == NULL)
+ methods->wc_free_string_list = core->wc_free_string_list;
+
+ if (methods->default_string == NULL)
+ methods->default_string = core->default_string;
+
+ return True;
+}
+
+extern Bool _XlcInitCTInfo();
+
+static Bool
+initialize(lcd)
+ XLCd lcd;
+{
+ XLCdPublicMethodsPart *methods = XLC_PUBLIC_METHODS(lcd);
+ XLCdPublicMethodsPart *pub_methods = &publicMethods.pub;
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+ char *name;
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ int len;
+ char sinamebuf[256];
+ char* siname;
+ char *_XlcMapOSLocaleName();
+#endif
+
+ _XlcInitCTInfo();
+
+ if (initialize_core(lcd) == False)
+ return False;
+
+ name = lcd->core->name;
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ /*
+ * _XlMapOSLOcaleName will return the same string or a substring
+ * of name, so strlen(name) is okay
+ */
+ if ((len = strlen(name)) < sizeof sinamebuf) siname = sinamebuf;
+ else siname = Xmalloc (len + 1);
+ if (siname == NULL) return False;
+ name = _XlcMapOSLocaleName(name, siname);
+#endif
+ /* _XlcResolveLocaleName will lookup the SI's name for the locale */
+ if (_XlcResolveLocaleName(name, pub) == 0) {
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ if (siname != sinamebuf) Xfree (siname);
+#endif
+ return False;
+ }
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ if (siname != sinamebuf) Xfree (siname);
+#endif
+
+ if (pub->default_string == NULL)
+ pub->default_string = "";
+
+ if (methods->get_values == NULL)
+ methods->get_values = pub_methods->get_values;
+
+ if (methods->get_resource == NULL)
+ methods->get_resource = pub_methods->get_resource;
+
+ return load_public(lcd);
+}
+
+static void
+destroy_core(lcd)
+ XLCd lcd;
+{
+ if (lcd->core) {
+ if (lcd->core->name)
+ Xfree(lcd->core->name);
+ Xfree(lcd->core);
+ }
+
+ if (lcd->methods)
+ Xfree(lcd->methods);
+
+ Xfree(lcd);
+}
+
+static void
+destroy(lcd)
+ XLCd lcd;
+{
+ XLCdPublicPart *pub = XLC_PUBLIC_PART(lcd);
+
+ _XlcDestroyLocaleDataBase(lcd);
+
+ if (pub->siname)
+ Xfree(pub->siname);
+ if (pub->encoding_name)
+ Xfree(pub->encoding_name);
+
+ destroy_core(lcd);
+}
+
+static XlcResource resources[] = {
+ { XlcNCodeset, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.codeset), XlcGetMask },
+ { XlcNDefaultString, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.default_string), XlcGetMask },
+ { XlcNEncodingName, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.encoding_name), XlcGetMask },
+ { XlcNLanguage, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.language), XlcGetMask },
+ { XlcNMbCurMax, NULLQUARK, sizeof(int),
+ XOffsetOf(XLCdPublicRec, pub.mb_cur_max), XlcGetMask },
+ { XlcNStateDependentEncoding, NULLQUARK, sizeof(Bool),
+ XOffsetOf(XLCdPublicRec, pub.is_state_depend), XlcGetMask },
+ { XlcNTerritory, NULLQUARK, sizeof(char *),
+ XOffsetOf(XLCdPublicRec, pub.territory), XlcGetMask }
+};
+
+static char *
+get_values(lcd, args, num_args)
+ register XLCd lcd;
+ register XlcArgList args;
+ register int num_args;
+{
+ XLCdPublic pub = (XLCdPublic) lcd->core;
+
+ if (resources[0].xrm_name == NULLQUARK)
+ _XlcCompileResourceList(resources, XlcNumber(resources));
+
+ return _XlcGetValues((XPointer) pub, resources, XlcNumber(resources), args,
+ num_args, XlcGetMask);
+}
diff --git a/src/xlibi18n/lcRM.c b/src/xlibi18n/lcRM.c
new file mode 100644
index 00000000..0824a6f7
--- /dev/null
+++ b/src/xlibi18n/lcRM.c
@@ -0,0 +1,122 @@
+/* $Xorg: lcRM.c,v 1.3 2000/08/17 19:45:19 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <stdio.h>
+
+typedef struct _StateRec {
+ XLCd lcd;
+ XlcConv conv;
+} StateRec, *State;
+
+static void
+mbinit(state)
+ XPointer state;
+{
+ _XlcResetConverter(((State) state)->conv);
+}
+
+static char
+mbchar(state, str, lenp)
+ XPointer state;
+ char *str;
+ int *lenp;
+{
+ XlcConv conv = ((State) state)->conv;
+ XlcCharSet charset;
+ char *from, *to, buf[BUFSIZ];
+ int from_left, to_left;
+ XPointer args[1];
+
+ from = str;
+ *lenp = from_left = XLC_PUBLIC(((State) state)->lcd, mb_cur_max);
+ to = buf;
+ to_left = BUFSIZ;
+ args[0] = (XPointer) &charset;
+
+ _XlcConvert(conv, (XPointer *) &from, &from_left, (XPointer *) &to,
+ &to_left, args, 1);
+
+ *lenp -= from_left;
+
+ /* XXX */
+ return buf[0];
+}
+
+static void
+mbfinish(state)
+ XPointer state;
+{
+}
+
+static char *
+lcname(state)
+ XPointer state;
+{
+ return ((State) state)->lcd->core->name;
+}
+
+static void
+destroy(state)
+ XPointer state;
+{
+ _XlcCloseConverter(((State) state)->conv);
+ _XCloseLC(((State) state)->lcd);
+ Xfree((char *) state);
+}
+
+static XrmMethodsRec rm_methods = {
+ mbinit,
+ mbchar,
+ mbfinish,
+ lcname,
+ destroy
+} ;
+
+XrmMethods
+_XrmDefaultInitParseInfo(lcd, rm_state)
+ XLCd lcd;
+ XPointer *rm_state;
+{
+ State state;
+
+ state = (State) Xmalloc(sizeof(StateRec));
+ if (state == NULL)
+ return (XrmMethods) NULL;
+
+ state->lcd = lcd;
+ state->conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNChar);
+ if (state->conv == NULL) {
+ Xfree((char *) state);
+
+ return (XrmMethods) NULL;
+ }
+
+ *rm_state = (XPointer) state;
+
+ return &rm_methods;
+}
diff --git a/src/xlibi18n/lcStd.c b/src/xlibi18n/lcStd.c
new file mode 100644
index 00000000..9d938d39
--- /dev/null
+++ b/src/xlibi18n/lcStd.c
@@ -0,0 +1,305 @@
+/* $Xorg: lcStd.c,v 1.4 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+
+int
+_Xlcmbtowc(lcd, wstr, str, len)
+ XLCd lcd;
+ wchar_t *wstr;
+ char *str;
+ int len;
+{
+ static XLCd last_lcd = NULL;
+ static XlcConv conv = NULL;
+ XPointer from, to;
+ int from_left, to_left;
+ wchar_t tmp_wc;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+ if (str == NULL)
+ return XLC_PUBLIC(lcd, is_state_depend);
+
+ if (conv && lcd != last_lcd) {
+ _XlcCloseConverter(conv);
+ conv = NULL;
+ }
+
+ last_lcd = lcd;
+
+ if (conv == NULL) {
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+ if (conv == NULL)
+ return -1;
+ }
+
+ from = (XPointer) str;
+ from_left = len;
+ to = (XPointer) (wstr ? wstr : &tmp_wc);
+ to_left = 1;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ return -1;
+
+ return (len - from_left);
+}
+
+int
+_Xlcwctomb(lcd, str, wc)
+ XLCd lcd;
+ char *str;
+ wchar_t wc;
+{
+ static XLCd last_lcd = NULL;
+ static XlcConv conv = NULL;
+ XPointer from, to;
+ int from_left, to_left, length;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+ if (str == NULL)
+ return XLC_PUBLIC(lcd, is_state_depend);
+
+ if (conv && lcd != last_lcd) {
+ _XlcCloseConverter(conv);
+ conv = NULL;
+ }
+
+ last_lcd = lcd;
+
+ if (conv == NULL) {
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return -1;
+ }
+
+ from = (XPointer) &wc;
+ from_left = 1;
+ to = (XPointer) str;
+ length = to_left = XLC_PUBLIC(lcd, mb_cur_max);
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ return -1;
+
+ return (length - to_left);
+}
+
+int
+_Xlcmbstowcs(lcd, wstr, str, len)
+ XLCd lcd;
+ wchar_t *wstr;
+ char *str;
+ int len;
+{
+ XlcConv conv;
+ XPointer from, to;
+ int from_left, to_left, ret;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+
+ conv = _XlcOpenConverter(lcd, XlcNMultiByte, lcd, XlcNWideChar);
+ if (conv == NULL)
+ return -1;
+
+ from = (XPointer) str;
+ from_left = strlen(str);
+ to = (XPointer) wstr;
+ to_left = len;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ ret = -1;
+ else {
+ ret = len - to_left;
+ if (wstr && to_left > 0)
+ wstr[ret] = (wchar_t) 0;
+ }
+
+ _XlcCloseConverter(conv);
+
+ return ret;
+}
+
+int
+_Xlcwcstombs(lcd, str, wstr, len)
+ XLCd lcd;
+ char *str;
+ wchar_t *wstr;
+ int len;
+{
+ XlcConv conv;
+ XPointer from, to;
+ int from_left, to_left, ret;
+
+ if (lcd == NULL) {
+ lcd = _XlcCurrentLC();
+ if (lcd == NULL)
+ return -1;
+ }
+
+ conv = _XlcOpenConverter(lcd, XlcNWideChar, lcd, XlcNMultiByte);
+ if (conv == NULL)
+ return -1;
+
+ from = (XPointer) wstr;
+ from_left = _Xwcslen(wstr);
+ to = (XPointer) str;
+ to_left = len;
+
+ if (_XlcConvert(conv, &from, &from_left, &to, &to_left, NULL, 0) < 0)
+ ret = -1;
+ else {
+ ret = len - to_left;
+ if (str && to_left > 0)
+ str[ret] = '\0';
+ }
+
+ _XlcCloseConverter(conv);
+
+ return ret;
+}
+
+
+int
+_Xmbtowc(wstr, str, len)
+ wchar_t *wstr;
+ char *str;
+ int len;
+{
+ return _Xlcmbtowc((XLCd) NULL, wstr, str, len);
+}
+
+int
+_Xmblen(str, len)
+ char *str;
+ int len;
+{
+ return _Xmbtowc((wchar_t *) NULL, str, len);
+}
+
+int
+_Xwctomb(str, wc)
+ char *str;
+ wchar_t wc;
+{
+ return _Xlcwctomb((XLCd) NULL, str, wc);
+}
+
+int
+_Xmbstowcs(wstr, str, len)
+ wchar_t *wstr;
+ char *str;
+ int len;
+{
+ return _Xlcmbstowcs((XLCd) NULL, wstr, str, len);
+}
+
+int
+_Xwcstombs(str, wstr, len)
+ char *str;
+ wchar_t *wstr;
+ int len;
+{
+ return _Xlcwcstombs((XLCd) NULL, str, wstr, len);
+}
+
+wchar_t *
+_Xwcscpy(wstr1, wstr2)
+ register wchar_t *wstr1, *wstr2;
+{
+ wchar_t *wstr_tmp = wstr1;
+
+ while ((*wstr1++ = *wstr2++))
+ ;
+
+ return wstr_tmp;
+}
+
+wchar_t *
+_Xwcsncpy(wstr1, wstr2, len)
+ register wchar_t *wstr1, *wstr2;
+ register int len;
+{
+ wchar_t *wstr_tmp = wstr1;
+
+ while (len-- > 0)
+ if (!(*wstr1++ = *wstr2++))
+ break;
+
+ while (len-- > 0)
+ *wstr1++ = (wchar_t) 0;
+
+ return wstr_tmp;
+}
+
+int
+_Xwcslen(wstr)
+ register wchar_t *wstr;
+{
+ register wchar_t *wstr_ptr = wstr;
+
+ while (*wstr_ptr)
+ wstr_ptr++;
+
+ return wstr_ptr - wstr;
+}
+
+int
+_Xwcscmp(wstr1, wstr2)
+ register wchar_t *wstr1, *wstr2;
+{
+ for ( ; *wstr1 && *wstr2; wstr1++, wstr2++)
+ if (*wstr1 != *wstr2)
+ break;
+
+ return *wstr1 - *wstr2;
+}
+
+int
+_Xwcsncmp(wstr1, wstr2, len)
+ register wchar_t *wstr1, *wstr2;
+ register int len;
+{
+ for ( ; *wstr1 && *wstr2 && len > 0; wstr1++, wstr2++, len--)
+ if (*wstr1 != *wstr2)
+ break;
+
+ if (len <= 0)
+ return 0;
+
+ return *wstr1 - *wstr2;
+}
diff --git a/src/xlibi18n/lcTxtPr.c b/src/xlibi18n/lcTxtPr.c
new file mode 100644
index 00000000..1efdb278
--- /dev/null
+++ b/src/xlibi18n/lcTxtPr.c
@@ -0,0 +1,235 @@
+/* $Xorg: lcTxtPr.c,v 1.3 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include "Xlibint.h"
+#include "XlcPubI.h"
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <stdio.h>
+
+static int
+get_buf_size(is_wide_char, list, count)
+ Bool is_wide_char;
+ XPointer list;
+ int count;
+{
+ register int length = 0;
+ register char **mb_list;
+ register wchar_t **wc_list;
+
+ if (list == NULL)
+ return 0;
+
+ if (is_wide_char) {
+ wc_list = (wchar_t **) list;
+ for ( ; count-- > 0; wc_list++) {
+ if (*wc_list)
+ length += _Xwcslen(*wc_list) + 1;
+ }
+ length *= 5; /* XXX */
+ } else {
+ mb_list = (char **) list;
+ for ( ; count-- > 0; mb_list++) {
+ if (*mb_list)
+ length += strlen(*mb_list) + 1;
+ }
+ length *= 3; /* XXX */
+ }
+ length = (length / BUFSIZ + 1) * BUFSIZ; /* XXX */
+
+ return length;
+}
+
+static int
+_XTextListToTextProperty(lcd, dpy, from_type, list, count, style, text_prop)
+ XLCd lcd;
+ Display *dpy;
+ char *from_type;
+ XPointer list;
+ int count;
+ XICCEncodingStyle style;
+ XTextProperty *text_prop;
+{
+ Atom encoding;
+ XlcConv conv;
+ char *to_type;
+ char **mb_list;
+ wchar_t **wc_list;
+ XPointer from;
+ char *to, *buf, *value;
+ int from_left, to_left, buf_len, nitems, unconv_num, ret, i;
+ Bool is_wide_char = False;
+
+ if (strcmp(XlcNWideChar, from_type) == 0)
+ is_wide_char = True;
+
+ buf_len = get_buf_size(is_wide_char, list, count);
+ if ((buf = (char *) Xmalloc(buf_len)) == NULL)
+ return XNoMemory;
+
+ switch (style) {
+ case XStringStyle:
+ case XStdICCTextStyle:
+ encoding = XA_STRING;
+ to_type = XlcNString;
+ break;
+ case XCompoundTextStyle:
+ encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ to_type = XlcNCompoundText;
+ break;
+ case XTextStyle:
+ encoding = XInternAtom(dpy, XLC_PUBLIC(lcd, encoding_name), False);
+ to_type = XlcNMultiByte;
+ if (is_wide_char == False) {
+ nitems = 0;
+ mb_list = (char **) list;
+ to = buf;
+ for (i = 0; i < count && buf_len > 0; i++) {
+ if (*mb_list)
+ strcpy(to, *mb_list);
+ else
+ *to = '\0';
+ from_left = (*mb_list ? strlen(*mb_list) : 0) + 1;
+ nitems += from_left;
+ to += from_left;
+ mb_list++;
+ }
+ unconv_num = 0;
+ goto done;
+ }
+ break;
+ default:
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+
+ if (count < 1) {
+ nitems = 0;
+ goto done;
+ }
+
+retry:
+ conv = _XlcOpenConverter(lcd, from_type, lcd, to_type);
+ if (conv == NULL) {
+ Xfree(buf);
+ return XConverterNotFound;
+ }
+
+ if (is_wide_char)
+ wc_list = (wchar_t **) list;
+ else
+ mb_list = (char **) list;
+
+ to = buf;
+ to_left = buf_len;
+
+ unconv_num = 0;
+
+ for (i = 1; to_left > 0; i++) {
+ if (is_wide_char) {
+ from = (XPointer) *wc_list;
+ from_left = _Xwcslen(*wc_list);
+ wc_list++;
+ } else {
+ from = (XPointer) *mb_list;
+ from_left = (*mb_list ? strlen(*mb_list) : 0);
+ mb_list++;
+ }
+
+ ret = _XlcConvert(conv, &from, &from_left, (XPointer *) &to, &to_left,
+ NULL, 0);
+
+ if (ret < 0)
+ continue;
+
+ if (ret > 0 && style == XStdICCTextStyle && encoding == XA_STRING) {
+ _XlcCloseConverter(conv);
+ encoding = XInternAtom(dpy, "COMPOUND_TEXT", False);
+ to_type = XlcNCompoundText;
+ goto retry;
+ }
+
+ unconv_num += ret;
+ *to++ = '\0';
+ to_left--;
+
+ if (i >= count)
+ break;
+
+ _XlcResetConverter(conv);
+ }
+
+ _XlcCloseConverter(conv);
+
+ nitems = to - buf;
+done:
+ if (nitems <= 0)
+ nitems = 1;
+ value = (char *) Xmalloc(nitems);
+ if (value == NULL) {
+ Xfree(buf);
+ return XNoMemory;
+ }
+ if (nitems == 1)
+ *value = 0;
+ else
+ memcpy(value, buf, nitems);
+ nitems--;
+ Xfree(buf);
+
+ text_prop->value = (unsigned char *) value;
+ text_prop->encoding = encoding;
+ text_prop->format = 8;
+ text_prop->nitems = nitems;
+
+ return unconv_num;
+}
+
+int
+_XmbTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
+ XLCd lcd;
+ Display *dpy;
+ char **list;
+ int count;
+ XICCEncodingStyle style;
+ XTextProperty *text_prop;
+{
+ return _XTextListToTextProperty(lcd, dpy, XlcNMultiByte, (XPointer) list,
+ count, style, text_prop);
+}
+
+int
+_XwcTextListToTextProperty(lcd, dpy, list, count, style, text_prop)
+ XLCd lcd;
+ Display *dpy;
+ wchar_t **list;
+ int count;
+ XICCEncodingStyle style;
+ XTextProperty *text_prop;
+{
+ return _XTextListToTextProperty(lcd, dpy, XlcNWideChar, (XPointer) list,
+ count, style, text_prop);
+}
diff --git a/src/xlibi18n/lcUtil.c b/src/xlibi18n/lcUtil.c
new file mode 100644
index 00000000..cb439b0b
--- /dev/null
+++ b/src/xlibi18n/lcUtil.c
@@ -0,0 +1,78 @@
+/* $Xorg: lcUtil.c,v 1.3 2000/08/17 19:45:20 cpqbld Exp $ */
+/*
+ * Copyright 1992, 1993 by TOSHIBA Corp.
+ *
+ * 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 TOSHIBA not be used in advertising
+ * or publicity pertaining to distribution of the software without specific,
+ * written prior permission. TOSHIBA make no representations about the
+ * suitability of this software for any purpose. It is provided "as is"
+ * without express or implied warranty.
+ *
+ * TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
+ * TOSHIBA 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.
+ *
+ * Author: Katsuhisa Yano TOSHIBA Corp.
+ * mopi@osa.ilab.toshiba.co.jp
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <X11/Xos.h>
+#include "Xlibint.h"
+
+#ifdef X_NOT_STDC_ENV
+#ifndef toupper
+#define toupper(c) ((int)(c) - 'a' + 'A')
+#endif
+#endif
+
+int
+_XlcCompareISOLatin1(str1, str2)
+ char *str1, *str2;
+{
+ register char ch1, ch2;
+
+ for ( ; (ch1 = *str1) && (ch2 = *str2); str1++, str2++) {
+ if (islower(ch1))
+ ch1 = toupper(ch1);
+ if (islower(ch2))
+ ch2 = toupper(ch2);
+
+ if (ch1 != ch2)
+ break;
+ }
+
+ return *str1 - *str2;
+}
+
+int
+_XlcNCompareISOLatin1(str1, str2, len)
+ char *str1, *str2;
+ int len;
+{
+ register char ch1, ch2;
+
+ for ( ; (ch1 = *str1) && (ch2 = *str2) && len; str1++, str2++, len--) {
+ if (islower(ch1))
+ ch1 = toupper(ch1);
+ if (islower(ch2))
+ ch2 = toupper(ch2);
+
+ if (ch1 != ch2)
+ break;
+ }
+
+ if (len == 0)
+ return 0;
+
+ return *str1 - *str2;
+}
diff --git a/src/xlibi18n/lcWrap.c b/src/xlibi18n/lcWrap.c
new file mode 100644
index 00000000..d2dcfe94
--- /dev/null
+++ b/src/xlibi18n/lcWrap.c
@@ -0,0 +1,620 @@
+/* $Xorg: lcWrap.c,v 1.6 2001/02/09 02:03:39 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 1991 by the Open Software Foundation
+ * Copyright 1993 by the TOSHIBA Corp.
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 names of Open Software Foundation and TOSHIBA
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation and TOSHIBA make no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION AND TOSHIBA DISCLAIM ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN OR TOSHIBA 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.
+ *
+ * M. Collins OSF
+ *
+ * Katsuhisa Yano TOSHIBA Corp.
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+#include <X11/Xlocale.h>
+#include <X11/Xos.h>
+#ifdef WIN32
+#undef close
+#endif
+#include <X11/Xutil.h>
+
+#ifdef __STDC__
+#define Const const
+#else
+#define Const /**/
+#endif
+
+#ifdef X_NOT_STDC_ENV
+extern char *getenv();
+#endif
+
+extern void _XlcInitLoader(
+#if NeedFunctionPrototypes
+ char*
+#endif
+);
+
+#ifdef XTHREADS
+LockInfoPtr _Xi18n_lock;
+#endif
+
+#if NeedFunctionPrototypes
+char *
+XSetLocaleModifiers(
+ _Xconst char *modifiers
+)
+#else
+char *
+XSetLocaleModifiers(modifiers)
+ char *modifiers;
+#endif
+{
+ XLCd lcd = _XlcCurrentLC();
+ char *user_mods;
+
+ if (!lcd)
+ return (char *) NULL;
+ if (!modifiers)
+ return lcd->core->modifiers;
+ user_mods = getenv("XMODIFIERS");
+ modifiers = (*lcd->methods->map_modifiers) (lcd,
+ user_mods, (char *)modifiers);
+ if (modifiers) {
+ if (lcd->core->modifiers)
+ Xfree(lcd->core->modifiers);
+ lcd->core->modifiers = (char *)modifiers;
+ }
+ return (char *)modifiers;
+}
+
+Bool
+XSupportsLocale()
+{
+ return _XlcCurrentLC() != (XLCd)NULL;
+}
+
+Bool _XlcValidModSyntax(mods, valid_mods)
+ char *mods;
+ char **valid_mods;
+{
+ int i;
+ char **ptr;
+
+ while (mods && (*mods == '@')) {
+ mods++;
+ if (*mods == '@')
+ break;
+ for (ptr = valid_mods; *ptr; ptr++) {
+ i = strlen(*ptr);
+ if (strncmp(mods, *ptr, i) || ((mods[i] != '=')
+#ifdef WIN32
+ && (mods[i] != '#')
+#endif
+ ))
+ continue;
+ mods = strchr(mods+i+1, '@');
+ break;
+ }
+ }
+ return !mods || !*mods;
+}
+
+static Const char *im_valid[] = {"im", (char *)NULL};
+
+/*ARGSUSED*/
+char *
+_XlcDefaultMapModifiers (lcd, user_mods, prog_mods)
+ XLCd lcd;
+ char *user_mods;
+ char *prog_mods;
+{
+ int i;
+ char *mods;
+
+ if (!_XlcValidModSyntax(prog_mods, (char **)im_valid))
+ return (char *)NULL;
+ if (!_XlcValidModSyntax(user_mods, (char **)im_valid))
+ return (char *)NULL;
+ i = strlen(prog_mods) + 1;
+ if (user_mods)
+ i += strlen(user_mods);
+ mods = Xmalloc(i);
+ if (mods) {
+ strcpy(mods, prog_mods);
+ if (user_mods)
+ strcat(mods, user_mods);
+#ifdef WIN32
+ {
+ char *s;
+ for (s = mods; s = strchr(s, '@'); s++) {
+ for (s++; *s && *s != '='; s++) {
+ if (*s == '#') {
+ *s = '=';
+ break;
+ }
+ }
+ }
+ }
+#endif
+ }
+ return mods;
+}
+
+typedef struct _XLCdListRec {
+ struct _XLCdListRec *next;
+ XLCd lcd;
+ int ref_count;
+} XLCdListRec, *XLCdList;
+
+static XLCdList lcd_list = NULL;
+
+typedef struct _XlcLoaderListRec {
+ struct _XlcLoaderListRec *next;
+ XLCdLoadProc proc;
+} XlcLoaderListRec, *XlcLoaderList;
+
+static XlcLoaderList loader_list = NULL;
+
+void
+_XlcRemoveLoader(proc)
+ XLCdLoadProc proc;
+{
+ XlcLoaderList loader, prev;
+
+ if (loader_list == NULL)
+ return;
+
+ prev = loader = loader_list;
+ if (loader->proc == proc) {
+ loader_list = loader->next;
+ Xfree(loader);
+ return;
+ }
+
+ while ((loader = loader->next)) {
+ if (loader->proc == proc) {
+ prev->next = loader->next;
+ Xfree(loader);
+ return;
+ }
+ prev = loader;
+ }
+
+ return;
+}
+
+Bool
+_XlcAddLoader(proc, position)
+ XLCdLoadProc proc;
+ XlcPosition position;
+{
+ XlcLoaderList loader, last;
+
+ _XlcRemoveLoader(proc); /* remove old loader, if exist */
+
+ loader = (XlcLoaderList) Xmalloc(sizeof(XlcLoaderListRec));
+ if (loader == NULL)
+ return False;
+
+ loader->proc = proc;
+
+ if (loader_list == NULL)
+ position = XlcHead;
+
+ if (position == XlcHead) {
+ loader->next = loader_list;
+ loader_list = loader;
+ } else {
+ last = loader_list;
+ while (last->next)
+ last = last->next;
+
+ loader->next = NULL;
+ last->next = loader;
+ }
+
+ return True;
+}
+
+XLCd
+_XOpenLC(name)
+ char *name;
+{
+ XLCd lcd;
+ XlcLoaderList loader;
+ XLCdList cur;
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ int len;
+ char sinamebuf[256];
+ char* siname;
+ char *_XlcMapOSLocaleName();
+#endif
+
+ if (name == NULL) {
+ name = setlocale (LC_CTYPE, (char *)NULL);
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ /*
+ * _XlMapOSLOcaleName will return the same string or a substring
+ * of name, so strlen(name) is okay
+ */
+ if ((len = strlen(name)) < sizeof sinamebuf) siname = sinamebuf;
+ else siname = Xmalloc (len + 1);
+ if (siname == NULL) return NULL;
+ name = _XlcMapOSLocaleName(name, siname);
+#endif
+ }
+
+ _XLockMutex(_Xi18n_lock);
+
+ /*
+ * search for needed lcd, if found return it
+ */
+ for (cur = lcd_list; cur; cur = cur->next) {
+ if (!strcmp (cur->lcd->core->name, name)) {
+ lcd = cur->lcd;
+ cur->ref_count++;
+ goto found;
+ }
+ }
+
+ _XlcInitLoader(name);
+
+ /*
+ * not there, so try to get and add to list
+ */
+ for (loader = loader_list; loader; loader = loader->next) {
+ lcd = (*loader->proc)(name);
+ if (lcd) {
+ cur = (XLCdList) Xmalloc (sizeof(XLCdListRec));
+ if (cur) {
+ cur->lcd = lcd;
+ cur->ref_count = 1;
+ cur->next = lcd_list;
+ lcd_list = cur;
+ } else {
+ (*lcd->methods->close)(lcd);
+ lcd = (XLCd) NULL;
+ }
+ break;
+ }
+ }
+
+found:
+ _XUnlockMutex(_Xi18n_lock);
+
+#if !defined(X_NOT_STDC_ENV) && !defined(X_LOCALE)
+ if (siname != sinamebuf) Xfree(siname);
+#endif
+
+ return lcd;
+}
+
+void
+_XCloseLC(lcd)
+ XLCd lcd;
+{
+ XLCdList cur, *prev;
+
+ for (prev = &lcd_list; (cur = *prev); prev = &cur->next) {
+ if (cur->lcd == lcd) {
+ if (--cur->ref_count < 1) {
+ (*lcd->methods->close)(lcd);
+ *prev = cur->next;
+ Xfree(cur);
+ }
+ break;
+ }
+ }
+}
+
+/*
+ * Get the XLCd for the current locale
+ */
+
+XLCd
+_XlcCurrentLC()
+{
+ XLCd lcd;
+ static XLCd last_lcd = NULL;
+
+ lcd = _XOpenLC((char *) NULL);
+
+ if (last_lcd)
+ _XCloseLC(last_lcd);
+
+ last_lcd = lcd;
+
+ return lcd;
+}
+
+XrmMethods
+_XrmInitParseInfo(state)
+ XPointer *state;
+{
+ XLCd lcd = _XOpenLC((char *) NULL);
+
+ if (lcd == (XLCd) NULL)
+ return (XrmMethods) NULL;
+
+ return (*lcd->methods->init_parse_info)(lcd, state);
+}
+
+int
+XmbTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
+ Display *dpy;
+ XTextProperty *text_prop;
+ char ***list_ret;
+ int *count_ret;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->mb_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
+ count_ret);
+}
+
+int
+XwcTextPropertyToTextList(dpy, text_prop, list_ret, count_ret)
+ Display *dpy;
+ XTextProperty *text_prop;
+ wchar_t ***list_ret;
+ int *count_ret;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->wc_text_prop_to_list)(lcd, dpy, text_prop, list_ret,
+ count_ret);
+}
+
+int
+XmbTextListToTextProperty(dpy, list, count, style, text_prop)
+ Display *dpy;
+ char **list;
+ int count;
+ XICCEncodingStyle style;
+ XTextProperty *text_prop;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->mb_text_list_to_prop)(lcd, dpy, list, count, style,
+ text_prop);
+}
+
+int
+XwcTextListToTextProperty(dpy, list, count, style, text_prop)
+ Display *dpy;
+ wchar_t **list;
+ int count;
+ XICCEncodingStyle style;
+ XTextProperty *text_prop;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return XLocaleNotSupported;
+
+ return (*lcd->methods->wc_text_list_to_prop)(lcd, dpy, list, count, style,
+ text_prop);
+}
+
+void
+XwcFreeStringList(list)
+ wchar_t **list;
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return;
+
+ (*lcd->methods->wc_free_string_list)(lcd, list);
+}
+
+char *
+XDefaultString()
+{
+ XLCd lcd = _XlcCurrentLC();
+
+ if (lcd == NULL)
+ return (char *) NULL;
+
+ return (*lcd->methods->default_string)(lcd);
+}
+
+void
+_XlcCopyFromArg(src, dst, size)
+ char *src;
+ register char *dst;
+ register int size;
+{
+ if (size == sizeof(long))
+ *((long *) dst) = (long) src;
+#ifdef LONG64
+ else if (size == sizeof(int))
+ *((int *) dst) = (int) src;
+#endif
+ else if (size == sizeof(short))
+ *((short *) dst) = (short)(long) src;
+ else if (size == sizeof(char))
+ *((char *) dst) = (char)(long) src;
+ else if (size == sizeof(XPointer))
+ *((XPointer *) dst) = (XPointer) src;
+ else if (size > sizeof(XPointer))
+ memcpy(dst, (char *) src, size);
+ else
+ memcpy(dst, (char *) &src, size);
+}
+
+void
+_XlcCopyToArg(src, dst, size)
+ register char *src;
+ register char **dst;
+ register int size;
+{
+ if (size == sizeof(long))
+ *((long *) *dst) = *((long *) src);
+ else if (size == sizeof(short))
+ *((short *) *dst) = *((short *) src);
+ else if (size == sizeof(char))
+ *((char *) *dst) = *((char *) src);
+ else if (size == sizeof(XPointer))
+ *((XPointer *) *dst) = *((XPointer *) src);
+ else
+ memcpy(*dst, src, size);
+}
+
+void
+_XlcCountVaList(var, count_ret)
+ va_list var;
+ int *count_ret;
+{
+ register int count;
+
+ for (count = 0; va_arg(var, char *); count++)
+ va_arg(var, XPointer);
+
+ *count_ret = count;
+}
+
+void
+_XlcVaToArgList(var, count, args_ret)
+ va_list var;
+ register int count;
+ XlcArgList *args_ret;
+{
+ register XlcArgList args;
+
+ *args_ret = args = (XlcArgList) Xmalloc(sizeof(XlcArg) * count);
+ if (args == (XlcArgList) NULL)
+ return;
+
+ for ( ; count-- > 0; args++) {
+ args->name = va_arg(var, char *);
+ args->value = va_arg(var, XPointer);
+ }
+}
+
+void
+_XlcCompileResourceList(resources, num_resources)
+ register XlcResourceList resources;
+ register int num_resources;
+{
+ for ( ; num_resources-- > 0; resources++)
+ resources->xrm_name = XrmPermStringToQuark(resources->name);
+}
+
+char *
+_XlcGetValues(base, resources, num_resources, args, num_args, mask)
+ XPointer base;
+ XlcResourceList resources;
+ int num_resources;
+ XlcArgList args;
+ int num_args;
+ unsigned long mask;
+{
+ XlcResourceList res;
+ XrmQuark xrm_name;
+ int count;
+
+ for ( ; num_args-- > 0; args++) {
+ res = resources;
+ count = num_resources;
+ xrm_name = XrmPermStringToQuark(args->name);
+
+ for ( ; count-- > 0; res++) {
+ if (xrm_name == res->xrm_name && (mask & res->mask)) {
+ _XlcCopyToArg(base + res->offset, &args->value, res->size);
+ break;
+ }
+ }
+
+ if (count < 0)
+ return args->name;
+ }
+
+ return NULL;
+}
+
+char *
+_XlcSetValues(base, resources, num_resources, args, num_args, mask)
+ XPointer base;
+ XlcResourceList resources;
+ int num_resources;
+ XlcArgList args;
+ int num_args;
+ unsigned long mask;
+{
+ XlcResourceList res;
+ XrmQuark xrm_name;
+ int count;
+
+ for ( ; num_args-- > 0; args++) {
+ res = resources;
+ count = num_resources;
+ xrm_name = XrmPermStringToQuark(args->name);
+
+ for ( ; count-- > 0; res++) {
+ if (xrm_name == res->xrm_name && (mask & res->mask)) {
+ _XlcCopyFromArg(args->value, base + res->offset, res->size);
+ break;
+ }
+ }
+
+ if (count < 0)
+ return args->name;
+ }
+
+ return NULL;
+}
diff --git a/src/xlibi18n/mbWMProps.c b/src/xlibi18n/mbWMProps.c
new file mode 100644
index 00000000..be256575
--- /dev/null
+++ b/src/xlibi18n/mbWMProps.c
@@ -0,0 +1,84 @@
+/* $Xorg: mbWMProps.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+#include <X11/Xlibint.h>
+#include <X11/Xutil.h>
+#include <X11/Xatom.h>
+#include <X11/Xlocale.h>
+
+#if NeedFunctionPrototypes
+void XmbSetWMProperties (
+ Display *dpy,
+ Window w,
+ _Xconst char *windowName,
+ _Xconst char *iconName,
+ char **argv,
+ int argc,
+ XSizeHints *sizeHints,
+ XWMHints *wmHints,
+ XClassHint *classHints)
+#else
+void XmbSetWMProperties (dpy, w, windowName, iconName, argv, argc, sizeHints,
+ wmHints, classHints)
+ Display *dpy;
+ Window w; /* window to decorate */
+ char *windowName; /* name of application */
+ char *iconName; /* name string for icon */
+ char **argv; /* command line */
+ int argc; /* size of command line */
+ XSizeHints *sizeHints; /* size hints for window in its normal state */
+ XWMHints *wmHints; /* miscelaneous window manager hints */
+ XClassHint *classHints; /* resource name and class */
+#endif
+{
+ XTextProperty wname, iname;
+ XTextProperty *wprop = NULL;
+ XTextProperty *iprop = NULL;
+ char *locale;
+
+ if (windowName &&
+ XmbTextListToTextProperty(dpy, (char**)&windowName, 1,
+ XStdICCTextStyle, &wname) >= Success)
+ wprop = &wname;
+ if (iconName &&
+ XmbTextListToTextProperty(dpy, (char**)&iconName, 1,
+ XStdICCTextStyle, &iname) >= Success)
+ iprop = &iname;
+ XSetWMProperties(dpy, w, wprop, iprop, argv, argc,
+ sizeHints, wmHints, classHints);
+ if (wprop)
+ Xfree((char *)wname.value);
+ if (iprop)
+ Xfree((char *)iname.value);
+ locale = setlocale(LC_CTYPE, (char *)NULL);
+ if (locale)
+ XChangeProperty (dpy, w, XInternAtom(dpy, "WM_LOCALE_NAME", False),
+ XA_STRING, 8, PropModeReplace,
+ (unsigned char *)locale, strlen(locale));
+}
diff --git a/src/xlibi18n/mbWrap.c b/src/xlibi18n/mbWrap.c
new file mode 100644
index 00000000..f82ba212
--- /dev/null
+++ b/src/xlibi18n/mbWrap.c
@@ -0,0 +1,220 @@
+/* $Xorg: mbWrap.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 Open Software Foundation
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN 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.
+ *
+ * M. Collins OSF
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+void
+XmbDrawText(dpy, d, gc, x, y, text_items, nitems)
+ Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XmbTextItem *text_items;
+ int nitems;
+{
+ register XFontSet fs;
+ register XmbTextItem *p = text_items;
+ register int i = nitems;
+ register int esc;
+
+ /* ignore leading items with no fontset */
+ while (i && !p->font_set) {
+ i--;
+ p++;
+ }
+
+ for (; --i >= 0; p++) {
+ if (p->font_set)
+ fs = p->font_set;
+ x += p->delta;
+ esc = (*fs->methods->mb_draw_string) (dpy, d, fs, gc, x, y,
+ p->chars, p->nchars);
+ if (!esc)
+ esc = fs->methods->mb_escapement (fs, p->chars, p->nchars);
+ x += esc;
+ }
+}
+
+#if NeedFunctionPrototypes
+void
+XmbDrawString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+#else
+void
+XmbDrawString(dpy, d, font_set, gc, x, y, text, text_len)
+ Display *dpy;
+ Drawable d;
+ XFontSet font_set;
+ GC gc;
+ int x, y;
+ char *text;
+ int text_len;
+#endif
+{
+ (void)(*font_set->methods->mb_draw_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+
+#if NeedFunctionPrototypes
+void
+XmbDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst char *text,
+ int text_len)
+#else
+void
+XmbDrawImageString(dpy, d, font_set, gc, x, y, text, text_len)
+ Display *dpy;
+ Drawable d;
+ XFontSet font_set;
+ GC gc;
+ int x, y;
+ char *text;
+ int text_len;
+#endif
+{
+ (*font_set->methods->mb_draw_image_string) (dpy, d, font_set, gc, x, y,
+ (char *)text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int
+XmbTextEscapement(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len)
+#else
+int
+XmbTextEscapement(font_set, text, text_len)
+ XFontSet font_set;
+ char *text;
+ int text_len;
+#endif
+{
+ return (*font_set->methods->mb_escapement) (font_set,
+ (char *)text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int
+XmbTextExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *overall_ink_extents,
+ XRectangle *overall_logical_extents)
+#else
+int
+XmbTextExtents(font_set, text, text_len,
+ overall_ink_extents, overall_logical_extents)
+ XFontSet font_set;
+ char *text;
+ int text_len;
+ XRectangle *overall_ink_extents;
+ XRectangle *overall_logical_extents;
+#endif
+{
+ return (*font_set->methods->mb_extents) (font_set,
+ (char *)text, text_len,
+ overall_ink_extents,
+ overall_logical_extents);
+}
+
+#if NeedFunctionPrototypes
+Status
+XmbTextPerCharExtents(
+ XFontSet font_set,
+ _Xconst char *text,
+ int text_len,
+ XRectangle *ink_extents_buffer,
+ XRectangle *logical_extents_buffer,
+ int buffer_size,
+ int *num_chars,
+ XRectangle *max_ink_extents,
+ XRectangle *max_logical_extents)
+#else
+Status
+XmbTextPerCharExtents(font_set, text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars,
+ max_ink_extents, max_logical_extents)
+ XFontSet font_set;
+ char *text;
+ int text_len;
+ XRectangle *ink_extents_buffer;
+ XRectangle *logical_extents_buffer;
+ int buffer_size;
+ int *num_chars;
+ XRectangle *max_ink_extents;
+ XRectangle *max_logical_extents;
+#endif
+{
+ return (*font_set->methods->mb_extents_per_char)
+ (font_set, (char *)text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}
diff --git a/src/xlibi18n/wcWrap.c b/src/xlibi18n/wcWrap.c
new file mode 100644
index 00000000..621423d3
--- /dev/null
+++ b/src/xlibi18n/wcWrap.c
@@ -0,0 +1,218 @@
+/* $Xorg: wcWrap.c,v 1.4 2001/02/09 02:03:40 xorgcvs Exp $ */
+/*
+
+Copyright 1991, 1998 The Open Group
+
+Permission to use, copy, modify, distribute, and sell this software and its
+documentation for any purpose is hereby granted without fee, provided that
+the above copyright notice appear in all copies and that both that
+copyright notice and this permission notice appear in supporting
+documentation.
+
+The above copyright notice and this permission notice shall be included
+in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE OPEN GROUP BE LIABLE FOR ANY CLAIM, DAMAGES OR
+OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+
+Except as contained in this notice, the name of The Open Group shall
+not be used in advertising or otherwise to promote the sale, use or
+other dealings in this Software without prior written authorization
+from The Open Group.
+
+*/
+
+/*
+ * Copyright 1991 by the Open Software Foundation
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, 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 Open Software Foundation
+ * not be used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission. Open Software
+ * Foundation makes no representations about the suitability of this
+ * software for any purpose. It is provided "as is" without express or
+ * implied warranty.
+ *
+ * OPEN SOFTWARE FOUNDATION DISCLAIMS ALL WARRANTIES WITH REGARD TO
+ * THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL OPEN SOFTWARE FOUNDATIONN 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.
+ *
+ * M. Collins OSF
+ */
+
+#include "Xlibint.h"
+#include "Xlcint.h"
+
+void
+XwcDrawText(dpy, d, gc, x, y, text_items, nitems)
+ Display *dpy;
+ Drawable d;
+ GC gc;
+ int x, y;
+ XwcTextItem *text_items;
+ int nitems;
+{
+ register XFontSet fs;
+ register XwcTextItem *p = text_items;
+ register int i = nitems;
+ register int esc;
+
+ /* ignore leading items with no fontset */
+ while (i && !p->font_set) {
+ i--;
+ p++;
+ }
+
+ for (; --i >= 0; p++) {
+ if (p->font_set)
+ fs = p->font_set;
+ x += p->delta;
+ esc = (*fs->methods->wc_draw_string) (dpy, d, fs, gc, x, y,
+ p->chars, p->nchars);
+ if (!esc)
+ esc = fs->methods->wc_escapement (fs, p->chars, p->nchars);
+ x += esc;
+ }
+}
+
+#if NeedFunctionPrototypes
+void
+XwcDrawString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst wchar_t *text,
+ int text_len)
+#else
+void
+XwcDrawString(dpy, d, font_set, gc, x, y, text, text_len)
+ Display *dpy;
+ Drawable d;
+ XFontSet font_set;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int text_len;
+#endif
+{
+ (void)(*font_set->methods->wc_draw_string) (dpy, d, font_set, gc, x, y,
+ text, text_len);
+}
+
+#if NeedFunctionPrototypes
+void
+XwcDrawImageString(
+ Display *dpy,
+ Drawable d,
+ XFontSet font_set,
+ GC gc,
+ int x,
+ int y,
+ _Xconst wchar_t *text,
+ int text_len)
+#else
+void
+XwcDrawImageString(dpy, d, font_set, gc, x, y, text, text_len)
+ Display *dpy;
+ Drawable d;
+ XFontSet font_set;
+ GC gc;
+ int x, y;
+ wchar_t *text;
+ int text_len;
+#endif
+{
+ (*font_set->methods->wc_draw_image_string) (dpy, d, font_set, gc, x, y,
+ text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int
+XwcTextEscapement(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len)
+#else
+int
+XwcTextEscapement(font_set, text, text_len)
+ XFontSet font_set;
+ wchar_t *text;
+ int text_len;
+#endif
+{
+ return (*font_set->methods->wc_escapement) (font_set, text, text_len);
+}
+
+#if NeedFunctionPrototypes
+int
+XwcTextExtents(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len,
+ XRectangle *overall_ink_extents,
+ XRectangle *overall_logical_extents)
+#else
+int
+XwcTextExtents(font_set, text, text_len,
+ overall_ink_extents, overall_logical_extents)
+ XFontSet font_set;
+ wchar_t *text;
+ int text_len;
+ XRectangle *overall_ink_extents;
+ XRectangle *overall_logical_extents;
+#endif
+{
+ return (*font_set->methods->wc_extents) (font_set, text, text_len,
+ overall_ink_extents,
+ overall_logical_extents);
+}
+
+#if NeedFunctionPrototypes
+Status
+XwcTextPerCharExtents(
+ XFontSet font_set,
+ _Xconst wchar_t *text,
+ int text_len,
+ XRectangle *ink_extents_buffer,
+ XRectangle *logical_extents_buffer,
+ int buffer_size,
+ int *num_chars,
+ XRectangle *max_ink_extents,
+ XRectangle *max_logical_extents)
+#else
+Status
+XwcTextPerCharExtents(font_set, text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars,
+ max_ink_extents, max_logical_extents)
+ XFontSet font_set;
+ wchar_t *text;
+ int text_len;
+ XRectangle *ink_extents_buffer;
+ XRectangle *logical_extents_buffer;
+ int buffer_size;
+ int *num_chars;
+ XRectangle *max_ink_extents;
+ XRectangle *max_logical_extents;
+#endif
+{
+ return (*font_set->methods->wc_extents_per_char)
+ (font_set, text, text_len,
+ ink_extents_buffer, logical_extents_buffer,
+ buffer_size, num_chars, max_ink_extents, max_logical_extents);
+}